/ / - * - C - * ------------------------------------------------------------------------------------------------------------------------------------ ----------------------- //// A Simple Lu Factorization Algorithm Written Using MTL // The Example Matrix Is The Same As The Geth EXAMPLE, WHICH / / Is the lapack version of l factorization./////--------------------------------------- ------------------------------------
#include "mtl / lu.h" #include "mtl / matrix.h" #include "mtl / dense1d.h" #include "mtl / utils.h"
/ * Sample Output: 3X3 [[1, 2, 2], [2, 1, 2], [2, 2, 1]] 3X3 [[2, 1, 2], [0.5, 1.5, 1], [ 1, 0.666667, -1.66667]] [2, 2, 3,]
That is, pivot = [2, 0, 0,] [0, 2, 0,] [0, 0, 3,]
L = [2 * 2, 0], [0.5, 1.5 * 2, 0], [1, 0.666667, -1.66667 * 3]
U = [1, 1, 2], [0, 1, 1], [0, 0.666667, 1]
* /
INTMAIN () {Using Namespace MTL; // Begin Typedef Matrix
Const matrix :: size_type n = 3; double da [] = {1, 2, 2, 2, 1, 2, 2, 2, 1};
Matrix A (DA, N, N); DENSE1D
Print_vector (pivots);
Return 0;}