本文整理汇总了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);
}
示例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);
}
示例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;
}