// -*- c++ -*- // // $COPYRIGHT$ // //=========================================================================== #include #include using namespace std; //begin template void print_banded_views(Matrix& A) { using namespace mtl; //end const int M = A.nrows(); const int N = A.nrows(); cout << "full matrix" << endl; print_all_matrix(A); cout << endl; typedef rows_type::type RowMatrix; cout << "rows banded" << endl; //begin typename band_view::type B(2, 1, A); //end print_all_banded(B, 2, 1); print_row(B); cout << endl; cout << "columns banded" << endl; typedef typename columns_type::type ColMatrix; typename band_view::type C(2, 1, columns(A)); print_all_banded(C, 2, 1); print_column(C); cout << endl; cout << "rows lower triangle" << endl; typename triangle_view::type L(A); print_all_banded(L, M-1, 0); print_row(L); cout << endl; cout << "rows unit upper triangle" << endl; typename triangle_view::type U(A); print_all_banded(U, -1, N-1); print_row(U); cout << "columns lower triangle" << endl; typename triangle_view::type CL(columns(A)); print_all_banded(CL, M-1, 0); print_column(CL); cout << endl; cout << "columns unit upper triangle" << endl; typename triangle_view::type CU(columns(A)); print_all_banded(CU, -1, N-1); print_column(CU); //begin } //end //begin int main(int argc, char* argv[]) { using namespace mtl; int M, N; if (argc < 2) { M = 10; N = 10; } else { M = atoi(argv[1]); N = atoi(argv[2]); } //end //begin typedef matrix::type Matrix; //end typedef matrix, dense<>, column_major>::type ColMatrix; //begin Matrix A(M, N); //end ColMatrix B(M, N); for (int j = 0; j < N; ++j) for (int i = 0; i < M; ++i) A(i,j) = double(i * N + j); mtl::copy(A, B); cout << "Row Matrix ***********" << endl; //begin print_banded_views(A); //end cout << "Column Matrix ***********" << endl; print_banded_views(B); //begin return 0; } //end