AFF --- A container for numbers (array) by Friederich and Forbriger.
simplearray.h
Go to the documentation of this file.
1 
42 // include guard
43 #ifndef AFF_SIMPLEARRAY_H_VERSION
44 
45 #define AFF_SIMPLEARRAY_H_VERSION \
46  "AFF_SIMPLEARRAY_H V1.4"
47 
48 #include<aff/lib/types.h>
49 #include<aff/lib/rawarfun.h>
50 
51 namespace aff {
52 
53 using namespace aff::util;
54 
93  template<class T, Tsize N>
95  public:
97  typedef T Telement;
101  typedef T Tvalue;
102 
103  /*-----------------------------------------------------------------*/
104 
111  SimpleRigidArray() { }
114  template<class TT>
116  {
118  }
120  explicit SimpleRigidArray(const T& value)
121  {
122  aff::util::Inline<T, N>::set(Marray, value);
123  }
125 
126  /*-----------------------------------------------------------------*/
127 
134  template<class TT>
136  SimpleRigidArray& operator=(const TT& value)
137  {
138  aff::util::Inline2<T, TT, N>::set(Marray, value);
139  return(*this);
140  }
142  template<class TT>
144  {
146  return(*this);
147  }
149 
150  /*-----------------------------------------------------------------*/
151 
155  T& operator[](const Tsubscript& i) { return Marray[i]; }
158  const T& operator[](const Tsubscript& i) const { return Marray[i]; }
160  T* pointer() { return Marray; }
162  const T* pointer() const { return Marray; }
164  Tsize size() const { return N; }
166 
167  /*-----------------------------------------------------------------*/
168 
169  private:
170  T Marray[N];
171  }; // Simple Array
172 
173  /*======================================================================*/
174  // inlined operations
175 
177  template<typename T, Tsize N>
178  inline T inline_product(const SimpleRigidArray<T, N>& array)
179  { return Inline<T, N>::product(array.pointer()); }
180 
182  template<typename T, Tsize N>
183  inline T inline_sum(const SimpleRigidArray<T, N>& array)
184  { return Inline<T, N>::sum(array.pointer()); }
185 
187  template<typename T, Tsize N>
189  const SimpleRigidArray<T, N>& B)
190  { return Inline<T, N>::anysmaller(A.pointer(), B.pointer()); }
191 
193  template<typename T, Tsize N>
195  const SimpleRigidArray<T, N>& B)
196  { return Inline<T, N>::anylarger(A.pointer(), B.pointer()); }
197 
199  template<typename T1, typename T2, Tsize N>
201  const SimpleRigidArray<T2, N>& B)
202  { return Inline2<T1, T2, N>::anylarger(A.pointer(), B.pointer()); }
203 
205  template<typename T, Tsize N>
207  const SimpleRigidArray<T, N>& B)
208  { return Inline<T, N>::innerproduct(A.pointer(), B.pointer()); }
209 
211  template<typename T1, typename T2, Tsize N>
213  const SimpleRigidArray<T2, N>& B)
214  { return Inline2<T1, T2, N>::innerproduct(A.pointer(), B.pointer()); }
215 
217  template<typename T, Tsize N>
219  const SimpleRigidArray<T, N>& B)
220  { return Inline<T, N>::strideproduct(A.pointer(), B.pointer()); }
221 
222 } // namespace aff
223 
224 #endif // AFF_SIMPLEARRAY_H_VERSION (includeguard)
225 
226 /* ----- END OF simplearray.h ----- */
Root namespace of library.
Definition: array.h:148
some typedefs we refer to
T inline_product(const SimpleRigidArray< T, N > &array)
Product of all elements.
Definition: simplearray.h:178
T Telement
element type
Definition: simplearray.h:97
T * pointer()
pointer access
Definition: simplearray.h:160
static T product(const T *array)
calculate product of all elements
Definition: rawarfun.h:73
Internal utilities.
Definition: fortranshape.cc:41
bool inline_anysmaller(const SimpleRigidArray< T, N > &A, const SimpleRigidArray< T, N > &B)
Returns true if any of A is smaller than corresponding B.
Definition: simplearray.h:188
bool inline_anylarger(const SimpleRigidArray< T, N > &A, const SimpleRigidArray< T, N > &B)
Returns true if any of A is larger than corresponding B.
Definition: simplearray.h:194
static T innerproduct(const T *A, const T *B)
calculate inner product
Definition: rawarfun.h:109
T inline_strideproduct(const SimpleRigidArray< T, N > &A, const SimpleRigidArray< T, N > &B)
Returns strided product.
Definition: simplearray.h:218
A very basic rigid array class (with deep inline copy).
Definition: simplearray.h:94
const T & operator[](const Tsubscript &i) const
const access
Definition: simplearray.h:158
static void set(T1 *array, const T2 &value)
set all elements to value
Definition: rawarfun.h:169
T inline_sum(const SimpleRigidArray< T, N > &array)
Sum of all elements.
Definition: simplearray.h:183
Tsize size() const
size of array
Definition: simplearray.h:164
SimpleRigidArray(const SimpleRigidArray< TT, N > &array)
copy with deep inline copy
Definition: simplearray.h:115
static bool anylarger(const T1 *A, const T2 *B)
true if ony of A is larger than corresponding B
Definition: rawarfun.h:180
SimpleRigidArray(const T &value)
set constructor
Definition: simplearray.h:120
static void copy(const T1 *source, T2 *target)
copy all values from source to target
Definition: rawarfun.h:163
const T * pointer() const
const pointer access
Definition: simplearray.h:162
static void set(T *array, const T &value)
set all elements to value
Definition: rawarfun.h:87
SimpleRigidArray & operator=(const SimpleRigidArray< TT, N > &array)
copy with deep inline copy
Definition: simplearray.h:143
static bool anylarger(const T *A, const T *B)
true if ony of A is larger than corresponding B
Definition: rawarfun.h:98
static bool anysmaller(const T *A, const T *B)
true if ony of A is smaller than corresponding B
Definition: rawarfun.h:92
T inline_innerproduct(const SimpleRigidArray< T, N > &A, const SimpleRigidArray< T, N > &B)
Returns inner product.
Definition: simplearray.h:206
ptrdiff_t Tsubscript
Type to hold an array&#39;s subscript value.
Definition: types.h:53
static T strideproduct(const T *A, const T *B)
calculate stride product
Definition: rawarfun.h:128
SimpleRigidArray & operator=(const TT &value)
copy a value to all positions
Definition: simplearray.h:136
static T1 innerproduct(const T1 *A, const T2 *B)
calculate inner product
Definition: rawarfun.h:191
raw array function templates
static T sum(const T *array)
calculate sum of all elements
Definition: rawarfun.h:82
size_t Tsize
Type to hold the size of an array dimension.
Definition: types.h:51