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


C++ SquareMatrix::ReSize方法代码示例

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


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

示例1: trymatm


//.........这里部分代码省略.........
      SM1.Row(2) << 4 << 5;
      SM1.Row(3) << 9 << 2 << 1;
      SM1.Row(4) << 3 << 6 << 8 << 2;

      SymmetricMatrix SM2(3);
      SM2.Row(1) <<  3;
      SM2.Row(2) << -7 << -6;
      SM2.Row(3) <<  4 << -2 << -1;

      SymmetricMatrix SM = KP(SM1, SM2);
      Matrix M1 = SM1; Matrix M2 = SM2;
      Matrix M = KP(SM1, SM2); M -= SM; Print(M);
      M = KP(SM1, SM2) - SM; Print(M);
      M = KP(M1, SM2) - SM; Print(M);
      M = KP(SM1, M2) - SM; Print(M);
      M = KP(M1, M2); M -= SM; Print(M);
   }

   {
      Tracer et1("Stage 5");

      Matrix A(2,3);
      A << 3 << 5 << 2
        << 4 << 1 << 6;

      Matrix B(3,4);
      B <<  7 <<  2 <<  9 << 11
        <<  1 <<  3 <<  6 <<  8
        <<  4 << 10 <<  5 << 12;

      RowVector C(2); C << 3 << 7;
      ColumnVector D(4); D << 0 << 5 << 13 << 11;

      Matrix M = KP(C * A, B * D) - KP(C, B) * KP(A, D); Print(M);
   }

   {
      Tracer et1("Stage 6");

      RowVector A(3), B(5), C(15);
      A << 5 << 2 << 4;
      B << 3 << 2 << 0 << 1 << 6;
      C << 15 << 10 << 0 << 5 << 30
        <<  6 <<  4 << 0 << 2 << 12
        << 12 <<  8 << 0 << 4 << 24;
      Matrix N = KP(A, B) - C;    Print(N);
      N = KP(A.t(), B.t()) - C.t();    Print(N);
      N = KP(A.AsDiagonal(), B.AsDiagonal()) - C.AsDiagonal();    Print(N);
   }

   {
      Tracer et1("Stage 7");
      IdentityMatrix I(3);
      ColumnVector CV(4); CV << 4 << 3 << 1 << 7;
      Matrix A = KP(I, CV) + 5;
      Matrix B(3,12);
      B.Row(1) << 9 << 8 << 6 << 12 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5;
      B.Row(2) << 5 << 5 << 5 << 5 << 9 << 8 << 6 << 12 << 5 << 5 << 5 << 5;
      B.Row(3) << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 5 << 9 << 8 << 6 << 12;
      B -= A.t(); Print(B);

   }

   {
      Tracer et1("Stage 8");          // SquareMatrix
      Matrix A(2,3), B(3,2);
      A << 2 << 6 << 7
        << 4 << 3 << 9;
      B << 1 << 3
        << 4 << 8
        << 0 << 6;
      SquareMatrix AB = A * B;
      Matrix M = (B.t() * A.t()).t(); M -= AB; Print(M);
      AB = B * A;
      M = (A.t() * B.t()).t(); M -= AB; Print(M);
      AB.ReSize(5,5); AB = 0;
      AB.SubMatrix(1,2,1,3) = A; AB.SubMatrix(4,5,3,5) = A;
      AB.SubMatrix(1,3,4,5) = B; AB.SubMatrix(3,5,1,2) = B;
      SquareMatrix C(5);
      C.Row(1) << 2 << 6 << 7 << 1 << 3;
      C.Row(2) << 4 << 3 << 9 << 4 << 8;
      C.Row(3) << 1 << 3 << 0 << 0 << 6;
      C.Row(4) << 4 << 8 << 2 << 6 << 7;
      C.Row(5) << 0 << 6 << 4 << 3 << 9;
      C -= AB; Print(C);
      AB = A.SymSubMatrix(1,2);
      AB = (AB | AB) & (AB | AB);
      C.ReSize(4);
      C.Row(1) << 2 << 6 << 2 << 6;
      C.Row(2) << 4 << 3 << 4 << 3;
      C.Row(3) << 2 << 6 << 2 << 6;
      C.Row(4) << 4 << 3 << 4 << 3;
      M = AB;
      C -= M; Print(C);
      C << M; C += -M; Print(C);
      
   }


}
开发者ID:151706061,项目名称:Slicer3,代码行数:101,代码来源:tmtm.cpp


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