mathsFunc Namespace Reference

Namespace for some extra maths function that are often needed
More...

Functions

Mdouble gamma (Mdouble gamma_in)
 This is the gamma function returns the true value for the half integer value. More...
 
Mdouble beta (Mdouble z, Mdouble w)
 This is the beta function, returns the approximation based on cmath's implementation of ln(gamma) More...
 
Mdouble chi_squared (Mdouble x, unsigned int k)
 This is a chi_squared function return the value x and degrees of freedom k. More...
 
Mdouble chi_squared_prob (Mdouble x, unsigned int k)
 This is the function which actually gives the probability back using a chi squared test. More...
 
Mdouble goldenSectionSearch (Mdouble(*function)(const Mdouble), Mdouble min, Mdouble cur, Mdouble max, Mdouble endCondition, Mdouble curVal=std::numeric_limits< Mdouble >::quiet_NaN())
 This function performs a golden section search to find the location of the minimum of a function. More...
 
template<typename T >
int sign (T val)
 This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0. More...
 
template<typename T >
T square (const T val)
 squares a number More...
 
template<typename T >
T cubic (const T val)
 calculates the cube of a number More...
 
bool isEqual (Mdouble v1, Mdouble v2, Mdouble absError)
 Compares the difference of two Mdouble with an absolute error, useful in UnitTests. More...
 
bool isEqual (Vec3D v1, Vec3D v2, Mdouble absError)
 Compares the difference of two Vec3D with an absolute error, useful in UnitTests. More...
 
bool isEqual (Matrix3D m1, Matrix3D m2, Mdouble absError)
 Compares the difference of two Vec3D with an absolute error, useful in UnitTests. More...
 
bool isEqual (MatrixSymmetric3D m1, MatrixSymmetric3D m2, Mdouble absError)
 
bool isEqual (Quaternion v1, Quaternion v2, double absError)
 
template<typename T >
constexpr T factorial (const T t)
 factorial function More...
 
Mdouble sin (Mdouble x)
 
Mdouble cos (Mdouble x)
 
Mdouble exp (Mdouble Exponent)
 
Mdouble log (Mdouble Power)
 
template<typename T >
T tan (T x)
 
Mdouble chebyshev (Mdouble x, const Mdouble coef[], int N)
 Namespace for evaluating the zeroth modified Bessel function of the first kind, I0(x), required in StatisticsPoint.hcc. More...
 
Mdouble I0_exp (Mdouble x)
 
Mdouble I0 (Mdouble x)
 

Detailed Description

Namespace for some extra maths function that are often needed

Function Documentation

◆ beta()

Mdouble mathsFunc::beta ( Mdouble  z,
Mdouble  w 
)

This is the beta function, returns the approximation based on cmath's implementation of ln(gamma)

Computes the beta function for real numbers, based on cmath's approximation of the ln of the gamma function. See https://en.wikipedia.org/wiki/Beta_function for more details

Parameters
zfirst Mdouble argument to compute the beta function of
wsecond Mdouble argument to compute the beta function of
Returns
the value of beta(z,w) as an Mdouble
144 {
145  return std::exp(std::lgamma(z) + std::lgamma(w) - std::lgamma(z + w));
146 }
RowVector3d w
Definition: Matrix_resize_int.cpp:3
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615

References Eigen::bfloat16_impl::exp(), and w.

Referenced by SuperQuadricParticle::computeMass(), SuperQuadricParticle::getVolume(), and SuperQuadricParticle::setInertia().

◆ chebyshev()

Mdouble mathsFunc::chebyshev ( Mdouble  x,
const Mdouble  coef[],
int  N 
)

Namespace for evaluating the zeroth modified Bessel function of the first kind, I0(x), required in StatisticsPoint.hcc.

