CEPS  24.01
Cardiac ElectroPhysiology Simulator
ceps::math Namespace Reference

math typedef for matrix coefficients of a single element More...

Functions

CepsReal polRef (CepsReal r)
 Pole function used in stimulation function definition. More...
 
CepsReal d4Polynomial (CepsReal x)
 A polynomial satisfying 0-derivative equalities. More...
 
CepsReal d5Polynomial (CepsReal r)
 Another polynomial satisfying more 0-derivative equalities. More...
 
CepsReal cInfinityStim (CepsReal t, CepsReal duration, CepsReal *point, const CepsVector< CepsReal > &orig, CepsReal diam, CepsReal amp)
 Regular $C^{\infty}$ stimulation function. More...
 
CepsReal constStim (CepsReal t, CepsReal duration, CepsReal *point, const CepsVector< CepsReal > &orig, CepsReal diam, CepsReal amp)
 Constant stimulation in a region (step function in time) More...
 
CepsReal c4Stim (CepsReal t, CepsReal duration, CepsReal *point, const CepsVector< CepsReal > &orig, CepsReal diam, CepsReal amp)
 Regular stimulation function. More...
 
CepsReal c5Stim (CepsReal t, CepsReal duration, CepsReal *point, const CepsVector< CepsReal > &orig, CepsReal diam, CepsReal amp)
 Regular stimulation function. More...
 
CepsReal lagrangianPol4Pts (CepsReal x, CepsReal f0, CepsReal f1, CepsReal f2, CepsReal f3)
 Lagrange interpolation of degree 3. More...
 
CepsReal derivativeLagrangianPol4Pts (CepsReal x, CepsReal f0, CepsReal f1, CepsReal f2, CepsReal f3)
 Derivative of Lagrange interpolating polynomial of degree 3. More...
 
CepsReal newtonSolvePol4Pts (CepsReal f0, CepsReal f1, CepsReal f2, CepsReal f3, CepsReal c, CepsReal t0)
 Solves for $t^*$ $f(t^*) = c$, based on a 4 points interpolation of $f$, using Newton method. More...
 
constexpr CepsUInt factorial (CepsUInt n)
 Compile-time factorial. More...
 
void computeInverse (const CepsMathDynamic2D &m, CepsMathDynamic2D &inv)
 Inverse of square matrices. More...
 
void computeInverse (const Eigen::Matrix< CepsReal, 3, 2 > &m, Eigen::Matrix< CepsReal, 2, 3 > &inv)
 Left inverse for 3x2 matrices. More...
 
void computeInverse (const Eigen::Matrix< CepsReal, 3, 1 > &m, Eigen::Matrix< CepsReal, 1, 3 > &inv)
 Left inverse 3x1 matrices. More...
 
void computeInverse (const Eigen::Matrix< CepsReal, 2, 1 > &m, Eigen::Matrix< CepsReal, 1, 2 > &inv)
 Left inverse for 2x1 matrices. More...
 
CepsMathDynamic2D compose (CepsUInt M, CepsVector< CepsMathDynamic2D * > blocks)
 Bloc matrices interleaving. More...
 
CepsMathDynamic1D compose (CepsUInt M, CepsVector< CepsMathDynamic1D * > blocks)
 Interleaving of M vectors. More...
 
void putRowsSumInDiagonal (CepsMathDynamic2D &mat)
 Mass lumping. More...
 
CepsMathDynamic2D multiplyByBlocks (const CepsMathDynamic2D &A, const CepsMathDynamic2D &B, const CepsArray2< CepsUInt > a, const CepsArray2< CepsUInt > b)
 Compute a matrix product by blocks [[C_11, C_12], [C_21, C_22]] = [[A_11 * B_11, A_12 * B_12], [A_21 * B_21, A_22 * B_22]] = [[A_11, A_12], [A_21, A_22]] * [[B_11, B_12], [B_21, B_22]]. More...
 
CepsReal interpolateLagrange (CepsReal x, const CepsVector< CepsReal > &f)
 Computes the interpolate of f at point x. assumes f is given at equidistant points on [0,1] Hard coded until 4 points are given. More...
 
CepsReal interpolateLagrange (CepsReal x, const CepsVector< CepsReal > &f, CepsReal xmin, CepsReal xmax)
 Computes the interpolate of f at point x. assumes f is given at equidistant points on [xmin,xmax]. More...
 
CepsReal interpolateLagrange (CepsReal x, const CepsVector< CepsReal > &f, const CepsVector< CepsReal > &xs)
 Computes the interpolate of f at point x. f given on points xs. More...
 

Detailed Description

math typedef for matrix coefficients of a single element

