LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
ArrayBaseN.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 #ifndef NDARRAY_ArrayBaseN_h_INCLUDED
24 #define NDARRAY_ArrayBaseN_h_INCLUDED
25 
32 #include "ndarray/ArrayBase.h"
33 
34 namespace ndarray {
35 
39 template <typename Derived, int N = ArrayBase<Derived>::ND::value>
40 class ArrayBaseN : public ArrayBase< Derived > {
42 protected:
43  typedef typename Super::Core Core;
44  typedef typename Super::CorePtr CorePtr;
45 public:
46  typedef typename Super::Element Element;
47 private:
48  template <typename T_, int N_, int C_> friend class Array;
49  template <typename T_, int N_, int C_> friend class ArrayRef;
50  void operator=(ArrayBaseN const & other) {
51  Super::operator=(other);
52  }
54  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
55 };
56 
57 
61 template <typename Derived>
62 class ArrayBaseN<Derived,1> : public ArrayBase< Derived > {
64 protected:
65  typedef typename Super::Core Core;
66  typedef typename Super::CorePtr CorePtr;
67 public:
68  typedef typename Super::Element Element;
69 
70  Element & operator()(int n0) const {
71  return this->operator[](makeVector(n0));
72  }
73 
74 private:
75  template <typename T_, int N_, int C_> friend class Array;
76  template <typename T_, int N_, int C_> friend class ArrayRef;
77  void operator=(ArrayBaseN const & other) {
78  Super::operator=(other);
79  }
81  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
82 };
83 
87 template <typename Derived>
88 class ArrayBaseN<Derived,2> : public ArrayBase< Derived > {
90 protected:
91  typedef typename Super::Core Core;
92  typedef typename Super::CorePtr CorePtr;
93 public:
94  typedef typename Super::Element Element;
95 
96  Element & operator()(int n0, int n1) const {
97  return this->operator[](makeVector(n0, n1));
98  }
99 
100 private:
101  template <typename T_, int N_, int C_> friend class Array;
102  template <typename T_, int N_, int C_> friend class ArrayRef;
103  void operator=(ArrayBaseN const & other) {
104  Super::operator=(other);
105  }
107  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
108 };
109 
113 template <typename Derived>
114 class ArrayBaseN<Derived,3> : public ArrayBase< Derived > {
116 protected:
117  typedef typename Super::Core Core;
118  typedef typename Super::CorePtr CorePtr;
119 public:
120  typedef typename Super::Element Element;
121 
122  Element & operator()(int n0, int n1, int n2) const {
123  return this->operator[](makeVector(n0, n1, n2));
124  }
125 
126 private:
127  template <typename T_, int N_, int C_> friend class Array;
128  template <typename T_, int N_, int C_> friend class ArrayRef;
129  void operator=(ArrayBaseN const & other) {
130  Super::operator=(other);
131  }
133  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
134 };
135 
139 template <typename Derived>
140 class ArrayBaseN<Derived,4> : public ArrayBase< Derived > {
142 protected:
143  typedef typename Super::Core Core;
144  typedef typename Super::CorePtr CorePtr;
145 public:
146  typedef typename Super::Element Element;
147 
148  Element & operator()(int n0, int n1, int n2, int n3) const {
149  return this->operator[](makeVector(n0, n1, n2, n3));
150  }
151 
152 private:
153  template <typename T_, int N_, int C_> friend class Array;
154  template <typename T_, int N_, int C_> friend class ArrayRef;
155  void operator=(ArrayBaseN const & other) {
156  Super::operator=(other);
157  }
159  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
160 };
161 
165 template <typename Derived>
166 class ArrayBaseN<Derived,5> : public ArrayBase< Derived > {
168 protected:
169  typedef typename Super::Core Core;
170  typedef typename Super::CorePtr CorePtr;
171 public:
172  typedef typename Super::Element Element;
173 
174  Element & operator()(int n0, int n1, int n2, int n3, int n4) const {
175  return this->operator[](makeVector(n0, n1, n2, n3, n4));
176  }
177 
178 private:
179  template <typename T_, int N_, int C_> friend class Array;
180  template <typename T_, int N_, int C_> friend class ArrayRef;
181  void operator=(ArrayBaseN const & other) {
182  Super::operator=(other);
183  }
185  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
186 };
187 
191 template <typename Derived>
192 class ArrayBaseN<Derived,6> : public ArrayBase< Derived > {
194 protected:
195  typedef typename Super::Core Core;
196  typedef typename Super::CorePtr CorePtr;
197 public:
198  typedef typename Super::Element Element;
199 
200  Element & operator()(int n0, int n1, int n2, int n3, int n4, int n5) const {
201  return this->operator[](makeVector(n0, n1, n2, n3, n4, n5));
202  }
203 
204 private:
205  template <typename T_, int N_, int C_> friend class Array;
206  template <typename T_, int N_, int C_> friend class ArrayRef;
207  void operator=(ArrayBaseN const & other) {
208  Super::operator=(other);
209  }
211  ArrayBaseN(Element * data, CorePtr const & core) : Super(data, core) {}
212 };
213 
214 } // namespace ndarray
215 
216 #endif // !NDARRAY_ArrayBaseN_h_INCLUDED
A proxy class for Array with deep assignment operators.
Definition: ArrayRef.h:46
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:63
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:185
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:141
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:133
void operator=(ArrayBase const &other)
Definition: ArrayBase.h:230
Super::Element Element
Definition: ArrayBaseN.h:46
Traits::Core Core
Definition: ArrayBase.h:59
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:81
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:181
Element & operator()(int n0, int n1, int n2, int n3, int n4) const
Definition: ArrayBaseN.h:174
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:77
ExpressionTraits< Derived >::Element Element
Data type of expression elements.
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:107
Element & operator()(int n0, int n1) const
Definition: ArrayBaseN.h:96
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:41
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:159
Super::CorePtr CorePtr
Definition: ArrayBaseN.h:44
An intermediate CRTP base class for Array and ArrayRef.
Definition: ArrayBaseN.h:40
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
CRTP implementation for Array and ArrayRef.
Definition: ArrayBase.h:56
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:50
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:211
A multidimensional strided array.
Definition: Array.h:47
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:167
Traits::Element Element
Data type of array elements.
Definition: ArrayBase.h:63
Element & operator()(int n0, int n1, int n2, int n3, int n4, int n5) const
Definition: ArrayBaseN.h:200
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:155
Element & operator()(int n0) const
Definition: ArrayBaseN.h:70
Element & operator()(int n0, int n1, int n2) const
Definition: ArrayBaseN.h:122
Definitions for ArrayBase.
ArrayBaseN(Element *data, CorePtr const &core)
Definition: ArrayBaseN.h:54
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:89
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:103
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:207
void operator=(ArrayBaseN const &other)
Definition: ArrayBaseN.h:129
Element & operator()(int n0, int n1, int n2, int n3) const
Definition: ArrayBaseN.h:148
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:115
Reference operator[](int n) const
Return a single subarray.
Definition: ArrayBase.h:86
ArrayBase< Derived > Super
Definition: ArrayBaseN.h:193
Super::Core Core
Definition: ArrayBaseN.h:43