SphinxBase 5prealpha
|
Matrix and linear algebra functions. More...
Go to the source code of this file.
Functions | |
SPHINXBASE_EXPORT void | norm_3d (float32 ***arr, uint32 d1, uint32 d2, uint32 d3) |
Norm an array. | |
SPHINXBASE_EXPORT void | accum_3d (float32 ***out, float32 ***in, uint32 d1, uint32 d2, uint32 d3) |
Floor 3-d array. | |
SPHINXBASE_EXPORT void | band_nz_1d (float32 *v, uint32 d1, float32 band) |
Ensures that non-zero values x such that -band < x < band, band > 0 are set to -band if x < 0 and band if x > 0. | |
SPHINXBASE_EXPORT void | floor_nz_3d (float32 ***m, uint32 d1, uint32 d2, uint32 d3, float32 floor) |
Floor 3-d array. | |
SPHINXBASE_EXPORT void | floor_nz_1d (float32 *v, uint32 d1, float32 floor) |
Floor 1-d array. | |
SPHINXBASE_EXPORT float64 | determinant (float32 **a, int32 len) |
Calculate the determinant of a positive definite matrix. | |
SPHINXBASE_EXPORT int32 | invert (float32 **out_ainv, float32 **a, int32 len) |
Invert (if possible) a positive definite matrix with QR algorithm. | |
SPHINXBASE_EXPORT int32 | solve (float32 **a, float32 *b, float32 *out_x, int32 n) |
Solve (if possible) a positive-definite system of linear equations AX=B for X. | |
SPHINXBASE_EXPORT void | outerproduct (float32 **out_a, float32 *x, float32 *y, int32 len) |
Calculate the outer product of two vectors. | |
SPHINXBASE_EXPORT void | matrixmultiply (float32 **out_c, float32 **a, float32 **b, int32 n) |
Multiply C=AB where A and B are symmetric matrices. | |
SPHINXBASE_EXPORT void | scalarmultiply (float32 **inout_a, float32 x, int32 n) |
Multiply a symmetric matrix by a constant in-place. | |
SPHINXBASE_EXPORT void | matrixadd (float32 **inout_a, float32 **b, int32 n) |
Add A += B. | |
Matrix and linear algebra functions.
This file contains some basic matrix and linear algebra operations. In general these operate on positive definite matrices ONLY, because all matrices we're likely to encounter are either covariance matrices or are derived from them, and therefore a non-positive-definite matrix indicates some kind of pathological condition.
Definition in file matrix.h.
SPHINXBASE_EXPORT void accum_3d | ( | float32 *** | out, |
float32 *** | in, | ||
uint32 | d1, | ||
uint32 | d2, | ||
uint32 | d3 ) |
Floor 3-d array.
out | output array |
in | input array |
d1 | dimension |
d2 | dimension |
d3 | dimension |
Definition at line 78 of file matrix.c.
References accum_3d().
Referenced by accum_3d().
SPHINXBASE_EXPORT void band_nz_1d | ( | float32 * | v, |
uint32 | d1, | ||
float32 | band ) |
Ensures that non-zero values x such that -band < x < band, band > 0 are set to -band if x < 0 and band if x > 0.
v | array |
d1 | array size |
band | band value |
Definition at line 127 of file matrix.c.
References band_nz_1d().
Referenced by band_nz_1d().
SPHINXBASE_EXPORT float64 determinant | ( | float32 ** | a, |
int32 | len ) |
Calculate the determinant of a positive definite matrix.
a | The input matrix, must be positive definite. |
len | The dimension of the input matrix. |
Definition at line 147 of file matrix.c.
References determinant(), and E_FATAL.
Referenced by determinant().
SPHINXBASE_EXPORT void floor_nz_1d | ( | float32 * | v, |
uint32 | d1, | ||
float32 | floor ) |
Floor 1-d array.
v | array |
d1 | dimension |
floor | floor value |
Definition at line 114 of file matrix.c.
References floor_nz_1d().
Referenced by floor_nz_1d().
SPHINXBASE_EXPORT void floor_nz_3d | ( | float32 *** | m, |
uint32 | d1, | ||
uint32 | d2, | ||
uint32 | d3, | ||
float32 | floor ) |
Floor 3-d array.
m | array |
d1 | dimension |
d2 | dimension |
d3 | dimension |
floor | floor value |
Definition at line 96 of file matrix.c.
References floor_nz_3d().
Referenced by floor_nz_3d().
SPHINXBASE_EXPORT int32 invert | ( | float32 ** | out_ainv, |
float32 ** | a, | ||
int32 | len ) |
Invert (if possible) a positive definite matrix with QR algorithm.
out_ainv | The inverse of a will be stored here. |
a | The input matrix, must be positive definite. |
len | The dimension of the input matrix. |
Definition at line 153 of file matrix.c.
References E_FATAL, and invert().
Referenced by invert().
SPHINXBASE_EXPORT void matrixadd | ( | float32 ** | inout_a, |
float32 ** | b, | ||
int32 | n ) |
Add A += B.
inout_a | The A matrix to add. |
b | The B matrix to add to A. |
n | dimension of a and b. |
Definition at line 309 of file matrix.c.
References matrixadd().
Referenced by matrixadd().
SPHINXBASE_EXPORT void matrixmultiply | ( | float32 ** | out_c, |
float32 ** | a, | ||
float32 ** | b, | ||
int32 | n ) |
Multiply C=AB where A and B are symmetric matrices.
out_c | The output matrix C. |
a | The input matrix A. |
b | The input matrix B. |
n | Dimensionality of A and B. |
Definition at line 166 of file matrix.c.
References matrixmultiply().
Referenced by matrixmultiply().
SPHINXBASE_EXPORT void norm_3d | ( | float32 *** | arr, |
uint32 | d1, | ||
uint32 | d2, | ||
uint32 | d3 ) |
SPHINXBASE_EXPORT void outerproduct | ( | float32 ** | out_a, |
float32 * | x, | ||
float32 * | y, | ||
int32 | len ) |
Calculate the outer product of two vectors.
out_a | A (pre-allocated) len x len array. The outer product will be stored here. |
x | A vector of length len. |
y | A vector of length len. |
len | The length of the input vectors. |
Definition at line 281 of file matrix.c.
References outerproduct().
Referenced by outerproduct().
SPHINXBASE_EXPORT void scalarmultiply | ( | float32 ** | inout_a, |
float32 | x, | ||
int32 | n ) |
Multiply a symmetric matrix by a constant in-place.
inout_a | The matrix to multiply. |
x | The constant to multiply it by. |
n | dimension of a. |
Definition at line 295 of file matrix.c.
References scalarmultiply().
Referenced by scalarmultiply().
SPHINXBASE_EXPORT int32 solve | ( | float32 ** | a, |
float32 * | b, | ||
float32 * | out_x, | ||
int32 | n ) |
Solve (if possible) a positive-definite system of linear equations AX=B for X.
a | The A matrix on the left-hand side of the equation, must be positive-definite. |
b | The B vector on the right-hand side of the equation. |
out_x | The X vector will be stored here. |
n | The dimension of the A matrix (n by n) and the B and X vectors. |
Definition at line 159 of file matrix.c.
References E_FATAL, and solve().
Referenced by solve().