// -*- c++ -*- // // $COPYRIGHT$ // //=========================================================================== #include using namespace std; #include #include /* Sample Output matrix A 3x3 [ [1,0,2], [0,3,0], [0,4,5] ] matrix B 3x3 [ [1,0,2], [0,3,0], [0,4,5] ] */ int main() { using namespace mtl; using namespace std; //begin // [1,0,2] // [0,3,0] // [0,4,5] const int m = 3, n = 3, nnz = 5; double values[] = { 1, 2, 3, 4, 5 }; int indices[] = { 1, 3, 2, 2, 3 }; int row_ptr[] = { 1, 3, 4, 6 }; // Create from pre-existing arrays typedef matrix, compressed, row_major>::type MatA; MatA A(m, n, nnz, values, row_ptr, indices); //end cout << "matrix A" << endl; print_all_matrix(A); //begin // Create from scratch typedef matrix, compressed<>, row_major >::type MatB; MatB B(m, n); B(0,0) = 1; B(0,2) = 2; B(1,1) = 3; B(2,1) = 4; B(2,2) = 5; //end cout << "matrix B" << endl; print_all_matrix(B); return 0; }