NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
Classes | Typedefs | Functions
numcxx Namespace Reference

Description

Numcxx template library.

untility functions

Classes

class  Geometry
 Class collecting data for the description of piecewise linear geometries. More...
 
class  SimpleGrid
 Class containing data for simple grid data structure. More...
 
class  TArray
 TArray is the common template base class for arrays and dense matrices of the numcxx project. More...
 
class  TArray1
 One dimensional array class. More...
 
class  TArray2
 Two-dimensional array class. More...
 
class  TLinOperator
 Base class for linear operators (matrices, sparse matrices) More...
 
class  TLinSolver
 Base class for linear solvers and preconditioners. More...
 
class  TMatrix
 Dense matrix class. More...
 
class  TPreconILU
 ILU preconditioner class. More...
 
class  TPreconJacobi
 Jacobi preconditioner class. More...
 
class  TSolverLapackLU
 Lapack LU factorization class. More...
 
class  TSolverUMFPACK
 Bridge class for using umfpack as solver for vmatrix. More...
 
class  TSparseMatrix
 Sparse matrix class using CRS storage scheme. More...
 

Typedefs

using index = unsigned int
 
using DArray1 = TArray1< double >
 
using DArray2 = TArray2< double >
 
using DMatrix = TMatrix< double >
 
using DSparseMatrix = TSparseMatrix< double >
 
using DSolverLapackLU = TSolverLapackLU< double >
 
using DSolverUMFPACK = TSolverUMFPACK< double >
 
using DPreconJacobi = TPreconJacobi< double >
 
using DPreconILU = TPreconILU< double >
 
using IArray1 = TArray1< int >
 
using IArray2 = TArray2< int >
 

