ulqr  0.1.0
matrix.h File Reference

Matrix type and basic operations. More...

#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  Matrix
 Represents a matrix of double-precision data. More...
 

Functions

Matrix slap_NewMatrix (int rows, int cols)
 Allocate a new matrix on the heap. More...
 
Matrix slap_NewMatrixZeros (int rows, int cols)
 Allocate a new matrix on the heap, initialized with zeros. More...
 
int slap_MatrixSetConst (Matrix *mat, double val)
 Sets all of the elements in a matrix to a single value. More...
 
int slap_FreeMatrix (Matrix *mat)
 Free the data for a matrix. More...
 
int slap_MatrixNumElements (const Matrix *mat)
 Get the number of elements in a matrix, i.e. m * n. More...
 
int slap_MatrixGetLinearIndex (const Matrix *mat, int row, int col)
 Get the linear index for a given row and column in the matrix. More...
 
double * slap_MatrixGetElementTranspose (const Matrix *mat, int row, int col, bool istranposed)
 Get the element of a matrix or its transpose. More...
 
int slap_MatrixSetElement (Matrix *mat, int row, int col, double val)
 The a matrix element to a given value. More...
 
double * slap_MatrixGetElement (const Matrix *mat, int row, int col)
 Get the element of a matrix given row, column indices. More...
 
int slap_MatrixCopyTranspose (Matrix *dest, Matrix *src)
 Copy a matrix to another matrix, transposed. More...
 
int slap_MatrixCopy (Matrix *dest, Matrix *src)
 Copy a matrix to another matrix. More...
 
int slap_MatrixCopyFromArray (Matrix *mat, const double *data)
 Copy the data from an array into the matrix, columnwise. More...
 
int slap_MatrixScaleByConst (Matrix *mat, double alpha)
 Scale a matrix by a constant factor. More...
 
double slap_MatrixNormedDifference (Matrix *A, Matrix *B)
 Return the normed difference between 2 matrices of the same size. More...
 
int slap_MatrixFlatten (Matrix *mat)
 Flatten a 2D matrix to a column vector. More...
 
int slap_MatrixFlattenToRow (Matrix *mat)
 Flatten a 2D matrix to a row vector. More...
 
int slap_PrintMatrix (const Matrix *mat)
 Print the elements of a matrix to stdout. More...
 
int slap_PrintRowVector (const Matrix *mat)
 Print the entire matrix as a row vector. More...
 
int slap_SetMatrixSize (Matrix *mat, int rows, int cols)
 Set the dimensions of the matrix. More...
 

Detailed Description

Matrix type and basic operations.

Author
Brian Jackson (bjack.nosp@m.205@.nosp@m.gmail.nosp@m..com)
Version
0.1
Date
2022-01-30