This project has moved and is read-only. For the latest updates, please go here.

Iterative solver experience numerical break down

Jul 2, 2013 at 7:52 PM
Hello all,

Following advice on other threads, I am using iterative methods in order to solve a sparse system of equations. The matrix is 40000X40000. If I set the iteration limit to 10000 then I am able to get a solution value, however the resulting residual is highly off from 0. When I increase the iteration limit to 15000 or more, I get "Iterative solver experience numerical break down" error, and process is terminated. I was wondering if this is a common issue and if there is something - an earlier check- I can do to prevent this.

I have already tried with other solvers : TFQMR, GpBiCg ,MlkBiCgStab -I get the same error..
Also I expremented with solver Preconditioners. In that case I get NaN's as solution, regardless of iteration no.
/// Given SparseMatrix A, and DenseVector rhs:
      MathNet.Numerics.Control.DisableParallelization = true;

      BiCgStab solver = new BiCgStab();

    // Choose stop criterias
    var stopCriterias = new List<IIterationStopCriterium>()
        new ResidualStopCriterium(1e-8),
        new IterationCountStopCriterium(15000),
        new DivergenceStopCriterium(),
        new FailureStopCriterium()
    solver.SetIterator(new Iterator(stopCriterias));

    var solution = solver.Solve(A, rhs);

    bool success = false;

    foreach (var item in stopCriterias)
        if (item.StopLevel == StopLevel.Convergence)
            success = true;

    var residual = A* solution - rhs;

Thanks in advance,

Jul 8, 2013 at 11:38 AM
Can you save the matrix + rhs and upload a zipped version?

Use the MathNet.Numerics.LinearAlgebra.Double.IO namespace or the following code (assuming it's a real valued matrix)
public void Save(SparseMatrix matrix, string filename)
    var nfi = CultureInfo.InvariantCulture.NumberFormat;

    int i, j, k, n = matrix.NonZerosCount;
    double value;

    var storage = matrix.IndexedEnumerator();

    using (var writer = new StreamWriter(filename))
        // Write header 1 (format)
        writer.WriteLine("%%MatrixMarket matrix coordinate real general");

        // Write header 2 (size)
        writer.WriteLine("{0} {1} {2}", matrix.RowCount, matrix.ColumnCount, n);

        string iformat = "{0," + (matrix.RowCount.ToString().Length + 1) + "}";
        string dformat = "e10";
        string sformat = "{0,20}";

        // Write entries
        foreach (var entry in storage)
            i = entry.Item1;
            j = entry.Item2;
            value = entry.Item3;

            writer.Write(iformat, i);
            writer.Write(iformat, j);
            writer.Write(sformat, value.ToString(dformat, nfi));