FEDEM Solver  R8.0
Source code of the dynamics solver
FFaMath.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
13 #ifndef FFA_MATH_H
14 #define FFA_MATH_H
15 
16 #include <cmath>
17 #include <cstddef>
18 
19 #if _MSC_VER > 1300 && _MSC_VER < 1500
20 #define hypot _hypot
21 #endif
22 
23 #ifndef EPS_ZERO
25 #define EPS_ZERO 1.0e-15
26 #endif
27 
28 #ifndef M_PI
30 #define M_PI 3.14159265358979323846
31 #endif
32 
33 #ifndef RAD
35 #define RAD(x) (x)*M_PI/180.0
36 #endif
37 
38 #ifdef FFA_NO_ROUND
40 inline double round (double value, int) { return value; }
41 #else
43 extern double round (double value, int precision);
44 #endif
45 
46 #ifdef FFA_DEBUG
47 extern double atan3 (double y, double x, const char* func = NULL);
48 #else
50 inline double atan3 (double y, double x, const char* = NULL)
51 {
52  return fabs(y) > EPS_ZERO || fabs(x) > EPS_ZERO ? atan2(y,x) : 0.0;
53 }
54 #endif
55 
56 
57 namespace FFa
58 {
61  int cubicSolve (double A, double B, double C, double D, double* X);
63  int bilinearSolve (const double* A, const double* B, double* X, double* Y);
64 }
65 
66 #endif
double round(double value, int precision)
Rounds off value down to precision significant digits.
Definition: FFaMath.C:32
double atan3(double y, double x, const char *=NULL)
Checks for singular rotations before using atan2 library function.
Definition: FFaMath.H:50
#define EPS_ZERO
Division by zero tolerance.
Definition: FFaMath.H:25
Various math utilities.
Definition: FFaMath.H:58
int bilinearSolve(const double *A, const double *B, double *X, double *Y)
Solves a bi-linear set of equations in X and Y.
Definition: FFaMath.C:164
int cubicSolve(double A, double B, double C, double D, double *X)
Solves the cubic equation A*x3 + B*x2 + C*x + D = 0.
Definition: FFaMath.C:67
integer(ptr), save, private x
Definition: extCtrlSysRoutinesModule.f90:16