AFF --- A container for numbers (array) by Friederich and Forbriger.
functionstest.cc
Go to the documentation of this file.
1 
35 #define FUNCTIONSTEST_VERSION \
36  "FUNCTIONSTEST V1.1 test function templates"
37 
38 #include <iostream>
39 #include <aff/dump.h>
40 #include <aff/array.h>
41 #include <aff/shaper.h>
42 #include <aff/subarray.h>
43 #include <aff/functions/avg.h>
44 #include <aff/functions/min.h>
45 #include <aff/functions/max.h>
46 #include <aff/functions/absmax.h>
47 #include <aff/functions/rms.h>
48 #include <aff/functions/sum.h>
49 #include <aff/functions/sqrsum.h>
50 #include <aff/functions/histo.h>
51 #include <aff/functions/valmap.h>
52 
53 using namespace aff;
54 
55 using std::cout;
56 using std::cerr;
57 using std::endl;
58 
59 typedef std::map<double, int> Tvalmap;
60 
61 int main(int iargc, char* argv[])
62 {
63  CODE( typedef aff::Array<double> Tarray );
64  CODE( Tarray A(3,4) );
65  CODE( A=5 );
66  CODE( Tarray::Tcoc AC=A );
67  CODE( subarray(A)(1,1)(2,4)=2. );
68  CODE( subarray(A)(2,3)(1,2)=1. );
69  CODE( subarray(A)(2,3)(3,4)=-7. );
70  CODE( dump_array(A) );
71  CODE( cout << aff::func::avg(A) << endl );
72  CODE( cout << aff::func::rms(A) << endl );
73  CODE( cout << aff::func::max(A) << endl );
74  CODE( cout << aff::func::min(A) << endl );
75  CODE( cout << aff::func::absmax(A) << endl );
76  CODE( cout << aff::func::min(AC) << endl );
77  CODE( cout << aff::func::sum(A) << endl );
78  CODE( cout << aff::func::sqrsum(A) << endl );
80  CODE( Tmap mymap=aff::func::histo(A) );
81  CODE( typedef Tmap::const_iterator Tmapit );
82  CODE( for (Tmapit i=mymap.begin(); i!=mymap.end(); ++i) \
83  { cout << i->first << "\t" << i->second << endl; } );
84  CODE( Tvalmap avalmap );
85  CODE( avalmap[-4.]=1 );
86  CODE( avalmap[1.]=2 );
87  CODE( avalmap[2.]=3 );
88  CODE( avalmap[5.]=4 );
90  aff::func::valmap<aff::Array>(A, avalmap) );
91  CODE( dump_array(B) );
92 }
93 
94 /* ----- END OF functionstest.cc ----- */
evaluate sum of all samples (prototypes)
evaluate square of sum of all samples (prototypes)
Root namespace of library.
Definition: array.h:148
C::Tvalue avg(const C &c)
Definition: avg.h:90
C::Tvalue sum(const C &c)
Definition: sum.h:89
C::Tvalue min(const C &c)
Definition: min.h:90
int main(int iargc, char *argv[])
aff::util::Subarray< C > subarray(const C &c)
Wrapper function to select correct type.
Definition: subarray.h:163
C::Tvalue rms(const C &c)
Definition: rms.h:91
external class to create subarrays (prototypes)
return minimum element value (prototypes)
full template array class headers (prototypes)
aff::func::util::Extracthisto< C >::Tmap histo(const C &c)
Definition: histo.h:91
#define CODE(C)
Dump code and execute (works like echo)
Definition: dump_macros.h:82
void dump_array(const ConstArray< T > &array, const Tdim &i=(Strided::Mmax_dimen-1), std::ostream &os=std::cout)
Dump array values.
Definition: dump_array.h:157
extract absolute maximum (prototypes)
map element values (prototypes)
return rms of element values (prototypes)
return maximum element value (prototypes)
C::Tvalue sqrsum(const C &c)
Definition: sqrsum.h:90
debug helpers (prototypes)
return average of element values (prototypes)
C::Tvalue absmax(const C &c)
Definition: absmax.h:98
Full multi-dimensional array functionality.This is the full array class template. It adds no addition...
Definition: array.h:151
std::map< Tvalue, int > Tmap
Definition: histo.h:63
C::Tvalue max(const C &c)
Definition: max.h:89
count elements of same value (prototypes)
std::map< double, int > Tvalmap
rectangular Fortran array layout (prototypes)