Skip to content
Snippets Groups Projects
Commit be0dd585 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MathLib] For better readability: scpr() -> scalarProduct().

parent 02ee0046
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -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) */
......
......@@ -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
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment