#include <stdio.h>
#define DIM 3
int main()
{
printf("Let's test some linear algebra functions....\n\n");
printf("\nNew Random Matrix A:\n");
printf("\nAinverse:\n");
printf("\nA times A_inverse:\n");
printf("\ninvert A again inplace\n");
printf("\nLUP decomposition of A\n");
printf("L:\n");
printf("U:\n");
printf("P:\n");
printf("\nQR Decomposition of A\n");
printf("Q:\n");
printf("R:\n");
printf("\nGaussian Elimination solution x to the equation Ax=b:\n");
printf("equivalent to A\\b in MATLAB\n");
printf("\nQR solution x to the equation Ax=b:\n");
printf("equivalent to A\\b in MATLAB\n");
printf("\nDONE\n");
return 0;
}
int rc_algebra_qr_decomp(rc_matrix_t A, rc_matrix_t *Q, rc_matrix_t *R)
Calculate the QR decomposition of matrix A.
int rc_algebra_invert_matrix(rc_matrix_t A, rc_matrix_t *Ainv)
Inverts matrix A via LUP decomposition method.
int rc_algebra_lup_decomp(rc_matrix_t A, rc_matrix_t *L, rc_matrix_t *U, rc_matrix_t *P)
Performs LUP decomposition on matrix A with partial pivoting.
int rc_algebra_lin_system_solve_qr(rc_matrix_t A, rc_vector_t b, rc_vector_t *x)
Finds a least-squares solution to the system Ax=b for non-square A using QR decomposition method.
int rc_algebra_lin_system_solve(rc_matrix_t A, rc_vector_t b, rc_vector_t *x)
Solves Ax=b for given matrix A and vector b.
int rc_algebra_invert_matrix_inplace(rc_matrix_t *A)
Inverts matrix A in place.
int rc_matrix_free(rc_matrix_t *A)
Frees the memory allocated for a matrix A.
#define RC_MATRIX_INITIALIZER
Definition: matrix.h:39
int rc_matrix_multiply(rc_matrix_t A, rc_matrix_t B, rc_matrix_t *C)
Multiplies A*B=C.
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_random(rc_matrix_t *A, int rows, int cols)
Generates a matrix populated with random numbers between -1 and 1.
int rc_vector_random(rc_vector_t *v, int length)
Resizes vector v and fills with random numbers between -1.0 and 1.0.
int rc_vector_free(rc_vector_t *v)
Frees the memory allocated for vector v.
#define RC_VECTOR_INITIALIZER
Definition: vector.h:48
int rc_vector_print(rc_vector_t v)
Prints to stdout the contents of vector v in one line.
Struct containing the state of a matrix and a pointer to dynamically allocated memory to hold its con...
Definition: matrix.h:32
Struct containing the state of a vector and a pointer to dynamically allocated memory to hold its con...
Definition: vector.h:41