Commit 5e38b99d authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

Move sign function to math.hh

parent 550edece
......@@ -26,14 +26,10 @@
#include <cmath>
namespace Dumux
{
#include "math.hh"
template<class ValueType>
int sign(const ValueType& value)
namespace Dumux
{
return (value < 0 ? -1 : 1);
}
template<int dim, class Matrix>
void identityMatrix(Matrix& matrix)
......
......@@ -475,6 +475,19 @@ Scalar antoine(Scalar temperature,
return std::exp(ln10*(A - B/(C + temperature)));
}
/*!
* \brief Sign or signum function.
*
* Returns 1 for a positive argument.
* Returns -1 for a negative argument.
* Returns 0 if the argument is zero.
*/
template<class ValueType>
int sign(const ValueType& value)
{
return (ValueType(0) < value) - (value < ValueType(0));
}
/*!
* \brief Cross product of two vectors in three-dimensional Euclidean space
*
......
......@@ -563,7 +563,7 @@ protected:
// to determine whether we're monotonically increasing
// or decreasing
x0 = x1;
return (x0*(x0*3*a + 2*b) + c > 0) ? 1 : -1;
return sign(x0*(x0*3*a + 2*b) + c);
}
if ((x0 < xE1 && xE1 < x1) ||
(x0 < xE2 && xE2 < x1))
......@@ -574,7 +574,7 @@ protected:
// no extremum in range (x0, x1)
x0 = (x0 + x1)/2; // pick point in the middle of the interval
// to avoid extrema on the boundaries
return (x0*(x0*3*a + 2*b) + c > 0) ? 1 : -1;
return sign(x0*(x0*3*a + 2*b) + c);
}
/*!
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment