// create some matrices and vectors // // note: i haven't tried running this test code // // note: run your code with assertions enabled when debugging // when not debugging, you can turn them off with #define NDEBUG #define LAPACK #include "CMatrix.h" CMatrix A(3,2); // 3 rows, 2 columns CVector b(2); // 2 element vector A(0,0) = 1; A(1,0) = 5; A(2,0) = 2; A(0,1) = 3; A(1,1) = 7; A(2,1) = 1; b(0) = 1; b(1) = 5; // solve "Ax = b" in a least-squares sense CVector x = A.solveLinearSystem(b); printf("x:\n"); x.printFloat(); CVector b_hat = A*x; // should be the same as b. printf("\nb:\n"); b.printFloat(); printf("\nb_hat:\n"); b_hat.printFloat();