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


C# DoubleMatrix.Transpose方法代码示例

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


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

示例1: TransposeSquare

 public void TransposeSquare()
 {
   DoubleMatrix a = new DoubleMatrix(2,2);
   a[0,0] = 1;
   a[0,1] = 2;
   a[1,0] = 3;
   a[1,1] = 4;
   a.Transpose();
   Assert.AreEqual(a[0,0], 1);
   Assert.AreEqual(a[0,1], 3);
   Assert.AreEqual(a[1,0], 2);
   Assert.AreEqual(a[1,1], 4);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:13,代码来源:DoubleMatrixTest.cs

示例2: TransposeLong

 public void TransposeLong()
 {
   DoubleMatrix a = new DoubleMatrix(3,2);
   a[0,0] = 1;
   a[0,1] = 2;
   a[1,0] = 3;
   a[1,1] = 4;
   a[2,0] = 5;
   a[2,1] = 6;
   a.Transpose();
   Assert.AreEqual(a[0,0], 1);
   Assert.AreEqual(a[0,1], 3);
   Assert.AreEqual(a[0,2], 5);
   Assert.AreEqual(a[1,0], 2);
   Assert.AreEqual(a[1,1], 4);
   Assert.AreEqual(a[1,2], 6);
   Assert.AreEqual(a.RowLength, 2);
   Assert.AreEqual(a.ColumnLength, 3);
 }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:19,代码来源:DoubleMatrixTest.cs

示例3: InternalCompute


//.........这里部分代码省略.........
              if (computeVectors) 
              {
                drot (v, k, k+1, cs, sn); 
              }
              drotg(ref f, ref g, ref cs, ref sn);
              s[k] = f;
              f = cs*e[k] + sn*s[k+1];
              s[k+1] = -sn*e[k] + cs*s[k+1];
              g = sn*e[k+1];
              e[k+1] = cs*e[k+1];
              if (computeVectors  &&  k < rows)
              {
                drot(u, k, k+1, cs, sn); 
              }
            } 
            e[m-2] =f;
            iter = iter + 1;
            break; 

            // convergence.
          case 4: 
            // make the singular value  positive
            if (s[l]  < 0.0) 
            {
              s[l] = -s[l];
              if (computeVectors) 
              {
                dscalColumn(v, l, 0, -1.0); 
              }
            }

            // order the singular value.
            while (l != mm-1) 
            {
              if (s[l]  >= s[l+1]) 
              {
                break;
              }
              t = s[l];
              s[l] = s[l+1];
              s[l+1] = t;
              if (computeVectors && l < cols) 
              { 
                dswap(v,l,l+1); 
              }
              if (computeVectors && l < rows) 
              {
                dswap(u,l,l+1); 
              }
              l = l + 1;
            } 
            iter = 0;
            m = m - 1;
            break;
        } 
      }

      // make matrix w from vector s
      // there is no constructor, creating diagonal matrix from vector
      // doing it ourselves
      mm=System.Math.Min(matrix.RowLength,matrix.ColumnLength);
#else
      u = new DoubleMatrix(rows);
      v = new DoubleMatrix(cols);
      double[] a = new double[matrix.data.Length];
      Array.Copy(matrix.data, a, matrix.data.Length);
      Lapack.Gesvd.Compute(rows, cols, a, s.data, u.data, v.data );
      v.Transpose();
#endif    
      w=new DoubleMatrix(matrix.RowLength,matrix.ColumnLength);
      for(int ii=0; ii<matrix.RowLength; ii++) 
      {
        for(int jj=0; jj<matrix.ColumnLength; jj++) 
        {
          if(ii==jj) 
          {
            w[ii,ii]=s[ii];
          } 
        }
      }
      
      double eps = System.Math.Pow(2.0,-52.0);
      double tol = System.Math.Max(matrix.RowLength,matrix.ColumnLength)*s[0]*eps;
      rank = 0;
      
      for (int h = 0; h < mm; h++) 
      {
        if (s[h] > tol) 
        {
          rank++;
        }
      }

      if( !computeVectors )
      {
        u = null;
        v = null;
      }
      matrix = null;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:DoubleSVDDecomp.cs


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