⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gather_scatter.cc

📁 很好用的库
💻 CC
字号:
#include "mtl/matrix.h"#include "mtl/mtl.h"#include "mtl/utils.h"#include "mtl/dense1D.h"#include "mtl/compressed1D.h"#include "mtl/sparse1D.h"/*Sample Outputusing compressed1Dvector before[2,2,2,2,2,2,2,2,2,]vector before[2,2,4,2,2,4,2,4,2,]using sparse1Dvector before[2,2,2,2,2,2,2,2,2,]vector before[2,2,4,2,2,4,2,4,2,]*/template <class DenseVec, class SparseVec>//beginvoid do_gather_scatter(DenseVec& d, SparseVec& c) {  using namespace mtl;  //end  std::cout << "vector before" <<std::endl;  print_vector(d);  //begin  c[2] = 0;  c[5] = 0;  c[7] = 0;  gather(d,c);  scale(c,2.0);  scatter(c,d);  //end  std::cout << "vector after" <<std::endl;  print_vector(d);  //being}//endint main (){  using namespace mtl;  //begin  typedef dense1D<double> denseVec;  typedef compressed1D<double> compVec;  denseVec d(9,2);  compVec c;  //end  std::cout << "using compressed1D" <<std::endl;  //begin  do_gather_scatter(d, c);  //end  typedef std::set< entry1<double> > RepType;  typedef sparse1D< RepType > sparseVec;  sparseVec s;  mtl::set_value(d, 2);  std::cout << "using sparse1D" << std::endl;  do_gather_scatter(d, s);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -