rsLQR  0.1
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 NewMatrix (int rows, int cols)
 Allocate a new matrix on the heap. More...
 
int MatrixSetConst (Matrix *mat, double val)
 Sets all of the elements in a matrix to a single value. More...
 
int FreeMatrix (Matrix *mat)
 Free the data for a matrix. More...
 
int MatrixNumElements (const Matrix *mat)
 Get the number of elements in a matrix, i.e. m * n. More...
 
int MatrixGetLinearIndex (const Matrix *mat, int row, int col)
 Get the linear index for a given row and column in the matrix. More...
 
double * MatrixGetElementTranspose (const Matrix *mat, int row, int col, bool istranposed)
 Get the element of a matrix or its transpose. More...
 
int MatrixSetElement (Matrix *mat, int row, int col, double val)
 The a matrix element to a given value. More...
 
double * MatrixGetElement (const Matrix *mat, int row, int col)
 Get the element of a matrix given row, column indices. More...
 
int MatrixCopyTranspose (Matrix *dest, Matrix *src)
 Copy a matrix to another matrix, transposed. More...
 
int MatrixCopy (Matrix *dest, Matrix *src)
 Copy a matrix to another matrix. More...
 
int MatrixScaleByConst (Matrix *mat, double alpha)
 Scale a matrix by a constant factor. More...
 
double MatrixNormedDifference (Matrix *A, Matrix *B)
 Return the normed difference between 2 matrices of the same size. More...
 
int MatrixFlatten (Matrix *mat)
 Flatten a 2D matrix to a column vector. More...
 
int MatrixFlattenToRow (Matrix *mat)
 Flatten a 2D matrix to a row vector. More...
 
int PrintMatrix (const Matrix *mat)
 Print the elements of a matrix to stdout. More...
 
int PrintRowVector (const Matrix *mat)
 Print the entire matrix as a row vector. 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