Robot Control Library
rc_test_matrix.c
/**
* @example rc_test_matrix.c
*
* @brief Tests the functions in rc_matrix.h
*
* @author James Strawson
* @date 1/29/2018
*/
#include <stdio.h>
#include <rc/math.h>
#define DIM 3 // dimension of matrix to test
int main()
{
double det;
printf("Let's test some matrix functions....\n\n");
// zeros matrix
printf("\nzeros Matrix:\n");
rc_matrix_zeros(&A,DIM,DIM);
// identity matrix
printf("\nIdentity Matrix:\n");
// random vector
printf("\nNew Random Vector b:\n");
// diagonal matrix
printf("\nDiagonal Matrix from b:\n");
// random matrix
printf("\nNew Random Matrix A:\n");
rc_matrix_random(&A,DIM,DIM);
// duplicate matrix
printf("\nDuplicate A into B:\n");
// print scientific notation
printf("\nMatrix B in sci notation:\n");
// times scalar
printf("\nMatrix B times 2.0:\n");
// get determinant of A & B
printf("\nDeterminant of A:");
printf("%8.6lf\n", det);
printf("\nDeterminant of B:");
printf("%8.6lf\n", det);
// multiply A*B=C
printf("\nThree ways to multiply:");
printf("\nA*B=C:\n");
// left multiply in place
printf("\nleft multiply inplace B=A*B\n");
// right multiply in place
printf("\nright multiply inplace A=A*B\n");
// add
printf("\ntwo ways to add:");
printf("\nA+B=C:\n");
rc_matrix_add(A,B,&C);
printf("\ninplace: A=A+B:\n");
// transpose
printf("\ntwo ways to transpose:");
printf("\nC=A':\n");
printf("\ninplace: A=A'\n");
// multiply b times A
printf("\nrow vector b times A:\n");
// multiply A times b
printf("\nA times column vector b\n");
// outer product
printf("\nouter product C=b*y\n");
printf("\nDONE\n");
return 0;
}