mmgs
eigenv.c File Reference

Find eigenvalues and eigenvectors of matrix. More...

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

Macros

#define _MG_EPSD   1.e-13
 
#define _MG_EPSD2   1.e-10
 
#define _MG_EPS6   5.e-06
 
#define _MG_EPS   1.e-06
 
#define _MG_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...
 
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

◆ _MG_EPS

#define _MG_EPS   1.e-06

◆ _MG_EPS6

#define _MG_EPS6   5.e-06

◆ _MG_EPSD

#define _MG_EPSD   1.e-13

◆ _MG_EPSD2

#define _MG_EPSD2   1.e-10

◆ _MG_EPSX2

#define _MG_EPSX2   2.e-06

◆ egal

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

Check if numbers x and y are equal.

◆ MAXTOU

#define MAXTOU   50

Function Documentation

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

Here is the caller graph for this function:

◆ _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:
Here is the caller 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.