20 #include <rc/math/vector.h>
39 #define RC_MATRIX_INITIALIZER {\
int rc_matrix_zeros(rc_matrix_t *A, int rows, int cols)
Resizes matrix A and allocates memory for a matrix with specified rows & columns. The new memory is p...
Definition: matrix.c:84
int rc_matrix_free(rc_matrix_t *A)
Frees the memory allocated for a matrix A.
Definition: matrix.c:68
int rc_matrix_subtract_inplace(rc_matrix_t *A, rc_matrix_t B)
Subtracts matrix B from A and leaves the result in A.
Definition: matrix.c:365
int rc_matrix_diagonal(rc_matrix_t *A, rc_vector_t v)
Generates a diagonal matrix with the elements of specified vector v.
Definition: matrix.c:145
rc_matrix_t rc_matrix_empty(void)
Returns an rc_matrix_t with no allocated memory and the initialized flag set to 0.
Definition: matrix.c:21
int rc_matrix_left_multiply_inplace(rc_matrix_t A, rc_matrix_t *B)
Multiplies A*B and puts the result back in the place of B.
Definition: matrix.c:282
int rc_matrix_identity(rc_matrix_t *A, int dim)
Resizes A to be a square identity matrix with dimensions dim-by-dim.
Definition: matrix.c:120
int rc_matrix_add(rc_matrix_t A, rc_matrix_t B, rc_matrix_t *C)
Adds matrices A+B and places the result in C.
Definition: matrix.c:329
int rc_matrix_times_col_vec(rc_matrix_t A, rc_vector_t v, rc_vector_t *c)
Multiplies matrix A times column vector v and places the result in column vector c.
Definition: matrix.c:429
int rc_matrix_multiply(rc_matrix_t A, rc_matrix_t B, rc_matrix_t *C)
Multiplies A*B=C.
Definition: matrix.c:244
int rc_matrix_print(rc_matrix_t A)
Prints the contents of matrix A to stdout in decimal notation with 4 decimal places.
Definition: matrix.c:181
int rc_matrix_add_inplace(rc_matrix_t *A, rc_matrix_t B)
Adds matrix A to B and places the result back in A.
Definition: matrix.c:350
int rc_matrix_symmetrize(rc_matrix_t *P)
Symmetrizes a square matrix.
Definition: matrix.c:543
struct rc_matrix_t rc_matrix_t
Struct containing the state of a matrix and a pointer to dynamically allocated memory to hold its con...
int rc_matrix_times_scalar(rc_matrix_t *A, double s)
Multiplies every entry in A by scalar value s.
Definition: matrix.c:231
int rc_matrix_row_vec_times_matrix(rc_vector_t v, rc_matrix_t A, rc_vector_t *c)
Multiplies row vector v times matrix A and places the result in row vector c.
Definition: matrix.c:451
int rc_matrix_duplicate(rc_matrix_t A, rc_matrix_t *B)
Duplicates the contents of matrix A and into matrix B.
Definition: matrix.c:163
int rc_matrix_alloc(rc_matrix_t *A, int rows, int cols)
Allocates memory for matrix A to have size rows&cols.
Definition: matrix.c:28
int rc_matrix_transpose(rc_matrix_t A, rc_matrix_t *T)
Transposes the contents of A and places the result in T.
Definition: matrix.c:381
int rc_matrix_transpose_inplace(rc_matrix_t *A)
Transposes matrix A in place.
Definition: matrix.c:403
int rc_matrix_outer_product(rc_vector_t v1, rc_vector_t v2, rc_matrix_t *A)
Computes v1 times v2 where v1 is a column vector and v2 is a row vector.
Definition: matrix.c:487
int rc_matrix_zero_out(rc_matrix_t *A)
Sets all values of an already-allocated matrix to 0.
Definition: matrix.c:215
int rc_matrix_right_multiply_inplace(rc_matrix_t *A, rc_matrix_t B)
Multiplies A*B and puts the result back in the place of A.
Definition: matrix.c:306
int rc_matrix_random(rc_matrix_t *A, int rows, int cols)
Generates a matrix populated with random numbers between -1 and 1.
Definition: matrix.c:133
int rc_matrix_print_sci(rc_matrix_t A)
Prints the contents of matrix A to stdout in scientific notation.
Definition: matrix.c:198
double rc_matrix_determinant(rc_matrix_t A)
Calculates the determinant of square matrix A.
Definition: matrix.c:506
Struct containing the state of a matrix and a pointer to dynamically allocated memory to hold its con...
Definition: matrix.h:32
double ** d
pointer to allocated 2d array
Definition: matrix.h:35
int initialized
set to 1 once memory has been allocated
Definition: matrix.h:36
int rows
number of rows in the matrix
Definition: matrix.h:33
int cols
number of columns in the matrix
Definition: matrix.h:34
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
Definition: vector.h:41