NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
util.hxx
Go to the documentation of this file.
1 #ifndef NUMCXX_UTIL_HXX
2 #define NUMCXX_UTIL_HXX
3 
5 namespace numcxx
6 {
7 
33  template <typename A> inline TArray1<typename A::value_type> arrayexpr(const A& a);
34 
35 
39  template <typename A> inline typename A::value_type normi(const A& a);
40 
44  template <typename A> inline typename A::value_type norm1(const A& a);
45 
49  template <typename A> inline typename A::value_type norm2(const A& a);
50 
54  template <typename A> inline typename A::value_type norm(const A& a) { return norm2(a);}
55 
56 
62  template <typename A, typename B> inline typename A::value_type dot(const A& a, const B&b);
63 
64 
65 
69  template <typename A> inline typename A::value_type min(const A&a);
70 
74  template <typename A> inline typename A::value_type max(const A&a);
75 
79  template <typename A> inline typename A::value_type sum(const A&a);
80 
81 
83  template <typename T>
84  inline std::shared_ptr<TArray1<T>> linspace(T x0, T x1, int n);
85 
86 
88  inline double cpu_clock();
89 
91  inline double wall_clock();
92 
93 
94  template <typename T>
95  inline void savetxt(const std::string fname, const TArray<T> &a);
96  template <typename T>
97  inline void savetxt(const std::ostream s, const TArray<T> &a);
98 
99 
100  using DArray1=TArray1<double>;
101  using DArray2=TArray2<double>;
102  inline double norm1(const std::shared_ptr<DArray1> a) {return norm1(*a);}
103  inline double norm2(const std::shared_ptr<DArray1> a) {return norm2(*a);}
104  inline double normi(const std::shared_ptr<DArray1> a){return normi(*a);}
105 
106 
107 }
108 
109 #include "util.ixx"
110 #endif
A::value_type max(const A &a)
Maximum of array or expression.
Definition: util.ixx:70
A::value_type normi(const A &a)
Maximum norm of array or expression.
Definition: util.ixx:26
void savetxt(const std::string fname, const TArray< T > &a)
Definition: util.ixx:114
TArray1< typename A::value_type > arrayexpr(const A &a)
Evaluate expression as array.
Definition: util.ixx:19
A::value_type norm2(const A &a)
Euklidean norm of array or expression.
Definition: util.ixx:47
TArray is the common template base class for arrays and dense matrices of the numcxx project...
Definition: tarray.hxx:17
A::value_type min(const A &a)
Minimum of of array or expression.
Definition: util.ixx:59
std::shared_ptr< TArray1< T > > linspace(T x0, T x1, int n)
Create array of $n$ equally spaced entries.
Definition: util.ixx:9
double wall_clock()
wall clock time in seconds
Definition: util.ixx:106
One dimensional array class.
Definition: tarray1.hxx:31
A::value_type sum(const A &a)
Sum of array or expression.
Definition: util.ixx:81
double cpu_clock()
cpu time in seconds
Definition: util.ixx:101
double B(double x)
Numcxx template library.
Definition: expression.ixx:41
A::value_type dot(const A &a, const B &b)
Dot product of array or expression.
Definition: util.ixx:91
Two-dimensional array class.
Definition: tarray2.hxx:31
A::value_type norm(const A &a)
Euklidean norm of array or expression.
Definition: util.hxx:54
A::value_type norm1(const A &a)
Sum norm of array or expression.
Definition: util.ixx:37