39 #define RC_MATRIX_INITIALIZER {\ 397 #endif // RC_MATRIX_H rc_matrix_t rc_matrix_empty(void)
Returns an rc_matrix_t with no allocated memory and the initialized flag set to 0.
int rc_matrix_transpose(rc_matrix_t A, rc_matrix_t *T)
Transposes the contents of A and places the result in T.
int rc_matrix_free(rc_matrix_t *A)
Frees the memory allocated for a matrix A.
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.
int rc_matrix_diagonal(rc_matrix_t *A, rc_vector_t v)
Generates a diagonal matrix with the elements of specified vector v.
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.
int rc_matrix_symmetrize(rc_matrix_t *P)
Symmetrizes a square matrix.
int rc_matrix_multiply(rc_matrix_t A, rc_matrix_t B, rc_matrix_t *C)
Multiplies A*B=C.
int rc_matrix_subtract_inplace(rc_matrix_t *A, rc_matrix_t B)
Subtracts matrix B from A and leaves the result in A.
int rc_matrix_print_sci(rc_matrix_t A)
Prints the contents of matrix A to stdout in scientific notation.
int rc_matrix_times_scalar(rc_matrix_t *A, double s)
Multiplies every entry in A by scalar value s.
double ** d
pointer to allocated 2d array
Definition: matrix.h:35
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
Definition: vector.h:41
double rc_matrix_determinant(rc_matrix_t A)
Calculates the determinant of square matrix A.
int rc_matrix_transpose_inplace(rc_matrix_t *A)
Transposes matrix A in place.
int rows
number of rows in the matrix
Definition: matrix.h:33
int rc_matrix_identity(rc_matrix_t *A, int dim)
Resizes A to be a square identity matrix with dimensions dim-by-dim.
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 initialized
set to 1 once memory has been allocated
Definition: matrix.h:36
int rc_matrix_zero_out(rc_matrix_t *A)
Sets all values of an already-allocated matrix to 0.
int rc_matrix_alloc(rc_matrix_t *A, int rows, int cols)
Allocates memory for matrix A to have size rows&cols.
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.
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.
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...
int cols
number of columns in the matrix
Definition: matrix.h:34
int rc_matrix_random(rc_matrix_t *A, int rows, int cols)
Generates a matrix populated with random numbers between -1 and 1.
int rc_matrix_print(rc_matrix_t A)
Prints the contents of matrix A to stdout in decimal notation with 4 decimal places.
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.
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.
Struct containing the state of a matrix and a pointer to dynamically allocated memory to hold its con...
Definition: matrix.h:32
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.
int rc_matrix_duplicate(rc_matrix_t A, rc_matrix_t *B)
Duplicates the contents of matrix A and into matrix B.