// -*- c++ -*- // // $COPYRIGHT$ // //=========================================================================== #include #include "mtl/mtl2lapack.h" #include "mtl/dense1D.h" #include "mtl/utils.h" using namespace std; /* Sample Output A: 3x3 [ [1,2,2], [2,1,2], [2,2,1] ] b: 3x1 [ [15], [15], [15] ] x: 3x1 [ [3], [3], [3] ] */ int main() { using namespace mtl2lapack; using namespace mtl; using namespace std; const int M = 3; const int N = 3; const int NRHS = 1; //begin double da [] = { 1, 2, 2, 2, 1, 2, 2, 2, 1 }; lapack_matrix::type A(da, M, N); lapack_matrix::type B(M*NRHS, NRHS); mtl::set(B, 15.0); dense1D pivot(N, 0); //end cout << "A:" << endl; print_all_matrix(A); cout << "b:" << endl; print_all_matrix(B); // Factor A, solve the system, and print the solution. //begin int info = getrf(A, pivot); //end print_all_matrix(A); cout << "pivots" << endl; print_vector(pivot); //begin if (info == 0) { info = getrs('N', A, pivot, B); if (info == 0) { cout << "x:" << endl; print_all_matrix(B); } else cout << "Factorization failed with INFO = " << info << endl; } else cout << "Solve failed with INFO = " << info << endl; //end return 0; }