/ * THANKS to Valient Gough for this Example Program! * /
// Solving by Robinkin
#include
Using namespace MTL;
// don't print out the mass on on get to this size ... # define max_print_size 5
Typedef Matrix
Double TestmatrixError (Const Matrix & A, Const Matrix & Ainv) {Int size = a.nrows ();
// Test it Matrix Ainva (size, size);
// ainva = ainv * a Mult (AINV, A, AINVA);
// i = Identity Typedef Matrix
// Ainva = -i add (scaled (i, -1.0), ainva);
IF (size // CREATE A Random Matrix and Invert It. The See How Close It Coms To // Identity. Matrix A (SIZE, SIZE); Vector B (Size); Vector X (size); // Initialize for (Sizet I = 0; i IF (size // Time Lu INV std :: cout << std :: endl << "---------- Testing Inversion use lu decomPosition" << std :: endl; testluinv (a, size); IF (size IF (size IF (argc == 1) std :: cout << std :: endl << "pass size argument to program to time larger matues." << std :: end1; return 0;} Output: Inverting Matrix of Size 3A = 3X3 [[1.66, -0.28, 1.54], [1.86, 0.7, 1.72], [- 1.02, -1.58, 1.24]]]] // reverse ----------- Testing Inversion Using Lu DecompositionAinv = 3X3 [[0.978889, -0.56949, -0.425792, 0.00251165], [- 0.607383, 0.79401, 0.459414]] AINV * A - i = 3 × 3 [[4.44089E-16, 2.01481E-16], [- 5.05491E-16, -2.22045E-16, -2.75514E-16], [- 1.91335E-16, - 1.27014E-16, -1.11022E-16]] Max error = -5.05491E-16Solution = [0, 0, 0,] // Solution to the solution amount Solution = [1.00642, -0.49478, -0.980001,]