当前位置: 首页>>代码示例>>C++>>正文


C++ DM类代码示例

本文整理汇总了C++中DM的典型用法代码示例。如果您正苦于以下问题:C++ DM类的具体用法?C++ DM怎么用?C++ DM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DM类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dumpDM

// simple {DM,IM} and {DV,IV} arrays
void dumpDM(const DM& A, const char* s) { 
  DMat M; M.load(A.num_rows(),A.num_cols(), A.data());
  M.print(g_MSGFile, s, "lf", 4, 8, 51,0,50); 
}
开发者ID:Chang-Liu-0520,项目名称:nodal-dg,代码行数:5,代码来源:Global_funcs.cpp

示例2: main

int main(int argc, char** argv)
{
    
    DM DualMesh;
    if ((argc!=4) && (argc!=6))
    {
       cout<<endl;
       cout<<" -------------------- Curvature Filter ------------------------- "<<endl;
       cout<<" Please cite Yuanhao's PhD thesis and related papers. Thank you! "<<endl;
       cout<<" --------------------------------------------------------------- \n\n";
       cout<<"usage: main imageName filterType Iterations.\n For example: ./cf lena.bmp m 30\n";
       cout<<"             or              "<<endl;
       cout<<"usage: main imageName filterType MaxItNum lambda DataFitOrder.\n For example: ./cf lena.bmp m 30 1.2 1.5\n";
       cout<<"************************************************\n";
       cout<<"Possible Filter Type: t (Total Variation) \n";
       cout<<"                      m (Mean Curvature) \n";
       cout<<"                      g (Gaussian Curvature) \n";
       cout<<"                      d (Difference Curvature) \n";
       cout<<"                      b (Bernstein Filter) \n";
       return -1;
    }

    DualMesh.read(argv[1]);

    char * filterType = argv[2];
    if (*filterType == 't') Type = 0;
    if (*filterType == 'm') Type = 1;
    if (*filterType == 'd') Type = 3;
    if (*filterType == 'b') Type = 4;

    ItNum = atoi(argv[3]);

    if (argc==6)
    {
    	lambda = atof(argv[4]);
    	DataFitOrder = atof(argv[5]);
    }

    DualMesh.split();
    double mytime;
    DualMesh.Filter(Type, mytime, ItNum);
    cout<<"runtime is "<<mytime<<" milliseconds."<<endl;

    DualMesh.merge();
    DualMesh.write();

    DualMesh.read(argv[1]);
    DualMesh.FilterNoSplit(Type, mytime, ItNum);
    cout<<"runtime (noSplit) is "<<mytime<<" milliseconds."<<endl;
    DualMesh.write("CF_NoSplit_result.png");
    
    if (argc==6)
    {
        //filter solver for the variational models
        DualMesh.read(argv[1]);
	    DualMesh.Solver(Type, mytime, ItNum, lambda, DataFitOrder);
	    cout<<"runtime is "<<mytime<<" milliseconds."<<endl;
	    DualMesh.write("CF_Solver.png");
    }
    
    return 0;
}
开发者ID:shaoguifang,项目名称:CurvatureFilter,代码行数:62,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{

  // A
  int ncol = 5, nrow = 5;
  vector<int> colind = {0, 3, 6, 8, 10, 12};
  vector<int> row = {0, 1, 4, 1, 2, 4, 0, 2, 0, 3, 3, 4};
  vector<double> nz = {19, 12, 12, 21, 12, 12, 21, 16, 21, 5, 21, 18};
  DM A(Sparsity(nrow, ncol, colind, row), nz);

  // Right hand side
  DM b = DM::ones(ncol);

  // Type of linear systems
  enum SymType {UNSYM, SYM, PD};

  // All Linear solvers to be tested
  struct Test {
    string solver;
    SymType type;
  };
  vector<Test> tests;
  tests.push_back({"csparse", UNSYM});
  tests.push_back({"csparsecholesky", PD});
  tests.push_back({"lapacklu", UNSYM});
  tests.push_back({"lapackqr", UNSYM});
  tests.push_back({"ma27", SYM});
  tests.push_back({"symbolicqr", UNSYM});

  // Test all combinations
  for (auto s : {UNSYM, SYM, PD}) {
    DM A_test;
    switch (s) {
    case UNSYM:
      cout << "Unsymmetric linear system" << endl;
      A_test = A;
      break;
    case SYM:
      cout << "Symmetric linear system" << endl;
      A_test = A + A.T();
      break;
    case PD:
      cout << "Positive definite linear system" << endl;
      A_test = mtimes(A.T(), A);
      break;
    }
    for (auto t : tests) {
      if (t.type > s) continue; // Cannot be solved
      if (!Linsol::has_plugin(t.solver)) {
        cout << t.solver << " not available" << endl;
        continue;
      }

      // Create a solver instance
      Linsol F("F", t.solver);

      // Solve
      F.reset(A_test.sparsity());
      F.pivoting(A_test.ptr());
      F.factorize(A_test.ptr());
      DM x = densify(b);
      F.solve(x.ptr(), x.size2());

      // Print the solution
      cout << "solution: " << x << " (" <<  t.solver << ")" << endl;
    }
  }

  return 0;
}
开发者ID:andrescodas,项目名称:casadi,代码行数:70,代码来源:test_linsol.cpp


注:本文中的DM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。