mmg3d
eigenv.c File Reference

Find eigenvalues and eigenvectors of matrix. More...

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
#include "eigenv.h"
Include dependency graph for eigenv.c:

Macros

#define MG_EIGENV_EPSD   1.e-13
 
#define MG_EIGENV_EPSD2   1.e-10
 
#define MG_EIGENV_EPS6   5.e-06
 
#define MG_EIGENV_EPS   1.e-06
 
#define MG_EIGENV_EPSX2   2.e-06
 
#define MAXTOU   50
 
#define egal(x, y)
 

Functions

static int newton3 (double p[4], double x[3])
 Find root(s) of a polynomial of degree 3. More...
 
static int MMG5_check_accuracy (double mat[6], double lambda[3], double v[3][3], double w1[3], double w2[3], double w3[3], double maxm, int order, int symmat)
 
int MMG5_eigenv (int symmat, double *mat, double lambda[3], double v[3][3])
 Find eigenvalues and vectors of a 3x3 matrix. More...
 
int MMG5_eigen2 (double *mm, double *lambda, double vp[2][2])
 Find eigenvalues and vectors of a 2x2 matrix. More...
 
int MMG5_eigensym (double m[3], double lambda[2], double vp[2][2])
 

Variables

static double Id [3][3]
 Identity matrix. More...
 

Detailed Description

Find eigenvalues and eigenvectors of matrix.

Author
Cécile Dobrzynski (Bx INP/Inria/UBordeaux)
Pascal Frey (UPMC)
Version
5

Find eigenvalues and eigenvectors of 2x2 or 3x3 symetric definite positive matrix.

Macro Definition Documentation

◆ egal

#define egal (   x,
 
)
Value:
( \
( ((x) == 0.0f) ? (fabs(y) < MG_EIGENV_EPS) : \
( ((y) == 0.0f) ? (fabs(x) < MG_EIGENV_EPS) : \
(fabs((x)-(y)) / (fabs(x) + fabs(y)) < MG_EIGENV_EPSX2) ) ) )
#define MG_EIGENV_EPSX2
Definition: eigenv.c:49
#define MG_EIGENV_EPS
Definition: eigenv.c:48

Check if numbers x and y are equal.

◆ MAXTOU

#define MAXTOU   50

◆ MG_EIGENV_EPS

#define MG_EIGENV_EPS   1.e-06

◆ MG_EIGENV_EPS6

#define MG_EIGENV_EPS6   5.e-06

◆ MG_EIGENV_EPSD

#define MG_EIGENV_EPSD   1.e-13

◆ MG_EIGENV_EPSD2

#define MG_EIGENV_EPSD2   1.e-10

◆ MG_EIGENV_EPSX2

#define MG_EIGENV_EPSX2   2.e-06

Function Documentation

◆ MMG5_check_accuracy()

static int MMG5_check_accuracy ( double  mat[6],
double  lambda[3],
double  v[3][3],
double  w1[3],
double  w2[3],
double  w3[3],
double  maxm,
int  order,
int  symmat 
)
static
Parameters
matpointer toward a 3x3 matrix.
lambdaeigenvalues.
veigenvectors.
w1temporary array to perform the matrix cross product.
w2temporary array to perform the matrix cross product.
w3temporary array to perform the matrix cross product.
maxmmaximal value of the matrix used for normalization.
orderorder of eigenvalues (1,2,3) or 0 if failed.
symmat0 if matrix is not symetric, 1 otherwise.
Returns
1 if success, 0 if fail.

Check the accuracy of the eigenvalues and vectors computation of a 3x3 matrix (symetric).

Here is the caller graph for this function:

◆ MMG5_eigen2()

int MMG5_eigen2 ( double *  mm,
double *  lambda,
double  vp[2][2] 
)

Find eigenvalues and vectors of a 2x2 matrix.

Parameters
mmpointer toward the matrix.
lambdapointer toward the output eigenvalues.
vpeigenvectors.
Returns
1.
Warning
not used for now

◆ MMG5_eigensym()

int MMG5_eigensym ( double  m[3],
double  lambda[2],
double  vp[2][2] 
)
inline
Parameters
mterms of symetric matrix $2x2$.
lambdaeigenvalues of m.
vpeigenvectors of m.
Returns
order of the eigenvalues.

Compute eigenelements of a symetric matrix m. Eigenvectors are orthogonal.

◆ MMG5_eigenv()

int MMG5_eigenv ( int  symmat,
double *  mat,
double  lambda[3],
double  v[3][3] 
)

Find eigenvalues and vectors of a 3x3 matrix.

Parameters
symmat0 if matrix is not symetric, 1 otherwise.
matpointer toward the matrix.
lambdaeigenvalues.
veigenvectors.
Returns
order of eigenvalues (1,2,3) or 0 if failed.
Remarks
the i^{th} eigenvector is stored in v[i][.].
Here is the call graph for this function:

◆ newton3()

static int newton3 ( double  p[4],
double  x[3] 
)
static

Find root(s) of a polynomial of degree 3.

Parameters
ppolynomial coefficients (b=p[2], c=p[1], d=p[0]).
xroot(s) of polynomial.
Returns
0 if no roots.
1 for 3 roots.
2 for 2 roots.
3 for 1 root.

Find root(s) of a polynomial of degree 3: $P(x) = x^3+bx^2+cx+d$.

Here is the caller graph for this function:

Variable Documentation

◆ Id

double Id[3][3]
static
Initial value:
= {
{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0} }

Identity matrix.