本文整理汇总了C#中Permutation.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Permutation.Initialize方法的具体用法?C# Permutation.Initialize怎么用?C# Permutation.Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permutation
的用法示例。
在下文中一共展示了Permutation.Initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInverse
public static void TestInverse()
{
//----------------------
//| 0.18 | 0.41 | 0.14 |
//| 0.60 | 0.24 | 0.30 |
//| 0.57 | 0.99 | 0.97 |
//----------------------
Matrix matrix = new Matrix(3, 3);
Matrix matrix2 = new Matrix(4, 4);
matrix.SetValue(0, 0, 0.18);
matrix.SetValue(0, 1, 0.41);
matrix.SetValue(0, 2, 0.14);
matrix.SetValue(1, 0, 0.60);
matrix.SetValue(1, 1, 0.24);
matrix.SetValue(1, 2, 0.30);
matrix.SetValue(2, 0, 0.57);
matrix.SetValue(2, 1, 0.99);
matrix.SetValue(2, 2, 0.97);
double[,] test = matrix.ToArray();
for (uint i = 0; i < matrix.Columns; i++)
{
for (uint j = 0; j < matrix.Rows; j++)
{
matrix2.SetValue(i + 1, j + 1, matrix.GetValue(i, j));
}
}
//LU分解による方法
Matrix inv = new Matrix(3, 3);
int sig;
Permutation perm = new Permutation(3);
perm.Initialize();
LinearAlgebra.LUDecomposition(ref matrix, ref perm, out sig);
LinearAlgebra.LUInvert(matrix, perm, ref inv);
for (uint i = 0; i < inv.Columns; i++)
{
for (uint j = 0; j < inv.Rows; j++)
{
Console.Write(inv.GetValue(i, j).ToString("F4").PadLeft(8) + " | ");
}
Console.WriteLine();
}
Console.WriteLine();
//部分行列のテスト
perm.Initialize();
Matrix inv2 = new Matrix(4, 4);
MatrixView mView = new MatrixView(matrix2, 1, 1, 3, 3);
MatrixView mViewINV = new MatrixView(inv2, 0, 1, 3, 3);
LinearAlgebra.LUDecomposition(ref mView, ref perm, out sig);
LinearAlgebra.LUInvert(mView, perm, ref mViewINV);
for (uint i = 0; i < mViewINV.ColumnSize; i++)
{
for (uint j = 0; j < mViewINV.RowSize; j++)
{
Console.Write(mViewINV.GetValue(i, j).ToString("F4").PadLeft(8) + " | ");
}
Console.WriteLine();
}
Console.WriteLine();
for (uint i = 0; i < inv2.Columns; i++)
{
for (uint j = 0; j < inv2.Rows; j++)
{
Console.Write(inv2.GetValue(i, j).ToString("F4").PadLeft(8) + " | ");
}
Console.WriteLine();
}
Console.Read();
}