Using Predefined Linear Solvers

The following program illustrates how to solve a linear system:

#include <iostream>
#include <boost/numeric/mtl/mtl.hpp>
#include <boost/numeric/itl/itl.hpp>

using namespace mtl;
using namespace itl;

int main(int argc, char* argv[])
{
    const int size = 100, N = size * size; 
    typedef compressed2D<double>  matrix_type;

    // Set up a matrix 10,000 x 10,000 with 5-point-stencil
    matrix_type                   A(N, N);
    matrix::laplacian_setup(A, size, size);

    // Create an ILU(0) preconditioner
    pc::ilu_0<matrix_type>        P(A);
    
    // Set b such that x == 1 is solution; start with x == 0
    dense_vector<double>          x(N, 1.0), b(N);
    b= A * x; x= 0;
    
    // Termination criterion: r < 1e-6 * b or N iterations
    noisy_iteration<double>       iter(b, 500, 1.e-6);
    
    // Solve Ax == b with preconditioner P
    bicgstab(A, x, b, P, iter);

    return 0;
}

Currently two solvers are available:

More solvers will follow.

As preconditioners we provide at the moment:

Return to Introduction Krylov-Subspace Methods                                Table of Content                                Proceed to Iteration






Using Predefined Linear Solvers -- MTL 4 -- Peter Gottschling and Andrew Lumsdaine -- Generated on 19 May 2009 by Doxygen 1.5.5 -- Copyright 2007 by the Trustees of Indiana University.