File numerics/src/tools/op3x3.h

Go to the source code of this file

linear algebra operations in 3D

Functions

static void add3(double a[3], double b[3])

add a vector[3]

Parameters
  • a: a[3]
  • b: b[3]

static void add3x3(double a[9], double b[9])

add a 3x3 matrix or a vector[9]

Parameters
  • a: a[9]
  • b: b[9]

static void cpy3(double a[3], double b[3])

copy a vector[3]

Parameters
  • a: a[3]
  • b: b[3]

static void cpy3x3(double *restrict a, double *restrict b)

copy a 3x3 matrix or a vector[9]

Parameters
  • a: a[9]
  • b: b[9]

static void cpytr3x3(double *restrict a, double *restrict b)

copy & transpose a matrix

Parameters
  • a: *a
  • b: transpose(*a)

static void cross3(double *restrict a, double *restrict b, double *restrict c)

cross product : c <- a x b

Parameters
  • a: double a[3]
  • b: double b[3]
  • c: double c[3]

static double det3x3(double *a)

determinant

Return
the value of the determinant
Parameters
  • a: double* a

static void diag_scal3(double *restrict scal_coeffs, double *restrict v)

diagonal scaling of a vector

Parameters
  • scal_coeffs: diagonal part of a matrix
  • v: a 3D vector

static double dot3(double *restrict a, double *restrict b)

scalar product : c <- a.b

Return
the scalar product
Parameters
  • a: double a[3]
  • b: double b[3]

static WARN_RESULT_IGNORED int eig_3x3(double *restrict a, double *restrict b, double *restrict eig)

Computation of the eigenvalues of a symmetric 3x3 real matrix.

Return
0 all the time
Parameters
  • a: symmetric column-major matrix (not modified)
  • b: a 3x3 work matrix
  • eig: eigenvalie in decreasing order

static int equal3(double *restrict a, double *restrict b)

check equality : a[3] == b[3]

Return
1 if true, 0 if false
Parameters
  • a: double a[3]
  • b: double b[3]

static int equal3x3(double *restrict a, double *restrict b)

check equality : a[9] == b[9]

Return
1 if true, 0 if false
Parameters
  • a: double a[9]
  • b: double b[9]

static void extract3x3(int n, int i0, int j0, double *restrict a, double *restrict b)

extract3x3 : copy a sub 3x3 matrix of *a into *b

static double hypot3(double *a)

norm : || a || may underflow & overflow

Return
the norm
Parameters
  • a: a[3]

static double hypot9(double *a)
static void insert3x3(int n, int i0, int j0, double *restrict a, double *restrict b)

insert3x3 : insert a 3x3 matrix *b into *a

static void mm3x3(double *restrict a, double *restrict b, double *restrict c)

matrix matrix multiplication : c = a * b

Parameters
  • a: a[9]
  • b: b[9]
  • c: c[9]

static void mmm3x3(double *restrict a, double *restrict b, double *restrict c)

sub a matrix matrix multiplication : c -= a*b

Parameters
  • a: a[9]
  • b: b[9]
  • c: c[9]

static void mmp3x3(double *restrict a, double *restrict b, double *restrict c)

add a matrix matrix multiplication : c += a*b

Parameters
  • a: a[9]
  • b: b[9]
  • c: c[9]

static void mtv3x3(double *restrict a, double *restrict v, double *restrict r)

transpose(matrix) vector multiplication

Parameters
  • a: 3 by 3 matrix in col-major
  • v: 3 dimensional vector
  • r: \(r = a^T*v\)

static void mtvm3x3(double *restrict a, double *restrict v, double *restrict r)

transpose(matrix) vector multiplication

Parameters
  • a: 3 by 3 matrix in col-major
  • v: 3 dimensional vector
  • r: \(r = a^T*v\)

static void mv3x3(double *restrict a, double *restrict v, double *restrict r)

matrix vector multiplication

Parameters
  • a: 3 by 3 matrix in col-major
  • v: 3 dimensional vector
  • r: \(r = a*v\)

static void mvm3x3(double *restrict a, double *restrict v, double *restrict r)

minux the result a matrix vector multiplication

Parameters
  • a: matrix
  • v: vector
  • r: the result of r -= av

static void mvp3x3(const double *restrict a, const double *restrict v, double *restrict r)

add a matrix vector multiplication

Parameters
  • a: a[9]
  • v: v[3]
  • r: r[3] the result of r += av

static void mvp_alpha3x3(double alpha, const double *restrict a, const double *restrict v, double *restrict r)

add a matrix vector multiplication scaled by alpha

Parameters
  • alpha: scalar coeff
  • a: a[9]
  • v: v[3]
  • r: r[3] the result of r += av

static WARN_RESULT_IGNORED int orthoBaseFromVector(double * Ax, double * Ay, double * Az, double * A1x, double * A1y, double * A1z, double * A2x, double * A2y, double * A2z)

orthoBaseFromVector : From a vector A, build a matrix (A,A1,A2) such that it is an orthonormal.

Return
0 if success, 1 if there is a problem
Parameters
  • Ax: first component of the vector A
  • Ay: second component of the vector A
  • Az: third component of the vector A
  • A1x: first component of the vector A
  • A1y: second component of the vector A
  • A1z: third component of the vector A
  • A2x: first component of the vector A
  • A2y: second component of the vector A
  • A2z: third component of the vector A

void print3(double *v)

print a vector

Parameters
  • v: the vector

void print3x3(double *mat)

print a matrix

Parameters
  • mat: the matrix

static void scal3(double scal, double *v)

scalar multiplication of a vector3

Parameters
  • scal: double scalar
  • v: v[3]

static void scal3x3(double scal, double m[9])

scalar multiplication of a matrix3x3

Parameters
  • scal: double scalar
  • m: m[9]

static WARN_RESULT_IGNORED int solv3x3(double *restrict a, double *restrict x, double *restrict b)

system resolution : x <- sol(Ax = b)

Return
0 if success, 1 if failed
Parameters
  • a: double a[9]
  • x: double x[3]
  • b: double b[3]

static WARN_RESULT_IGNORED int solve_3x3_gepp(const double *restrict a, double *restrict b)

solve Ax = b by partial pivoting Gaussian elimination.

This function is 10 to 20 times faster than calling LAPACK (tested with netlib and atlas).

Return
0 if ok, otherwise the column where no pivot could be selected
Parameters
  • a: column-major matrix (not modified)
  • b: on input, the right-hand side; on output the solution x

static void sub3(double a[3], double b[3])

sub a vector[3]

Parameters
  • a: a[3]
  • b: b[3]

static void sub3x3(double a[9], double b[9])

sub a 3x3 matrix or a vector[9]

Parameters
  • a: a[9]
  • b: b[9]