Functions

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const AdditionExpression< A, Boperator+ (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const SubtractionExpression< A, Boperator- (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarMultiplicationExpression< A, Boperator* (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarMultiplicationExpression< A, Boperator* (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarAdditionExpression< A, Boperator+ (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarAdditionExpression< A, Boperator+ (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarSubtractionExpression< A, Boperator- (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarSubtractionExpression< A, Boperator- (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarDivisionExpression< A, Boperator/ (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<MatrixExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftMatrixMultiplicationExpression< A, Boperator* (const A &a, const B &b)
 
template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<SparseMatrixExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftSparseMatrixMultiplicationExpression< A, Boperator* (const A &a, const B &b)
 
template<typename T >
std::ostream & operator<< (std::ostream &s, TArray< T > &A)
 
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
TArray< T > & assign (TArray< T > &A, const EXPR &expr, const EXPR *x=0)
 
template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
TArray< T > & assign (TArray< T > &A, const VAL &a)
 
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void xadd (TArray< T > &A, const EXPR &expr, const EXPR *x=0)
 
template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void xadd (TArray< T > &A, const VAL &a)
 
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void xsub (TArray< T > &A, const EXPR &expr, const EXPR *x=0)
 
template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void xsub (TArray< T > &A, const VAL &a)
 
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void xmul (TArray< T > &A, const EXPR &expr, const EXPR *x=0)
 
template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void xmul (TArray< T > &A, const VAL &a)
 
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void xdiv (TArray< T > &A, const EXPR &expr, const EXPR *x=0)
 
template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void xdiv (TArray< T > &A, const VAL &a)
 
void dgemm_ (char *TRANSA, char *TRANSB, int *M, int *N, int *K, double *ALPHA, const double *A, int *LDA, double *B, int *LDB, double *BETA, double *C, int *LDC)
 
void sgemm_ (char *TRANSA, char *TRANSB, int *M, int *N, int *K, float *ALPHA, const float *A, int *LDA, float *B, int *LDB, float *BETA, float *C, int *LDC)
 
template<typename T >
std::ostream & operator<< (std::ostream &s, TSolverLapackLU< T > &LU)
 
void sgetrf_ (int *n, int *m, float *a, int *lda, int *ipiv, int *info)
 
void sgetrs_ (char *trans, int *n, const int *nrhs, float *a, int *lda, int *ipiv, float *b, int *ldb, int *info)
 
void sgetri_ (int *n, float *a, int *lda, int *ipiv, float *work, int *lwork, int *info)
 
void dgetrf_ (int *n, int *m, double *a, int *lda, int *ipiv, int *info)
 
void dgetrs_ (char *trans, int *n, const int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info)
 
void dgetri_ (int *n, double *a, int *lda, int *ipiv, double *work, int *lwork, int *info)
 
template<typename A >
TArray1< typename A::value_type > arrayexpr (const A &a)
 Evaluate expression as array. More...
 
template<typename A >
A::value_type normi (const A &a)
 Maximum norm of array or expression. More...
 
template<typename A >
A::value_type norm1 (const A &a)
 Sum norm of array or expression. More...
 
template<typename A >
A::value_type norm2 (const A &a)
 Euklidean norm of array or expression. More...
 
template<typename A >
A::value_type norm (const A &a)
 Euklidean norm of array or expression. More...
 
template<typename A , typename B >
A::value_type dot (const A &a, const B &b)
 Dot product of array or expression. More...
 
template<typename A >
A::value_type min (const A &a)
 Minimum of of array or expression. More...
 
template<typename A >
A::value_type max (const A &a)
 Maximum of array or expression. More...
 
template<typename A >
A::value_type sum (const A &a)
 Sum of array or expression. More...
 
template<typename T >
std::shared_ptr< TArray1< T > > linspace (T x0, T x1, int n)
 Create array of $n$ equally spaced entries. More...
 
double cpu_clock ()
 cpu time in seconds More...
 
double wall_clock ()
 wall clock time in seconds More...
 
template<typename T >
void savetxt (const std::string fname, const TArray< T > &a)
 
template<typename T >
void savetxt (const std::ostream s, const TArray< T > &a)
 
double norm1 (const std::shared_ptr< DArray1 > a)
 
double norm2 (const std::shared_ptr< DArray1 > a)
 
double normi (const std::shared_ptr< DArray1 > a)
 
template<typename T >
void savetxt (std::ostream &s, const TArray< T > &a)
 
void print_triangulateio (triangle::triangulateio *in)
 
double dist (const numcxx::DArray2 &points, int p1, int p2)
 

Typedef Documentation

using numcxx::index = typedef unsigned int

Definition at line 21 of file numcxx.hxx.

typedef TArray1< double > numcxx::DArray1
Examples:
45-convdiff1d.cxx.

Definition at line 38 of file numcxx.hxx.

typedef TArray2< double > numcxx::DArray2

Definition at line 39 of file numcxx.hxx.

using numcxx::DMatrix = typedef TMatrix<double>

Definition at line 40 of file numcxx.hxx.

using numcxx::DSparseMatrix = typedef TSparseMatrix<double>

Definition at line 41 of file numcxx.hxx.

using numcxx::DSolverLapackLU = typedef TSolverLapackLU<double>

Definition at line 42 of file numcxx.hxx.

using numcxx::DSolverUMFPACK = typedef TSolverUMFPACK<double>

Definition at line 43 of file numcxx.hxx.

using numcxx::DPreconJacobi = typedef TPreconJacobi<double>

Definition at line 44 of file numcxx.hxx.

using numcxx::DPreconILU = typedef TPreconILU<double>

Definition at line 45 of file numcxx.hxx.

using numcxx::IArray1 = typedef TArray1<int>

Definition at line 46 of file numcxx.hxx.

using numcxx::IArray2 = typedef TArray2<int>

Definition at line 47 of file numcxx.hxx.

Function Documentation

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const AdditionExpression<A,B> numcxx::operator+ ( const A &  a,
const B b 
)

Definition at line 80 of file expression.ixx.

81  {
82  return AdditionExpression<A,B>(a, b);
83  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const SubtractionExpression<A,B> numcxx::operator- ( const A &  a,
const B b 
)

Definition at line 105 of file expression.ixx.

106  {
107  return SubtractionExpression<A,B>(a, b);
108  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarMultiplicationExpression<A,B> numcxx::operator* ( const A &  a,
const B b 
)

Definition at line 129 of file expression.ixx.

130  {
131  return LeftScalarMultiplicationExpression<A,B>(a, b);
132  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarMultiplicationExpression<A,B> numcxx::operator* ( const A &  a,
const B b 
)

Definition at line 154 of file expression.ixx.

155  {
156  return RightScalarMultiplicationExpression<A,B>(a, b);
157  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarAdditionExpression<A,B> numcxx::operator+ ( const A &  a,
const B b 
)

Definition at line 180 of file expression.ixx.

181  {
182  return RightScalarAdditionExpression<A,B>(a, b);
183  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarAdditionExpression<A,B> numcxx::operator+ ( const A &  a,
const B b 
)

Definition at line 204 of file expression.ixx.

205  {
206  return LeftScalarAdditionExpression<A,B>(a, b);
207  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarSubtractionExpression<A,B> numcxx::operator- ( const A &  a,
const B b 
)

Definition at line 228 of file expression.ixx.

229  {
230  return RightScalarSubtractionExpression<A,B>(a, b);
231  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_fundamental<A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftScalarSubtractionExpression<A,B> numcxx::operator- ( const A &  a,
const B b 
)

Definition at line 252 of file expression.ixx.

253  {
254  return LeftScalarSubtractionExpression<A,B>(a, b);
255  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<ExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_fundamental<B>::value, B>::type>
const RightScalarDivisionExpression<A,B> numcxx::operator/ ( const A &  a,
const B b 
)

Definition at line 276 of file expression.ixx.

277  {
278  return RightScalarDivisionExpression<A,B>(a, b);
279  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<MatrixExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftMatrixMultiplicationExpression<A,B> numcxx::operator* ( const A &  a,
const B b 
)

Definition at line 306 of file expression.ixx.

307  {
308  return LeftMatrixMultiplicationExpression<A,B>(a, b);
309  }

+ Here is the call graph for this function:

template<typename A , typename B , typename = typename std::enable_if<std::is_base_of<SparseMatrixExpressionBase,A>::value, A>::type, typename = typename std::enable_if<std::is_base_of<ExpressionBase,B>::value, B>::type>
const LeftSparseMatrixMultiplicationExpression<A,B> numcxx::operator* ( const A &  a,
const B b 
)

Definition at line 340 of file expression.ixx.

341  {
342  return LeftSparseMatrixMultiplicationExpression<A,B>(a, b);
343  }
template<typename T >
std::ostream & numcxx::operator<< ( std::ostream &  s,
TArray< T > &  A 
)
inline

Definition at line 328 of file tarray.ixx.

329  {
330  if (A.ndim()==1)
331  for (index i=0;i<A.size();i++) s <<"[" << i << "]: " <<A(i) << std::endl << std::flush;
332  else
333  {
334  s << " ";
335  for (index j=0;j<A.shape(1);j++)
336  s << "[" << j << "] ";
337  s<< "\n";
338  for (index i=0;i<A.shape(0);i++)
339  {
340  s << "[" << i << "]: ";
341  for (index j=0;j<A.shape(1);j++)
342  s << A(i,j) << " ";
343  s<< "\n";
344  }
345  }
346  return s;
347  }
unsigned int index
Definition: numcxx.hxx:21
template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
TArray<T>& numcxx::assign ( TArray< T > &  A,
const EXPR &  expr,
const EXPR *  x = 0 
)
inline

Definition at line 35 of file tarray.ixx.

36  {
37  A.resize( expr.size() );
38  T *data=A.data();
39  for(index i=0; i<expr.size(); i++ ) data[i] = expr[i];
40  return A;
41  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
TArray<T>& numcxx::assign ( TArray< T > &  A,
const VAL &  a 
)
inline

Definition at line 45 of file tarray.ixx.

46  {
47  T *data=A.data();
48  for(index i=0; i<A.size(); i++ ) data[i] = a;
49  return A;
50  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void numcxx::xadd ( TArray< T > &  A,
const EXPR &  expr,
const EXPR *  x = 0 
)
inline

Definition at line 54 of file tarray.ixx.

55  {
56  A.resize( expr.size() );
57  T *data=A.data();
58  for(index i=0; i<expr.size(); i++ ) data[i] += expr[i];
59  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void numcxx::xadd ( TArray< T > &  A,
const VAL &  a 
)
inline

Definition at line 64 of file tarray.ixx.

65  {
66  T *data=A.data();
67  for(index i=0; i<A.size(); i++ )data[i] += a;
68  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void numcxx::xsub ( TArray< T > &  A,
const EXPR &  expr,
const EXPR *  x = 0 
)
inline

Definition at line 73 of file tarray.ixx.

74  {
75  A.resize( expr.size() );
76  T *data=A.data();
77  for(index i=0; i<expr.size(); i++ ) data[i] -= expr[i];
78  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void numcxx::xsub ( TArray< T > &  A,
const VAL &  a 
)
inline

Definition at line 83 of file tarray.ixx.

84  {
85  T *data=A.data();
86  for(index i=0; i<A.size(); i++ )data[i] -= a;
87  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void numcxx::xmul ( TArray< T > &  A,
const EXPR &  expr,
const EXPR *  x = 0 
)
inline

Definition at line 92 of file tarray.ixx.

93  {
94  A.resize( expr.size() );
95  T *data=A.data();
96  for(index i=0; i<expr.size(); i++ ) data[i] *= expr[i];
97  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void numcxx::xmul ( TArray< T > &  A,
const VAL &  a 
)
inline

Definition at line 102 of file tarray.ixx.

103  {
104  T *data=A.data();
105  for(index i=0; i<A.size(); i++ )data[i] *= a;
106  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename EXPR , typename = typename std::enable_if<std::is_class<EXPR>::value, EXPR>::type>
void numcxx::xdiv ( TArray< T > &  A,
const EXPR &  expr,
const EXPR *  x = 0 
)
inline

Definition at line 111 of file tarray.ixx.

112  {
113  A.resize( expr.size() );
114  T *data=A.data();
115  for(index i=0; i<expr.size(); i++ ) data[i] /= expr[i];
116  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

template<typename T , typename VAL , typename = typename std::enable_if<!std::is_class<VAL>::value, VAL>::type>
void numcxx::xdiv ( TArray< T > &  A,
const VAL &  a 
)
inline

Definition at line 121 of file tarray.ixx.

122  {
123  T *data=A.data();
124  for(index i=0; i<A.size(); i++ )data[i] /= a;
125  }
unsigned int index
Definition: numcxx.hxx:21

+ Here is the call graph for this function:

void numcxx::dgemm_ ( char *  TRANSA,
char *  TRANSB,
int *  M,
int *  N,
int *  K,
double *  ALPHA,
const double *  A,
int *  LDA,
double *  B,
int *  LDB,
double *  BETA,
double *  C,
int *  LDC 
)
void numcxx::sgemm_ ( char *  TRANSA,
char *  TRANSB,
int *  M,
int *  N,
int *  K,
float *  ALPHA,
const float *  A,
int *  LDA,
float *  B,
int *  LDB,
float *  BETA,
float *  C,
int *  LDC 
)
template<typename T >
std::ostream& numcxx::operator<< ( std::ostream &  s,
TSolverLapackLU< T > &  LU 
)
inline

Definition at line 69 of file tsolver-lapacklu.hxx.

70  {
71  s << "LU:" << std::endl;
72  s << LU.LU() << std::endl;
73  s << "IPiv:" << std::endl;
74  s << LU.IPiv() << std::endl;
75  }

+ Here is the call graph for this function:

void numcxx::sgetrf_ ( int *  n,
int *  m,
float *  a,
int *  lda,
int *  ipiv,
int *  info 
)
void numcxx::sgetrs_ ( char *  trans,
int *  n,
const int *  nrhs,
float *  a,
int *  lda,
int *  ipiv,
float *  b,
int *  ldb,
int *  info 
)
void numcxx::sgetri_ ( int *  n,
float *  a,
int *  lda,
int *  ipiv,
float *  work,
int *  lwork,
int *  info 
)
void numcxx::dgetrf_ ( int *  n,
int *  m,
double *  a,
int *  lda,
int *  ipiv,
int *  info 
)
void numcxx::dgetrs_ ( char *  trans,
int *  n,
const int *  nrhs,
double *  a,
int *  lda,
int *  ipiv,
double *  b,
int *  ldb,
int *  info 
)
void numcxx::dgetri_ ( int *  n,
double *  a,
int *  lda,
int *  ipiv,
double *  work,
int *  lwork,
int *  info 
)
template<typename A >
TArray1< typename A::value_type > numcxx::arrayexpr ( const A &  a)
inline

Evaluate expression as array.

This shall help with the issue with type inference for expression templates For two vectors A,B of type TArray<double>,

auto C=A+B

results in C being an instannce of AdditionExpression<TArray<double>,TArray<double>> which will not behave like an array. Operators like << are not defined, and, more dangerously, subsequent operations using C may create wrong results, similar to the situation described in https://eigen.tuxfamily.org/dox/TopicPitfalls.html.

The best solution is to avoid auto altogther in code with expression templates. Just write

TArray<double> C=A+B

arrayexpr provides an (more or less experimental) alternative by using move semantics for constructing and returning an array. So another safe way would be to write

auto C=arrayexpr(A+B)

resulting in C being detected as of type TArray<double>

Returns
Array of corresponding result type of expression
Examples:
10-numcxx-expressions.cxx.

Definition at line 19 of file util.ixx.

20  {
21  TArray1<typename A::value_type> v=a;
22  return std::move(v);
23  }
template<typename A >
A::value_type numcxx::normi ( const A &  a)
inline

Maximum norm of array or expression.

Returns
Maximum ( \(l^\infty\)) norm.
Examples:
13-numcxx-lapack.cxx, 14-numcxx-lapack-sharedptr.cxx, 15-numcxx-umfpack.cxx, and 16-numcxx-umfpack-sharedptr.cxx.

Definition at line 26 of file util.ixx.

27  {
28  typename A::value_type norm=std::abs(a[0]);
29  for(index i=1; i<a.size(); i++ )
30  {
31  typename A::value_type x=std::abs(a[i]);
32  if (x>norm) norm=x;
33  }
34  return norm;
35  }
unsigned int index
Definition: numcxx.hxx:21
Real abs(Real x)
Definition: gmres.h:43
A::value_type norm(const A &a)
Euklidean norm of array or expression.
Definition: util.hxx:54

+ Here is the call graph for this function:

template<typename A >
A::value_type numcxx::norm1 ( const A &  a)
inline

Sum norm of array or expression.

Returns
Sum ( \(l^1\)) norm.

Definition at line 37 of file util.ixx.

38  {
39  typename A::value_type norm=std::abs(a[0]);
40  for(index i=1; i<a.size(); i++ )
41  {
42  norm+=std::abs(a[i]);
43  }
44  return norm;
45  }
unsigned int index
Definition: numcxx.hxx:21
Real abs(Real x)
Definition: gmres.h:43
A::value_type norm(const A &a)
Euklidean norm of array or expression.
Definition: util.hxx:54

+ Here is the call graph for this function:

template<typename A >
A::value_type numcxx::norm2 ( const A &  a)
inline

Euklidean norm of array or expression.

Returns
Euklidean ( \(l^2\)) norm
Examples:
46-nonlin-fvm.cxx.

Definition at line 47 of file util.ixx.

48  {
49  typename A::value_type norm=0.0;
50  for(index i=0; i<a.size(); i++ )
51  {
52  typename A::value_type x=a[i];
53  norm+=x*x;
54  }
55  return sqrt(norm);
56  }
unsigned int index
Definition: numcxx.hxx:21
A::value_type norm(const A &a)
Euklidean norm of array or expression.
Definition: util.hxx:54

+ Here is the call graph for this function:

template<typename A >
A::value_type numcxx::norm ( const A &  a)
inline

Euklidean norm of array or expression.

Returns
Euklidean ( \(l^2\)) norm
Examples:
46-nonlin-fvm.cxx.

Definition at line 54 of file util.hxx.

54 { return norm2(a);}
double norm2(const std::shared_ptr< DArray1 > a)
Definition: util.hxx:103

+ Here is the call graph for this function:

template<typename A , typename B >
A::value_type numcxx::dot ( const A &  a,
const B b 
)
inline

Dot product of array or expression.

Parameters
AFirst argument.
BSecond argument.
Returns
Dot product

Definition at line 91 of file util.ixx.

92  {
93  typename A::value_type dot=0.0;
94  for(index i=0; i<a.size(); i++ )
95  {
96  dot+=a[i]*b[i];
97  }
98  return dot;
99  }
unsigned int index
Definition: numcxx.hxx:21
A::value_type dot(const A &a, const B &b)
Dot product of array or expression.
Definition: util.ixx:91
template<typename A >
A::value_type numcxx::min ( const A &  a)
inline

Minimum of of array or expression.

Returns
Minimum of all elements in array.
Examples:
46-nonlin-fvm.cxx.

Definition at line 59 of file util.ixx.

60  {
61  typename A::value_type m=a[0];
62  for(index i=1; i<a.size(); i++ )
63  {
64  typename A::value_type x=a[i];
65  if (x<m) m=x;
66  }
67  return m;
68  }
unsigned int index
Definition: numcxx.hxx:21
template<typename A >
A::value_type numcxx::max ( const A &  a)
inline

Maximum of array or expression.

Returns
Maximum of all elements in array.

Definition at line 70 of file util.ixx.

71  {
72  typename A::value_type m=a[0];
73  for(index i=1; i<a.size(); i++ )
74  {
75  typename A::value_type x=a[i];
76  if (x>m) m=x;
77  }
78  return m;
79  }
unsigned int index
Definition: numcxx.hxx:21
template<typename A >
A::value_type numcxx::sum ( const A &  a)
inline

Sum of array or expression.

Returns
Sum of all elements in array.
Examples:
01-c-style-stack.cxx, 02-c-style-heap.cxx, 03-cxx-style-ref.cxx, 04-cxx-style-sharedptr.cxx, 05-cxx-style-sharedptr2.cxx, 11-numcxx-ref.cxx, and 12-numcxx-sharedptr.cxx.

Definition at line 81 of file util.ixx.

82  {
83  typename A::value_type s=a[0];
84  for(index i=1; i<a.size(); i++ )
85  {
86  s+=a[i];
87  }
88  return s;
89  }
unsigned int index
Definition: numcxx.hxx:21
template<typename T >
std::shared_ptr< TArray1< T > > numcxx::linspace ( x0,
x1,
int  n 
)
inline

Create array of $n$ equally spaced entries.

Examples:
45-convdiff1d.cxx.

Definition at line 9 of file util.ixx.

10  {
11  auto pX=std::make_shared<TArray1<T>>(n);
12  auto &X=*pX;
13  T h=1.0/(T)(n-1);
14  T x=0.0;
15  for (int i=0;i<n;i++,x+=h) X[i]=x;
16  return pX;
17  }
double numcxx::cpu_clock ( )
inline

cpu time in seconds

Examples:
42-convtest-fem-sin.cxx, and 43-convtest-fvm-sin.cxx.

Definition at line 101 of file util.ixx.

102  {
103  return (double)std::clock()/(double)CLOCKS_PER_SEC;
104  }
double numcxx::wall_clock ( )
inline

wall clock time in seconds

Definition at line 106 of file util.ixx.

107  {
108  time_t t;
109  t=time(&t);
110  return ((double)t);
111  }
template<typename T >
void numcxx::savetxt ( const std::string  fname,
const TArray< T > &  a 
)
inline

Definition at line 114 of file util.ixx.

115  {
116  std::filebuf fb;
117  fb.open (fname,std::ios::out);
118  std::ostream s(&fb);
119  a.savetxt(s);
120  fb.close();
121  }

+ Here is the call graph for this function:

template<typename T >
void numcxx::savetxt ( const std::ostream  s,
const TArray< T > &  a 
)
inline
double numcxx::norm1 ( const std::shared_ptr< DArray1 a)
inline

Definition at line 102 of file util.hxx.

102 {return norm1(*a);}
double norm1(const std::shared_ptr< DArray1 > a)
Definition: util.hxx:102

+ Here is the call graph for this function:

double numcxx::norm2 ( const std::shared_ptr< DArray1 a)
inline

Definition at line 103 of file util.hxx.

103 {return norm2(*a);}
double norm2(const std::shared_ptr< DArray1 > a)
Definition: util.hxx:103

+ Here is the call graph for this function:

double numcxx::normi ( const std::shared_ptr< DArray1 a)
inline

Definition at line 104 of file util.hxx.

104 {return normi(*a);}
double normi(const std::shared_ptr< DArray1 > a)
Definition: util.hxx:104

+ Here is the call graph for this function:

template<typename T >
void numcxx::savetxt ( std::ostream &  s,
const TArray< T > &  a 
)
inline

Definition at line 124 of file util.ixx.

125  {
126  a.savetxt(s);
127  }

+ Here is the call graph for this function:

void numcxx::print_triangulateio ( triangle::triangulateio in)
inline

Definition at line 21 of file simplegrid.cxx.

22  {
23  std::printf("pointlist=%p\n",in->pointlist);
24  std::printf("pointattributelist=%p\n",in->pointattributelist);
25  std::printf("pointmarkerlist=%p\n",in->pointmarkerlist);
26  std::printf("numberofpoints=%d\n",in->numberofpoints);
27  std::printf("numberofpointattributes=%d\n",in->numberofpointattributes);
28  std::printf("trianglelist=%p\n",in->trianglelist);
29  std::printf("triangleattributelist=%p\n",in->triangleattributelist);
30  std::printf("trianglearealist=%p\n",in->trianglearealist);
31  std::printf("neighborlist=%p\n",in->neighborlist);
32  std::printf("numberoftriangles=%d\n",in->numberoftriangles);
33  std::printf("numberofcorners=%d\n",in->numberofcorners);
34  std::printf("numberoftriangleattributes=%d\n",in->numberoftriangleattributes);
35  std::printf("segmentlist=%p\n",in->segmentlist);
36  std::printf("segmentmarkerlist=%p\n",in->segmentmarkerlist);
37  std::printf("numberofsegments=%d\n",in->numberofsegments);
38  std::printf("holelist=%p\n",in->holelist);
39  std::printf("numberofholes=%d\n",in->numberofholes);
40  std::printf("regionlist=%p\n",in->regionlist);
41  std::printf("numberofregions=%d\n",in->numberofregions);
42  std::printf("edgelist=%p\n",in->edgelist);
43  std::printf("edgemarkerlist=%p\n",in->edgemarkerlist);
44  std::printf("normlist=%p\n",in->normlist);
45  std::printf("numberofedges=%d\n",in->numberofedges);
46  }
double numcxx::dist ( const numcxx::DArray2 points,
int  p1,
int  p2 
)
inline

Definition at line 48 of file simplegrid.cxx.

49  {
50  double dx=points(p2,0)-points(p1,0);
51  double dy=points(p2,1)-points(p1,1);
52  return sqrt(dx*dx+dy*dy);
53  }