03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

250 CHAPTER 11. <strong>C++</strong> LIBRARIES FOR SCIENTIFIC COMPUTING<br />

#include <br />

#include <br />

#include <br />

int main() {<br />

namespace ublas = boost::numeric::ublas ;<br />

namespace mumps = boost::numeric::bindings::mumps ;<br />

...<br />

typedef ublas::coordinate matrix< double, ublas::column major<br />

, 1, ublas::unbounded array<br />

> sparse matrix type ;<br />

sparse matrix type matrix( n, n, nnz ) ;<br />

// Fill the sparse matrix<br />

...<br />

mumps::mumps< sparse matrix type > mumps solver ;<br />

// Analysis (Set the pointer and sizes of the integer data of the matrix)<br />

matrix integer data( mumps solver, matrix ) ;<br />

mumps solver.job = 1 ;<br />

driver( mumps solver ) ;<br />

// Factorization (Set the pointer <strong>for</strong> the values of the matrix)<br />

matrix value data( mumps solver, matrix ) ;<br />

mumps solver.job = 2 ;<br />

driver( mumps solver ) ;<br />

// Set the right−hand side<br />

ublas::vector v( 10 ) ;<br />

...<br />

// Solve (set pointer and size <strong>for</strong> the right−hand side vector)<br />

rhs sol value data( mumps solver, v ) ;<br />

mumps solver.job = 3 ;<br />

mumps::driver( mumps solver ) ;<br />

return 0 ;<br />

}<br />

Figure 11.5: Example of the use of the MUMPS bindings

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!