banded_matmat.cc
来自「MTL C++ Numeric Library」· CC 代码 · 共 49 行
CC
49 行
#include <iostream>using namespace std;#include <mtl/mtl.h>#include <mtl/matrix.h>#include <mtl/dense1D.h>#include <mtl/utils.h>intmain(){ typedef mtl::matrix<double, mtl::diagonal<>, mtl::banded<mtl::external>, mtl::column_major>::type DiagMatE; typedef mtl::matrix<double, mtl::rectangle<>, mtl::dense<mtl::external>, mtl::column_major>::type MatrixE; typedef mtl::matrix<double, mtl::rectangle<>, mtl::dense<mtl::internal>, mtl::column_major>::type MatrixI; int N = 3; double da [] = { 1, 3, 2, 2, 1, 2, 2, 2, 1 }; double dc [] = { 1, 3, 2}; MatrixE A(da, N, N); DiagMatE C(dc, N, N, 0, 0); MatrixI AxC(N,N); cout << "Full A:" << endl; mtl::print_all_matrix(A); cout << "Diag C:" << endl; mtl::print_all_banded(C,0,0); cout << "Output AxC:" << endl; //put C as the first parameter in mult //since C is a banded matrix mtl::mult(C,A,AxC); mtl::print_all_matrix(AxC); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?