mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.45k stars 891 forks source link

mathnet numerics solvers #585

Open ghosghos opened 6 years ago

ghosghos commented 6 years ago

1- any one can give an example of iterative solvers of linear system Ax = b. I am not able to completely understand the input of the function. lets say I have marrix A and vector b and i want to use the iterative solver to solve for x.

2- what other types of solvers does mathnet numerics support. please provide with complete example of implementation.

I need this with a FEM project I am working on. and performance is a huge issue. so I want to try different solvers to see how they compare.

Ghassan

wo80 commented 6 years ago
  1. Did you take a look at the examples (e.g. BiCgStab)?

  2. Math.NET does not support direct methods for large sparse matrices. Direct methods usually have a better performance, but require more memory. You might be interested in CSparse.NET and CSparse.Interop.

wo80 commented 6 years ago

BTW: when using iterative methods, you should always apply a preconditioner. In Math.NET, the only preconditioner optimized for sparse matrices is MILU0:

var iterator = new Iterator<double>(
    new IterationCountStopCriterion<double>(limit),
    new ResidualStopCriterion<double>(tolerance),
    new DivergenceStopCriterion<double>()
);

var solver = new BiCgStab();
var preconditioner = new MILU0Preconditioner();

preconditioner.Initialize(matrix);

solver.Solve(matrix, b, x, iterator, preconditioner);