Robot Control Library
rc_test_algebra.c
/**
* @example rc_test_algebra.c
*
* @brief Tests the functions in rc_algebra.h
*
* @author James Strawson
* @date 1/29/2018
*/
#include <stdio.h>
#include <rc/math.h>
#define DIM 3
int main()
{
printf("Let's test some linear algebra functions....\n\n");
// random matrix
printf("\nNew Random Matrix A:\n");
rc_matrix_random(&A,DIM,DIM);
// get an inverse for A
printf("\nAinverse:\n");
// multiply A times A inverse
printf("\nA times A_inverse:\n");
rc_matrix_multiply(A,Ainv,&AA);
// invert A back again
printf("\ninvert A again inplace\n");
// do an LUP decomposition on A
printf("\nLUP decomposition of A\n");
rc_algebra_lup_decomp(A,&L,&U,&P);
printf("L:\n");
printf("U:\n");
printf("P:\n");
// do a QR decomposition on A
printf("\nQR Decomposition of A\n");
printf("Q:\n");
printf("R:\n");
// solve a square linear system
printf("\nGaussian Elimination solution x to the equation Ax=b:\n");
printf("equivalent to A\\b in MATLAB\n");
// now do again but with qr decomposition method
printf("\nQR solution x to the equation Ax=b:\n");
printf("equivalent to A\\b in MATLAB\n");
// free memory
printf("\nDONE\n");
return 0;
}