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

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )
Examples:
14-numcxx-lapack-sharedptr.cxx.

Definition at line 12 of file 14-numcxx-lapack-sharedptr.cxx.

13 {
14  int n=5000;
15  auto pA=numcxx::DMatrix::create(n,n);
16  auto pF=numcxx::DArray1::create(n);
17  auto pU=numcxx::DArray1::create(n);
18 
19  // Here, we need to derefernce the smart pointer to references
20  // in order to use the () operator in a convenient way.
21  auto &A=*pA;
22  auto &F=*pF;
23  auto &U=*pU;
24 
25  F=1.0;
26  for (int i=0;i<n;i++)
27  {
28  A(i,i)=3.0;
29  if (i>0) A(i,i-1)=-1;
30  if (i<n-1) A(i,i+1)=-1;
31  }
32 
33  auto pLapack=numcxx::DSolverLapackLU::create(pA);
34  pLapack->solve(U,F);
35  double residual=normi(A*U-F);
36 
37  std::cout << "residual:" << residual << std::endl;
38 }
A::value_type normi(const A &a)
Maximum norm of array or expression.
Definition: util.ixx:26
static std::shared_ptr< TSolverLapackLU< T > > create(const std::shared_ptr< TMatrix< T >> pMatrix)
Static wrapper around constructor.
static std::shared_ptr< TMatrix< T > > create(index n1, index n2)
Construct empty square matrix.
Definition: tmatrix.hxx:81
static std::shared_ptr< TArray1< T > > create(index n1)
Construct smart pointer empty 1D Array.
Definition: tarray1.hxx:81

+ Here is the call graph for this function: