NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
13-numcxx-lapack.cxx
Go to the documentation of this file.
1 #include <iostream>
7 #include <limits>
8 #include <numcxx/numcxx.hxx>
9 
10 
11 int main(void)
12 {
13  int n=5000;
14  numcxx::DMatrix A(n,n);
15  numcxx::DArray1 F(n);
16  numcxx::DArray1 U(n);
17 
18 
19  F=1.0;
20  for (int i=0;i<n;i++)
21  {
22  A(i,i)=3.0;
23  if (i>0) A(i,i-1)=-1;
24  if (i<n-1) A(i,i+1)=-1;
25  }
26 
27  numcxx::DSolverLapackLU LapackSolver(A);
28  LapackSolver.solve(U,F);
29  double residual=normi(A*U-F);
30 
31  std::cout << "residual:" << residual << std::endl;
32 }
33 
A::value_type normi(const A &a)
Maximum norm of array or expression.
Definition: util.ixx:26
void solve(TArray< T > &Sol, const TArray< T > &Rhs) const
Solve LU factorized system.
Main header of the library.
One dimensional array class.
Definition: tarray1.hxx:31
Dense matrix class.
Definition: tmatrix.hxx:38
int main(void)
Lapack LU factorization class.