NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
15-numcxx-umfpack.cxx
Go to the documentation of this file.
1 
7 
8 #include <iostream>
9 #include <limits>
10 #include <cassert>
11 #include <numcxx/numcxx.hxx>
12 
13 
14 int main(void)
15 {
16  int n=5000;
17  numcxx::DSparseMatrix A(n,n);
18  numcxx::DArray1 U(n);
19  numcxx::DArray1 F(n);
20 
21  F=1.0;
22  for (int i=0;i<n;i++)
23  {
24  A(i,i)=3.0;
25  if (i>0) A(i,i-1)=-1;
26  if (i<n-1) A(i,i+1)=-1;
27  }
28  A.flush();
29 
30  numcxx::DSolverUMFPACK UmfpackSolver(A);
31  UmfpackSolver.update(A);
32  UmfpackSolver.solve(U,F);
33  double residual=normi(A*U-F);
34 
35  std::cout << "residual:" << residual << std::endl;
36 }
37 
38 
Sparse matrix class using CRS storage scheme.
A::value_type normi(const A &a)
Maximum norm of array or expression.
Definition: util.ixx:26
int main(void)
void flush()
Re-create the internal data structure in order to accomodated all newly created elements.
void solve(TArray< T > &Sol, const TArray< T > &Rhs)
Solve LU factorized system.
Main header of the library.
One dimensional array class.
Definition: tarray1.hxx:31
Bridge class for using umfpack as solver for vmatrix.
void update()
Perform actual computation of LU factorization.