diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index eb068f147f9a35f65bfcce867d766c836a000140..36b3ee0754860c30e643b0f29cd59f554e4932cf 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -167,7 +167,7 @@ double getOrientedTriArea(GeoLib::Point const& a, GeoLib::Point const& b, GeoLib const double v[3] = { b[0] - a[0], b[1] - a[1], b[2] - a[2] }; double w[3]; MathLib::crossProd(u, v, w); - return 0.5 * sqrt(MathLib::scpr<double, 3>(w, w)); + return 0.5 * sqrt(MathLib::scalarProduct<double, 3>(w, w)); } bool isPointInTriangle(GeoLib::Point const& p, GeoLib::Point const& a, GeoLib::Point const& b, diff --git a/MathLib/LinAlg/Solvers/CG.cpp b/MathLib/LinAlg/Solvers/CG.cpp index 13b7d15ad975962453367d00e34f71428cae9a0d..55c8a3b217e75c5bfc653eea0e9f22a5a5d4f9c9 100644 --- a/MathLib/LinAlg/Solvers/CG.cpp +++ b/MathLib/LinAlg/Solvers/CG.cpp @@ -46,7 +46,7 @@ unsigned CG(CRSMatrix<double,unsigned> const * mat, double const * const b, r = q + N; rhat = r + N; - double nrmb = sqrt(scpr(b, b, N)); + double nrmb = sqrt(scalarProduct(b, b, N)); if (nrmb < std::numeric_limits<double>::epsilon()) { blas::setzero(N, x); eps = 0.0; @@ -78,7 +78,7 @@ unsigned CG(CRSMatrix<double,unsigned> const * mat, double const * const b, mat->precondApply(rhat); // rho = r * r^; - rho = scpr(r, rhat, N); // num_threads); + rho = scalarProduct(r, rhat, N); // num_threads); if (l > 1) { double beta = rho / rho1; @@ -94,7 +94,7 @@ unsigned CG(CRSMatrix<double,unsigned> const * mat, double const * const b, mat->amux(D_ONE, p, q); // alpha = rho / p*q - double alpha = rho / scpr(p, q, N); + double alpha = rho / scalarProduct(p, q, N); // x += alpha * p blas::axpy(N, alpha, p, x); @@ -102,7 +102,7 @@ unsigned CG(CRSMatrix<double,unsigned> const * mat, double const * const b, // r -= alpha * q blas::axpy(N, -alpha, q, r); - resid = sqrt(scpr(r, r, N)); + resid = sqrt(scalarProduct(r, r, N)); if (resid <= eps * nrmb) { eps = resid / nrmb; diff --git a/MathLib/LinAlg/Solvers/CGParallel.cpp b/MathLib/LinAlg/Solvers/CGParallel.cpp index b9d92cc1e0965a509840a7e426cfb4e07254eee9..c502ae0b0b4317f88616a8313fd3433b306a3d2d 100644 --- a/MathLib/LinAlg/Solvers/CGParallel.cpp +++ b/MathLib/LinAlg/Solvers/CGParallel.cpp @@ -53,7 +53,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const double * __restrict__ rhat(new double[N]); double rho, rho1 = 0.0; - double nrmb = sqrt(scpr(b, b, N)); + double nrmb = sqrt(scalarProduct(b, b, N)); if (nrmb < std::numeric_limits<double>::epsilon()) { blas::setzero(N, x); @@ -96,7 +96,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const mat->precondApply(rhat); // rho = r * r^; - rho = scpr(r, rhat, N); + rho = scalarProduct(r, rhat, N); if (l > 1) { double beta = rho / rho1; @@ -117,7 +117,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const mat->amux(D_ONE, p, q); // alpha = rho / p*q - double alpha = rho / scpr(p, q, N); + double alpha = rho / scalarProduct(p, q, N); #pragma omp parallel { @@ -136,7 +136,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const #pragma omp barrier } // end #pragma omp parallel - resid = sqrt(scpr(r, r, N)); + resid = sqrt(scalarProduct(r, r, N)); if (resid <= eps * nrmb) { eps = resid / nrmb; diff --git a/MathLib/MathTools.cpp b/MathLib/MathTools.cpp index b98e4f117f039515cf8c73e8d1f5ae827c2e9bde..7de70163cbea2329342798b05848b02c8f505e3c 100644 --- a/MathLib/MathTools.cpp +++ b/MathLib/MathTools.cpp @@ -30,7 +30,7 @@ double calcProjPntToLineAndDists(const double p[3], const double a[3], double v[3] = {b[0] - a[0], b[1] - a[1], b[2] - a[2]}; // orthogonal projection: (g(lambda)-p) * v = 0 => in order to compute lambda we define a help vector u double u[3] = {p[0] - a[0], p[1] - a[1], p[2] - a[2]}; - lambda = scpr<double,3> (u, v) / scpr<double,3> (v, v); + lambda = scalarProduct<double,3> (u, v) / scalarProduct<double,3> (v, v); // compute projected point double proj_pnt[3]; @@ -45,7 +45,7 @@ double calcProjPntToLineAndDists(const double p[3], const double a[3], double sqrDist(const double* p0, const double* p1) { const double v[3] = {p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2]}; - return scpr<double,3>(v,v); + return scalarProduct<double,3>(v,v); } float normalize(float min, float max, float val) @@ -59,7 +59,7 @@ double getAngle (const double p0[3], const double p1[3], const double p2[3]) const double v1[3] = {p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]}; // apply Cauchy Schwarz inequality - return acos (scpr<double,3> (v0,v1) / (sqrt(scpr<double,3>(v0,v0)) * sqrt(scpr<double,3>(v1,v1)))); + return acos (scalarProduct<double,3> (v0,v1) / (sqrt(scalarProduct<double,3>(v0,v0)) * sqrt(scalarProduct<double,3>(v1,v1)))); } double calcTriangleArea(const double* p0, const double* p1, const double* p2) diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h index 15adac659646e539415fbf1e7fa65142db2984a7..98b50e3b90dc19c9fdb2cb1ab2b8aa37d0b78f99 100644 --- a/MathLib/MathTools.h +++ b/MathLib/MathTools.h @@ -33,7 +33,7 @@ namespace MathLib * \param v1 array of type T representing the vector * */ template<typename T, int N> inline -T scpr(T const * const v0, T const * const v1) +T scalarProduct(T const * const v0, T const * const v1) { T res (v0[0] * v1[0]); #ifdef _OPENMP @@ -51,7 +51,7 @@ T scpr(T const * const v0, T const * const v1) } template <> inline -double scpr<double,3>(double const * const v0, double const * const v1) +double scalarProduct<double,3>(double const * const v0, double const * const v1) { double res (v0[0] * v1[0]); for (std::size_t k(1); k < 3; k++) @@ -60,7 +60,7 @@ double scpr<double,3>(double const * const v0, double const * const v1) } template<typename T> inline -T scpr(T const * const v0, T const * const v1, unsigned n) +T scalarProduct(T const * const v0, T const * const v1, unsigned n) { T res (v0[0] * v1[0]); #ifdef _OPENMP @@ -112,7 +112,7 @@ template <typename T> T sqrDist(const MathLib::TemplatePoint<T>* p0, const MathLib::TemplatePoint<T>* p1) { const T v[3] = {(*p1)[0] - (*p0)[0], (*p1)[1] - (*p0)[1], (*p1)[2] - (*p0)[2]}; - return MathLib::scpr<T,3>(v,v); + return MathLib::scalarProduct<T,3>(v,v); } /** squared dist between double arrays p0 and p1 (size of arrays is 3) */ diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index de118f0802b8c0de2ba92ddaed976d1955fa1d6c..8ddaba5787bf3ae61a2c996f0c3033e8eee2576a 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -133,7 +133,7 @@ public: /// Returns the squared length double LenSqr(void) const { - return scpr<double,3> (this->getCoords (), this->getCoords ()); + return scalarProduct<double,3> (this->getCoords (), this->getCoords ()); } /// Returns the length diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index 29537d036f87389670aefdddf1b948a5a6624d2e..255428cf8be1a5a4c6141e34ecd8af78edad54c8 100644 --- a/MeshLib/MeshSurfaceExtraction.cpp +++ b/MeshLib/MeshSurfaceExtraction.cpp @@ -105,7 +105,7 @@ void MeshSurfaceExtraction::get2DSurfaceElements(const std::vector<MeshLib::Elem ERR("Cannot handle meshes of dimension %i", mesh_dimension); bool complete_surface (true); - if (MathLib::scpr<double, 3>(dir, dir) != 0) + if (MathLib::scalarProduct<double, 3>(dir, dir) != 0) complete_surface = false; for (auto elem = all_elements.begin(); elem != all_elements.end(); ++elem) @@ -121,7 +121,7 @@ void MeshSurfaceExtraction::get2DSurfaceElements(const std::vector<MeshLib::Elem MeshLib::Face* face = dynamic_cast<MeshLib::Face*>(*elem); double normal[3]; face->getSurfaceNormal(normal); - if (MathLib::scpr(normal, dir, 3) <= 0) + if (MathLib::scalarProduct(normal, dir, 3) <= 0) continue; } sfc_elements.push_back(*elem); @@ -142,7 +142,7 @@ void MeshSurfaceExtraction::get2DSurfaceElements(const std::vector<MeshLib::Elem { double normal[3]; face->getSurfaceNormal(normal); - if (MathLib::scpr<double,3>(normal, dir) <= 0) + if (MathLib::scalarProduct<double,3>(normal, dir) <= 0) continue; }