本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Double.SparseMatrix.ToMatrixString方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.ToMatrixString方法的具体用法?C# SparseMatrix.ToMatrixString怎么用?C# SparseMatrix.ToMatrixString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Double.SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.ToMatrixString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicFluid2D
public BasicFluid2D(int max_x, int max_y)
{
if (max_x != max_y) throw new ArgumentException();
this.max_x = max_x;
this.max_y = max_y;
u_x = new double[max_x + 1, max_y];
u_y = new double[max_x, max_y + 1];
cells = new GridCell[max_x, max_y];
A = new SparseMatrix(max_x * max_y);
for (int i = 0; i < max_x; i++)
for (int j = 0; j < max_y; j++)
{
A[i * max_x + j, i * max_x + j] = 2 + (i == 0 || i + 1 == max_x ? 1 : 0) + (j == 0 || j + 1 == max_y ? 1 : 0);
if (i > 0)
A[(i - 1) * max_x + j, i * max_x + j] = A[i * max_x + j, (i - 1) * max_x + j] = -1;
if (j > 0)
A[i * max_x + j - 1, i * max_x + j] = A[i * max_x + j, i * max_x + j - 1] = -1;
if (i < max_x - 1)
A[(i + 1) * max_x + j, i * max_x + j] = A[i * max_x + j, (i + 1) * max_x + j] = -1;
if (j < max_y - 1)
A[i * max_x + j + 1, i * max_x + j] = A[i * max_x + j, i * max_x + j + 1] = -1;
cells[i, j] = new GridCell();
//cells[i, j].Adiag = (short)(2 + (i == 0 || i + 1 == max_x ? 1 : 0) + (j == 0 || j + 1 == max_y ? 1 : 0));
//cells[i, j].Aplusi = (short)(i + 1 < max_x ? -1 : 0);
//cells[i, j].Aplusj = (short)(j + 1 < max_y ? -1 : 0);
if (new Vector2(i - max_x / 2, j - max_y / 2).LengthSquared < max_x * max_y / 16)
cells[i, j].ImplicitSurface = 5;
}
using (TextWriter tw = new StreamWriter("output.txt")) tw.WriteLine(A.ToMatrixString(900, 900));
solver = new
MathNet.Numerics.LinearAlgebra.Double.Solvers.Preconditioners.IncompleteLU();
solver.Initialize(A);
p = new DenseVector(max_x * max_y);
d = new DenseVector(max_x * max_y);
}