math typedef for vector coefficients of a single element math typedef for vector coefficients of a single element (source term side) using CoeffVector = Eigen::Array<CepsReal, Eigen::Dynamic, 1>; math typedef for 3D point math typedef for data on dofs math typedef for vectory data on dofs using DofVertices = Eigen::Matrix<CepsReal, 3, Eigen::Dynamic>; math typedef for values of unknowns on dofs using UnknownVector = CepsMathDynamic1D;

Function Documentation

◆ c4Stim()

CepsReal ceps::math::c4Stim ( CepsReal  t,
CepsReal  duration,
CepsReal point,
const CepsVector< CepsReal > &  orig,
CepsReal  diam,
CepsReal  amp 
)

Regular stimulation function.

$f(x,t) = Ap_4\left(\frac{x-c}{d_x/2}\right)p_4\left(\frac{t-d_t/2}{d_t/2}\right)$ Function is restricted to the compact support $\left|x-c\right|< d_x/2$. It is a $C^4$ function such that $\int_D f\,\mathrm{d}t\mathrm{d}x = \left|D\right|$.

See also
d4Polynomial
Parameters
[in]ttime from stimulation start
[in]durationstimulation duration
[in]pointspatial position
[in]origorigin point
[in]diamdiameter
[in]ampintensity

Definition at line 83 of file CepsContinuousFunctions.cpp.

◆ c5Stim()

CepsReal ceps::math::c5Stim ( CepsReal  t,
CepsReal  duration,
CepsReal point,
const CepsVector< CepsReal > &  orig,
CepsReal  diam,
CepsReal  amp 
)

Regular stimulation function.

$f(x,t) = Ap_5\left(\frac{x-c}{d_x/2}\right)p_5\left(\frac{t-d_t/2}{d_t/2}\right)$ Function is restricted to the compact support $\left|x-c\right|< d_x/2$. It is a $C^5$ function such that $\int_D f\,\mathrm{d}t\mathrm{d}x = \left|D\right|$.

See also
d5Polynomial
Parameters
[in]ttime from stimulation start
[in]durationstimulation duration
[in]pointspatial position
[in]origorigin point
[in]diamdiameter
[in]ampintensity

Definition at line 96 of file CepsContinuousFunctions.cpp.

◆ cInfinityStim()

CepsReal ceps::math::cInfinityStim ( CepsReal  t,
CepsReal  duration,
CepsReal point,
const CepsVector< CepsReal > &  orig,
CepsReal  diam,
CepsReal  amp 
)

Regular $C^{\infty}$ stimulation function.

$f(x,t) = Af_\infty((x-c)/d)f_\infty((t-dT/2)/(dT/2))$ Function is restricted to the compact support $\left|x-c\right|< d_x/2$.

See also
polRef
Parameters
[in]ttime from stimulation start
[in]durationstimulation duration
[in]pointspatial position
[in]origorigin point
[in]diamdiameter
[in]ampintensity

Definition at line 65 of file CepsContinuousFunctions.cpp.

◆ compose() [1/2]

CepsMathDynamic1D ceps::math::compose ( CepsUInt  M,
CepsVector< CepsMathDynamic1D * >  blocks 
)

Interleaving of M vectors.

Parameters
[in]Mnumber of vectors
[in]blockspointers on blocks of size N
Returns
vector of size M*N

Definition at line 130 of file EigenTools.cpp.

◆ compose() [2/2]

CepsMathDynamic2D ceps::math::compose ( CepsUInt  M,
CepsVector< CepsMathDynamic2D * >  blocks 
)

Bloc matrices interleaving.

This is a helper method that enables the user to express a MNxMN matrix resulting from the union of M**2 block matrices of size N. Example with M=N=2:

\[ \left( \begin{matrix}[A] & [B]\\ [C] & [D] \end{matrix}\right) \rightarrow \left( \begin{matrix} a_{11} & b_{11} & a_{12} & b_{12} \\ c_{11} & d_{11} & c_{12} & d_{12} \\ a_{21} & b_{21} & a_{22} & b_{22} \\ c_{21} & d_{21} & c_{22} & d_{22} \end{matrix}\right). \]

This method is useful when several unknows need to be computed per node.

Parameters
[in]Mproblem dimension
[in]blockspointers small N*N matrices

Definition at line 96 of file EigenTools.cpp.

◆ computeInverse() [1/4]

void ceps::math::computeInverse ( const CepsMathDynamic2D m,
CepsMathDynamic2D inv 
)

Inverse of square matrices.

Overload of ceps::math::computeInverse(...) function for square matrices.

Parameters
[in]msquare matrix of size MxM
[out]invinverse of param square matrix

Definition at line 41 of file EigenTools.cpp.

◆ computeInverse() [2/4]

