本文整理汇总了C#中DoubleMatrix.GetTranspose方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleMatrix.GetTranspose方法的具体用法?C# DoubleMatrix.GetTranspose怎么用?C# DoubleMatrix.GetTranspose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.GetTranspose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test01a
public static void Test01a()
{
var X = new DoubleMatrix(new double[,] { { 73, 71, 52 }, { 87, 74, 46 }, { 72, 2, 7 }, { 80, 89, 71 } });
var y = new DoubleMatrix(new double[,] { { 49 }, { 67 }, { 68 }, { 20 } });
var XtX = X.GetTranspose() * X;
var Xty = X.GetTranspose() * y;
IMatrix x, w;
FastNonnegativeLeastSquares.Execution(XtX, Xty, null, out x, out w);
Assert.AreEqual(0.65, x[0, 0], 0.01);
Assert.AreEqual(0, x[1, 0], 0.01);
Assert.AreEqual(0, x[2, 0], 0.01);
Assert.AreEqual(0, w[0, 0], 1e-8);
Assert.Less(w[1, 0], 0);
Assert.Less(w[2, 0], 0);
}
示例2: Test01c
public static void Test01c()
{
var X = new DoubleMatrix(new double[,] { { 106, 743, 746, 73 }, { 579, 420, 531, 584 }, { 693, 234, 562, 255 }, { 484, 381, 474, 360 }, { 313, 68, 78, 301 } });
var y = new DoubleMatrix(new double[,] { { 803 }, { 292 }, { 230 }, { 469 }, { 655 } });
var XtX = X.GetTranspose() * X;
var Xty = X.GetTranspose() * y;
IMatrix x, w;
FastNonnegativeLeastSquares.Execution(XtX, Xty, null, out x, out w);
Assert.AreEqual(0, x[0, 0], 1e-4);
Assert.AreEqual(0.90443, x[1, 0], 1e-4);
Assert.AreEqual(0, x[2, 0], 1e-4);
Assert.AreEqual(0.29507, x[3, 0], 1e-4);
Assert.Less(w[0, 0], 0);
Assert.AreEqual(0, w[1, 0], 1e-8);
Assert.Less(w[2, 0], 0);
Assert.AreEqual(0, w[3, 0], 1e-8);
}
示例3: Test01b
public static void Test01b()
{
var X = new DoubleMatrix(new double[,] { { 771, 307, 765, 280 }, { 404, 802, 29, 703 }, { 166, 446, 8, 236 }, { 985, 225, 510, 731 }, { 109, 12, 382, 89 } });
var y = new DoubleMatrix(new double[,] { { 83 }, { 339 }, { 330 }, { 731 }, { 896 } });
var XtX = X.GetTranspose() * X;
var Xty = X.GetTranspose() * y;
IMatrix x, w;
FastNonnegativeLeastSquares.Execution(XtX, Xty, null, out x, out w);
Assert.AreEqual(0, x[0, 0], 1e-4);
Assert.AreEqual(0, x[1, 0], 1e-4);
Assert.AreEqual(0.41813, x[2, 0], 1e-4);
Assert.AreEqual(0.58480, x[3, 0], 1e-4);
Assert.Less(w[0, 0], 0);
Assert.Less(w[1, 0], 0);
Assert.AreEqual(0, w[2, 0], 1e-8);
Assert.AreEqual(0, w[3, 0], 1e-8);
}
示例4: GetTransposeLong
public void GetTransposeLong()
{
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;
DoubleMatrix b = a.GetTranspose();
Assert.AreEqual(b[0,0], 1);
Assert.AreEqual(b[0,1], 3);
Assert.AreEqual(b[0,2], 5);
Assert.AreEqual(b[1,0], 2);
Assert.AreEqual(b[1,1], 4);
Assert.AreEqual(b[1,2], 6);
Assert.AreEqual(b.RowLength, a.ColumnLength);
Assert.AreEqual(b.ColumnLength, a.RowLength);
}
示例5: GetTransposeSquare
public void GetTransposeSquare()
{
DoubleMatrix a = new DoubleMatrix(2,2);
a[0,0] = 1;
a[0,1] = 2;
a[1,0] = 3;
a[1,1] = 4;
DoubleMatrix b = a.GetTranspose();
Assert.AreEqual(b[0,0], 1);
Assert.AreEqual(b[0,1], 3);
Assert.AreEqual(b[1,0], 2);
Assert.AreEqual(b[1,1], 4);
}
示例6: GetMatrix
/// <summary>
/// Get a copy of the Toeplitz matrix.
/// </summary>
public DoubleMatrix GetMatrix()
{
int i;
// allocate memory for the matrix
DoubleMatrix tm = new DoubleMatrix(m_Order);
#if MANAGED
// fill lower triangle
for (i = 0; i < m_Order; i++)
{
Array.Copy(m_LeftColumn.data, 0, tm.data[i], i, m_Order - i);
}
tm = tm.GetTranspose();
// fill upper triangle
for (i = 0; i < m_Order - 1; i++)
{
Array.Copy(m_TopRow.data, 1, tm.data[i], i + 1, m_Order - i - 1);
}
#else
int j, k;
// fill lower triangle
for (i = 0; i < m_Order; i++)
{
for (j = i, k = 0; j < m_Order; j++, k++)
{
tm[j, i] = m_LeftColumn[k];
}
}
// fill upper triangle
for (i = 0; i < m_Order; i++)
{
for (j = i + 1, k = 1; j < m_Order; j++, k++)
{
tm[i, j] = m_TopRow[k];
}
}
#endif
return tm;
}
示例7: Test01e_2
public static void Test01e_2()
{
var X = new DoubleMatrix(new double[,] { { 73, 746, 743, 106 }, { 584, 531, 420, 579 }, { 255, 562, 234, 693 }, { 360, 474, 381, 484 }, { 301, 78, 68, 313 } });
var y = new DoubleMatrix(new double[,] { { 803 }, { 292 }, { 230 }, { 469 }, { 655 } });
var XtX = X.GetTranspose() * X;
var Xty = X.GetTranspose() * y;
var solver = new DoubleLUDecomp(XtX);
var expected = solver.Solve(Xty);
IMatrix x, w;
FastNonnegativeLeastSquares.Execution(XtX, Xty, (i) => false, null, out x, out w);
Assert.AreEqual(expected[0, 0], x[0, 0], 1e-4);
Assert.AreEqual(expected[1, 0], x[1, 0], 1e-4);
Assert.AreEqual(expected[2, 0], x[2, 0], 1e-4);
Assert.AreEqual(expected[3, 0], x[3, 0], 1e-4);
Assert.AreEqual(0, w[0, 0], 1e-8);
Assert.AreEqual(0, w[1, 0], 1e-8);
Assert.AreEqual(0, w[2, 0], 1e-8);
Assert.AreEqual(0, w[3, 0], 1e-8);
}
示例8: Test01d2
public static void Test01d2()
{
var X = new DoubleMatrix(new double[,] { { 73, 746, 743, 106 }, { 584, 531, 420, 579 }, { 255, 562, 234, 693 }, { 360, 474, 381, 484 }, { 301, 78, 68, 313 } });
var y = new DoubleMatrix(new double[,] { { 803 }, { 292 }, { 230 }, { 469 }, { 655 } });
var XtX = X.GetTranspose() * X;
var Xty = X.GetTranspose() * y;
IMatrix x, w;
FastNonnegativeLeastSquares.Execution(XtX, Xty, (i) => i != 3, null, out x, out w);
Assert.AreEqual(0.37911, x[0, 0], 1e-4);
Assert.AreEqual(0, x[1, 0], 1e-4);
Assert.AreEqual(0.91034, x[2, 0], 1e-4);
Assert.AreEqual(-0.07097, x[3, 0], 1e-4);
Assert.AreEqual(0, w[0, 0], 1e-8);
Assert.Less(w[1, 0], 0);
Assert.AreEqual(0, w[2, 0], 1e-8);
Assert.AreEqual(0, w[3, 0], 1e-8);
}