7 #ifndef cf3_Math_Functions_hpp
8 #define cf3_Math_Functions_hpp
34 Real
signum (
const Real& value);
40 Real
sign(
const Real& value);
47 Real
change_sign(
const Real& value,
const Real& newSignValue);
58 template <
class T1,
class T2>
74 template <
class T1,
class T2,
class T3,
class T4>
85 template <
class T1,
class T2,
class T3>
96 template <
class T1,
class T2>
104 template <
class T1,
class T2,
class T3>
112 if ( value < 0.0 )
return -1.0;
113 if ( value == 0.0 )
return 0.0;
118 inline Real
sign(
const Real& value)
120 if (value < 0.0)
return -1.0;
125 inline Real
change_sign(
const Real& value,
const Real& newSignValue)
127 return newSignValue >= 0 ? (value >=0 ? value : -value) : (value >= 0 ? -value : value);
133 if (value < 0.0)
return 0.0;
134 if (value == 0.0)
return 0.5;
139 template <
class T1,
class T2>
145 const Uint size = n1.size();
146 for (
Uint i = 0; i < size; ++i)
148 const Real
diff = n1[i] - n2[i];
151 return std::sqrt(dist);
164 template <
class T1,
class T2,
class T3,
class T4>
180 template <
class T1,
class T2,
class T3>
190 result[0] = v1[1]*v2[2] - v1[2]*v2[1];
191 result[1] = -v1[0]*v2[2] + v1[2]*v2[0];
192 result[2] = v1[0]*v2[1] - v1[1]*v2[0];
196 template <
class T1,
class T2>
201 const Uint size = v1.size();
203 for (
Uint i = 0; i < size; ++i)
204 result += v1[i]*v2[i];
209 template <
class T1,
class T2,
class T3>
215 const Uint v1size = v1.size();
216 const Uint v2size = v2.size();
217 for (
Uint i = 0; i < v1size; ++i) {
218 for (
Uint j = 0; j < v2size; ++j) {
219 m(i,j) = v1[i]*v2[j];
236 #endif // cf3_Math_Functions_hpp
Real get_distance(const T1 &n1, const T2 &n2)
void cross_product(const T1 &v1, const T2 &v2, T3 &result)
Real sign(const Real &value)
Real change_sign(const Real &value, const Real &newSignValue)
Top-level namespace for coolfluid.
Uint factorial(const Uint &n)
Real mixed_product(const T1 &v1, const T2 &v2, const T3 &v3, T4 &temp)
Real signum(const Real &value)
unsigned int Uint
typedef for unsigned int
Real heavyside(const Real &value)
coolfluid3 header, included almost everywhere
Real inner_product(const T1 &v1, const T2 &v2)
void tensor_product(const T1 &v1, const T2 &v2, T3 &m)