proteus  1.8.1
C/C++/Fortran libraries
ArrayRef.h
Go to the documentation of this file.
1 #ifndef ARRAYREF_H
2 #define ARRAYREF_H
3 
4 template <class T>
5 class ArrayRef1D
6 {
7  T *values;
8 
9 public:
10  inline ArrayRef1D(T* vals) : values(vals) {};
11  inline T &operator[](int i) { return values[i]; };
12 };
13 
14 template <class T>
16 {
17  T *values;
18  int dimension1;
19  int dimension2;
20 
21 public:
22  inline ArrayRef2D(T* vals, int dim1, int dim2) : values(vals), dimension2(dim2) {};
23  inline ArrayRef2D(T* vals, int dim2) : values(vals), dimension2(dim2) {};
24  inline T* operator[] (int i) { return values + i * dimension2; }
25 };
26 
27 template <class T>
29 {
30  T *values;
31  int dimension1;
32  int dimension2;
33  int dimension3;
34  int mult;
35 
36 public:
37  ArrayRef3D(T* vals, int dim1, int dim2, int dim3) : values(vals), dimension2(dim2), dimension3(dim3), mult(dim2 * dim3) {};
38  inline ArrayRef2D<T> operator[] (int i) { return ArrayRef2D<T>(values + i * mult, dimension3); } ;
39 };
40 
41 template <class T>
43 {
44  T *values;
45  int dimension1;
46  int dimension2;
47  int dimension3;
48  int dimension4;
49  int mult1;
50 
51 public:
52  ArrayRef4D(T* vals, int dim1, int dim2, int dim3, int dim4) :
53  values(vals), dimension2(dim2), dimension3(dim3), dimension4(dim4),mult1(dim2 * dim3 * dim4) {};
54  inline ArrayRef3D<T> operator[] (int i) { return ArrayRef3D<T>(values + i * mult1 , dimension2, dimension3, dimension4); } ;
55 };
56 
57 template <class T>
59 {
60  T *values;
61  int dimension1;
62  int dimension2;
63  int dimension3;
64  int dimension4;
65  int dimension5;
66  int mult1;
67 
68 public:
69  ArrayRef5D(T* vals, int dim1, int dim2, int dim3, int dim4, int dim5) :
70  values(vals), dimension2(dim2), dimension3(dim3), dimension4(dim4), dimension5(dim5),mult1(dim2 * dim3 * dim4* dim5) {};
71  inline ArrayRef4D<T> operator[] (int i) { return ArrayRef4D<T>(values + i * mult1 , dimension2, dimension3, dimension4, dimension5); } ;
72 };
73 
74 template <class T>
76 {
77  T *values;
78  int dimension1;
79  int dimension2;
80  int dimension3;
81  int dimension4;
82  int dimension5;
83  int dimension6;
84  int mult1;
85 
86 public:
87  ArrayRef6D(T* vals, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6) :
88  values(vals), dimension2(dim2), dimension3(dim3), dimension4(dim4), dimension5(dim5), dimension6(dim6), mult1(dim2 * dim3 * dim4 * dim5 * dim6) {};
89  inline ArrayRef5D<T> operator[] (int i) { return ArrayRef5D<T>(values + i * mult1 , dimension2, dimension3, dimension4, dimension5, dimension6); } ;
90 };
91 
92 #endif
ArrayRef1D::operator[]
T & operator[](int i)
Definition: ArrayRef.h:11
ArrayRef2D::operator[]
T * operator[](int i)
Definition: ArrayRef.h:24
ArrayRef3D::ArrayRef3D
ArrayRef3D(T *vals, int dim1, int dim2, int dim3)
Definition: ArrayRef.h:37
ArrayRef6D::ArrayRef6D
ArrayRef6D(T *vals, int dim1, int dim2, int dim3, int dim4, int dim5, int dim6)
Definition: ArrayRef.h:87
ArrayRef2D
Definition: ArrayRef.h:16
ArrayRef1D
Definition: ArrayRef.h:6
ArrayRef3D
Definition: ArrayRef.h:29
ArrayRef6D
Definition: ArrayRef.h:76
ArrayRef5D
Definition: ArrayRef.h:59
ArrayRef3D::operator[]
ArrayRef2D< T > operator[](int i)
Definition: ArrayRef.h:38
ArrayRef4D
Definition: ArrayRef.h:43
ArrayRef1D::ArrayRef1D
ArrayRef1D(T *vals)
Definition: ArrayRef.h:10
ArrayRef2D::ArrayRef2D
ArrayRef2D(T *vals, int dim1, int dim2)
Definition: ArrayRef.h:22
T
Double T
Definition: Headers.h:87
ArrayRef6D::operator[]
ArrayRef5D< T > operator[](int i)
Definition: ArrayRef.h:89
ArrayRef5D::operator[]
ArrayRef4D< T > operator[](int i)
Definition: ArrayRef.h:71
ArrayRef2D::ArrayRef2D
ArrayRef2D(T *vals, int dim2)
Definition: ArrayRef.h:23
ArrayRef4D::operator[]
ArrayRef3D< T > operator[](int i)
Definition: ArrayRef.h:54
ArrayRef4D::ArrayRef4D
ArrayRef4D(T *vals, int dim1, int dim2, int dim3, int dim4)
Definition: ArrayRef.h:52
ArrayRef5D::ArrayRef5D
ArrayRef5D(T *vals, int dim1, int dim2, int dim3, int dim4, int dim5)
Definition: ArrayRef.h:69