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


C++ Vector4f::toString方法代码示例

本文整理汇总了C++中Vector4f::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4f::toString方法的具体用法?C++ Vector4f::toString怎么用?C++ Vector4f::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector4f的用法示例。


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

示例1: iterativeSolvers_unitTest

void iterativeSolvers_unitTest() {
   // small matrix test
   {
      Vector4f test = makeVector4f(1.0f, 3.14f, 2.0f, 2.71f);
      Matrix4f mat = makeRotX4f(0.32f) * makeRotY4f(-0.39f) * makeRotZ4f(0.76f);
      mat += mat.transpose();
      mat += IDENTITY4F*5;
      Vector4f rhs = mat * test;
      Matrix4f invMat = invertMatrix(mat);
      Vector4f directFloat = invMat * rhs;

      DVectorD testD(4); for (card32 i=0; i<4; i++) testD[i] = test[i];
      DVectorD rhsD(4); for (card32 i=0; i<4; i++) rhsD[i] = rhs[i];
      SparseMatrixD matS(4);
      for (card32 r=0; r<4; r++) {
         for (card32 c=0; c<4; c++) {
            double v = mat[c][r];
            if (v != 0) {
               matS[r].setEntry(c, v);
            }
         }
      }

      output << "Matrix:\n" << mat.toString() << "\n";
      output << "true solution: " << test.toString() << "\n";
      output << "right hand side: " << rhs.toString() << "\n";
      output << "direct float prec. solution: " << directFloat.toString() << "\n\n";

      output << "Matrix:\n" << matS.toString() << "\n";
      output << "true solution: " << testD.toString() << "\n";
      output << "right hand side: " << rhsD.toString() << "\n\n";

      DVectorD x = nullDVector<double>(4);

	  card32 numIterations = 1000;
      gaussSeidelSolve(matS, x, rhsD, numIterations, 1E-20, 1E-5, false);
      output << "Gauss-Seidel solution: " << x.toString() << "\n\n";

	  numIterations = 1000;
      x = nullDVector<double>(4);
      steepestDescentSolve(matS, x, rhsD, numIterations, 1E-5, false);
      output << "Steepest-Descent solution: " << x.toString() << "\n\n";

	  numIterations = 1000;
      x = nullDVector<double>(4);
      conjugateGradientsSolve(matS, x, rhsD, numIterations, 1E-5, true);
      output << "CG solution: " << x.toString() << "\n\n";
   }

   // large matrix test
   {
      SparseMatrixD mat(MDIM*MDIM);
      for (int y=0; y<MDIM; y++) {
         for (int x=0; x<MDIM; x++) {
            addEntry(mat, x,y, x,y,  -4, MDIM);
            addEntry(mat, x,y, x+1,y, 1, MDIM);
            addEntry(mat, x,y, x-1,y, 1, MDIM);
            addEntry(mat, x,y, x,y+1, 1, MDIM);
            addEntry(mat, x,y, x,y-1, 1, MDIM);
         }
      }

      Timer T; card32 vt;

      DVectorD x = nullDVector<double>(MDIM*MDIM);
      DVectorD b = scalarDVector<double>(MDIM*MDIM, 1);
      DVectorD gs, sd, cg;


      x = nullDVector<double>(MDIM*MDIM);
      T.getDeltaValue();
	  card32 numIterations = 100000;
      conjugateGradientsSolve(mat, x, b, numIterations, 1E-7, false);
      vt = T.getDeltaValue();
      output << "CG time: " << vt << "\n\n";
      output << "Large sytem CG solution (LAPL(f) == 1):\n";
      for (int y=0; y<MDIM; y++) {
			for (int xp=0; xp<MDIM; xp++) {
            output << x[xp +y*MDIM] << "\t";
         }
         output.cr();
      }
      output.cr();
      cg = x;

      x = nullDVector<double>(MDIM*MDIM);
      T.getDeltaValue();
	  numIterations = 100000;
      gaussSeidelSolve(mat, x, b, numIterations, 1E-20, 1E-7, false);
      vt = T.getDeltaValue();
      output << "GS time: " << vt << "\n\n";
      output << "Large sytem Gauss-Seidel solution (LAPL(f) == 1):\n";
      for (int y=0; y<MDIM; y++) {
         for (int xp=0; xp<MDIM; xp++) {
           output << x[xp +y*MDIM] << "\t";
         }
        output.cr();
      }
      output.cr();

//.........这里部分代码省略.........
开发者ID:antonaut,项目名称:vis15-group7,代码行数:101,代码来源:IterativeSolvers.cpp


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