Added cmptSign functions
This commit is contained in:
parent
56bc36fb62
commit
5236b1c3d6
3 changed files with 27 additions and 5 deletions
|
@ -235,6 +235,12 @@ inline Scalar cmptMag(const Scalar s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Scalar cmptSign(const Scalar s)
|
||||||
|
{
|
||||||
|
return sign(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Standard C++ transcendental functions
|
// Standard C++ transcendental functions
|
||||||
transFunc(sqrt)
|
transFunc(sqrt)
|
||||||
transFunc(cbrt)
|
transFunc(cbrt)
|
||||||
|
@ -268,7 +274,7 @@ transFunc(y1)
|
||||||
|
|
||||||
|
|
||||||
// Stabilisation around zero for division
|
// 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)
|
if (s >= 0)
|
||||||
{
|
{
|
||||||
|
@ -283,9 +289,9 @@ inline Scalar stabilise(const Scalar s, const Scalar small)
|
||||||
|
|
||||||
inline Scalar cmptStabilise
|
inline Scalar cmptStabilise
|
||||||
(
|
(
|
||||||
const Scalar s,
|
const Scalar& s,
|
||||||
const Scalar small,
|
const Scalar& small,
|
||||||
const Scalar value
|
const Scalar& value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (mag(s) < small)
|
if (mag(s) < small)
|
||||||
|
|
|
@ -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>
|
template<class Form, class Cmpt, int nCmpt>
|
||||||
inline Form cmptStabilise
|
inline Form cmptStabilise
|
||||||
(
|
(
|
||||||
|
@ -440,7 +452,7 @@ inline Form cmptStabilise
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Form v = vs;
|
Form v = vs;
|
||||||
for (int i=0; i<nCmpt; i++)
|
for (int i = 0; i < nCmpt; i++)
|
||||||
{
|
{
|
||||||
if (mag(vs.v_[i]) < small)
|
if (mag(vs.v_[i]) < small)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,6 +94,10 @@ template<class T>
|
||||||
class eqMagOp
|
class eqMagOp
|
||||||
{ public: void operator()(T& x, const T& y) const { x = mag(y); } };
|
{ 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>
|
template<class T1, class T2>
|
||||||
class plusEqMagSqrOp2
|
class plusEqMagSqrOp2
|
||||||
{ public: void operator()(T1& x, const T2& y) const { x += magSqr(y); } };
|
{ public: void operator()(T1& x, const T2& y) const { x += magSqr(y); } };
|
||||||
|
|
Reference in a new issue