Added cmptSign functions

This commit is contained in:
Hrvoje Jasak 2016-03-17 11:22:31 +00:00
parent 56bc36fb62
commit 5236b1c3d6
3 changed files with 27 additions and 5 deletions

View file

@ -235,6 +235,12 @@ inline Scalar cmptMag(const Scalar s)
}
inline Scalar cmptSign(const Scalar s)
{
return sign(s);
}
// Standard C++ transcendental functions
transFunc(sqrt)
transFunc(cbrt)
@ -268,7 +274,7 @@ transFunc(y1)
// Stabilisation around zero for division
inline Scalar stabilise(const Scalar s, const Scalar small)
inline Scalar stabilise(const Scalar& s, const Scalar& small)
{
if (s >= 0)
{
@ -283,9 +289,9 @@ inline Scalar stabilise(const Scalar s, const Scalar small)
inline Scalar cmptStabilise
(
const Scalar s,
const Scalar small,
const Scalar value
const Scalar& s,
const Scalar& small,
const Scalar& value
)
{
if (mag(s) < small)

View file

@ -431,6 +431,18 @@ inline Form cmptMag
}
template<class Form, class Cmpt, int nCmpt>
inline Form cmptSign
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
)
{
Form v;
VectorSpaceOps<nCmpt,0>::eqOp(v, vs, eqSignOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, int nCmpt>
inline Form cmptStabilise
(
@ -440,7 +452,7 @@ inline Form cmptStabilise
)
{
Form v = vs;
for (int i=0; i<nCmpt; i++)
for (int i = 0; i < nCmpt; i++)
{
if (mag(vs.v_[i]) < small)
{

View file

@ -94,6 +94,10 @@ template<class T>
class eqMagOp
{ public: void operator()(T& x, const T& y) const { x = mag(y); } };
template<class T>
class eqSignOp
{ public: void operator()(T& x, const T& y) const { x = sign(y); } };
template<class T1, class T2>
class plusEqMagSqrOp2
{ public: void operator()(T1& x, const T2& y) const { x += magSqr(y); } };