52#define MATD_ALLOC(name, nrows, ncols) double name ## _storage [nrows*ncols]; matd_t name = { .nrows = nrows, .ncols = ncols, .data = &name ## _storage };
65#define MATD_EL(m, row, col) (m)->data[((row)*(m)->ncols + (col))]
253 return a->ncols <= 1 && a->nrows <= 1;
264 return a->ncols == 1 || a->nrows == 1;
274 return (a->ncols == 1 && a->nrows == (
unsigned int)len) || (a->ncols == (
unsigned int)len && a->nrows == 1);
377#define MATD_SVD_NO_WARNINGS 1
matd_t * matd_vec_normalize(const matd_t *a)
Calculates the normalization of the supplied vector 'a' (i.e.
matd_t * matd_subtract(const matd_t *a, const matd_t *b)
Subtracts matrix 'b' from matrix 'a', cell-by-cell, and returns the results as a new matrix of the sa...
matd_t * matd_create(int rows, int cols)
Creates a double matrix with the given number of rows and columns (or a scalar in the case where rows...
double matd_vec_dist(const matd_t *a, const matd_t *b)
Calculates the magnitude of the distance between the points represented by matrices 'a' and 'b'.
void matd_add_inplace(matd_t *a, const matd_t *b)
Adds the values of 'b' to matrix 'a', cell-by-cell, and overwrites the contents of 'a' with the resul...
matd_plu_t * matd_plu(const matd_t *a)
double matd_get_scalar(const matd_t *m)
Retrieves the scalar value of the given element ('m' must be a scalar).
double matd_plu_det(const matd_plu_t *lu)
matd_t * matd_inverse(const matd_t *a)
Attempts to compute an inverse of the supplied matrix 'a' and return it as a new matrix.
matd_t * matd_identity(int dim)
Creates a square identity matrix with the given number of rows (and therefore columns),...
double matd_det(const matd_t *a)
Calculates the determinant of the supplied matrix 'a'.
void matd_print(const matd_t *m, const char *fmt)
Prints the supplied matrix 'm' to standard output by applying the supplied printf format specifier 'f...
double matd_get(const matd_t *m, unsigned int row, unsigned int col)
Retrieves the cell value for matrix 'm' at the given zero-based row and column index.
matd_t * matd_plu_p(const matd_plu_t *lu)
static int matd_is_vector(const matd_t *a)
Determines whether the supplied matrix 'a' is a row or column vector (positive return) or not (zero r...
Definition matd.h:261
matd_t * matd_chol_inverse(matd_t *a)
matd_t * matd_scale(const matd_t *a, double s)
Scales all cell values of matrix 'a' by the given scale factor 's' and returns the result as a new ma...
void matd_scale_inplace(matd_t *a, double s)
Scales all cell values of matrix 'a' by the given scale factor 's' and overwrites the contents of 'a'...
double matd_vec_dot_product(const matd_t *a, const matd_t *b)
Calculates the dot product of two vectors.
matd_t * matd_select(const matd_t *a, unsigned int r0, int r1, unsigned int c0, int c1)
Creates a copy of a subset of the supplied matrix 'a'.
void matd_print_transpose(const matd_t *m, const char *fmt)
Prints the transpose of the supplied matrix 'm' to standard output by applying the supplied printf fo...
matd_t * matd_create_scalar(double v)
Creates a scalar with the supplied value 'v'.
matd_t * matd_solve(matd_t *A, matd_t *b)
void matd_destroy(matd_t *m)
Frees the memory associated with matrix 'm', being the result of an earlier call to a matd_*() functi...
void matd_put(matd_t *m, unsigned int row, unsigned int col, double value)
Assigns the given value to the matrix cell at the given zero-based row and column index.
matd_svd_t matd_svd_flags(matd_t *A, int flags)
void matd_chol_destroy(matd_chol_t *chol)
matd_t * matd_transpose(const matd_t *a)
Creates a matrix which is the transpose of the supplied matrix 'a'.
matd_t * matd_multiply(const matd_t *a, const matd_t *b)
Multiplies the two supplied matrices together (matrix product), and returns the results as a new matr...
matd_t * matd_create_dataf(int rows, int cols, const float *data)
Creates a double matrix with the given number of rows and columns (or a scalar in the case where rows...
double matd_max(matd_t *m)
matd_t * matd_chol_solve(const matd_chol_t *chol, const matd_t *b)
matd_t * matd_plu_solve(const matd_plu_t *mlu, const matd_t *b)
void matd_put_scalar(matd_t *m, double value)
Assigns the given value to the supplied scalar element ('m' must be a scalar).
matd_svd_t matd_svd(matd_t *A)
Compute a complete SVD of a matrix.
matd_t * matd_plu_u(const matd_plu_t *lu)
matd_t * matd_add(const matd_t *a, const matd_t *b)
Adds the two supplied matrices together, cell-by-cell, and returns the results as a new matrix of the...
double matd_vec_mag(const matd_t *a)
Calculates the magnitude of the supplied matrix 'a'.
matd_t * matd_plu_l(const matd_plu_t *lu)
static void matd_set_data(matd_t *m, const double *data)
Definition matd.h:241
void matd_ltriangle_solve(matd_t *u, const double *b, double *x)
matd_t * matd_crossproduct(const matd_t *a, const matd_t *b)
Calculates the cross product of supplied matrices 'a' and 'b' (i.e.
matd_t * matd_copy(const matd_t *m)
Creates an exact copy of the supplied matrix 'm'.
static int matd_is_scalar(const matd_t *a)
Determines whether the supplied matrix 'a' is a scalar (positive return) or not (zero return,...
Definition matd.h:250
double matd_vec_dist_n(const matd_t *a, const matd_t *b, int n)
Same as matd_vec_dist, but only uses the first 'n' terms to compute distance.
double matd_err_inf(const matd_t *a, const matd_t *b)
void matd_plu_destroy(matd_plu_t *mlu)
void matd_utriangle_solve(matd_t *u, const double *b, double *x)
void matd_ltransposetriangle_solve(matd_t *u, const double *b, double *x)
matd_chol_t * matd_chol(matd_t *A)
void matd_subtract_inplace(matd_t *a, const matd_t *b)
Subtracts the values of 'b' from matrix 'a', cell-by-cell, and overwrites the contents of 'a' with th...
matd_t * matd_create_data(int rows, int cols, const double *data)
Creates a double matrix with the given number of rows and columns (or a scalar in the case where rows...
matd_t * matd_op(const char *expr,...)
Creates a new matrix by applying a series of matrix operations, as expressed in 'expr',...
static int matd_is_vector_len(const matd_t *a, int len)
Determines whether the supplied matrix 'a' is a row or column vector with a dimension of 'len' (posit...
Definition matd.h:271
Creates a double matrix with the Cholesky lower triangular matrix of A.
Definition matd.h:426
int is_spd
Definition matd.h:427
matd_t * u
Definition matd.h:428
unsigned int * piv
Definition matd.h:394
int singular
Definition matd.h:392
matd_t * lu
Definition matd.h:401
int pivsign
Definition matd.h:395
matd_t * V
Definition matd.h:361
matd_t * U
Definition matd.h:359
matd_t * S
Definition matd.h:360
Defines a matrix structure for holding double-precision values with data in row-major order (i....
Definition matd.h:46
double data[]
Definition matd.h:48
unsigned int nrows
Definition matd.h:47
unsigned int ncols
Definition matd.h:47