NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
Functions
16-numcxx-umfpack-sharedptr.cxx File Reference
+ Include dependency graph for 16-numcxx-umfpack-sharedptr.cxx:

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )
Examples:
16-numcxx-umfpack-sharedptr.cxx.

Definition at line 13 of file 16-numcxx-umfpack-sharedptr.cxx.

14 {
15  int n=5000;
16  auto pA=numcxx::DSparseMatrix::create(n,n);
17  auto pF=numcxx::DArray1::create(n);
18  auto pU=numcxx::DArray1::create(n);
19 
20  auto &A=*pA;
21  auto &F=*pF;
22  auto &U=*pU;
23 
24  F=1.0;
25  for (int i=0;i<n;i++)
26  {
27  A(i,i)=3.0;
28  if (i>0) A(i,i-1)=-1;
29  if (i<n-1) A(i,i+1)=-1;
30  }
31  pA->flush();
32 
33  auto pUmfpack=numcxx::DSolverUMFPACK::create(pA);
34  pUmfpack->update();
35  pUmfpack->solve(U,F);
36  double residual=normi(A*U-F);
37 
38  std::cout << "residual:" << residual << std::endl;
39 }
static std::shared_ptr< TSolverUMFPACK< T > > create(const std::shared_ptr< TSparseMatrix< T >> pA)
Create LU factorization class.
A::value_type normi(const A &a)
Maximum norm of array or expression.
Definition: util.ixx:26
static std::shared_ptr< TArray1< T > > create(index n1)
Construct smart pointer empty 1D Array.
Definition: tarray1.hxx:81
static std::shared_ptr< TSparseMatrix< T > > create(index n1, index n2)
Static wrapper around corresponding constructor.

+ Here is the call graph for this function: