programmer's documentation
Functions | Variables
cs_math.h File Reference
#include "cs_defs.h"
#include <math.h>
Include dependency graph for cs_math.h:

Go to the source code of this file.

Functions

void symmetric_matrix_inverse (const cs_real_6_t s, cs_real_6_t sout)
 
void symmetric_matrix_product (const cs_real_6_t s1, const cs_real_6_t s2, cs_real_6_t sout)
 
static cs_real_t cs_math_sq (cs_real_t x)
 Compute the square of a real value. More...
 
static cs_real_t cs_math_3_length (const cs_real_t xa[3], const cs_real_t xb[3])
 Compute the (euclidean) length between two points xa and xb in a cartesian coordinate system of dimension 3. More...
 
static cs_real_t cs_math_3_dot_product (const cs_real_t u[3], const cs_real_t v[3])
 Compute the dot product of two vectors of 3 real values. More...
 
static cs_real_t cs_math_3_norm (const cs_real_t v[3])
 Compute the euclidean norm of a vector of dimension 3. More...
 
static cs_real_t cs_math_3_square_norm (const cs_real_t v[3])
 Compute the square norm of a vector of 3 real values. More...
 
static void cs_math_33_3_product (const cs_real_t m[3][3], const cs_real_t v[3], cs_real_3_t mv)
 Compute the product of a matrix of 3x3 real values by a vector of 3 real values. More...
 
static void cs_math_33t_3_product (const cs_real_t m[3][3], const cs_real_t v[3], cs_real_3_t mv)
 Compute the product of the transpose of a matrix of 3x3 real values by a vector of 3 real values. More...
 
static void cs_math_sym_33_3_product (const cs_real_t m[6], const cs_real_t v[3], cs_real_t mv[restrict 3])
 Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values. NB: Symmetric matrix are stored as follows (s11, s22, s33, s12, s23, s13) More...
 
static cs_real_t cs_math_33_determinant (const cs_real_t m[3][3])
 Compute the determinant of a 3x3 matrix. More...
 
static void cs_math_3_cross_product (const cs_real_t u[3], const cs_real_t v[3], cs_real_t uv[restrict 3])
 Compute the cross product of two vectors of 3 real values. More...
 
static void cs_math_33_inv (const cs_real_t in[3][3], cs_real_t out[3][3])
 Inverse a 3x3 matrix. More...
 
static void cs_math_sym_33_inv_cramer (const cs_real_t s[6], cs_real_t sout[restrict 6])
 Compute the inverse of a symmetric matrix using Cramer's rule. More...
 
static void cs_math_sym_33_product (const cs_real_t s1[6], const cs_real_t s2[6], cs_real_t sout[restrict 6])
 Compute the product of two symmetric matrices. More...
 
static void cs_math_sym_33_double_product (const cs_real_t s1[6], const cs_real_t s2[6], const cs_real_t s3[6], cs_real_t sout[restrict 3][3])
 Compute the product of three symmetric matrices. More...
 
void cs_math_set_machine_epsilon (void)
 Compute the value related to the machine precision. More...
 
double cs_math_get_machine_epsilon (void)
 Get the value related to the machine precision. More...
 
void cs_math_3_length_unitv (const cs_real_t xa[3], const cs_real_t xb[3], cs_real_t *len, cs_real_3_t unitv)
 Compute the length (euclidien norm) between two points xa and xb in a cartesian coordinate system of dimension 3. More...
 
void cs_math_33_eigen (const cs_real_t m[3][3], cs_real_t *eig_ratio, cs_real_t *eig_max)
 Compute the eigenvalues of a 3x3 matrix which is symmetric and real -> Oliver K. Smith "eigenvalues of a symmetric 3x3 matrix", Communication of the ACM (April 1961) -> Wikipedia article entitled "Eigenvalue algorithm". More...
 
double cs_math_surftri (const cs_real_t xv[3], const cs_real_t xe[3], const cs_real_t xf[3])
 Compute the area of the convex_hull generated by 3 points. This corresponds to the computation of the surface of a triangle. More...
 
double cs_math_voltet (const cs_real_t xv[3], const cs_real_t xe[3], const cs_real_t xf[3], const cs_real_t xc[3])
 Compute the volume of the convex_hull generated by 4 points. This is equivalent to the computation of the volume of a tetrahedron. More...
 

Variables

const cs_real_t cs_math_zero_threshold
 
const cs_real_t cs_math_onethird
 
