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


C++ DiagonalMatrix::cleanup方法代码示例

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


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

示例1: trymate


//.........这里部分代码省略.........
      // matrix with all singular values close to 1
      Matrix A(8,8);
      A.Row(1)<<-0.4343<<-0.0445<<-0.4582<<-0.1612<<-0.3191<<-0.6784<<0.1068<<0;
      A.Row(2)<<0.5791<<0.5517<<0.2575<<-0.1055<<-0.0437<<-0.5282<<0.0442<<0;
      A.Row(3)<<0.5709<<-0.5179<<-0.3275<<0.2598<<-0.196<<-0.1451<<-0.4143<<0;
      A.Row(4)<<0.2785<<-0.5258<<0.1251<<-0.4382<<0.0514<<-0.0446<<0.6586<<0;
      A.Row(5)<<0.2654<<0.3736<<-0.7436<<-0.0122<<0.0376<<0.3465<<0.3397<<0;
      A.Row(6)<<0.0173<<-0.0056<<-0.1903<<-0.7027<<0.4863<<-0.0199<<-0.4825<<0;
      A.Row(7)<<0.0434<<0.0966<<0.1083<<-0.4576<<-0.7857<<0.3425<<-0.1818<<0;
      A.Row(8)<<0.0<<0.0<<0.0<<0.0<<0.0<<0.0<<0.0<<-1.0;
      Matrix U,V; DiagonalMatrix D;
      SVD(A,D,U,V); CheckIsSorted(D);
      Matrix B = U * D * V.t() - A; Clean(B,0.000000001); Print(B);
      DiagonalMatrix I(8); I = 1; D -= I; Clean(D,0.0001); Print(D);
      U *= U.t(); U -= I; Clean(U,0.000000001); Print(U);
      V *= V.t(); V -= I; Clean(V,0.000000001); Print(V);

   }

   {
      Tracer et1("Stage 8");
      // check SortSV functions

      Matrix A(15, 10);
      int i, j;
      for (i = 1; i <= 15; ++i) for (j = 1; j <= 10; ++j)
         A(i, j) = i + j / 1000.0;
      DiagonalMatrix D(10);
      D << 0.2 << 0.5 << 0.1 << 0.7 << 0.8 << 0.3 << 0.4 << 0.7 << 0.9 << 0.6;
      Matrix U = A; Matrix V = 10 - 2 * A;
      Matrix Prod = U * D * V.t();

      DiagonalMatrix D2 = D; SortDescending(D2);
      DiagonalMatrix D1 = D; SortSV(D1, U, V); Matrix X = D1 - D2; Print(X);
      X = Prod - U * D1 * V.t(); Clean(X,0.000000001); Print(X);
      U = A; V = 10 - 2 * A;
      D1 = D; SortSV(D1, U); X = D1 - D2; Print(X);
      D1 = D; SortSV(D1, V); X = D1 - D2; Print(X);
      X = Prod - U * D1 * V.t(); Clean(X,0.000000001); Print(X);

      D2 = D; SortAscending(D2);
      U = A; V = 10 - 2 * A;
      D1 = D; SortSV(D1, U, V, true); X = D1 - D2; Print(X);
      X = Prod - U * D1 * V.t(); Clean(X,0.000000001); Print(X);
      U = A; V = 10 - 2 * A;
      D1 = D; SortSV(D1, U, true); X = D1 - D2; Print(X);
      D1 = D; SortSV(D1, V, true); X = D1 - D2; Print(X);
      X = Prod - U * D1 * V.t(); Clean(X,0.000000001); Print(X);
   }

   {
      Tracer et1("Stage 9");
      // Tom William's example
      Matrix A(10,10);
      Matrix U;
      Matrix V;
      DiagonalMatrix Sigma;
      Real myVals[] =
      {
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    0,
         1,    1,    1,    1,    1,    1,    1,    1,    0,    0,
         1,    1,    1,    1,    1,    1,    1,    0,    0,    0,
         1,    1,    1,    1,    1,    0,    0,    0,    0,    0,
      };

      A << myVals;
      SVD(A, Sigma, U, V); CheckIsSorted(Sigma);
      A -= U * Sigma * V.t();
      Clean(A, 0.000000001); Print(A);
   }

   {
      Tracer et1("Stage 10");
      // 2x2 evalue test
      SymmetricMatrix A(2); DiagonalMatrix D; Matrix V;
      Real a[] = {0.616556, 0.61544, 0.716556};
      A << a;
      EigenValues(A,D,V);
      Matrix X = V * D * V.t() - A;
      Clean(X, 0.000000001); Print(X);
      Matrix Y = V * V.t() - IdentityMatrix(2);
      Clean(Y, 0.000000001); Print(Y);
      D.cleanup(); V.cleanup();
      Jacobi(A,D,V);
      X = V * D * V.t() - A;
      Clean(X, 0.000000001); Print(X);
      Y = V * V.t() - IdentityMatrix(2);
      Clean(Y, 0.000000001); Print(Y);
            
   }



}
开发者ID:BloodyPudding,项目名称:Sign_Language_Recognition,代码行数:101,代码来源:tmte.cpp


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