7.1
general documentation
cs_math.h File Reference
#include "cs_defs.h"
#include <assert.h>
#include <math.h>
+ Include dependency graph for cs_math.h:

Go to the source code of this file.

Enumerations

enum  cs_math_sym_tensor_component_t {
  XX, YY, ZZ, XY,
  YZ, XZ
}
 

Functions

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 (Euclidean norm) between two points xa and xb in a Cartesian coordinate system of dimension 3. More...
 
void cs_math_sym_33_eigen (const cs_real_t m[6], cs_real_t eig_vals[3])
 Compute all eigenvalues of a 3x3 symmetric matrix with symmetric storage. More...
 
void cs_math_33_eigen (const cs_real_t m[3][3], cs_real_t *eig_ratio, cs_real_t *eig_max)
 Compute max/min eigenvalues ratio and max. eigenvalue of a 3x3 symmetric matrix with non-symmetric storage. 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...
 
void cs_math_33_eig_val_vec (const cs_real_t m_in[3][3], const cs_real_t tol_err, cs_real_t eig_val[restrict 3], cs_real_t eig_vec[restrict 3][3])
 Evaluate eigenvalues and eigenvectors of a real symmetric matrix m1[3,3]: m1*m2 = lambda*m2. More...
 
void cs_math_fact_lu (cs_lnum_t n_blocks, const int b_size, const cs_real_t *a, cs_real_t *a_lu)
 Compute LU factorization of an array of dense matrices of identical size. More...
 
void cs_math_fw_and_bw_lu (const cs_real_t a_lu[], const int n, cs_real_t x[], const cs_real_t b[])
 Block Jacobi utilities. Compute forward and backward to solve an LU P*P system. More...
 

Variables

const cs_real_t cs_math_zero_threshold
 
const cs_real_t cs_math_1ov3
 
const cs_real_t cs_math_2ov3
 
const cs_real_t cs_math_4ov3
 
const cs_real_t cs_math_5ov3
 
const cs_real_t cs_math_1ov6
 
const cs_real_t cs_math_1ov12
 
const cs_real_t cs_math_1ov24
 
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
 

Enumeration Type Documentation

◆ cs_math_sym_tensor_component_t

Enumerator
XX 
YY 
ZZ 
XY 
YZ 
XZ 

Function Documentation

◆ cs_math_33_eig_val_vec()

void cs_math_33_eig_val_vec ( const cs_real_t  m_in[3][3],
const cs_real_t  tol_err,
cs_real_t  eig_val[restrict 3],
cs_real_t  eig_vec[restrict 3][3] 
)

Evaluate eigenvalues and eigenvectors of a real symmetric matrix m1[3,3]: m1*m2 = lambda*m2.

Use of Jacobi method for symmetric matrices (adapted from the book Numerical Recipes in C, Chapter 11.1)

Parameters
[in]m_inmatrix of 3x3 real values (initial)
[in]tol_errabsolute tolerance (sum of off-diagonal elements)
[out]eig_valvector of 3 real values (eigenvalues)
[out]eig_vecmatrix of 3x3 real values (eigenvectors)

◆ 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 max/min eigenvalues ratio and max. eigenvalue of a 3x3 symmetric matrix with non-symmetric storage.

Based on: 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_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 (Euclidean 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 along va -> vb

◆ cs_math_fact_lu()

void cs_math_fact_lu ( cs_lnum_t  n_blocks,
int  b_size,
const cs_real_t a,
cs_real_t a_lu 
)

Compute LU factorization of an array of dense matrices of identical size.

Parameters
[in]n_blocksnumber of blocks
[in]b_sizeblock size
[in]amatrix blocks
[out]a_luLU factorizations of matrix blocks

◆ cs_math_fw_and_bw_lu()

void cs_math_fw_and_bw_lu ( const cs_real_t  a_lu[],
int  n,
cs_real_t  x[],
const cs_real_t  b[] 
)

Block Jacobi utilities. Compute forward and backward to solve an LU P*P system.

Parameters
[in]a_lumatrix LU factorization
[in]nmatrix size
[out]xsolution
[out]bright hand side

◆ 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_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_eigen()

void cs_math_sym_33_eigen ( const cs_real_t  m[6],
cs_real_t  eig_vals[3] 
)

Compute all eigenvalues of a 3x3 symmetric matrix with symmetric storage.

Based on: Oliver K. Smith "eigenvalues of a symmetric 3x3 matrix", Communication of the ACM (April 1961) (Wikipedia article entitled "Eigenvalue algorithm")

Parameters
[in]m3x3 symmetric matrix (m11, m22, m33, m12, m23, m13)
[out]eig_valssize 3 vector

◆ 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.

Variable Documentation

◆ cs_math_1ov12

const cs_real_t cs_math_1ov12

◆ cs_math_1ov24

const cs_real_t cs_math_1ov24

◆ cs_math_1ov3

const cs_real_t cs_math_1ov3

◆ cs_math_1ov6

const cs_real_t cs_math_1ov6

◆ cs_math_2ov3

const cs_real_t cs_math_2ov3

◆ cs_math_4ov3

const cs_real_t cs_math_4ov3

◆ cs_math_5ov3

const cs_real_t cs_math_5ov3

◆ 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_pi

const cs_real_t cs_math_pi

◆ cs_math_zero_threshold

const cs_real_t cs_math_zero_threshold