Skip to content

Commit

Permalink
Replace usage of 'abs()' by 'fabs()'
Browse files Browse the repository at this point in the history
'abs()' is only defined for int's in the standard, but on some platforms works for doubles too
  • Loading branch information
Kanma committed Dec 13, 2024
1 parent 45fb7df commit 038838c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/gafro/algebra/Circle.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace gafro
{
auto mv = ((*this) * (Scalar<T>(T(-1.0)) * ((*this).dual() | Ei<T>(T(1.0))).evaluate().inverse())).evaluate();

return sqrt(abs((mv * mv).template get<blades::scalar>()));
return sqrt(fabs((mv * mv).template get<blades::scalar>()));
}

template <typename T>
Expand Down
8 changes: 4 additions & 4 deletions src/gafro/algebra/Multivector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ namespace gafro
template <class T, int... index>
T Multivector<T, index...>::norm() const
{
return sqrt(abs(squaredNorm()));
return sqrt(fabs(squaredNorm()));
}

template <class T, int... index>
Expand All @@ -247,7 +247,7 @@ namespace gafro
{
T squared_norm = squaredNorm();

return squared_norm > 0 ? sqrt(squared_norm) : -sqrt(abs(squared_norm));
return squared_norm > 0 ? sqrt(squared_norm) : -sqrt(fabs(squared_norm));
}

template <class T, int... index>
Expand Down Expand Up @@ -326,7 +326,7 @@ namespace gafro

for (unsigned int k = 0; k < mv.vector().rows(); ++k)
{
if (abs(mv.vector().coeff(k, 0)) < 1e-10)
if (fabs(mv.vector().coeff(k, 0)) < 1e-10)
{
continue;
}
Expand All @@ -335,7 +335,7 @@ namespace gafro
{
ostream << (mv.vector().coeff(k, 0) >= 0 ? " + " : " - ");

ostream << abs(mv.vector().coeff(k, 0));
ostream << fabs(mv.vector().coeff(k, 0));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/gafro/algebra/Rotor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace gafro
{
T acos = std::acos(scalar());

if (abs(acos) < 1e-6)
if (fabs(acos) < 1e-6)
{
return Rotor<T>::Generator({ e23(), e13(), e12() });
}
Expand Down
2 changes: 1 addition & 1 deletion src/gafro/algebra/Sphere.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace gafro
template <typename T>
T Sphere<T>::getRadius() const
{
return sqrt(abs(((*this) * Scalar<T>(-1.0 / (this->dual() | Ei<T>(1.0)).template get<blades::scalar>())).evaluate().squaredNorm()));
return sqrt(fabs(((*this) * Scalar<T>(-1.0 / (this->dual() | Ei<T>(1.0)).template get<blades::scalar>())).evaluate().squaredNorm()));
}

template <typename T>
Expand Down
6 changes: 3 additions & 3 deletions src/gafro/algebra/expressions/MotorLogarithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ namespace gafro
switch (blade)
{
case blades::e23:
if (TypeTraits<T>::greaterEqual(abs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
if (TypeTraits<T>::greaterEqual(fabs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
{
return TypeTraits<T>::Zero();
}

return motor.template get<blades::e23>() * TypeTraits<T>::Value(-2.0) * acos(motor.template get<blades::scalar>()) /
(sin(acos(motor.template get<blades::scalar>())) + TypeTraits<T>::Value(1e-10));
case blades::e13:
if (TypeTraits<T>::greaterEqual(abs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
if (TypeTraits<T>::greaterEqual(fabs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
{
return TypeTraits<T>::Zero();
}

return motor.template get<blades::e13>() * TypeTraits<T>::Value(-2.0) * acos(motor.template get<blades::scalar>()) /
(sin(acos(motor.template get<blades::scalar>())) + TypeTraits<T>::Value(1e-10));
case blades::e12:
if (TypeTraits<T>::greaterEqual(abs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
if (TypeTraits<T>::greaterEqual(fabs(motor.template get<blades::scalar>()), TypeTraits<T>::Value(1.0 - 1e-10)))
{
return TypeTraits<T>::Zero();
}
Expand Down

0 comments on commit 038838c

Please sign in to comment.