MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Functions
matrix.c File Reference

This is a collection of functions for generating and implementing discrete SISO filters for arbitrary transfer functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rc/math/other.h>
#include <rc/math/matrix.h>
#include "algebra_common.h"
Include dependency graph for matrix.c:

Functions

rc_matrix_t rc_matrix_empty (void)
 Returns an rc_matrix_t with no allocated memory and the initialized flag set to 0. More...
 
int rc_matrix_alloc (rc_matrix_t *A, int rows, int cols)
 Allocates memory for matrix A to have size rows&cols. More...
 
int rc_matrix_free (rc_matrix_t *A)
 Frees the memory allocated for a matrix A. More...
 
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 pre-filled with zeros using calloc. Any existing memory allocated for A is freed if necessary to avoid memory leaks. More...
 
int rc_matrix_identity (rc_matrix_t *A, int dim)
 Resizes A to be a square identity matrix with dimensions dim-by-dim. More...
 
int rc_matrix_random (rc_matrix_t *A, int rows, int cols)
 Generates a matrix populated with random numbers between -1 and 1. More...
 
int rc_matrix_diagonal (rc_matrix_t *A, rc_vector_t v)
 Generates a diagonal matrix with the elements of specified vector v. More...
 
int rc_matrix_duplicate (rc_matrix_t A, rc_matrix_t *B)
 Duplicates the contents of matrix A and into matrix B. More...
 
int rc_matrix_print (rc_matrix_t A)
 Prints the contents of matrix A to stdout in decimal notation with 4 decimal places. More...
 
int rc_matrix_print_sci (rc_matrix_t A)
 Prints the contents of matrix A to stdout in scientific notation. More...
 
int rc_matrix_zero_out (rc_matrix_t *A)
 Sets all values of an already-allocated matrix to 0. More...
 
int rc_matrix_times_scalar (rc_matrix_t *A, double s)
 Multiplies every entry in A by scalar value s. More...
 
int rc_matrix_multiply (rc_matrix_t A, rc_matrix_t B, rc_matrix_t *C)
 Multiplies A*B=C. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int rc_matrix_subtract_inplace (rc_matrix_t *A, rc_matrix_t B)
 Subtracts matrix B from A and leaves the result in A. More...
 
int rc_matrix_transpose (rc_matrix_t A, rc_matrix_t *T)
 Transposes the contents of A and places the result in T. More...
 
int rc_matrix_transpose_inplace (rc_matrix_t *A)
 Transposes matrix A in place. More...
 
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. More...
 
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. More...
 
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. More...
 
double rc_matrix_determinant (rc_matrix_t A)
 Calculates the determinant of square matrix A. More...
 
int rc_matrix_symmetrize (rc_matrix_t *P)
 Symmetrizes a square matrix. More...
 

Detailed Description

This is a collection of functions for generating and implementing discrete SISO filters for arbitrary transfer functions.

Author
James Strawson
Date
2016