Changeset 677 for XIOS/trunk/src/array_new.hpp
 Timestamp:
 08/31/15 16:19:19 (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

XIOS/trunk/src/array_new.hpp
r501 r677 9 9 #include <cmath> 10 10 11 using namespace blitz 11 using namespace blitz; 12 12 BZ_DECLARE_FUNCTION(round) 13 13 14 namespace xios 14 15 { 15 16 template <typename T_numtype,int N_rank> 17 class CArray : public Array<T_numtype,N_rank>, public virtual CBaseType 18 { 19 public : 20 using Array<T_numtype,N_rank>::operator = ; 21 typedef typename Array<T_numtype,N_rank>::T_default_storage T_default_storage; 22 23 template<typename T_expr> explicit CArray(_bz_ArrayExpr<T_expr> expr) : Array<T_numtype,N_rank>(expr) {} 24 25 CArray(GeneralArrayStorage<N_rank> storage=T_default_storage()) : Array<T_numtype,N_rank>(storage) {} 26 27 explicit CArray(int length0,GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(length0,storage ) {} 28 29 CArray(int length0, int length1, GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(length0, length1, storage ) {} 30 31 CArray(int length0, int length1, int length2, GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(length0, length1, length2, storage ) {} 32 33 CArray(int length0, int length1, int length2, int length3, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 34 : Array<T_numtype,N_rank>(length0, length1, length2, length3, storage ) {} 35 36 CArray(int length0, int length1, int length2, int length3, int length4, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 37 : Array<T_numtype,N_rank>(length0,length1, length2, length3, length4, storage ) {} 38 39 CArray(int length0, int length1, int length2, int length3, int length4, int length5, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 40 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, storage ) {} 41 42 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 43 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, storage ) {} 44 45 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, int length7, 46 GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, storage ) {} 47 48 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, 49 int length7, int length8, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 50 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, storage ) {} 51 52 CArray(int length0, int length1, int length2, int length3, int length4, 53 int length5, int length6, int length7, int length8, int length9, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 54 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, length9, storage ) {} 55 56 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, 57 int length7, int length8, int length9, int length10, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 58 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, 59 length9, length10, storage ) {} 60 61 62 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 63 : Array<T_numtype,N_rank>(dataFirst, shape, storage ) {} 64 65 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, 66 GeneralArrayStorage<N_rank> storage=T_default_storage()) : Array<T_numtype,N_rank>(dataFirst, shape, stride, storage ) {} 67 68 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, preexistingMemoryPolicy deletionPolicy, 69 GeneralArrayStorage<N_rank> storage=T_default_storage()) : Array<T_numtype,N_rank>(dataFirst, shape, deletionPolicy, storage) {} 70 71 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, 72 preexistingMemoryPolicy deletionPolicy, GeneralArrayStorage<N_rank> storage=T_default_storage()) 73 : Array<T_numtype,N_rank>(dataFirst, shape, stride, deletionPolicy, storage) {} 74 75 CArray(const TinyVector<int, N_rank>& extent, GeneralArrayStorage<N_rank> storage=T_default_storage()) 76 : Array<T_numtype,N_rank>(extent, storage) {} 77 78 CArray(const TinyVector<int, N_rank>& lbounds, const TinyVector<int, N_rank>& extent, 79 const GeneralArrayStorage<N_rank>& storage ) : Array<T_numtype,N_rank>(lbounds, extent, storage ) {} 80 81 CArray(Range r0, GeneralArrayStorage<N_rank> storage=T_default_storage() ) : CArray(r0, storage ) {} 82 83 CArray(Range r0, Range r1, GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(r0, r1, storage ) {} 84 85 CArray(Range r0, Range r1, Range r2, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 86 : Array<T_numtype,N_rank>(r0, r1, r2, storage ) {} 87 88 CArray(Range r0, Range r1, Range r2, Range r3, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 89 : Array<T_numtype,N_rank>(r0, r1, r2, r3, storage ) {} 90 91 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 92 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, storage ) {} 93 94 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 95 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, storage ) {} 96 97 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, 98 GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, storage ) {} 99 100 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, 101 GeneralArrayStorage<N_rank> storage=T_default_storage() ) : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, storage ) {} 102 103 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 104 Range r6, Range r7, Range r8, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 105 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, storage ) {} 106 107 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 108 Range r6, Range r7, Range r8, Range r9, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 109 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, storage ) {} 110 111 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, 112 Range r8, Range r9, Range r10, GeneralArrayStorage<N_rank> storage=T_default_storage() ) 113 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, storage ) {} 114 115 CArray(const Array<T_numtype, N_rank>& array) : Array<T_numtype,N_rank>(array) {} 116 117 CArray(const TinyVector<int,N_rank1>& shape, int lastExtent, const GeneralArrayStorage<N_rank>& storage) 118 : Array<T_numtype,N_rank>(shape, lastExtent, storage) {} 119 120 CArray(Array<T_numtype, N_rank>& array, Range r0) : Array<T_numtype,N_rank>(array, r0) {} 121 122 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1) : Array<T_numtype,N_rank>(array, r0, r1) {} 123 124 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2) : Array<T_numtype,N_rank>( array, r0, r1, r2) {} 125 126 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3) {} 127 128 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, 129 Range r3, Range r4) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4) {} 130 131 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, 132 Range r3, Range r4, Range r5) : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5) {} 133 134 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, 135 Range r4, Range r5, Range r6) : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5, r6) {} 136 137 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, 138 Range r5, Range r6, Range r7) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7) {} 139 140 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 141 Range r6, Range r7, Range r8) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8) {} 142 143 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 144 Range r6, Range r7, Range r8, Range r9) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) {} 145 146 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, 147 Range r7, Range r8, Range r9, Range r10) : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) {} 148 149 CArray(Array<T_numtype, N_rank>& array, const RectDomain<N_rank>& subdomain) : Array<T_numtype,N_rank>(array, subdomain) {} 150 151 CArray(Array<T_numtype, N_rank>& array, const StridedDomain<N_rank>& subdomain) : Array<T_numtype,N_rank>(array, subdomain) {} 152 153 template<int N_rank2, typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, 154 typename R6, typename R7, typename R8, typename R9, typename R10> 155 CArray(Array<T_numtype,N_rank2>& array, R0 r0, R1 r1, R2 r2, R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9, R10 r10) 156 : Array<T_numtype,N_rank>(array, r0,r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) {} 157 158 virtual ~CArray() {} 159 virtual void fromString(const string& str) { istringstream iss(str) ; iss>>*this ; } 160 virtual string toString(void) const { ostringstream oss ; oss<<*this ; return oss.str() ; } 161 virtual void reset(void) { this>free(); } 162 virtual bool isEmpty(void) const { if (this>numElements()==0) return true; else return false; } 163 virtual size_t size(void) const { return (this>dimensions()+1)*sizeof(int)+sizeof(size_t) + this>numElements()*sizeof(T_numtype) ;} 164 165 virtual CBaseType* clone(void) const { return new CArray(*this); } 166 167 virtual bool toBuffer(CBufferOut& buffer) const 168 { 169 bool ret ; 170 ret=buffer.put(this>dimensions()) ; 171 ret&=buffer.put(this>shape().data(),this>dimensions()) ; 172 ret&=buffer.put(this>numElements()) ; 173 ret&=buffer.put(this>dataFirst(),this>numElements()) ; 174 return ret ; 175 } 176 177 178 virtual bool fromBuffer(CBufferIn& buffer) 179 { 180 181 bool ret ; 182 int numDim ; 183 TinyVector<int,N_rank> vect; 184 size_t ne; 185 186 ret=buffer.get(numDim) ; 187 ret&=buffer.get(vect.data(),N_rank) ; 188 this>resize(vect) ; 189 ret&=buffer.get(ne) ; 190 ret&=buffer.get(this>dataFirst(),ne) ; 191 return ret ; 192 } 193 194 } ; 195 16 template <typename T_numtype,int N_rank> 17 class CArray : public Array<T_numtype,N_rank>, public virtual CBaseType 18 { 19 private: 20 bool initialized; 21 22 public: 23 typedef typename Array<T_numtype,N_rank>::T_default_storage T_default_storage; 24 using Array<T_numtype,N_rank>::operator =; 25 26 template<typename T_expr> explicit CArray(_bz_ArrayExpr<T_expr> expr) 27 : Array<T_numtype,N_rank>(expr) 28 , initialized(true) 29 {} 30 31 CArray(GeneralArrayStorage<N_rank> storage = T_default_storage()) 32 : Array<T_numtype,N_rank>(storage) 33 , initialized(false) 34 {} 35 36 explicit CArray(int length0, GeneralArrayStorage<N_rank> storage = T_default_storage()) 37 : Array<T_numtype,N_rank>(length0, storage) 38 , initialized(true) 39 {} 40 41 CArray(int length0, int length1, GeneralArrayStorage<N_rank> storage = T_default_storage()) 42 : Array<T_numtype,N_rank>(length0, length1, storage) 43 , initialized(true) 44 {} 45 46 CArray(int length0, int length1, int length2, GeneralArrayStorage<N_rank> storage = T_default_storage()) 47 : Array<T_numtype,N_rank>(length0, length1, length2, storage) 48 , initialized(true) 49 {} 50 51 CArray(int length0, int length1, int length2, int length3, GeneralArrayStorage<N_rank> storage = T_default_storage()) 52 : Array<T_numtype,N_rank>(length0, length1, length2, length3, storage) 53 , initialized(true) 54 {} 55 56 CArray(int length0, int length1, int length2, int length3, int length4, GeneralArrayStorage<N_rank> storage = T_default_storage()) 57 : Array<T_numtype,N_rank>(length0,length1, length2, length3, length4, storage) 58 , initialized(true) 59 {} 60 61 CArray(int length0, int length1, int length2, int length3, int length4, int length5, GeneralArrayStorage<N_rank> storage = T_default_storage()) 62 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, storage) 63 , initialized(true) 64 {} 65 66 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, GeneralArrayStorage<N_rank> storage = T_default_storage()) 67 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, storage) 68 , initialized(true) 69 {} 70 71 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, int length7, 72 GeneralArrayStorage<N_rank> storage = T_default_storage()) 73 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, storage) 74 , initialized(true) 75 {} 76 77 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, 78 int length7, int length8, GeneralArrayStorage<N_rank> storage = T_default_storage()) 79 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, storage) 80 , initialized(true) 81 {} 82 83 CArray(int length0, int length1, int length2, int length3, int length4, 84 int length5, int length6, int length7, int length8, int length9, GeneralArrayStorage<N_rank> storage = T_default_storage()) 85 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, length9, storage) 86 , initialized(true) 87 {} 88 89 CArray(int length0, int length1, int length2, int length3, int length4, int length5, int length6, 90 int length7, int length8, int length9, int length10, GeneralArrayStorage<N_rank> storage = T_default_storage()) 91 : Array<T_numtype,N_rank>(length0, length1, length2, length3, length4, length5, length6, length7, length8, length9, length10, storage) 92 , initialized(true) 93 {} 94 95 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, GeneralArrayStorage<N_rank> storage = T_default_storage()) 96 : Array<T_numtype,N_rank>(dataFirst, shape, storage) 97 , initialized(true) 98 {} 99 100 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, 101 GeneralArrayStorage<N_rank> storage = T_default_storage()) 102 : Array<T_numtype,N_rank>(dataFirst, shape, stride, storage) 103 , initialized(true) 104 {} 105 106 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, preexistingMemoryPolicy deletionPolicy, 107 GeneralArrayStorage<N_rank> storage = T_default_storage()) 108 : Array<T_numtype,N_rank>(dataFirst, shape, deletionPolicy, storage) 109 , initialized(true) 110 {} 111 112 CArray(T_numtype* restrict dataFirst, TinyVector<int, N_rank> shape, TinyVector<diffType, N_rank> stride, 113 preexistingMemoryPolicy deletionPolicy, GeneralArrayStorage<N_rank> storage = T_default_storage()) 114 : Array<T_numtype,N_rank>(dataFirst, shape, stride, deletionPolicy, storage) 115 , initialized(true) 116 {} 117 118 CArray(const TinyVector<int, N_rank>& extent, GeneralArrayStorage<N_rank> storage = T_default_storage()) 119 : Array<T_numtype,N_rank>(extent, storage) 120 , initialized(true) 121 {} 122 123 CArray(const TinyVector<int, N_rank>& lbounds, const TinyVector<int, N_rank>& extent, 124 const GeneralArrayStorage<N_rank>& storage) 125 : Array<T_numtype,N_rank>(lbounds, extent, storage) 126 , initialized(true) 127 {} 128 129 CArray(Range r0, GeneralArrayStorage<N_rank> storage = T_default_storage()) 130 : Array<T_numtype,N_rank>(r0, storage) 131 , initialized(true) 132 {} 133 134 CArray(Range r0, Range r1, GeneralArrayStorage<N_rank> storage = T_default_storage()) 135 : Array<T_numtype,N_rank>(r0, r1, storage) 136 , initialized(true) 137 {} 138 139 CArray(Range r0, Range r1, Range r2, GeneralArrayStorage<N_rank> storage = T_default_storage()) 140 : Array<T_numtype,N_rank>(r0, r1, r2, storage) 141 , initialized(true) 142 {} 143 144 CArray(Range r0, Range r1, Range r2, Range r3, GeneralArrayStorage<N_rank> storage = T_default_storage()) 145 : Array<T_numtype,N_rank>(r0, r1, r2, r3, storage) 146 , initialized(true) 147 {} 148 149 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, GeneralArrayStorage<N_rank> storage = T_default_storage()) 150 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, storage) 151 , initialized(true) 152 {} 153 154 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, GeneralArrayStorage<N_rank> storage = T_default_storage()) 155 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, storage) 156 , initialized(true) 157 {} 158 159 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, 160 GeneralArrayStorage<N_rank> storage = T_default_storage()) 161 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, storage) 162 , initialized(true) 163 {} 164 165 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, 166 GeneralArrayStorage<N_rank> storage = T_default_storage()) 167 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, storage) 168 , initialized(true) 169 {} 170 171 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 172 Range r6, Range r7, Range r8, GeneralArrayStorage<N_rank> storage = T_default_storage()) 173 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, storage) 174 , initialized(true) 175 {} 176 177 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 178 Range r6, Range r7, Range r8, Range r9, GeneralArrayStorage<N_rank> storage = T_default_storage()) 179 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, storage) 180 , initialized(true) 181 {} 182 183 CArray(Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, Range r7, 184 Range r8, Range r9, Range r10, GeneralArrayStorage<N_rank> storage = T_default_storage()) 185 : Array<T_numtype,N_rank>(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, storage) 186 , initialized(true) 187 {} 188 189 CArray(const CArray<T_numtype, N_rank>& array) 190 : Array<T_numtype,N_rank>(array) 191 , initialized(array.initialized) 192 {} 193 194 CArray(const Array<T_numtype, N_rank>& array) 195 : Array<T_numtype,N_rank>(array) 196 , initialized(true) 197 {} 198 199 CArray(const TinyVector<int,N_rank1>& shape, int lastExtent, const GeneralArrayStorage<N_rank>& storage) 200 : Array<T_numtype,N_rank>(shape, lastExtent, storage) 201 , initialized(true) 202 {} 203 204 CArray(Array<T_numtype, N_rank>& array, Range r0) 205 : Array<T_numtype,N_rank>(array, r0) 206 , initialized(true) 207 {} 208 209 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1) 210 : Array<T_numtype,N_rank>(array, r0, r1) 211 , initialized(true) 212 {} 213 214 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2) 215 : Array<T_numtype,N_rank>( array, r0, r1, r2) 216 , initialized(true) 217 {} 218 219 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3) 220 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3) 221 , initialized(true) 222 {} 223 224 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, 225 Range r3, Range r4) 226 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4) 227 , initialized(true) 228 {} 229 230 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, 231 Range r3, Range r4, Range r5) 232 : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5) 233 , initialized(true) 234 {} 235 236 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, 237 Range r4, Range r5, Range r6) 238 : Array<T_numtype,N_rank>( array, r0, r1, r2, r3, r4, r5, r6) 239 , initialized(true) 240 {} 241 242 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, 243 Range r5, Range r6, Range r7) 244 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7) 245 , initialized(true) 246 {} 247 248 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 249 Range r6, Range r7, Range r8) 250 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8) 251 , initialized(true) 252 {} 253 254 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, 255 Range r6, Range r7, Range r8, Range r9) 256 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9) 257 , initialized(true) 258 {} 259 260 CArray(Array<T_numtype, N_rank>& array, Range r0, Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, 261 Range r7, Range r8, Range r9, Range r10) 262 : Array<T_numtype,N_rank>(array, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) 263 , initialized(true) 264 {} 265 266 CArray(Array<T_numtype, N_rank>& array, const RectDomain<N_rank>& subdomain) 267 : Array<T_numtype,N_rank>(array, subdomain) 268 , initialized(true) 269 {} 270 271 CArray(Array<T_numtype, N_rank>& array, const StridedDomain<N_rank>& subdomain) 272 : Array<T_numtype,N_rank>(array, subdomain) 273 , initialized(true) 274 {} 275 276 template<int N_rank2, typename R0, typename R1, typename R2, typename R3, typename R4, typename R5, 277 typename R6, typename R7, typename R8, typename R9, typename R10> 278 CArray(Array<T_numtype,N_rank2>& array, R0 r0, R1 r1, R2 r2, R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9, R10 r10) 279 : Array<T_numtype,N_rank>(array, r0,r1, r2, r3, r4, r5, r6, r7, r8, r9, r10) 280 , initialized(true) 281 {} 282 283 virtual ~CArray() {} 284 285 CArray<T_numtype, N_rank> copy() const 286 { 287 CArray<T_numtype, N_rank> copy = Array<T_numtype, N_rank>::copy(); 288 copy.initialized = initialized; 289 return copy; 290 } 291 292 void reference(const CArray<T_numtype, N_rank>& array) 293 { 294 Array<T_numtype,N_rank>::reference(array); 295 initialized = array.initialized; 296 } 297 298 void reference(const Array<T_numtype,N_rank>& array) 299 { 300 Array<T_numtype,N_rank>::reference(array); 301 initialized = true; 302 } 303 304 void resize(int extent) 305 { 306 Array<T_numtype,N_rank>::resize(extent); 307 initialized = true; 308 } 309 void resize(int extent1, int extent2) 310 { 311 Array<T_numtype,N_rank>::resize(extent1, extent2); 312 initialized = true; 313 } 314 void resize(int extent1, int extent2, int extent3) 315 { 316 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3); 317 initialized = true; 318 } 319 void resize(int extent1, int extent2, int extent3, int extent4) 320 { 321 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4); 322 initialized = true; 323 } 324 void resize(int extent1, int extent2, int extent3, int extent4, int extent5) 325 { 326 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5); 327 initialized = true; 328 } 329 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, int extent6) 330 { 331 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, extent6); 332 initialized = true; 333 } 334 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, 335 int extent6, int extent7) 336 { 337 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, 338 extent6, extent7); 339 initialized = true; 340 } 341 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, 342 int extent6, int extent7, int extent8) 343 { 344 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, 345 extent6, extent7, extent8); 346 initialized = true; 347 } 348 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, 349 int extent6, int extent7, int extent8, int extent9) 350 { 351 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, 352 extent6, extent7, extent8, extent9); 353 initialized = true; 354 } 355 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, 356 int extent6, int extent7, int extent8, int extent9, int extent10) 357 { 358 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, 359 extent6, extent7, extent8, extent9, extent10); 360 initialized = true; 361 } 362 void resize(int extent1, int extent2, int extent3, int extent4, int extent5, int extent6, 363 int extent7, int extent8, int extent9, int extent10, int extent11) 364 { 365 Array<T_numtype,N_rank>::resize(extent1, extent2, extent3, extent4, extent5, extent6, 366 extent7, extent8, extent9, extent10, extent11); 367 initialized = true; 368 } 369 370 void resize(Range r1) 371 { 372 Array<T_numtype,N_rank>::resize(r1); 373 initialized = true; 374 } 375 void resize(Range r1, Range r2) 376 { 377 Array<T_numtype,N_rank>::resize(r1, r2); 378 initialized = true; 379 } 380 void resize(Range r1, Range r2, Range r3) 381 { 382 Array<T_numtype,N_rank>::resize(r1, r2, r3); 383 initialized = true; 384 } 385 void resize(Range r1, Range r2, Range r3, Range r4) 386 { 387 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4); 388 initialized = true; 389 } 390 void resize(Range r1, Range r2, Range r3, Range r4, Range r5) 391 { 392 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5); 393 initialized = true; 394 } 395 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, Range r6) 396 { 397 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, r6); 398 initialized = true; 399 } 400 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, 401 Range r6, Range r7) 402 { 403 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, 404 r6, r7); 405 initialized = true; 406 } 407 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, 408 Range r6, Range r7, Range r8) 409 { 410 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, 411 r6, r7, r8); 412 initialized = true; 413 } 414 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, 415 Range r6, Range r7, Range r8, Range r9) 416 { 417 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, 418 r6, r7, r8, r9); 419 initialized = true; 420 } 421 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, 422 Range r6, Range r7, Range r8, Range r9, Range r10) 423 { 424 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, 425 r6, r7, r8, r9, r10); 426 initialized = true; 427 } 428 void resize(Range r1, Range r2, Range r3, Range r4, Range r5, Range r6, 429 Range r7, Range r8, Range r9, Range r10, Range r11) 430 { 431 Array<T_numtype,N_rank>::resize(r1, r2, r3, r4, r5, r6, 432 r7, r8, r9, r10, r11); 433 initialized = true; 434 } 435 436 void resize(const TinyVector<int,N_rank>& extent) 437 { 438 Array<T_numtype,N_rank>::resize(extent); 439 initialized = true; 440 } 441 442 void resizeAndPreserve(const TinyVector<int,N_rank>& extent) 443 { 444 Array<T_numtype,N_rank>::resizeAndPreserve(extent); 445 initialized = true; 446 } 447 448 void resizeAndPreserve(int extent) 449 { 450 Array<T_numtype,N_rank>::resizeAndPreserve(extent); 451 initialized = true; 452 } 453 void resizeAndPreserve(int extent1, int extent2) 454 { 455 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2); 456 initialized = true; 457 } 458 void resizeAndPreserve(int extent1, int extent2, int extent3) 459 { 460 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3); 461 initialized = true; 462 } 463 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4) 464 { 465 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4); 466 initialized = true; 467 } 468 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, int extent5) 469 { 470 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, extent5); 471 initialized = true; 472 } 473 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, 474 int extent5, int extent6) 475 { 476 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, 477 extent5, extent6); 478 initialized = true; 479 } 480 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, 481 int extent5, int extent6, int extent7) 482 { 483 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, 484 extent5, extent6, extent7); 485 initialized = true; 486 } 487 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, 488 int extent5, int extent6, int extent7, int extent8) 489 { 490 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, 491 extent5, extent6, extent7, extent8); 492 initialized = true; 493 } 494 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, int extent5, 495 int extent6, int extent7, int extent8, int extent9) 496 { 497 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, extent5, 498 extent6, extent7, extent8, extent9); 499 initialized = true; 500 } 501 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, int extent5, 502 int extent6, int extent7, int extent8, int extent9, int extent10) 503 { 504 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, extent5, 505 extent6, extent7, extent8, extent9, extent10); 506 initialized = true; 507 } 508 void resizeAndPreserve(int extent1, int extent2, int extent3, int extent4, int extent5, int extent6, 509 int extent7, int extent8, int extent9, int extent10, int extent11) 510 { 511 Array<T_numtype,N_rank>::resizeAndPreserve(extent1, extent2, extent3, extent4, extent5, extent6, 512 extent7, extent8, extent9, extent10, extent11); 513 initialized = true; 514 } 515 516 virtual void fromString(const string& str) { istringstream iss(str); iss >> *this; initialized = true; } 517 virtual string toString(void) const { ostringstream oss; oss << *this; return oss.str(); } 518 virtual void reset(void) { this>free(); initialized = false; } 519 virtual bool isEmpty(void) const { return !initialized; } 520 virtual size_t size(void) const { return (this>dimensions() + 1) * sizeof(int) + sizeof(size_t) + this>numElements() * sizeof(T_numtype); } 521 522 virtual CBaseType* clone(void) const { return new CArray(*this); } 523 524 virtual bool toBuffer(CBufferOut& buffer) const 525 { 526 bool ret; 527 ret = buffer.put(this>dimensions()); 528 ret &= buffer.put(this>shape().data(), this>dimensions()); 529 ret &= buffer.put(this>numElements()); 530 ret &= buffer.put(this>dataFirst(), this>numElements()); 531 return ret; 532 } 533 534 virtual bool fromBuffer(CBufferIn& buffer) 535 { 536 bool ret; 537 int numDim; 538 TinyVector<int,N_rank> vect; 539 size_t ne; 540 541 ret = buffer.get(numDim); 542 ret &= buffer.get(vect.data(), N_rank); 543 this>resize(vect); 544 ret &= buffer.get(ne); 545 ret &= buffer.get(this>dataFirst(), ne); 546 547 initialized = true; 548 549 return ret; 550 } 551 }; 552 196 553 template <typename T_numtype,int N_rank> inline CBufferOut& operator<<(CBufferOut& buffer, const CArray<T_numtype,N_rank>& array) 197 554 { 198 if (!array.toBuffer(buffer)) ERROR(" 199 << "Buffer remain size is to low for size type");200 return buffer 555 if (!array.toBuffer(buffer)) ERROR("template <typename T_numtype,int N_rank> inline CBufferOut& operator<<(CBufferOut& buffer, const CArray& array)", 556 << "Buffer remain size is to low for size type"); 557 return buffer; 201 558 } 202 559 … … 204 561 { 205 562 if (!array.fromBuffer(buffer)) ERROR("template <typename T_numtype,int N_rank> inline CBufferIn& operator>>(CBufferIn& buffer, CArray& array)", 206 <<"Buffer remain size is to low for size type");207 return buffer 563 << "Buffer remain size is to low for size type"); 564 return buffer; 208 565 } 209 566 210 567 template <typename T_numtype,int N_rank> inline CMessage& operator<<(CMessage& msg, const CArray<T_numtype, N_rank>& array) 211 568 { 212 msg.push(array) 213 return msg 569 msg.push(array); 570 return msg; 214 571 } 215 572 216 573 template <typename T_numtype,int N_rank> inline CMessage& operator<<(CMessage& msg, CArray<T_numtype, N_rank>& array) 217 574 { 218 msg.push(array) 219 return msg 575 msg.push(array); 576 return msg; 220 577 } 221 222 223 578 } 224 579
Note: See TracChangeset
for help on using the changeset viewer.