void ceps::math::computeInverse ( const Eigen::Matrix< CepsReal, 2, 1 > &  m,
Eigen::Matrix< CepsReal, 1, 2 > &  inv 
)

Left inverse for 2x1 matrices.

Computes left inverse: $ (M^{T} \times M)^{-1} \times M^{T} $ where M is the rectangular matrix to inverse.

Parameters
[in]mrectangular matrix to inverse
[out]invwhere the inverse will be stored

Definition at line 85 of file EigenTools.cpp.

◆ computeInverse() [3/4]

void ceps::math::computeInverse ( const Eigen::Matrix< CepsReal, 3, 1 > &  m,
Eigen::Matrix< CepsReal, 1, 3 > &  inv 
)

Left inverse 3x1 matrices.

Computes left inverse: $ (M^{T} \times M)^{-1} \times M^{T} $ where M is the rectangular matrix to inverse.

Parameters
[in]mrectangular matrix to inverse
[out]invwhere the inverse will be stored

Definition at line 47 of file EigenTools.cpp.

◆ computeInverse() [4/4]

void ceps::math::computeInverse ( const Eigen::Matrix< CepsReal, 3, 2 > &  m,
Eigen::Matrix< CepsReal, 2, 3 > &  inv 
)

Left inverse for 3x2 matrices.

Computes left inverse: $ (M^{T} \times M)^{-1} \times M^{T} $ where M is the rectangular matrix to inverse.

Parameters
[in]mrectangular matrix to inverse
[out]invwhere the inverse will be stored

Definition at line 58 of file EigenTools.cpp.

◆ constStim()

CepsReal ceps::math::constStim ( CepsReal  t,
CepsReal  duration,
CepsReal point,
const CepsVector< CepsReal > &  orig,
CepsReal  diam,
CepsReal  amp 
)

Constant stimulation in a region (step function in time)

Time arguments are there for compatibility with other function calls, but are not used by the function. $f(x,t) = A\mathds{1}(\left|x-c\right|<d_x/2)$.

Parameters
[in]ttime from stimulation start
[in]durationstimulation duration
[in]pointspatial position
[in]origorigin point
[in]diamdiameter
[in]ampintensity

Definition at line 74 of file CepsContinuousFunctions.cpp.

◆ d4Polynomial()

CepsReal ceps::math::d4Polynomial ( CepsReal  x)

A polynomial satisfying 0-derivative equalities.

See also
c4Stim

\[\begin{cases} p_4(0) = 1,\\ p_4(1) = 0,\\ p_4^{(i)}(0) = p_4^{(i)}(1) = 0\text{ for } i\ \in\ \llbracket 1,4 \rrbracket, \end{cases}\]

with $f(r) = p_4(r/d)$.

\[\begin{tikzpicture}[x=3cm,y=3cm] \foreach \x in {0,0.5,1} { \draw (\x,0) node [below]{\x} -- +(0,5pt); } \foreach \y in {0,0.5,1} { \draw (0,\y) node [left]{\y} -- +(5pt,0); } \draw[thick] (0,0) rectangle (0.5,1); \draw[thick,domain=0:1,smooth,variable=\x,blue] plot ({\x},{1.+21*\x^5*(-6+20*\x-180/7.*\x*\x+15*\x*\x*\x-10/3.*\x^4)}); \end{tikzpicture}\]

Definition at line 41 of file CepsContinuousFunctions.cpp.

◆ d5Polynomial()

CepsReal ceps::math::d5Polynomial ( CepsReal  r)

Another polynomial satisfying more 0-derivative equalities.

See also
c5Stim

\[\begin{cases} p_5(0) = 1,\\ p_5(1) = 0,\\ p_5^{(i)}(0) = p_5^{(i)}(1) = 0\text{ for } i\ \in\ \llbracket 1,5 \rrbracket, \end{cases}\]

\[\begin{tikzpicture}[x=6cm,y=6cm] \foreach \x in {0,0.5,1} { \draw (\x,0) node [below]{\x} -- +(0,5pt); } \foreach \y in {0,0.5,1} { \draw (0,\y) node [left]{\y} -- +(5pt,0); } \draw[thick] (0,0) rectangle (1,1); \draw[thick,domain=0:1,smooth,variable=\x,blue] plot ({\x},{(1-\x)^6*(1+6*\x+21*\x*\x+56*\x^3+126*\x^4+252*\x^5)}); \end{tikzpicture}\]

Definition at line 53 of file CepsContinuousFunctions.cpp.

◆ derivativeLagrangianPol4Pts()

CepsReal ceps::math::derivativeLagrangianPol4Pts ( CepsReal  x,
CepsReal  f0,
CepsReal  f1,
CepsReal  f2,
CepsReal  f3 
)

Derivative of Lagrange interpolating polynomial of degree 3.

