VectorSpace: Added cmptSqr

This commit is contained in:
Henry Weller
2016-11-14 11:22:43 +00:00
parent 4fcff9e106
commit a856ea0b0e
3 changed files with 21 additions and 1 deletions

View File

@ -302,11 +302,18 @@ inline Scalar cmptAv(const Scalar s)
}
inline Scalar cmptSqr(const Scalar s)
{
return sqr(s);
}
inline Scalar cmptMag(const Scalar s)
{
return mag(s);
}
inline Scalar sqrtSumSqr(const Scalar a, const Scalar b)
{
Scalar maga = mag(a);
@ -323,7 +330,7 @@ inline Scalar sqrtSumSqr(const Scalar a, const Scalar b)
}
// Stabilisation around zero for division
//- Stabilisation around zero for division
inline Scalar stabilise(const Scalar s, const Scalar small)
{
if (s >= 0)

View File

@ -537,6 +537,18 @@ inline Cmpt cmptProduct
}
template<class Form, class Cmpt, direction Ncmpts>
inline Form cmptSqr
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Form v;
VectorSpaceOps<Ncmpts,0>::eqOp(v, vs, eqSqrOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction Ncmpts>
inline Form cmptMag
(

View File

@ -72,6 +72,7 @@ EqOp(plusEq, x += y)
EqOp(minusEq, x -= y)
EqOp(multiplyEq, x *= y)
EqOp(divideEq, x /= y)
EqOp(eqSqr, x = sqr(y))
EqOp(eqMag, x = mag(y))
EqOp(plusEqMagSqr, x += magSqr(y))
EqOp(maxEq, x = max(x, y))