const cs_real_t cs_math_onesix
 
const cs_real_t cs_math_onetwelve
 
const cs_real_t cs_math_epzero
 
const cs_real_t cs_math_infinite_r
 
const cs_real_t cs_math_big_r
 
const cs_real_t cs_math_pi
 

Function Documentation

◆ cs_math_33_3_product()

static void cs_math_33_3_product ( const cs_real_t  m[3][3],
const cs_real_t  v[3],
cs_real_3_t  mv 
)
inlinestatic

Compute the product of a matrix of 3x3 real values by a vector of 3 real values.

Parameters
[in]mmatrix of 3x3 real values
[in]vvector of 3 real values
[out]mvvector of 3 real values

◆ cs_math_33_determinant()

static cs_real_t cs_math_33_determinant ( const cs_real_t  m[3][3])
inlinestatic

Compute the determinant of a 3x3 matrix.

Parameters
[in]m3x3 matrix
Returns
the determinant

◆ cs_math_33_eigen()

void cs_math_33_eigen ( const cs_real_t  m[3][3],
cs_real_t eig_ratio,
cs_real_t eig_max 
)

Compute the eigenvalues of a 3x3 matrix which is symmetric and real -> Oliver K. Smith "eigenvalues of a symmetric 3x3 matrix", Communication of the ACM (April 1961) -> Wikipedia article entitled "Eigenvalue algorithm".

Parameters
[in]m3x3 matrix
[out]eig_ratiomax/min
[out]eig_maxmax. eigenvalue

◆ cs_math_33_inv()

static void cs_math_33_inv ( const cs_real_t  in[3][3],
cs_real_t  out[3][3] 
)
inlinestatic

Inverse a 3x3 matrix.

Parameters
[in]inmatrix to inverse
[out]outinversed matrix

◆ cs_math_33t_3_product()

static void cs_math_33t_3_product ( const cs_real_t  m[3][3],
const cs_real_t  v[3],
cs_real_3_t  mv 
)
inlinestatic

Compute the product of the transpose of a matrix of 3x3 real values by a vector of 3 real values.

Parameters
[in]mmatrix of 3x3 real values
[in]vvector of 3 real values
[out]mvvector of 3 real values

◆ cs_math_3_cross_product()

static void cs_math_3_cross_product ( const cs_real_t  u[3],
const cs_real_t  v[3],
cs_real_t  uv[restrict 3] 
)
inlinestatic

Compute the cross product of two vectors of 3 real values.

Parameters
[in]uvector of 3 real values
[in]vvector of 3 real values
[out]uvvector of 3 real values

◆ cs_math_3_dot_product()

static cs_real_t cs_math_3_dot_product ( const cs_real_t  u[3],
const cs_real_t  v[3] 
)
inlinestatic

Compute the dot product of two vectors of 3 real values.

Parameters
[in]uvector of 3 real values
[in]vvector of 3 real values
Returns
the resulting dot product u.v.

◆ cs_math_3_length()

static cs_real_t cs_math_3_length ( const cs_real_t  xa[3],
const cs_real_t  xb[3] 
)
inlinestatic

Compute the (euclidean) length between two points xa and xb in a cartesian coordinate system of dimension 3.

Parameters
[in]xafirst coordinate
[in]xbsecond coordinate
Returns
the length between two points xa and xb

◆ cs_math_3_length_unitv()

void cs_math_3_length_unitv ( const cs_real_t  xa[3],
const cs_real_t  xb[3],
cs_real_t len,
cs_real_3_t  unitv 
)
inline

Compute the length (euclidien norm) between two points xa and xb in a cartesian coordinate system of dimension 3.

Parameters
[in]xacoordinate of the first extremity
[in]xbcoordinate of the second extremity
[out]lenpointer to the length of the vector va -> vb
[out]unitvunitary vector along xa -> xb
[in]xacoordinate of the first extremity
[in]xbcoordinate of the second extremity
[out]lenpointer to the length of the vector va -> vb
[out]unitvunitary vector anlong va -> vb

◆ cs_math_3_norm()

static cs_real_t cs_math_3_norm ( const cs_real_t  v[3])
inlinestatic

Compute the euclidean norm of a vector of dimension 3.

Parameters
[in]v
Returns
the value of the norm

◆ cs_math_3_square_norm()

static cs_real_t cs_math_3_square_norm ( const cs_real_t  v[3])
inlinestatic

Compute the square norm of a vector of 3 real values.

