00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CASA_CUBE_H
00029 #define CASA_CUBE_H
00030
00031
00032
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/casa/Arrays/Array.h>
00035
00036 namespace casacore {
00037
00038
00039 template<class T> class Matrix;
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 template<class T> class Cube : public Array<T>
00081 {
00082 public:
00083
00084
00085 Cube();
00086
00087
00088 Cube(size_t l1, size_t l2, size_t l3);
00089
00090
00091 Cube(size_t l1, size_t l2, size_t l3, ArrayInitPolicy initPolicy);
00092
00093
00094
00095 Cube(size_t l1, size_t l2, size_t l3, const T &initialValue);
00096
00097
00098 Cube(const IPosition &len);
00099
00100
00101 Cube(const IPosition &len, ArrayInitPolicy initPolicy);
00102
00103
00104
00105 Cube(const IPosition &len, const T &initialValue);
00106
00107
00108 Cube(const Cube<T> &);
00109
00110
00111
00112
00113 Cube(const Array<T> &);
00114
00115
00116 Cube(const IPosition &shape, T *storage, StorageInitPolicy policy = COPY);
00117
00118 Cube(const IPosition &shape, T *storage, StorageInitPolicy policy, AbstractAllocator<T> const &allocator);
00119
00120
00121 Cube(const IPosition &shape, const T *storage);
00122
00123
00124 virtual ~Cube();
00125
00126
00127
00128 virtual void assign (const Array<T>& other);
00129
00130
00131
00132 virtual void reference(const Array<T> &other);
00133
00134
00135
00136
00137 using Array<T>::resize;
00138 void resize(size_t nx, size_t ny, size_t nz, Bool copyValues=False) {
00139 Cube<T>::resize(nx, ny, nz, copyValues, Array<T>::defaultArrayInitPolicy());
00140 }
00141 void resize(size_t nx, size_t ny, size_t nz, Bool copyValues, ArrayInitPolicy policy);
00142 virtual void resize();
00143 virtual void resize(const IPosition &newShape, Bool copyValues, ArrayInitPolicy policy);
00144
00145
00146
00147
00148
00149
00150
00151
00152 Cube<T> &operator=(const Cube<T> &other);
00153 virtual Array<T> &operator=(const Array<T> &other);
00154
00155
00156
00157
00158 Array<T> &operator=(const T &val)
00159 { return Array<T>::operator=(val); }
00160
00161
00162
00163 Cube<T> &operator= (const MaskedArray<T> &marray)
00164 { Array<T> (*this) = marray; return *this; }
00165
00166
00167
00168
00169
00170 T &operator()(const IPosition &i)
00171 { return Array<T>::operator()(i); }
00172 const T &operator()(const IPosition &i) const
00173 { return Array<T>::operator()(i); }
00174
00175 T &operator()(size_t i1, size_t i2, size_t i3)
00176 {
00177 #if defined(AIPS_ARRAY_INDEX_CHECK)
00178 this->validateIndex(i1, i2, i3);
00179 #endif
00180 return this->begin_p[i1*xinc_p + i2*yinc_p + i3*zinc_p];
00181 }
00182
00183 const T &operator()(size_t i1, size_t i2, size_t i3) const
00184 {
00185 #if defined(AIPS_ARRAY_INDEX_CHECK)
00186 this->validateIndex(i1, i2, i3);
00187 #endif
00188 return this->begin_p[i1*xinc_p + i2*yinc_p + i3*zinc_p];
00189 }
00190
00191
00192
00193 T &at(size_t i1, size_t i2, size_t i3)
00194 {
00195 #if defined(AIPS_ARRAY_INDEX_CHECK)
00196 this->validateIndex(i1, i2, i3);
00197 #endif
00198 return this->contiguous_p ? this->begin_p[i1 + i2*yinc_p + i3*zinc_p] :
00199 this->begin_p[i1*xinc_p + i2*yinc_p + i3*zinc_p];
00200 }
00201
00202 const T &at(size_t i1, size_t i2, size_t i3) const
00203 {
00204 #if defined(AIPS_ARRAY_INDEX_CHECK)
00205 this->validateIndex(i1, i2, i3);
00206 #endif
00207 return this->contiguous_p ? this->begin_p[i1 + i2*yinc_p + i3*zinc_p] :
00208 this->begin_p[i1*xinc_p + i2*yinc_p + i3*zinc_p];
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 Cube<T> operator()(const Slice &sliceX, const Slice &sliceY,
00222 const Slice &sliceZ);
00223 const Cube<T> operator()(const Slice &sliceX, const Slice &sliceY,
00224 const Slice &sliceZ) const;
00225
00226
00227
00228
00229
00230 Array<T> operator()(const IPosition &blc, const IPosition &trc,
00231 const IPosition &incr)
00232 { return Array<T>::operator()(blc,trc,incr); }
00233 const Array<T> operator()(const IPosition &blc, const IPosition &trc,
00234 const IPosition &incr) const
00235 { return Array<T>::operator()(blc,trc,incr); }
00236 Array<T> operator()(const IPosition &blc, const IPosition &trc)
00237 { return Array<T>::operator()(blc,trc); }
00238 const Array<T> operator()(const IPosition &blc, const IPosition &trc) const
00239 { return Array<T>::operator()(blc,trc); }
00240 Array<T> operator()(const Slicer& slicer)
00241 { return Array<T>::operator()(slicer); }
00242 const Array<T> operator()(const Slicer& slicer) const
00243 { return Array<T>::operator()(slicer); }
00244
00245
00246
00247
00248
00249
00250
00251
00252 const MaskedArray<T> operator() (const LogicalArray &mask) const
00253 { return Array<T>::operator() (mask); }
00254
00255
00256 MaskedArray<T> operator() (const LogicalArray &mask)
00257 { return Array<T>::operator() (mask); }
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 const MaskedArray<T> operator() (const MaskedLogicalArray &mask) const
00270 { return Array<T>::operator() (mask); }
00271
00272
00273 MaskedArray<T> operator() (const MaskedLogicalArray &mask)
00274 { return Array<T>::operator() (mask); }
00275
00276
00277
00278
00279
00280
00281
00282
00283 Matrix<T> xyPlane(size_t zplane);
00284 const Matrix<T> xyPlane(size_t zplane) const;
00285 Matrix<T> xzPlane(size_t yplane);
00286 const Matrix<T> xzPlane(size_t yplane) const;
00287 Matrix<T> yzPlane(size_t xplane);
00288 const Matrix<T> yzPlane(size_t xplane) const;
00289
00290
00291
00292 const IPosition &shape() const
00293 { return this->length_p; }
00294 void shape(Int &s1, Int &s2, Int &s3) const
00295 { s1 = this->length_p(0); s2=this->length_p(1); s3=this->length_p(2); }
00296
00297
00298 size_t nrow() const
00299 { return this->length_p(0); }
00300
00301
00302 size_t ncolumn() const
00303 { return this->length_p(1); }
00304
00305
00306 size_t nplane() const
00307 { return this->length_p(2); }
00308
00309
00310 virtual Bool ok() const;
00311
00312 protected:
00313 virtual void preTakeStorage(const IPosition &shape);
00314 virtual void postTakeStorage();
00315
00316
00317
00318 virtual void doNonDegenerate(const Array<T> &other,
00319 const IPosition &ignoreAxes);
00320
00321 private:
00322
00323 size_t xinc_p, yinc_p, zinc_p;
00324
00325 void makeIndexingConstants();
00326 };
00327
00328 }
00329 #ifndef CASACORE_NO_AUTO_TEMPLATES
00330 #include <casacore/casa/Arrays/Cube.tcc>
00331 #endif //# CASACORE_NO_AUTO_TEMPLATES
00332 #endif