The function returns the value at position x, not the polynomial coefficients.

Parameters
[in]xposition
[in]f0f(0)
[in]f1f(1/3)
[in]f2f(2/3)
[in]f3f(1)

Definition at line 121 of file CepsContinuousFunctions.cpp.

◆ factorial()

constexpr CepsUInt ceps::math::factorial ( CepsUInt  n)
constexpr

Compile-time factorial.

Definition at line 245 of file CepsContinuousFunctions.hpp.

◆ interpolateLagrange() [1/3]

CepsReal ceps::math::interpolateLagrange ( CepsReal  x,
const CepsVector< CepsReal > &  f 
)

Computes the interpolate of f at point x. assumes f is given at equidistant points on [0,1] Hard coded until 4 points are given.

Definition at line 37 of file LagrangeInterpolator.cpp.

◆ interpolateLagrange() [2/3]

CepsReal ceps::math::interpolateLagrange ( CepsReal  x,
const CepsVector< CepsReal > &  f,
CepsReal  xmin,
CepsReal  xmax 
)

Computes the interpolate of f at point x. assumes f is given at equidistant points on [xmin,xmax].

Definition at line 77 of file LagrangeInterpolator.cpp.

◆ interpolateLagrange() [3/3]

CepsReal ceps::math::interpolateLagrange ( CepsReal  x,
const CepsVector< CepsReal > &  f,
const CepsVector< CepsReal > &  xs 
)

Computes the interpolate of f at point x. f given on points xs.

Definition at line 84 of file LagrangeInterpolator.cpp.

◆ lagrangianPol4Pts()

CepsReal ceps::math::lagrangianPol4Pts ( CepsReal  x,
CepsReal  f0,
CepsReal  f1,
CepsReal  f2,
CepsReal  f3 
)

Lagrange interpolation of degree 3.

The function returns the value at position x, not the polynomial coefficients.

Parameters
[in]xposition
[in]f0f(0)
[in]f1f(1/3)
[in]f2f(2/3)
[in]f3f(1)

Definition at line 108 of file CepsContinuousFunctions.cpp.

◆ multiplyByBlocks()

CepsMathDynamic2D ceps::math::multiplyByBlocks ( const CepsMathDynamic2D A,
const CepsMathDynamic2D B,
const CepsArray2< CepsUInt a,
const CepsArray2< CepsUInt b 
)

Compute a matrix product by blocks [[C_11, C_12], [C_21, C_22]] = [[A_11 * B_11, A_12 * B_12], [A_21 * B_21, A_22 * B_22]] = [[A_11, A_12], [A_21, A_22]] * [[B_11, B_12], [B_21, B_22]].

Parameters
Athe left side matrix
Bthe right side matrix
ashape block in A
bshape block in B
Returns

Definition at line 183 of file EigenTools.cpp.

◆ newtonSolvePol4Pts()

CepsReal ceps::math::newtonSolvePol4Pts ( CepsReal  f0,
CepsReal  f1,
CepsReal  f2,
CepsReal  f3,
CepsReal  c,
CepsReal  t0 
)

Solves for $t^*$ $f(t^*) = c$, based on a 4 points interpolation of $f$, using Newton method.

Parameters
[in]f0f(0)
[in]f1f(1/3)
[in]f2f(2/3)
[in]f3f(1)
[in]ctarget value
[in]t0initial guess of $t^*$

Definition at line 133 of file CepsContinuousFunctions.cpp.

◆ polRef()

CepsReal ceps::math::polRef ( CepsReal  r)

Pole function used in stimulation function definition.

$f_\infty(r)=\mathrm{e}^{1-\frac{1}{1-r^2}}$ This function belongs to $C^{\infty}((-1,1))$. It is extended by 0 if $\left|r\right|\geqslant 1$.

\[\begin{tikzpicture}[x=3cm,y=5cm] \foreach \x in {-1,0,1} { \draw (\x,0) node [below]{\x} -- +(0,5pt); } \foreach \y in {0,0.25,0.5} { \draw (-1,\y) node [left]{\y} -- +(5pt,0); } \draw[thick] (-1,0) rectangle (1,1); \draw[thick,domain=-0.995:0.995,smooth,variable=\x,blue] plot ({\x},{exp(1-1/(1-\x*\x))}); \end{tikzpicture}\]

Definition at line 35 of file CepsContinuousFunctions.cpp.

◆ putRowsSumInDiagonal()

void ceps::math::putRowsSumInDiagonal ( CepsMathDynamic2D mat)

Mass lumping.

Computes the mass lumping approximation putting the sum of off-diagonal entries into the diagonal

Parameters
[in,out]matelementary Eigen matrix to modify

Definition at line 162 of file EigenTools.cpp.