Parameters
[in]vvector of 3 real values
Returns
square norm of v.

◆ cs_math_get_machine_epsilon()

double cs_math_get_machine_epsilon ( void  )

Get the value related to the machine precision.

◆ cs_math_set_machine_epsilon()

void cs_math_set_machine_epsilon ( void  )

Compute the value related to the machine precision.

◆ cs_math_sq()

static cs_real_t cs_math_sq ( cs_real_t  x)
inlinestatic

Compute the square of a real value.

Parameters
[in]xvalue
Returns
the square of the given value

◆ cs_math_surftri()

double cs_math_surftri ( const cs_real_t  xv[3],
const cs_real_t  xe[3],
const cs_real_t  xf[3] 
)
inline

Compute the area of the convex_hull generated by 3 points. This corresponds to the computation of the surface of a triangle.

Parameters
[in]xvcoordinates of the first vertex
[in]xecoordinates of the second vertex
[in]xfcoordinates of the third vertex
Returns
the surface of a triangle

◆ cs_math_sym_33_3_product()

static void cs_math_sym_33_3_product ( const cs_real_t  m[6],
const cs_real_t  v[3],
cs_real_t  mv[restrict 3] 
)
inlinestatic

Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values. NB: Symmetric matrix are stored as follows (s11, s22, s33, s12, s23, s13)

Parameters
[in]mmatrix of 3x3 real values
[in]vvector of 3 real values
[out]mvvector of 3 real values

◆ cs_math_sym_33_double_product()

static void cs_math_sym_33_double_product ( const cs_real_t  s1[6],
const cs_real_t  s2[6],
const cs_real_t  s3[6],
cs_real_t  sout[restrict 3][3] 
)
inlinestatic

Compute the product of three symmetric matrices.

Remarks
Symmetric matrix coefficients are stored as follows: (s11, s22, s33, s12, s23, s13)
Parameters
[in]s1symmetric matrix
[in]s2symmetric matrix
[in]s3symmetric matrix
[out]soutsout = s1 * s2 * s3

◆ cs_math_sym_33_inv_cramer()

static void cs_math_sym_33_inv_cramer ( const cs_real_t  s[6],
cs_real_t  sout[restrict 6] 
)
inlinestatic

Compute the inverse of a symmetric matrix using Cramer's rule.

Remarks
Symmetric matrix coefficients are stored as follows: (s11, s22, s33, s12, s23, s13)
Parameters
[in]ssymmetric matrix
[out]soutsout = 1/s1

◆ cs_math_sym_33_product()

static void cs_math_sym_33_product ( const cs_real_t  s1[6],
const cs_real_t  s2[6],
cs_real_t  sout[restrict 6] 
)
inlinestatic

Compute the product of two symmetric matrices.

Remarks
Symmetric matrix coefficients are stored as follows: (s11, s22, s33, s12, s23, s13)
Parameters
[in]s1symmetric matrix
[in]s2symmetric matrix
[out]soutsout = s1 * s2

◆ cs_math_voltet()

double cs_math_voltet ( const cs_real_t  xv[3],
const cs_real_t  xe[3],
const cs_real_t  xf[3],
const cs_real_t  xc[3] 
)

Compute the volume of the convex_hull generated by 4 points. This is equivalent to the computation of the volume of a tetrahedron.

Parameters
[in]xvcoordinates of the first vertex
[in]xecoordinates of the second vertex
[in]xfcoordinates of the third vertex
[in]xccoordinates of the fourth vertex
Returns
the volume of the tetrahedron.

◆ symmetric_matrix_inverse()

void symmetric_matrix_inverse ( const cs_real_6_t  s,
cs_real_6_t  sout 
)

◆ symmetric_matrix_product()

void symmetric_matrix_product ( const cs_real_6_t  s1,
const cs_real_6_t  s2,
cs_real_6_t  sout 
)

Variable Documentation

◆ cs_math_big_r

const cs_real_t cs_math_big_r

◆ cs_math_epzero

const cs_real_t cs_math_epzero

◆ cs_math_infinite_r

const cs_real_t cs_math_infinite_r

◆ cs_math_onesix

const cs_real_t cs_math_onesix

◆ cs_math_onethird

const cs_real_t cs_math_onethird

◆ cs_math_onetwelve

const cs_real_t cs_math_onetwelve

◆ cs_math_pi

const cs_real_t cs_math_pi

◆ cs_math_zero_threshold

const cs_real_t cs_math_zero_threshold