273 {
274  const Mdouble* p = coef;
275  Mdouble b0 = *p++;
276  Mdouble b1 = 0, b2;
277  int i = N - 1;
278 
279  logger.assert_debug(i > 0, "i is greater than 0");
280  do
281  {
282  b2 = b1;
283  b1 = b0;
284  b0 = x * b1 - b2 + *p++;
285  } while (--i);
286 
287  return (0.5 * (b0 - b2));
288 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
float * p
Definition: Tutorial_Map_using.cpp:9
@ N
Definition: constructor.cpp:22
list x
Definition: plotDoE.py:28

References i, logger, N, p, and plotDoE::x.

Referenced by I0_exp().

◆ chi_squared()

Mdouble mathsFunc::chi_squared ( Mdouble  x,
unsigned int  k 
)

This is a chi_squared function return the value x and degrees of freedom k.

This is a chi_squared function return the value x and degrees of freedom k

152 {
153 
154  Mdouble prefactor = pow(2, k / 2.0) * gamma(k / 2.0);
155  Mdouble mainfactor = pow(x, k / 2.0 - 1) * exp(x / -2.0);
156 
157  return mainfactor / prefactor;
158 
159 }
EIGEN_DEVICE_FUNC const GlobalUnaryPowReturnType< Derived, ScalarExponent > pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
Definition: GlobalFunctions.h:137
char char char int int * k
Definition: level2_impl.h:374
Mdouble gamma(Mdouble gamma_in)
This is the gamma function returns the true value for the half integer value.
Definition: ExtendedMath.cc:116

References Eigen::bfloat16_impl::exp(), gamma(), k, Eigen::ArrayBase< Derived >::pow(), and plotDoE::x.

Referenced by chi_squared_prob().

◆ chi_squared_prob()

Mdouble mathsFunc::chi_squared_prob ( Mdouble  x,
unsigned int  k 
)

This is the function which actually gives the probability back using a chi squared test.

This calculates the probability based on a chi squared test First we calculated the cumulative chi_squared function. This is the function which actually gives the probability back It is calculated by calling the normal chi_squared function and using the trapezoidal rule. The final results is 1-the cumulative chi_squared function

168 {
169 
170 //The current value was picked by tried were it stopped effect the 4 d.p.
171  const int num_steps_per_unit = 100;
172  Mdouble sum = 0;
173  Mdouble x = 0;
174  long int num_steps = static_cast<int>(num_steps_per_unit * x_max);
175 //Use trapezional rule, but ignoring the ends
176  for (int i = 0; i < num_steps; i++)
177  {
178  x = x_max / num_steps * (i + 0.5);
179  sum = sum + chi_squared(x, k);
180  }
181  return 1.0 - sum * x_max / num_steps;
182 
183 }
Mdouble chi_squared(Mdouble x, unsigned int k)
This is a chi_squared function return the value x and degrees of freedom k.
Definition: ExtendedMath.cc:151

References chi_squared(), i, k, and plotDoE::x.

Referenced by main(), and RNG::test().

◆ cos()

Mdouble mathsFunc::cos ( Mdouble  x)
44 {
45  Mdouble N = floor(x / (2.0 * constants::pi) + 0.5);
46  x -= N * 2.0 * constants::pi;
47  Mdouble Sum = 1.0;
48  Mdouble Power = 1;
49  Mdouble Sign = 1;
50  const Mdouble x2 = x * x;
51  Mdouble Fact = 1.0;
52  for (unsigned int i = 2; i < 25; i += 2)
53  {
54  Power *= x2;
55  Fact *= i * (i - 1);
56  Sign *= -1.0;
57  Sum += Sign * Power / Fact;
58  }
59  return Sum;
60 }
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 floor(const bfloat16 &a)
Definition: BFloat16.h:643
int Sign
Definition: linear_solvers/direct_solver_test.cc:52
Vector< double > x2(const Vector< double > &coord)
Cartesian coordinates centered at the point (1.5,1)
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:102
const Mdouble pi
Definition: ExtendedMath.h:23

References Eigen::bfloat16_impl::floor(), i, N, constants::pi, FishSolnOneDPoisson::Sign, plotDoE::x, and Global_parameters::x2().

Referenced by ChuteWithHopper::addHopper(), AxisymmetricHopper::create_inflow_particle(), main(), HopperInsertionBoundary::placeParticle(), HourGlass::setupInitialConditions(), Tutorial11::setupInitialConditions(), and tan().

◆ cubic()

◆ exp()

Mdouble mathsFunc::exp ( Mdouble  Exponent)
64 {
65  Mdouble X, P, Frac, I, L;
66  X = Exponent;
67  Frac = X;
68  P = (1.0 + X);
69  I = 1.0;
70 
71  do
72  {
73  I++;
74  Frac *= (X / I);
75  L = P;
76  P += Frac;
77  } while (L != P);
78 
79  return P;
80 }
MatrixXd L
Definition: LLT_example.cpp:6
#define X
Definition: icosphere.cpp:20
#define I
Definition: main.h:127
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77

References I, L, Global_Physical_Variables::P, and X.

Referenced by MeltableInteraction::computeNormalForce(), and main().

◆ factorial()

template<typename T >
constexpr T mathsFunc::factorial ( const T  t)
constexpr

factorial function

136 {
137  return (t == 0) ? 1 : t * factorial(t - 1);
138 }
constexpr T factorial(const T t)
factorial function
Definition: ExtendedMath.h:135
t
Definition: plotPSD.py:36

References plotPSD::t.

Referenced by sphericalHarmonics::computeSquaredFactorialValues(), HGridOptimiser::histNumberParticlesPerCell(), and sphericalHarmonics::sphericalHarmonics().

◆ gamma()

Mdouble mathsFunc::gamma ( Mdouble  gamma_in)

This is the gamma function returns the true value for the half integer value.

This is the gamma function, gives 'exact' answers for the half integer values This is done using the recussion relation and the known values for 1 and 0.5 Note, return NaN for non-half integer values

117 {
118  const Mdouble ep = 1e-5;
119 
120  if (gamma_in > 1.0 + ep)
121  {
122  return ((gamma_in - 1) * gamma(gamma_in - 1));
123  }
124  else
125  {
126 
127  if ((gamma_in - ep < 1.0) && (gamma_in + ep > 1.0))
128  return 1.0;
129  else if ((gamma_in - ep < 0.5) && (gamma_in + ep > 0.5))
130  return constants::sqrt_pi;
131  else
132  return std::numeric_limits<Mdouble>::quiet_NaN();
133  }
134 } //end func gamma
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const Mdouble sqrt_pi
Definition: ExtendedMath.h:24

References e(), and constants::sqrt_pi.

Referenced by TwoDDGProblem< ELEMENT >::apply_initial_conditions(), Eigen::internal::bicgstabl(), FourierDecomposedHelmholtzProblem< ELEMENT >::check_gamma(), chi_squared(), SegregationWithHopper::create_inflow_particle(), AngleOfRepose::create_inflow_particle(), ElasticRefineableQuarterCircleSectorMesh< ELEMENT >::ElasticRefineableQuarterCircleSectorMesh(), Eigen::internal::erfc_double_large(), eulerangles_manual(), oomph::PVDEquations< DIM >::extended_output(), oomph::PVDEquationsWithPressure< DIM >::extended_output(), oomph::KirchhoffLoveBeamEquations::fill_in_contribution_to_residuals_beam(), oomph::KirchhoffLoveShellEquations::fill_in_contribution_to_residuals_shell(), oomph::RefineableQDPVDElement< DIM, NNODE_1D >::fill_in_generic_contribution_to_residuals_pvd(), oomph::RefineablePVDEquations< DIM >::fill_in_generic_contribution_to_residuals_pvd(), oomph::PVDEquations< DIM >::fill_in_generic_contribution_to_residuals_pvd(), oomph::ScaleCoupledElement< ELEMENT >::fill_in_generic_contribution_to_residuals_pvd(), oomph::VolumeCoupledElement< ELEMENT >::fill_in_generic_contribution_to_residuals_pvd(), oomph::FourierDecomposedHelmholtzDtNBoundaryElement< ELEMENT >::fill_in_generic_residual_contribution_fourier_decomposed_helmholtz_DtN_bc(), oomph::HelmholtzDtNBoundaryElement< ELEMENT >::fill_in_generic_residual_contribution_helmholtz_DtN_bc(), oomph::RefineablePVDEquationsWithPressure< DIM >::fill_in_generic_residual_contribution_pvd_with_pressure(), oomph::PVDEquationsWithPressure< DIM >::fill_in_generic_residual_contribution_pvd_with_pressure(), oomph::KirchhoffLoveShellEquations::get_energy(), oomph::PVDEquationsBase< DIM >::get_energy(), oomph::KirchhoffLoveBeamEquations::get_energy(), RachelsAdvectionDiffusion::get_exact_u(), QThermalPVDElement< DIM >::get_isotropic_growth(), oomph::PVDEquationsBase< DIM >::get_isotropic_growth(), oomph::SCoupledElement< ELEMENT >::get_momentum_and_energy(), oomph::VolumeCoupledElement< ELEMENT >::get_momentum_and_energy(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::PVDEquations< DIM >::get_stress(), oomph::PVDEquationsWithPressure< DIM >::get_stress(), InfiniteWall::getFurthestPointSuperQuadric(), SolidProblem< ELEMENT_TYPE >::getMassMomentumEnergy(), Eigen::internal::idrs(), Eigen::internal::idrstabl(), TwoDDGProblem< ELEMENT >::limit(), Eigen::internal::llt_rank_update_lower(), main(), oomph::DGEulerFaceElement< ELEMENT >::numerical_flux(), oomph::PVDEquations< DIM >::output(), oomph::PVDEquationsWithPressure< DIM >::output(), ElasticBeamProblem::parameter_study(), HopperInsertionBoundary::placeParticle(), oomph::EulerEquations< DIM >::pressure(), Eigen::internal::generic_fast_erfc< Scalar >::run(), SuperQuadricParticle::setBoundingRadius(), test_scalar_sugar_add_mul(), test_scalar_sugar_sub_div(), Eigen::internal::ldlt_inplace< Lower >::updateInPlace(), Eigen::internal::veltkamp_splitting(), oomph::MooneyRivlin::W(), and oomph::GeneralisedMooneyRivlin::W().

◆ goldenSectionSearch()

Mdouble mathsFunc::goldenSectionSearch ( Mdouble(*)(const Mdouble function,
Mdouble  min,
Mdouble  cur,
Mdouble  max,
Mdouble  endCondition,
Mdouble  curVal = std::numeric_limits<Mdouble>::quiet_NaN() 
)

This function performs a golden section search to find the location of the minimum of a function.

Parameters
[in]functionA function pointer to the function of which you want to calculate the location of its minimum.
[in]minThe minimum location
[in]curThe current location
[in]maxThe maximum location
[in]endConditionThe algorithm terminates when abs(max - min) < endCondition
[in]curValThe value of the function at the current location (on default this value is calculated internally)
187 {
188  if (std::abs(max - min) < endCondition)
189  {
190  return 0.5 * (min + max);
191  }
192  logger(INFO, "Min=% Max=% diff= %", min, max, max - min);
193  Mdouble resphi = 2 - 0.5 * (1 + std::sqrt(5));
194  Mdouble x;
195  if (max - cur > cur - min)
196  {
197  x = cur + resphi * (max - cur);
198  }
199  else
200  {
201  x = cur - resphi * (cur - min);
202  }
203  if (std::isnan(curVal))
204  curVal = function(cur);
205  Mdouble xVal = function(x);
206  if (xVal < curVal)
207  {
208  if (max - cur > cur - min)
209  {
210  return goldenSectionSearch(function, cur, x, max, endCondition, xVal);
211  }
212  else
213  {
214  return goldenSectionSearch(function, min, x, cur, endCondition, xVal);
215  }
216  }
217  else
218  {
219  if (max - cur > cur - min)
220  {
221  return goldenSectionSearch(function, min, cur, x, endCondition, curVal);
222  }
223  else
224  {
225  return goldenSectionSearch(function, x, cur, max, endCondition, curVal);
226  }
227  }
228 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
#define isnan(X)
Definition: main.h:109
#define INFO(i)
Definition: mumps_solver.h:54
Mdouble goldenSectionSearch(Mdouble(*function)(const Mdouble), Mdouble min, Mdouble cur, Mdouble max, Mdouble endCondition, Mdouble curVal=std::numeric_limits< Mdouble >::quiet_NaN())
This function performs a golden section search to find the location of the minimum of a function.
Definition: ExtendedMath.cc:185

References abs(), INFO, isnan, logger, max, min, sqrt(), and plotDoE::x.

◆ I0()

Mdouble mathsFunc::I0 ( Mdouble  x)
371 {
372  if (x < 0)
373  x = -x;
374  return exp(x) * I0_exp(x);
375 }
Mdouble I0_exp(Mdouble x)
Definition: ExtendedMath.cc:290

References Eigen::bfloat16_impl::exp(), I0_exp(), and plotDoE::x.

◆ I0_exp()

Mdouble mathsFunc::I0_exp ( Mdouble  x)
291 {
292  // Coefficients for [0..8]
293  const Mdouble A[] =
294  {
295  -4.415341646479339379501E-18,
296  3.330794518822238097831E-17,
297  -2.431279846547954693591E-16,
298  1.715391285555133030611E-15,
299  -1.168533287799345168081E-14,
300  7.676185498604935616881E-14,
301  -4.856446783111929460901E-13,
302  2.955052663129639834611E-12,
303  -1.726826291441555707231E-11,
304  9.675809035373236912241E-11,
305  -5.189795601635262906661E-10,
306  2.659823724682386650351E-9,
307  -1.300025009986248042121E-8,
308  6.046995022541918949321E-8,
309  -2.670793853940611733911E-7,
310  1.117387539120103718151E-6,
311  -4.416738358458750563591E-6,
312  1.644844807072889708931E-5,
313  -5.754195010082103703981E-5,
314  1.885028850958416557291E-4,
315  -5.763755745385823658851E-4,
316  1.639475616941335798421E-3,
317  -4.324309995050575944301E-3,
318  1.054646039459499831831E-2,
319  -2.373741480589946881561E-2,
320  4.930528423967070848781E-2,
321  -9.490109704804764442101E-2,
322  1.716209015222087753491E-1,
323  -3.046826723431983986831E-1,
324  6.767952744094760849951E-1
325  };
326 
327  // Coefficients for [8..infinity]
328  const Mdouble B[] =
329  {
330  -7.233180487874753954561E-18,
331  -4.830504485944182071261E-18,
332  4.465621420296759999011E-17,
333  3.461222867697461093101E-17,
334  -2.827623980516583484941E-16,
335  -3.425485619677219134621E-16,
336  1.772560133056526383601E-15,
337  3.811680669352622420751E-15,
338  -9.554846698828307648701E-15,
339  -4.150569347287222086631E-14,
340  1.540086217521409826911E-14,
341  3.852778382742142701141E-13,
342  7.180124451383666233671E-13,
343  -1.794178531506806117781E-12,
344  -1.321581184044771311881E-11,
345  -3.149916527963241364541E-11,
346  1.188914710784643834241E-11,
347  4.940602388224969589101E-10,
348  3.396232025708386345151E-9,
349  2.266668990498178064591E-8,
350  2.048918589469063741831E-7,
351  2.891370520834756482971E-6,
352  6.889758346916823984261E-5,
353  3.369116478255694089901E-3,
354  8.044904110141088316081E-1
355  };
356 
357  if (x < 0)
358  x = -x;
359 
360  if (x <= 8.0)
361  {
362  Mdouble y = (x / 2.0) - 2.0;
363  return (chebyshev(y, A, 30));
364  }
365 
366  return (chebyshev(32.0 / x - 2.0, B, 25) / sqrt(x));
367 
368 }
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Definition: matrices.h:74
Scalar * y
Definition: level1_cplx_impl.h:128
Mdouble chebyshev(Mdouble x, const Mdouble coef[], int N)
Namespace for evaluating the zeroth modified Bessel function of the first kind, I0(x),...
Definition: ExtendedMath.cc:272

References chebyshev(), sqrt(), plotDoE::x, and y.

Referenced by I0().

◆ isEqual() [1/5]

bool mathsFunc::isEqual ( Matrix3D  m1,
Matrix3D  m2,
Mdouble  absError 
)

Compares the difference of two Vec3D with an absolute error, useful in UnitTests.

Parameters
[in]m1The first Vec3D
[in]m2The second Vec3D
[in]absErrorThe allowed maximum absolute error
Returns
true if the two Vec3D are equal
242 {
243  return (isEqual(m1.XX, m2.XX, absError)
244  && isEqual(m1.XY, m2.XY, absError)
245  && isEqual(m1.XZ, m2.XZ, absError)
246  && isEqual(m1.YX, m2.YX, absError)
247  && isEqual(m1.YY, m2.YY, absError)
248  && isEqual(m1.YZ, m2.YZ, absError)
249  && isEqual(m1.ZX, m2.ZX, absError)
250  && isEqual(m1.ZY, m2.ZY, absError)
251  && isEqual(m1.ZZ, m2.ZZ, absError));
252 }
Matrix3d m1
Definition: IOFormat.cpp:2
bool isEqual(const std::vector< DistributionElements > &l, const std::vector< DistributionElements > &r)
Definition: PSDConversionUnitTest.cpp:30
MatrixType m2(n_dims)

References isEqual(), m1, and m2().

◆ isEqual() [2/5]

bool mathsFunc::isEqual ( MatrixSymmetric3D  m1,
MatrixSymmetric3D  m2,
Mdouble  absError 
)
255 {
256  return (isEqual(m1.XX, m2.XX, absError)
257  && isEqual(m1.XY, m2.XY, absError)
258  && isEqual(m1.XZ, m2.XZ, absError)
259  && isEqual(m1.YY, m2.YY, absError)
260  && isEqual(m1.YZ, m2.YZ, absError)
261  && isEqual(m1.ZZ, m2.ZZ, absError));
262 }

References isEqual(), m1, and m2().

◆ isEqual() [3/5]

bool mathsFunc::isEqual ( Mdouble  v1,
Mdouble  v2,
Mdouble  absError 
)

◆ isEqual() [4/5]

bool mathsFunc::isEqual ( Quaternion  v1,
Quaternion  v2,
double  absError 
)
265 {
266  return isEqual(v1.getComponent(0), v2.getComponent(0), absError) &&
267  isEqual(v1.getComponent(1), v2.getComponent(1), absError) &&
268  isEqual(v1.getComponent(2), v2.getComponent(2), absError) &&
269  isEqual(v1.getComponent(3), v2.getComponent(3), absError);
270 }

References isEqual(), v1(), and v2().

◆ isEqual() [5/5]

bool mathsFunc::isEqual ( Vec3D  v1,
Vec3D  v2,
Mdouble  absError 
)

Compares the difference of two Vec3D with an absolute error, useful in UnitTests.

Parameters
[in]v1The first Vec3D
[in]v2The second Vec3D
[in]absErrorThe allowed maximum absolute error
Returns
true if the two Vec3D are equal
237 {
238  return isEqual(v1.X, v2.X, absError) && isEqual(v1.Y, v2.Y, absError) && isEqual(v1.Z, v2.Z, absError);
239 }

References isEqual(), v1(), and v2().

◆ log()

Mdouble mathsFunc::log ( Mdouble  Power)
Todo:
check if this function works
84 {
85  Mdouble N, P, L, R, A, E;
86  E = 2.71828182845905;
87  P = Power;
88  N = 0.0;
89 
90  // This speeds up the convergence by calculating the integral
91  while (P >= E)
92  {
93  P /= E;
94  N++;
95  }
96  N += (P / E);
97  P = Power;
98  do
99  {
100  A = N;
101  L = (P / (exp(N - 1.0)));
102  R = ((N - 1.0) * E);
103  N = ((L + R) / E);
104  } while (N < A);
105  //} while (N != A);
106 
107  return N;
108 }
@ R
Definition: StatisticsVector.h:21
double E
Elastic modulus.
Definition: TwenteMeshGluing.cpp:68

References Global_Physical_Variables::E, Eigen::bfloat16_impl::exp(), L, N, Global_Physical_Variables::P, and R.

Referenced by main(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), and SPHNormalSpecies::setCollisionTimeAndRestitutionCoefficient().

◆ sign()

template<typename T >
int mathsFunc::sign ( T  val)

This is a sign function, it returns -1 for negative numbers, 1 for positive numbers and 0 for 0.

78 {
79  return (T(0) < val) - (val < T(0));
80 }
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11

References calibrate::val.

Referenced by PeriodicBoundaryHandler::checkIsReal(), SuperQuadricParticle::computeHessianLabFixed(), SuperQuadricParticle::computeShapeGradientLabFixed(), HorizontalScrew::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), InfiniteWall::getFurthestPointSuperQuadric(), and PeriodicBoundaryHandler::updateParticles().

◆ sin()

Mdouble mathsFunc::sin ( Mdouble  x)
24 {
25  Mdouble N = floor(x / (2.0 * constants::pi) + 0.5);
26  x -= N * 2.0 * constants::pi;
27  Mdouble Sum = 0;
28  Mdouble Power = x;
29  Mdouble Sign = 1;
30  const Mdouble x2 = x * x;
31  Mdouble Fact = 1.0;
32  for (unsigned int i = 1; i < 25; i += 2)
33  {
34  Sum += Sign * Power / Fact;
35  Power *= x2;
36  Fact *= (i + 1) * (i + 2);
37  Sign *= -1.0;
38  }
39  return Sum;
40 }

References Eigen::bfloat16_impl::floor(), i, N, constants::pi, FishSolnOneDPoisson::Sign, plotDoE::x, and Global_parameters::x2().

Referenced by ChuteWithHopper::addHopper(), AxisymmetricHopper::create_inflow_particle(), ChuteWithHopper::getMaximumVelocityInducedByGravity(), main(), HopperInsertionBoundary::placeParticle(), AxisymmetricHopper::setupInitialConditions(), HourGlass::setupInitialConditions(), Tutorial11::setupInitialConditions(), and tan().

◆ square()

template<typename T >
T mathsFunc::square ( const T  val)

squares a number

87 {
88  return val * val;
89 }

References calibrate::val.

Referenced by MeltableInteraction::actionsAfterTimeStep(), AngleOfRepose::actionsBeforeTimeStep(), MeltableParticle::actionsBeforeTimeStep(), MeltableNormalSpecies::analyseTimeScales(), DPMBase::checkParticleForInteractionLocal(), helpers::computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(), FrictionInteraction::computeFrictionForce(), MindlinRollingTorsionInteraction::computeFrictionForce(), SlidingFrictionInteraction::computeFrictionForce(), ChuteWithPeriodicInflow::computeInternalForces(), BaseParticle::computeMass(), MeltableInteraction::computeNormalForce(), SinterInteraction::computeNormalForce(), HertzianSinterInteraction::computeSinterForce(), LinearPlasticViscoelasticNormalSpecies::computeTimeStep(), LinearViscoelasticNormalSpecies::computeTimeStep(), SinterLinNormalSpecies::computeTimeStep(), SinterNormalSpecies::computeTimeStep(), AngleOfRepose::create_inflow_particle(), Slide::create_rough_wall(), Matrix3D::deviator(), statistics_while_running< T >::finishStatistics(), SinterNormalSpecies::getCollisionTime(), LinearPlasticViscoelasticNormalSpecies::getCollisionTime(), LinearViscoelasticNormalSpecies::getCollisionTime(), SinterLinNormalSpecies::getCollisionTime(), SPHNormalSpecies::getCollisionTime(), HertzianViscoelasticNormalSpecies::getCollisionTime(), StatisticsVector< T >::getCutoff2(), Coil::getDistanceAndNormal(), ParabolaChute::getDistanceAndNormal(), SineWall::getDistanceAndNormal(), Screw::getDistanceAndNormalLabCoordinates(), CGCoordinates::R::getDistanceSquared(), CGCoordinates::RZ::getDistanceSquared(), CGCoordinates::X::getDistanceSquared(), CGCoordinates::XY::getDistanceSquared(), CGCoordinates::XZ::getDistanceSquared(), CGCoordinates::Y::getDistanceSquared(), CGCoordinates::YZ::getDistanceSquared(), CGCoordinates::Z::getDistanceSquared(), MeltableNormalSpecies::getEffectiveElasticModulus(), ChargedBondedInteraction::getElasticEnergy(), IrreversibleAdhesiveInteraction::getElasticEnergy(), HertzianSinterInteraction::getElasticEnergy(), HertzianViscoelasticInteraction::getElasticEnergy(), LinearPlasticViscoelasticInteraction::getElasticEnergy(), LinearViscoelasticInteraction::getElasticEnergy(), SinterInteraction::getElasticEnergy(), SinterLinInteraction::getElasticEnergy(), SPHInteraction::getElasticEnergy(), HertzianViscoelasticInteraction::getElasticEnergyAtEquilibrium(), CGCoordinates::Base_X_Y_Z::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussIntegralPrefactor(), CGCoordinates::XYZ::getGaussIntegralPrefactor(), CGCoordinates::Base_XY_XZ_YZ::getGaussPrefactor(), CGCoordinates::XYZ::getGaussPrefactor(), WallSpecies::getInfo(), helpers::getMaximumVelocity(), CGFields::GradVelocityField::getSquared(), CGFields::LiquidMigrationFields::getSquared(), CGFields::StandardFields::getSquared(), CGCoordinates::RZ::getTangentialSquared(), CGCoordinates::XY::getTangentialSquared(), CGCoordinates::XYZ::getTangentialSquared(), CGCoordinates::XZ::getTangentialSquared(), CGCoordinates::YZ::getTangentialSquared(), Mercury3D::hGridFindContactsWithTargetCell(), MercuryBase::hGridUpdateMove(), BaseParticle::isInContactWith(), LaserOnLayer::LaserOnLayer(), main(), CGCoordinates::Base_XY_XZ_YZ::normalisePolynomialCoefficients(), particleParticleTest(), statistics_while_running< T >::processStatistics(), Vreman::set_symmetric_contraction(), ContractionWithPeriodicInflow::set_symmetric_contraction(), ChuteWithPeriodicInflowAndContraction::set_symmetric_contraction(), ChuteWithContraction::set_symmetric_contraction(), SuperQuadricParticle::setBoundingRadius(), StatisticsVector< T >::setCGWidth(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(), LinearPlasticViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), SinterLinNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), SinterNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), SPHNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), LinearPlasticViscoelasticNormalSpecies::setRestitutionCoefficient(), LinearViscoelasticNormalSpecies::setRestitutionCoefficient(), SinterLinNormalSpecies::setRestitutionCoefficient(), SPHNormalSpecies::setRestitutionCoefficient(), SinterLinNormalSpecies::setStiffnessAndRestitutionCoefficient(), SinterNormalSpecies::setStiffnessAndRestitutionCoefficient(), RotatingDrumWet::setupInitialConditions(), StressStrainControl::setupInitialConditions(), AngleOfRepose::setupInitialConditions(), HertzianSinterForceUnitTest::setupInitialConditions(), SinterForceUnitTest::setupInitialConditions(), Matrix3D::square(), MatrixSymmetric3D::square(), and wallParticleTest().

◆ tan()

template<typename T >
T mathsFunc::tan ( T  x)
Todo:
should be properly computed
159 {
160  return sin(x) / cos(x);
161 }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137

References cos(), sin(), and plotDoE::x.

Referenced by ChuteWithHopper::addHopper(), and ChuteWithHopper::setHopper().