Hi Florian,
The iterative solvers accept a result vector, where the resulting solution is then put into. This vector is effectively also used as initial guess, although note that its values will be overwritten. Unfortunately this is not exposed in the
Christoph
The iterative solvers accept a result vector, where the resulting solution is then put into. This vector is effectively also used as initial guess, although note that its values will be overwritten. Unfortunately this is not exposed in the
Matrix.SolverIterative
routines, but works when you use the solvers directly. Example in LINQPad (with its Dump methods):var A = Matrix<double>.Build.SparseOfArray(new double[,] { { 1, 1, 1 }, { 1, 2, 3 }, { 1, 3, 6 } });
var b = Vector<double>.Build.Dense(new double[] {3, 1, 4});
//var x = Vector<double>.Build.Dense(A.RowCount);
var x = Vector<double>.Build.Dense(new double[] { 10.5, -12.5, 5.5 });
var preconditioner = new MILU0Preconditioner();
//var preconditioner = new UnitPreconditioner<double>();
var iterator = new Iterator<double>(new IIterationStopCriterium<double>[]
{
new IterationCountStopCriterium<double>(100),
new ResidualStopCriterium<double>(1e-12),
new DivergenceStopCriterium<double>(),
new FailureStopCriterium<double>()
});
var solver = new BiCgStab();
solver.Solve(A, b, x, iterator, preconditioner);
iterator.Dump();
x.Dump();
A.LU().Solve(b).Dump("Verify with LU decompositon");
A.QR().Solve(b).Dump("Verify with QR decompositon");
Thanks,Christoph