6 template<
class Type,
class Dim>
15 #define DIM_ARGUMENTS \
16 const Dim& dim0 = 0, const Dim& dim1 = 0, \
17 const Dim& dim2 = 0, const Dim& dim3 = 0, \
18 const Dim& dim4 = 0, const Dim& dim5 = 0, \
19 const Dim& dim6 = 0, const Dim& dim7 = 0, \
20 const Dim& dim8 = 0, const Dim& dim9 = 0
21 #define DIM_ARGS dim0, dim1, dim2, dim3, dim4, dim5, dim6, dim7, dim8, dim9
23 x.dimension[0], x.dimension[1], x.dimension[2], \
24 x.dimension[3], x.dimension[4], x.dimension[5], \
25 x.dimension[6], x.dimension[7], x.dimension[8], \
27 #define DIM_DECLARATIONS \
29 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; \
30 dim[3] = dim3; dim[4] = dim4; dim[5] = dim5; \
31 dim[6] = dim6; dim[7] = dim7; dim[8] = dim8; \
38 #ifdef USE_DEFAULT_ARGUMENTS
40 numberOfElements = numberOfDimensions = 0;
41 dataPointer = basePointer = 0;
42 for (
int i=0; i<
MAXDIM; i++)
43 { dimension[i] = Dim(0); stride[i] = 1; }
47 #define TrivialArray_constructor \
48 numberOfElements = numberOfDimensions = 0; \
49 dataPointer = basePointer = 0; \
50 for (int i=0; i<MAXDIM; i++) \
51 { dimension[i] = Dim(0); stride[i] = 1; }
67 redim(dim0, dim1, dim2);
72 redim(dim0, dim1, dim2, dim3);
75 const Dim& dim3,
const Dim& dim4) {
77 redim(dim0, dim1, dim2, dim3, dim4);
80 const Dim& dim3,
const Dim& dim4,
const Dim& dim5) {
82 redim(dim0, dim1, dim2, dim3, dim4, dim5);
85 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6) {
87 redim(dim0, dim1, dim2, dim3, dim4, dim5, dim6);
90 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
93 redim(dim0, dim1, dim2, dim3, dim4, dim5, dim6, dim7);
96 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
97 const Dim& dim7,
const Dim& dim8) {
99 redim(dim0, dim1, dim2, dim3, dim4, dim5, dim6, dim7, dim8);
102 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
103 const Dim& dim7,
const Dim& dim8,
const Dim& dim9) {
105 redim(dim0, dim1, dim2, dim3, dim4, dim5, dim6, dim7, dim8, dim9);
107 #undef TrivialArray_constructor
108 #endif // USE_DEFAULT_ARGUMENTS
113 numberOfElements = numberOfDimensions = 0;
114 dataPointer = basePointer = 0;
115 for (
int i=0; i<
MAXDIM; i++)
116 { dimension[i] = Dim(0); stride[i] = 1; }
123 {
if (dataPointer)
delete [] dataPointer; }
127 #ifdef USE_DEFAULT_ARGUMENTS
130 int numberOfElements_, numberOfDimensions_, dimsChanged, i;
131 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0;
132 numberOfDimensions_ <
MAXDIM &&
dim[numberOfDimensions_] != Dim(0);
133 numberOfDimensions_++)
134 if (numberOfDimensions_)
135 numberOfElements_ *=
dim[numberOfDimensions_].getCount();
136 else numberOfElements_ =
dim[numberOfDimensions_].getCount();
137 assert(numberOfElements_ == numberOfElements);
138 dimsChanged = numberOfDimensions_ != numberOfDimensions;
139 numberOfDimensions = numberOfDimensions_;
140 basePointer = dataPointer;
141 for (i=0; i<numberOfDimensions; i++) {
142 dimsChanged = dimsChanged ||
dim[i] != dimension[i];
143 dimension[i] =
dim[i];
144 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1;
145 basePointer -= stride[i] * dimension[i].getBase();
147 for (i=numberOfDimensions; i<
MAXDIM; i++) {
148 dimension[i] = Dim(0);
149 stride[i] = i ? stride[i-1] : 1;
154 #define TrivialArray_reshape \
155 int numberOfElements_, numberOfDimensions_, dimsChanged, i; \
156 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0; \
157 numberOfDimensions_ < MAXDIM && !(dim[numberOfDimensions_] == Dim(0)); \
158 numberOfDimensions_++) \
159 if (numberOfDimensions_) \
160 numberOfElements_ *= dim[numberOfDimensions_].getCount(); \
161 else numberOfElements_ = dim[numberOfDimensions_].getCount(); \
162 assert(numberOfElements_ == numberOfElements); \
163 dimsChanged = numberOfDimensions_ != numberOfDimensions; \
164 numberOfDimensions = numberOfDimensions_; \
165 basePointer = dataPointer; \
166 for (i=0; i<numberOfDimensions; i++) { \
167 dimsChanged = dimsChanged || !(dim[i] == dimension[i]); \
168 dimension[i] = dim[i]; \
169 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1; \
170 basePointer -= stride[i] * dimension[i].getBase(); \
172 for (i=numberOfDimensions; i<MAXDIM; i++) { \
173 dimension[i] = Dim(0); \
174 stride[i] = i ? stride[i-1] : 1; \
179 dim[0] = 0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
180 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
185 dim[0] = dim0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
186 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
189 int reshape(
const Dim& dim0,
const Dim& dim1) {
191 dim[0] = dim0; dim[1] = dim1; dim[2] = 0; dim[3] = 0; dim[4] = 0;
192 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
195 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2) {
197 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = 0; dim[4] = 0;
198 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
201 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
204 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3; dim[4] = 0;
205 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
208 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
209 const Dim& dim3,
const Dim& dim4) {
211 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
212 dim[4] = dim4; dim[5] = 0; dim[6] = 0; dim[7] = 0;
213 dim[8] = 0; dim[9] = 0;
216 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
217 const Dim& dim3,
const Dim& dim4,
const Dim& dim5) {
219 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
220 dim[4] = dim4; dim[5] = dim5; dim[6] = 0; dim[7] = 0;
221 dim[8] = 0; dim[9] = 0;
224 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
225 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6) {
227 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
228 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = 0;
229 dim[8] = 0; dim[9] = 0;
232 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
233 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
236 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
237 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
238 dim[8] = 0; dim[9] = 0;
241 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
242 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
243 const Dim& dim7,
const Dim& dim8) {
245 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
246 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
247 dim[8] = dim8; dim[9] = 0;
250 int reshape(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
251 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
252 const Dim& dim7,
const Dim& dim8,
const Dim& dim9) {
254 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
255 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
256 dim[8] = dim8; dim[9] = dim9;
259 #undef TrivialArray_reshape
260 #endif // USE_DEFAULT_ARGUMENTS
265 #ifdef USE_DEFAULT_ARGUMENTS
268 int numberOfElements_, numberOfDimensions_, dimsChanged, i;
269 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0;
270 numberOfDimensions_ <
MAXDIM &&
dim[numberOfDimensions_] != Dim(0);
271 numberOfDimensions_++) {
272 if (numberOfDimensions_)
273 numberOfElements_ *=
dim[numberOfDimensions_].getCount();
274 else numberOfElements_ =
dim[numberOfDimensions_].getCount();
275 dimsChanged = dimsChanged ||
276 numberOfDimensions_ >= numberOfDimensions ||
277 dim[numberOfDimensions_] != dimension[numberOfDimensions_];
279 dimsChanged = dimsChanged || numberOfDimensions_ != numberOfDimensions;
280 if (numberOfElements != numberOfElements_) {
282 if (dataPointer)
delete [] dataPointer;
283 dataPointer = (numberOfElements = numberOfElements_) ?
284 new Type[numberOfElements] : 0;
287 numberOfDimensions = numberOfDimensions_;
288 basePointer = dataPointer;
289 for (i=0; i<numberOfDimensions; i++) {
290 dimension[i] =
dim[i];
291 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1;
292 basePointer -= stride[i] * dimension[i].getBase();
294 for (i=numberOfDimensions; i<
MAXDIM; i++)
295 { dimension[i] = Dim(0); stride[i] = i ? stride[i-1] : 1; }
300 #define TrivialArray_redim \
301 int numberOfElements_, numberOfDimensions_, dimsChanged, i; \
302 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0; \
303 numberOfDimensions_ < MAXDIM && !(dim[numberOfDimensions_] == Dim(0)); \
304 numberOfDimensions_++) { \
305 if (numberOfDimensions_) \
306 numberOfElements_ *= dim[numberOfDimensions_].getCount(); \
307 else numberOfElements_ = dim[numberOfDimensions_].getCount(); \
308 dimsChanged = dimsChanged || \
309 numberOfDimensions_ >= numberOfDimensions || \
310 !(dim[numberOfDimensions_] == dimension[numberOfDimensions_]); \
312 dimsChanged = dimsChanged || numberOfDimensions_ != numberOfDimensions; \
313 if (numberOfElements != numberOfElements_) { \
314 assert(dimsChanged); \
315 if (dataPointer) delete [] dataPointer; \
316 dataPointer = (numberOfElements = numberOfElements_) ? \
317 new Type[numberOfElements] : 0; \
320 numberOfDimensions = numberOfDimensions_; \
321 basePointer = dataPointer; \
322 for (i=0; i<numberOfDimensions; i++) { \
323 dimension[i] = dim[i]; \
324 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1; \
325 basePointer -= stride[i] * dimension[i].getBase(); \
327 for (i=numberOfDimensions; i<MAXDIM; i++) \
328 { dimension[i] = Dim(0); stride[i] = i ? stride[i-1] : 1; } \
333 dim[0] = 0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
334 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
339 dim[0] = dim0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
340 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
343 int redim(
const Dim& dim0,
const Dim& dim1) {
345 dim[0] = dim0; dim[1] = dim1; dim[2] = 0; dim[3] = 0; dim[4] = 0;
346 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
349 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2) {
351 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = 0; dim[4] = 0;
352 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
355 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
358 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3; dim[4] = 0;
359 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
362 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
363 const Dim& dim3,
const Dim& dim4) {
365 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
366 dim[4] = dim4; dim[5] = 0; dim[6] = 0; dim[7] = 0;
367 dim[8] = 0; dim[9] = 0;
370 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
371 const Dim& dim3,
const Dim& dim4,
const Dim& dim5) {
373 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
374 dim[4] = dim4; dim[5] = dim5; dim[6] = 0; dim[7] = 0;
375 dim[8] = 0; dim[9] = 0;
378 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
379 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6) {
381 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
382 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = 0;
383 dim[8] = 0; dim[9] = 0;
386 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
387 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
390 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
391 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
392 dim[8] = 0; dim[9] = 0;
395 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
396 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
397 const Dim& dim7,
const Dim& dim8) {
399 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
400 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
401 dim[8] = dim8; dim[9] = 0;
404 int redim(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
405 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
406 const Dim& dim7,
const Dim& dim8,
const Dim& dim9) {
408 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
409 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
410 dim[8] = dim8; dim[9] = dim9;
413 #undef TrivialArray_redim
414 #endif // USE_DEFAULT_ARGUMENTS
419 #ifdef USE_DEFAULT_ARGUMENTS
424 int numberOfElements_, numberOfDimensions_, dimsChanged,
426 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0;
427 numberOfDimensions_ <
MAXDIM &&
dim[numberOfDimensions_] != Dim(0);
428 numberOfDimensions_++) {
429 dimension_[numberOfDimensions_] = dimension[numberOfDimensions_];
430 if ((base[numberOfDimensions_] = max0(
431 dimension[numberOfDimensions_].
getBase(),
432 dim[numberOfDimensions_] .
getBase())) >
433 (bound[numberOfDimensions_] = min0(
434 dimension[numberOfDimensions_].
getBound(),
435 dim[numberOfDimensions_] .
getBound())))
437 stride_[numberOfDimensions_] = stride[numberOfDimensions_];
438 if (numberOfDimensions_)
439 numberOfElements_ *=
dim[numberOfDimensions_].getCount();
440 else numberOfElements_ =
dim[numberOfDimensions_].getCount();
441 dimsChanged = dimsChanged ||
442 numberOfDimensions_ >= numberOfDimensions ||
443 dim[numberOfDimensions_] != dimension[numberOfDimensions_];
445 assert (numberOfDimensions_ == numberOfDimensions);
447 Type *dataPointer_ = dataPointer, *basePointer_ = basePointer;
448 dataPointer = (numberOfElements = numberOfElements_) ?
449 new Type[numberOfElements] : 0;
450 basePointer = dataPointer;
451 for (i=0; i<numberOfDimensions; i++) {
452 dimension[i] =
dim[i];
453 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1;
454 basePointer -= stride[i] * dimension[i].getBase();
456 for (i=numberOfDimensions; i<
MAXDIM; i++) {
457 dimension[i] = Dim(0); stride[i] = i ? stride[i-1] : 1;
458 base[i] = bound[i] = dimension[i].getBase();
461 for (
int i9=base[9]; i9<=bound[9]; i9++)
462 for (
int i8=base[8]; i8<=bound[8]; i8++)
463 for (
int i7=base[7]; i7<=bound[7]; i7++)
464 for (
int i6=base[6]; i6<=bound[6]; i6++)
465 for (
int i5=base[5]; i5<=bound[5]; i5++)
466 for (
int i4=base[4]; i4<=bound[4]; i4++)
467 for (
int i3=base[3]; i3<=bound[3]; i3++)
468 for (
int i2=base[2];
i2<=bound[2];
i2++)
469 for (
int i1=base[1]; i1<=bound[1]; i1++)
470 for (
int i0=base[0]; i0<=bound[0]; i0++)
472 stride[1] * i1 + stride[2] *
i2 + stride[3] * i3 +
473 stride[4] * i4 + stride[5] * i5 + stride[6] * i6 +
474 stride[7] * i7 + stride[8] * i8 + stride[9] * i9] =
476 stride_[1] * i1 + stride_[2] *
i2 + stride_[3] * i3 +
477 stride_[4] * i4 + stride_[5] * i5 + stride_[6] * i6 +
478 stride_[7] * i7 + stride_[8] * i8 + stride_[9] * i9];
479 if (dataPointer_)
delete [] dataPointer_;
484 #define TrivialArray_resize \
485 Dim dimension_[MAXDIM]; \
486 int stride_[MAXDIM], base[MAXDIM], bound[MAXDIM]; \
487 int numberOfElements_, numberOfDimensions_, dimsChanged, \
488 dimsOverlap = 1, i; \
489 for (numberOfElements_ = numberOfDimensions_ = dimsChanged = 0; \
490 numberOfDimensions_ < MAXDIM && !(dim[numberOfDimensions_] == Dim(0)); \
491 numberOfDimensions_++) { \
492 dimension_[numberOfDimensions_] = dimension[numberOfDimensions_]; \
493 if ((base[numberOfDimensions_] = max0( \
494 dimension[numberOfDimensions_].getBase(), \
495 dim[numberOfDimensions_] .getBase())) > \
496 (bound[numberOfDimensions_] = min0( \
497 dimension[numberOfDimensions_].getBound(), \
498 dim[numberOfDimensions_] .getBound()))) \
500 stride_[numberOfDimensions_] = stride[numberOfDimensions_]; \
501 if (numberOfDimensions_) \
502 numberOfElements_ *= dim[numberOfDimensions_].getCount(); \
503 else numberOfElements_ = dim[numberOfDimensions_].getCount(); \
504 dimsChanged = dimsChanged || \
505 numberOfDimensions_ >= numberOfDimensions || \
506 !(dim[numberOfDimensions_] == dimension[numberOfDimensions_]); \
508 assert (numberOfDimensions_ == numberOfDimensions); \
510 Type *dataPointer_ = dataPointer, *basePointer_ = basePointer; \
511 dataPointer = (numberOfElements = numberOfElements_) ? \
512 new Type[numberOfElements] : 0; \
513 basePointer = dataPointer; \
514 for (i=0; i<numberOfDimensions; i++) { \
515 dimension[i] = dim[i]; \
516 stride[i] = i ? stride[i-1] * dimension[i-1].getCount() : 1; \
517 basePointer -= stride[i] * dimension[i].getBase(); \
519 for (i=numberOfDimensions; i<MAXDIM; i++) { \
520 dimension[i] = Dim(0); stride[i] = i ? stride[i-1] : 1; \
521 base[i] = bound[i] = dimension[i].getBase(); \
524 for (int i9=base[9]; i9<=bound[9]; i9++) \
525 for (int i8=base[8]; i8<=bound[8]; i8++) \
526 for (int i7=base[7]; i7<=bound[7]; i7++) \
527 for (int i6=base[6]; i6<=bound[6]; i6++) \
528 for (int i5=base[5]; i5<=bound[5]; i5++) \
529 for (int i4=base[4]; i4<=bound[4]; i4++) \
530 for (int i3=base[3]; i3<=bound[3]; i3++) \
531 for (int i2=base[2]; i2<=bound[2]; i2++) \
532 for (int i1=base[1]; i1<=bound[1]; i1++) \
533 for (int i0=base[0]; i0<=bound[0]; i0++) \
535 stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + \
536 stride[4] * i4 + stride[5] * i5 + stride[6] * i6 + \
537 stride[7] * i7 + stride[8] * i8 + stride[9] * i9] = \
539 stride_[1] * i1 + stride_[2] * i2 + stride_[3] * i3 + \
540 stride_[4] * i4 + stride_[5] * i5 + stride_[6] * i6 + \
541 stride_[7] * i7 + stride_[8] * i8 + stride_[9] * i9]; \
542 if (dataPointer_) delete [] dataPointer_; \
547 dim[0] = 0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
548 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
553 dim[0] = dim0; dim[1] = 0; dim[2] = 0; dim[3] = 0; dim[4] = 0;
554 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
557 int resize(
const Dim& dim0,
const Dim& dim1) {
559 dim[0] = dim0; dim[1] = dim1; dim[2] = 0; dim[3] = 0; dim[4] = 0;
560 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
563 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2) {
565 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = 0; dim[4] = 0;
566 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
569 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
572 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3; dim[4] = 0;
573 dim[5] = 0; dim[6] = 0; dim[7] = 0; dim[8] = 0; dim[9] = 0;
576 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
577 const Dim& dim3,
const Dim& dim4) {
579 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
580 dim[4] = dim4; dim[5] = 0; dim[6] = 0; dim[7] = 0;
581 dim[8] = 0; dim[9] = 0;
584 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
585 const Dim& dim3,
const Dim& dim4,
const Dim& dim5) {
587 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
588 dim[4] = dim4; dim[5] = dim5; dim[6] = 0; dim[7] = 0;
589 dim[8] = 0; dim[9] = 0;
592 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
593 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6) {
595 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
596 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = 0;
597 dim[8] = 0; dim[9] = 0;
600 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
601 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
604 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
605 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
606 dim[8] = 0; dim[9] = 0;
609 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
610 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
611 const Dim& dim7,
const Dim& dim8) {
613 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
614 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
615 dim[8] = dim8; dim[9] = 0;
618 int resize(
const Dim& dim0,
const Dim& dim1,
const Dim& dim2,
619 const Dim& dim3,
const Dim& dim4,
const Dim& dim5,
const Dim& dim6,
620 const Dim& dim7,
const Dim& dim8,
const Dim& dim9) {
622 dim[0] = dim0; dim[1] = dim1; dim[2] = dim2; dim[3] = dim3;
623 dim[4] = dim4; dim[5] = dim5; dim[6] = dim6; dim[7] = dim7;
624 dim[8] = dim8; dim[9] = dim9;
627 #undef TrivialArray_resize
628 #endif // USE_DEFAULT_ARGUMENTS
635 if (numberOfElements == 0) {
638 assert(numberOfElements == x.numberOfElements);
639 assert(numberOfDimensions == x.numberOfDimensions);
640 for (
int i=0; i<
MAXDIM; i++)
641 assert(dimension[i] == x.dimension[i]);
643 for (
int i=0; i<numberOfElements; i++)
644 dataPointer[i] = x.dataPointer[i];
649 for (
int i=0; i<numberOfElements; i++) dataPointer[i] = x;
657 int getBase(
const int i)
const {
return dimension[i].getBase(); }
658 int getBound(
const int i)
const {
return dimension[i].getBound(); }
669 {
assert(numberOfDimensions == 1);
return basePointer[i0]; }
671 {
assert(numberOfDimensions == 2);
return basePointer[i0 + stride[1] * i1]; }
673 {
assert(numberOfDimensions == 3);
return basePointer[i0 + stride[1] * i1 + stride[2] *
i2]; }
674 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3)
675 {
assert(numberOfDimensions == 4);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3]; }
676 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4)
677 {
assert(numberOfDimensions == 5);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4]; }
678 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5)
679 {
assert(numberOfDimensions == 6);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4 + stride[5] * i5]; }
680 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6)
681 {
assert(numberOfDimensions == 7);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4 + stride[5] * i5
683 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7)
684 {
assert(numberOfDimensions == 8);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4 + stride[5] * i5
685 + stride[6] * i6 + stride[7] * i7]; }
686 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7,
const int i8)
687 {
assert(numberOfDimensions == 9);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4 + stride[5] * i5
688 + stride[6] * i6 + stride[7] * i7 + stride[8] * i8]; }
689 Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7,
const int i8,
const int i9)
690 {
assert(numberOfDimensions ==10);
return basePointer[i0 + stride[1] * i1 + stride[2] * i2 + stride[3] * i3 + stride[4] * i4 + stride[5] * i5
691 + stride[6] * i6 + stride[7] * i7 + stride[8] * i8 + stride[9] * i9]; }
698 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3)
const
700 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4)
const
702 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5)
const
704 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6)
const
706 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7)
const
707 {
return ((
TrivialArray&)*
this)(i0, i1,
i2, i3, i4, i5, i6, i7); }
708 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7,
const int i8)
const
709 {
return ((
TrivialArray&)*
this)(i0, i1,
i2, i3, i4, i5, i6, i7, i8); }
710 const Type&
operator()(
const int i0,
const int i1,
const int i2,
const int i3,
const int i4,
const int i5,
const int i6,
const int i7,
const int i8,
712 {
return ((
TrivialArray&)*
this)(i0, i1,
i2, i3, i4, i5, i6, i7, i8, i9); }
714 static int min0(
const int i,
const int j) {
return i < j ? i : j; }
715 static int max0(
const int i,
const int j) {
return i > j ? i : j; }
719 int numberOfElements;
720 int numberOfDimensions;
723 Type *dataPointer, *basePointer;
727 #undef DIM_DECLARATIONS
730 #endif // TrivialArray_