ARTS  2.2.66
matpackVI.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2012 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
28 #ifndef matpackVI_h
29 #define matpackVI_h
30 
31 #include "matpackV.h"
32 
33 #define CHECK(x) assert( 0 <= x ); assert( x < m ## x ## r.mextent )
34 #define OFFSET(x) m ## x ## r.mstart + x * m ## x ## r.mstride
35 
38 class Iterator6D {
39 public:
40  // Constructors:
42  Iterator6D() : msv(), mstride(0) { /* Nothing to do here. */ }
43 
45  Iterator6D(const Tensor5View& x, Index stride) : msv(x), mstride(stride)
46  { /* Nothing to do here. */ }
47 
48  // Operators:
50  Iterator6D& operator++() { msv.mdata += mstride; return *this; }
51 
56  bool operator!=(const Iterator6D& other) const
57  { if ( msv.mdata +
58  msv.msr.mstart +
59  msv.mbr.mstart +
60  msv.mpr.mstart +
61  msv.mrr.mstart +
62  msv.mcr.mstart
63  !=
64  other.msv.mdata +
65  other.msv.msr.mstart +
66  other.msv.mbr.mstart +
67  other.msv.mpr.mstart +
68  other.msv.mrr.mstart +
69  other.msv.mcr.mstart )
70  return true;
71  else
72  return false;
73  }
74 
77  Tensor5View* operator->() { return &msv; }
78 
80  Tensor5View& operator*() { return msv; }
81 
82 private:
87 };
88 
91 public:
92  // Constructors:
94  ConstIterator6D() : msv(), mstride(0) { /* Nothing to do here. */ }
95 
97  ConstIterator6D(const ConstTensor5View& x, Index stride) : msv(x), mstride(stride)
98  { /* Nothing to do here. */ }
99 
100  // Operators:
102  ConstIterator6D& operator++() { msv.mdata += mstride; return *this; }
103 
108  bool operator!=(const ConstIterator6D& other) const
109  { if ( msv.mdata +
110  msv.msr.mstart +
111  msv.mbr.mstart +
112  msv.mpr.mstart +
113  msv.mrr.mstart +
114  msv.mcr.mstart
115  !=
116  other.msv.mdata +
117  other.msv.msr.mstart +
118  other.msv.mbr.mstart +
119  other.msv.mpr.mstart +
120  other.msv.mrr.mstart +
121  other.msv.mcr.mstart )
122  return true;
123  else
124  return false;
125  }
126 
129  const ConstTensor5View* operator->() const { return &msv; }
130 
132  const ConstTensor5View& operator*() const { return msv; }
133 
134 private:
139 };
140 
141 
142 // Declare class Tensor6:
143 class Tensor6;
144 
145 
160 public:
161  // Member functions:
162  Index nvitrines() const;
163  Index nshelves() const;
164  Index nbooks() const;
165  Index npages() const;
166  Index nrows() const;
167  Index ncols() const;
168 
169  // Const index operators:
170 
171  // Result 6D (1 combination)
172  // ------
173  ConstTensor6View operator()( const Range& v, const Range& s, const Range& b,
174  const Range& p, const Range& r, const Range& c) const;
175 
176  // Result 5D (6 combinations)
177  // -----|
178  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
179  const Range& p, const Range& r, Index c) const;
180  // ----|-
181  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
182  const Range& p, Index r, const Range& c) const;
183  // ---|--
184  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
185  Index p, const Range& r, const Range& c) const;
186  // --|---
187  ConstTensor5View operator()( const Range& v, const Range& s, Index b,
188  const Range& p, const Range& r, const Range& c) const;
189  // -|----
190  ConstTensor5View operator()( const Range& v, Index s, const Range& b,
191  const Range& p, const Range& r, const Range& c) const;
192  // |-----
193  ConstTensor5View operator()( Index v, const Range& s, const Range& b,
194  const Range& p, const Range& r, const Range& c) const;
195 
196  // Result 4D (5+4+3+2+1 = 15 combinations)
197  // ----||
198  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
199  const Range& p, Index r, Index c) const;
200  // ---|-|
201  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
202  Index p, const Range& r, Index c) const;
203  // --|--|
204  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
205  const Range& p, const Range& r, Index c) const;
206  // -|---|
207  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
208  const Range& p, const Range& r, Index c) const;
209  // |----|
210  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
211  const Range& p, const Range& r, Index c) const;
212  // ---||-
213  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
214  Index p, Index r, const Range& c) const;
215  // --|-|-
216  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
217  const Range& p, Index r, const Range& c) const;
218  // -|--|-
219  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
220  const Range& p, Index r, const Range& c) const;
221  // |---|-
222  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
223  const Range& p, Index r, const Range& c) const;
224  // --||--
225  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
226  Index p, const Range& r, const Range& c) const;
227  // -|-|--
228  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
229  Index p, const Range& r, const Range& c) const;
230  // |--|--
231  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
232  Index p, const Range& r, const Range& c) const;
233  // -||---
234  ConstTensor4View operator()( const Range& v, Index s, Index b,
235  const Range& p, const Range& r, const Range& c) const;
236  // |-|---
237  ConstTensor4View operator()( Index v, const Range& s, Index b,
238  const Range& p, const Range& r, const Range& c) const;
239  // ||----
240  ConstTensor4View operator()( Index v, Index s, const Range& b,
241  const Range& p, const Range& r, const Range& c) const;
242 
243  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
244  // ---|||
245  ConstTensor3View operator()( const Range& v, const Range& s, const Range& b,
246  Index p, Index r, Index c) const;
247  // --|-||
248  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
249  const Range& p, Index r, Index c) const;
250  // -|--||
251  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
252  const Range& p, Index r, Index c) const;
253  // |---||
254  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
255  const Range& p, Index r, Index c) const;
256  // --||-|
257  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
258  Index p, const Range& r, Index c) const;
259  // -|-|-|
260  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
261  Index p, const Range& r, Index c) const;
262  // |--|-|
263  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
264  Index p, const Range& r, Index c) const;
265  // -||--|
266  ConstTensor3View operator()( const Range& v, Index s, Index b,
267  const Range& p, const Range& r, Index c) const;
268  // |-|--|
269  ConstTensor3View operator()( Index v, const Range& s, Index b,
270  const Range& p, const Range& r, Index c) const;
271  // ||---|
272  ConstTensor3View operator()( Index v, Index s, const Range& b,
273  const Range& p, const Range& r, Index c) const;
274  // --|||-
275  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
276  Index p, Index r, const Range& c) const;
277  // -|-||-
278  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
279  Index p, Index r, const Range& c) const;
280  // |--||-
281  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
282  Index p, Index r, const Range& c) const;
283  // -||-|-
284  ConstTensor3View operator()( const Range& v, Index s, Index b,
285  const Range& p, Index r, const Range& c) const;
286  // |-|-|-
287  ConstTensor3View operator()( Index v, const Range& s, Index b,
288  const Range& p, Index r, const Range& c) const;
289  // ||--|-
290  ConstTensor3View operator()( Index v, Index s, const Range& b,
291  const Range& p, Index r, const Range& c) const;
292  // -|||--
293  ConstTensor3View operator()( const Range& v, Index s, Index b,
294  Index p, const Range& r, const Range& c) const;
295  // |-||--
296  ConstTensor3View operator()( Index v, const Range& s, Index b,
297  Index p, const Range& r, const Range& c) const;
298  // ||-|--
299  ConstTensor3View operator()( Index v, Index s, const Range& b,
300  Index p, const Range& r, const Range& c) const;
301  // |||---
302  ConstTensor3View operator()( Index v, Index s, Index b,
303  const Range& p, const Range& r, const Range& c) const;
304 
305  // Result 2D (15 combinations)
306  // IIII--
307  ConstMatrixView operator()( Index v, Index s, Index b,
308  Index p, const Range& r, const Range& c) const;
309  // III-I-
310  ConstMatrixView operator()( Index v, Index s, Index b,
311  const Range& p, Index r, const Range& c) const;
312  // II-II-
313  ConstMatrixView operator()( Index v, Index s, const Range& b,
314  Index p, Index r, const Range& c) const;
315  // I-III-
316  ConstMatrixView operator()( Index v, const Range& s, Index b,
317  Index p, Index r, const Range& c) const;
318  // -IIII-
319  ConstMatrixView operator()( const Range& v, Index s, Index b,
320  Index p, Index r, const Range& c) const;
321  // III--I
322  ConstMatrixView operator()( Index v, Index s, Index b,
323  const Range& p, const Range& r, Index c) const;
324  // II-I-I
325  ConstMatrixView operator()( Index v, Index s, const Range& b,
326  Index p, const Range& r, Index c) const;
327  // I-II-I
328  ConstMatrixView operator()( Index v, const Range& s, Index b,
329  Index p, const Range& r, Index c) const;
330  // -III-I
331  ConstMatrixView operator()( const Range& v, Index s, Index b,
332  Index p, const Range& r, Index c) const;
333  // II--II
334  ConstMatrixView operator()( Index v, Index s, const Range& b,
335  const Range& p, Index r, Index c) const;
336  // I-I-II
337  ConstMatrixView operator()( Index v, const Range& s, Index b,
338  const Range& p, Index r, Index c) const;
339  // -II-II
340  ConstMatrixView operator()( const Range& v, Index s, Index b,
341  const Range& p, Index r, Index c) const;
342  // I--III
343  ConstMatrixView operator()( Index v, const Range& s, const Range& b,
344  Index p, Index r, Index c) const;
345  // -I-III
346  ConstMatrixView operator()( const Range& v, Index s, const Range& b,
347  Index p, Index r, Index c) const;
348  // --IIII
349  ConstMatrixView operator()( const Range& v, const Range& s, Index b,
350  Index p, Index r, Index c) const;
351 
352  // Result 1D (6 combinations)
353  // IIIII-
354  ConstVectorView operator()( Index v, Index s, Index b,
355  Index p, Index r, const Range& c) const;
356  // IIII-I
357  ConstVectorView operator()( Index v, Index s, Index b,
358  Index p, const Range& r, Index c) const;
359  // III-II
360  ConstVectorView operator()( Index v, Index s, Index b,
361  const Range& p, Index r, Index c) const;
362  // II-III
363  ConstVectorView operator()( Index v, Index s, const Range& b,
364  Index p, Index r, Index c) const;
365  // I-IIII
366  ConstVectorView operator()( Index v, const Range& s, Index b,
367  Index p, Index r, Index c) const;
368  // -IIIII
369  ConstVectorView operator()( const Range& v, Index s, Index b,
370  Index p, Index r, Index c) const;
371 
372  // Result scalar (1 combination)
373  // IIIIII
374  Numeric operator() ( Index v, Index s, Index b,
375  Index p, Index r, Index c) const
376  { CHECK(v);
377  CHECK(s);
378  CHECK(b);
379  CHECK(p);
380  CHECK(r);
381  CHECK(c);
382  return get(v, s, b, p, r, c);
383  }
384 
386  Numeric get( Index v, Index s, Index b,
387  Index p, Index r, Index c) const
388  {
389  return *(mdata +
390  OFFSET(v) + OFFSET(s) + OFFSET(b) +
391  OFFSET(p) + OFFSET(r) + OFFSET(c) );
392  }
393 
394 
395  // Functions returning iterators:
396  ConstIterator6D begin() const;
397  ConstIterator6D end() const;
398 
399  // Destructor:
400  virtual ~ConstTensor6View() {}
401 
402  // Friends:
403  friend class ConstIterator7D;
404  friend class Tensor6View;
405  friend class ConstTensor7View;
406 
407  // Special constructor to make a Tensor6 view of a Tensor5.
409 
410 protected:
411  // Constructors:
414  const Range& v, const Range& s, const Range& b,
415  const Range& p, const Range& r, const Range& c);
417  const Range& pv, const Range& ps, const Range& pb,
418  const Range& pp, const Range& pr, const Range& pc,
419  const Range& nv, const Range& ns, const Range& nb,
420  const Range& np, const Range& nr, const Range& nc);
421 
422  // Data members:
423  // -------------
438 };
439 
450 public:
451 
452  // Const index operators:
453 
454  // Result 6D (1 combination)
455  // ------
456  ConstTensor6View operator()( const Range& v, const Range& s, const Range& b,
457  const Range& p, const Range& r, const Range& c) const;
458 
459  // Result 5D (6 combinations)
460  // -----|
461  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
462  const Range& p, const Range& r, Index c) const;
463  // ----|-
464  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
465  const Range& p, Index r, const Range& c) const;
466  // ---|--
467  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
468  Index p, const Range& r, const Range& c) const;
469  // --|---
470  ConstTensor5View operator()( const Range& v, const Range& s, Index b,
471  const Range& p, const Range& r, const Range& c) const;
472  // -|----
473  ConstTensor5View operator()( const Range& v, Index s, const Range& b,
474  const Range& p, const Range& r, const Range& c) const;
475  // |-----
476  ConstTensor5View operator()( Index v, const Range& s, const Range& b,
477  const Range& p, const Range& r, const Range& c) const;
478 
479  // Result 4D (5+4+3+2+1 = 15 combinations)
480  // ----||
481  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
482  const Range& p, Index r, Index c) const;
483  // ---|-|
484  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
485  Index p, const Range& r, Index c) const;
486  // --|--|
487  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
488  const Range& p, const Range& r, Index c) const;
489  // -|---|
490  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
491  const Range& p, const Range& r, Index c) const;
492  // |----|
493  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
494  const Range& p, const Range& r, Index c) const;
495  // ---||-
496  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
497  Index p, Index r, const Range& c) const;
498  // --|-|-
499  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
500  const Range& p, Index r, const Range& c) const;
501  // -|--|-
502  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
503  const Range& p, Index r, const Range& c) const;
504  // |---|-
505  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
506  const Range& p, Index r, const Range& c) const;
507  // --||--
508  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
509  Index p, const Range& r, const Range& c) const;
510  // -|-|--
511  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
512  Index p, const Range& r, const Range& c) const;
513  // |--|--
514  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
515  Index p, const Range& r, const Range& c) const;
516  // -||---
517  ConstTensor4View operator()( const Range& v, Index s, Index b,
518  const Range& p, const Range& r, const Range& c) const;
519  // |-|---
520  ConstTensor4View operator()( Index v, const Range& s, Index b,
521  const Range& p, const Range& r, const Range& c) const;
522  // ||----
523  ConstTensor4View operator()( Index v, Index s, const Range& b,
524  const Range& p, const Range& r, const Range& c) const;
525 
526  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
527  // ---|||
528  ConstTensor3View operator()( const Range& v, const Range& s, const Range& b,
529  Index p, Index r, Index c) const;
530  // --|-||
531  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
532  const Range& p, Index r, Index c) const;
533  // -|--||
534  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
535  const Range& p, Index r, Index c) const;
536  // |---||
537  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
538  const Range& p, Index r, Index c) const;
539  // --||-|
540  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
541  Index p, const Range& r, Index c) const;
542  // -|-|-|
543  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
544  Index p, const Range& r, Index c) const;
545  // |--|-|
546  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
547  Index p, const Range& r, Index c) const;
548  // -||--|
549  ConstTensor3View operator()( const Range& v, Index s, Index b,
550  const Range& p, const Range& r, Index c) const;
551  // |-|--|
552  ConstTensor3View operator()( Index v, const Range& s, Index b,
553  const Range& p, const Range& r, Index c) const;
554  // ||---|
555  ConstTensor3View operator()( Index v, Index s, const Range& b,
556  const Range& p, const Range& r, Index c) const;
557  // --|||-
558  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
559  Index p, Index r, const Range& c) const;
560  // -|-||-
561  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
562  Index p, Index r, const Range& c) const;
563  // |--||-
564  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
565  Index p, Index r, const Range& c) const;
566  // -||-|-
567  ConstTensor3View operator()( const Range& v, Index s, Index b,
568  const Range& p, Index r, const Range& c) const;
569  // |-|-|-
570  ConstTensor3View operator()( Index v, const Range& s, Index b,
571  const Range& p, Index r, const Range& c) const;
572  // ||--|-
573  ConstTensor3View operator()( Index v, Index s, const Range& b,
574  const Range& p, Index r, const Range& c) const;
575  // -|||--
576  ConstTensor3View operator()( const Range& v, Index s, Index b,
577  Index p, const Range& r, const Range& c) const;
578  // |-||--
579  ConstTensor3View operator()( Index v, const Range& s, Index b,
580  Index p, const Range& r, const Range& c) const;
581  // ||-|--
582  ConstTensor3View operator()( Index v, Index s, const Range& b,
583  Index p, const Range& r, const Range& c) const;
584  // |||---
585  ConstTensor3View operator()( Index v, Index s, Index b,
586  const Range& p, const Range& r, const Range& c) const;
587 
588  // Result 2D (15 combinations)
589  // IIII--
590  ConstMatrixView operator()( Index v, Index s, Index b,
591  Index p, const Range& r, const Range& c) const;
592  // III-I-
593  ConstMatrixView operator()( Index v, Index s, Index b,
594  const Range& p, Index r, const Range& c) const;
595  // II-II-
596  ConstMatrixView operator()( Index v, Index s, const Range& b,
597  Index p, Index r, const Range& c) const;
598  // I-III-
599  ConstMatrixView operator()( Index v, const Range& s, Index b,
600  Index p, Index r, const Range& c) const;
601  // -IIII-
602  ConstMatrixView operator()( const Range& v, Index s, Index b,
603  Index p, Index r, const Range& c) const;
604  // III--I
605  ConstMatrixView operator()( Index v, Index s, Index b,
606  const Range& p, const Range& r, Index c) const;
607  // II-I-I
608  ConstMatrixView operator()( Index v, Index s, const Range& b,
609  Index p, const Range& r, Index c) const;
610  // I-II-I
611  ConstMatrixView operator()( Index v, const Range& s, Index b,
612  Index p, const Range& r, Index c) const;
613  // -III-I
614  ConstMatrixView operator()( const Range& v, Index s, Index b,
615  Index p, const Range& r, Index c) const;
616  // II--II
617  ConstMatrixView operator()( Index v, Index s, const Range& b,
618  const Range& p, Index r, Index c) const;
619  // I-I-II
620  ConstMatrixView operator()( Index v, const Range& s, Index b,
621  const Range& p, Index r, Index c) const;
622  // -II-II
623  ConstMatrixView operator()( const Range& v, Index s, Index b,
624  const Range& p, Index r, Index c) const;
625  // I--III
626  ConstMatrixView operator()( Index v, const Range& s, const Range& b,
627  Index p, Index r, Index c) const;
628  // -I-III
629  ConstMatrixView operator()( const Range& v, Index s, const Range& b,
630  Index p, Index r, Index c) const;
631  // --IIII
632  ConstMatrixView operator()( const Range& v, const Range& s, Index b,
633  Index p, Index r, Index c) const;
634 
635  // Result 1D (6 combinations)
636  // IIIII-
637  ConstVectorView operator()( Index v, Index s, Index b,
638  Index p, Index r, const Range& c) const;
639  // IIII-I
640  ConstVectorView operator()( Index v, Index s, Index b,
641  Index p, const Range& r, Index c) const;
642  // III-II
643  ConstVectorView operator()( Index v, Index s, Index b,
644  const Range& p, Index r, Index c) const;
645  // II-III
646  ConstVectorView operator()( Index v, Index s, const Range& b,
647  Index p, Index r, Index c) const;
648  // I-IIII
649  ConstVectorView operator()( Index v, const Range& s, Index b,
650  Index p, Index r, Index c) const;
651  // -IIIII
652  ConstVectorView operator()( const Range& v, Index s, Index b,
653  Index p, Index r, Index c) const;
654 
655  // Result scalar (1 combination)
656  // IIIIII
657  Numeric operator() ( Index v, Index s, Index b,
658  Index p, Index r, Index c) const
659  { return ConstTensor6View::operator()(v,s,b,p,r,c); }
660 
662  Numeric get( Index v, Index s, Index b,
663  Index p, Index r, Index c) const
664  { return ConstTensor6View::get(v,s,b,p,r,c); }
665 
666  // Non-const index operators:
667 
668  // Result 6D (1 combination)
669  // ------
670  Tensor6View operator()( const Range& v, const Range& s, const Range& b,
671  const Range& p, const Range& r, const Range& c);
672 
673  // Result 5D (6 combinations)
674  // -----|
675  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
676  const Range& p, const Range& r, Index c);
677  // ----|-
678  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
679  const Range& p, Index r, const Range& c);
680  // ---|--
681  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
682  Index p, const Range& r, const Range& c);
683  // --|---
684  Tensor5View operator()( const Range& v, const Range& s, Index b,
685  const Range& p, const Range& r, const Range& c);
686  // -|----
687  Tensor5View operator()( const Range& v, Index s, const Range& b,
688  const Range& p, const Range& r, const Range& c);
689  // |-----
690  Tensor5View operator()( Index v, const Range& s, const Range& b,
691  const Range& p, const Range& r, const Range& c);
692 
693  // Result 4D (5+4+3+2+1 = 15 combinations)
694  // ----||
695  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
696  const Range& p, Index r, Index c);
697  // ---|-|
698  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
699  Index p, const Range& r, Index c);
700  // --|--|
701  Tensor4View operator()( const Range& v, const Range& s, Index b,
702  const Range& p, const Range& r, Index c);
703  // -|---|
704  Tensor4View operator()( const Range& v, Index s, const Range& b,
705  const Range& p, const Range& r, Index c);
706  // |----|
707  Tensor4View operator()( Index v, const Range& s, const Range& b,
708  const Range& p, const Range& r, Index c);
709  // ---||-
710  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
711  Index p, Index r, const Range& c);
712  // --|-|-
713  Tensor4View operator()( const Range& v, const Range& s, Index b,
714  const Range& p, Index r, const Range& c);
715  // -|--|-
716  Tensor4View operator()( const Range& v, Index s, const Range& b,
717  const Range& p, Index r, const Range& c);
718  // |---|-
719  Tensor4View operator()( Index v, const Range& s, const Range& b,
720  const Range& p, Index r, const Range& c);
721  // --||--
722  Tensor4View operator()( const Range& v, const Range& s, Index b,
723  Index p, const Range& r, const Range& c);
724  // -|-|--
725  Tensor4View operator()( const Range& v, Index s, const Range& b,
726  Index p, const Range& r, const Range& c);
727  // |--|--
728  Tensor4View operator()( Index v, const Range& s, const Range& b,
729  Index p, const Range& r, const Range& c);
730  // -||---
731  Tensor4View operator()( const Range& v, Index s, Index b,
732  const Range& p, const Range& r, const Range& c);
733  // |-|---
734  Tensor4View operator()( Index v, const Range& s, Index b,
735  const Range& p, const Range& r, const Range& c);
736  // ||----
737  Tensor4View operator()( Index v, Index s, const Range& b,
738  const Range& p, const Range& r, const Range& c);
739 
740  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
741  // ---|||
742  Tensor3View operator()( const Range& v, const Range& s, const Range& b,
743  Index p, Index r, Index c);
744  // --|-||
745  Tensor3View operator()( const Range& v, const Range& s, Index b,
746  const Range& p, Index r, Index c);
747  // -|--||
748  Tensor3View operator()( const Range& v, Index s, const Range& b,
749  const Range& p, Index r, Index c);
750  // |---||
751  Tensor3View operator()( Index v, const Range& s, const Range& b,
752  const Range& p, Index r, Index c);
753  // --||-|
754  Tensor3View operator()( const Range& v, const Range& s, Index b,
755  Index p, const Range& r, Index c);
756  // -|-|-|
757  Tensor3View operator()( const Range& v, Index s, const Range& b,
758  Index p, const Range& r, Index c);
759  // |--|-|
760  Tensor3View operator()( Index v, const Range& s, const Range& b,
761  Index p, const Range& r, Index c);
762  // -||--|
763  Tensor3View operator()( const Range& v, Index s, Index b,
764  const Range& p, const Range& r, Index c);
765  // |-|--|
766  Tensor3View operator()( Index v, const Range& s, Index b,
767  const Range& p, const Range& r, Index c);
768  // ||---|
769  Tensor3View operator()( Index v, Index s, const Range& b,
770  const Range& p, const Range& r, Index c);
771  // --|||-
772  Tensor3View operator()( const Range& v, const Range& s, Index b,
773  Index p, Index r, const Range& c);
774  // -|-||-
775  Tensor3View operator()( const Range& v, Index s, const Range& b,
776  Index p, Index r, const Range& c);
777  // |--||-
778  Tensor3View operator()( Index v, const Range& s, const Range& b,
779  Index p, Index r, const Range& c);
780  // -||-|-
781  Tensor3View operator()( const Range& v, Index s, Index b,
782  const Range& p, Index r, const Range& c);
783  // |-|-|-
784  Tensor3View operator()( Index v, const Range& s, Index b,
785  const Range& p, Index r, const Range& c);
786  // ||--|-
787  Tensor3View operator()( Index v, Index s, const Range& b,
788  const Range& p, Index r, const Range& c);
789  // -|||--
790  Tensor3View operator()( const Range& v, Index s, Index b,
791  Index p, const Range& r, const Range& c);
792  // |-||--
793  Tensor3View operator()( Index v, const Range& s, Index b,
794  Index p, const Range& r, const Range& c);
795  // ||-|--
796  Tensor3View operator()( Index v, Index s, const Range& b,
797  Index p, const Range& r, const Range& c);
798  // |||---
799  Tensor3View operator()( Index v, Index s, Index b,
800  const Range& p, const Range& r, const Range& c);
801 
802  // Result 2D (15 combinations)
803  // IIII--
804  MatrixView operator()( Index v, Index s, Index b,
805  Index p, const Range& r, const Range& c);
806  // III-I-
807  MatrixView operator()( Index v, Index s, Index b,
808  const Range& p, Index r, const Range& c);
809  // II-II-
810  MatrixView operator()( Index v, Index s, const Range& b,
811  Index p, Index r, const Range& c);
812  // I-III-
813  MatrixView operator()( Index v, const Range& s, Index b,
814  Index p, Index r, const Range& c);
815  // -IIII-
816  MatrixView operator()( const Range& v, Index s, Index b,
817  Index p, Index r, const Range& c);
818  // III--I
819  MatrixView operator()( Index v, Index s, Index b,
820  const Range& p, const Range& r, Index c);
821  // II-I-I
822  MatrixView operator()( Index v, Index s, const Range& b,
823  Index p, const Range& r, Index c);
824  // I-II-I
825  MatrixView operator()( Index v, const Range& s, Index b,
826  Index p, const Range& r, Index c);
827  // -III-I
828  MatrixView operator()( const Range& v, Index s, Index b,
829  Index p, const Range& r, Index c);
830  // II--II
831  MatrixView operator()( Index v, Index s, const Range& b,
832  const Range& p, Index r, Index c);
833  // I-I-II
834  MatrixView operator()( Index v, const Range& s, Index b,
835  const Range& p, Index r, Index c);
836  // -II-II
837  MatrixView operator()( const Range& v, Index s, Index b,
838  const Range& p, Index r, Index c);
839  // I--III
840  MatrixView operator()( Index v, const Range& s, const Range& b,
841  Index p, Index r, Index c);
842  // -I-III
843  MatrixView operator()( const Range& v, Index s, const Range& b,
844  Index p, Index r, Index c);
845  // --IIII
846  MatrixView operator()( const Range& v, const Range& s, Index b,
847  Index p, Index r, Index c);
848 
849  // Result 1D (6 combinations)
850  // IIIII-
851  VectorView operator()( Index v, Index s, Index b,
852  Index p, Index r, const Range& c);
853  // IIII-I
854  VectorView operator()( Index v, Index s, Index b,
855  Index p, const Range& r, Index c);
856  // III-II
857  VectorView operator()( Index v, Index s, Index b,
858  const Range& p, Index r, Index c);
859  // II-III
860  VectorView operator()( Index v, Index s, const Range& b,
861  Index p, Index r, Index c);
862  // I-IIII
863  VectorView operator()( Index v, const Range& s, Index b,
864  Index p, Index r, Index c);
865  // -IIIII
866  VectorView operator()( const Range& v, Index s, Index b,
867  Index p, Index r, Index c);
868 
869  // Result scalar (1 combination)
870  // IIIIII
871  Numeric& operator() ( Index v, Index s, Index b,
872  Index p, Index r, Index c)
873  { CHECK(v);
874  CHECK(s);
875  CHECK(b);
876  CHECK(p);
877  CHECK(r);
878  CHECK(c);
879  return get(v, s, b, p, r, c);
880  }
881 
883  Numeric& get( Index v, Index s, Index b,
884  Index p, Index r, Index c)
885  {
886  return *(mdata +
887  OFFSET(v) + OFFSET(s) + OFFSET(b) +
888  OFFSET(p) + OFFSET(r) + OFFSET(c) );
889  }
890 
891  // Conversion to a plain C-array
892  const Numeric *get_c_array() const;
893  Numeric *get_c_array();
894 
895  // Functions returning const iterators:
896  ConstIterator6D begin() const;
897  ConstIterator6D end() const;
898  // Functions returning iterators:
899  Iterator6D begin();
900  Iterator6D end();
901 
902  // Assignment operators:
903  Tensor6View& operator=(const ConstTensor6View& v);
904  Tensor6View& operator=(const Tensor6View& v);
905  Tensor6View& operator=(const Tensor6& v);
906  Tensor6View& operator=(Numeric x);
907 
908  // Other operators:
909  Tensor6View& operator*=(Numeric x);
910  Tensor6View& operator/=(Numeric x);
911  Tensor6View& operator+=(Numeric x);
912  Tensor6View& operator-=(Numeric x);
913 
914  Tensor6View& operator*=(const ConstTensor6View& x);
915  Tensor6View& operator/=(const ConstTensor6View& x);
916  Tensor6View& operator+=(const ConstTensor6View& x);
917  Tensor6View& operator-=(const ConstTensor6View& x);
918 
919  // Destructor:
920  virtual ~Tensor6View() {}
921 
922  // Friends:
923  friend class Iterator7D;
924  friend class Tensor7View;
925 
926  // Special constructor to make a Tensor6 view of a Tensor5.
927  Tensor6View(const Tensor5View& a);
928 
929 protected:
930  // Constructors:
931  Tensor6View();
932  Tensor6View(Numeric *data,
933  const Range& v, const Range& s, const Range& b,
934  const Range& p, const Range& r, const Range& c);
935  Tensor6View(Numeric *data,
936  const Range& pv, const Range& ps, const Range& pb,
937  const Range& pp, const Range& pr, const Range& pc,
938  const Range& nv, const Range& ns, const Range& nb,
939  const Range& np, const Range& nr, const Range& nc);
940 };
941 
950 class Tensor6 : public Tensor6View {
951 public:
952  // Constructors:
953  Tensor6();
954  Tensor6(Index v, Index s, Index b,
955  Index p, Index r, Index c);
956  Tensor6(Index v, Index s, Index b,
957  Index p, Index r, Index c,
958  Numeric fill);
959  Tensor6(const ConstTensor6View& v);
960  Tensor6(const Tensor6& v);
961 
962  // Assignment operators:
963  Tensor6& operator=(Tensor6 x);
964  Tensor6& operator=(Numeric x);
965 
966  // Resize function:
967  void resize(Index v, Index s, Index b,
968  Index p, Index r, Index c);
969 
970  // Swap function:
971  friend void swap(Tensor6& t1, Tensor6& t2);
972 
973  // Destructor:
974  virtual ~Tensor6();
975 };
976 
977 
978 // Function declarations:
979 // ----------------------
980 
981 void copy(ConstIterator6D origin,
982  const ConstIterator6D& end,
983  Iterator6D target);
984 
985 void copy(Numeric x,
986  Iterator6D target,
987  const Iterator6D& end);
988 
989 void transform( Tensor6View y,
990  double (&my_func)(double),
991  ConstTensor6View x );
992 
993 Numeric max(const ConstTensor6View& x);
994 
995 Numeric min(const ConstTensor6View& x);
996 
997 std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v);
998 
1000 // Helper function for debugging
1001 #ifndef NDEBUG
1002 
1004  Index p, Index r, Index c);
1005 
1006 #endif
1007 
1009 #endif // matpackVI_h
Index mstride
Stride.
Definition: matpackVI.h:86
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:262
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
#define OFFSET(x)
Definition: matpackVI.h:34
bool operator!=(const Iterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:56
void swap(Vector &v1, Vector &v2)
Swaps two objects.
Definition: matpackI.cc:813
The VectorView class.
Definition: matpackI.h:372
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:38
The Tensor4View class.
Definition: matpackIV.h:243
ConstTensor5View msv
Current position.
Definition: matpackVI.h:136
bool operator!=(const ConstIterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:108
A constant view of a Tensor7.
Definition: matpackVII.h:162
The Tensor7View class.
Definition: matpackVII.h:780
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:435
Index mstart
The start index.
Definition: matpackI.h:204
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Definition: matpackVI.h:386
The MatrixView class.
Definition: matpackI.h:679
A constant view of a Tensor6.
Definition: matpackVI.h:159
Tensor5View & operator*()
Dereferencing.
Definition: matpackVI.h:80
Iterator6D()
Default constructor.
Definition: matpackVI.h:42
The range class.
Definition: matpackI.h:148
Const version of Iterator6D.
Definition: matpackVI.h:90
Numeric min(const ConstTensor6View &x)
Min function, tensor version.
Definition: matpackVI.cc:3010
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVI.h:427
ConstIterator6D()
Default constructor.
Definition: matpackVI.h:94
The Tensor6View class.
Definition: matpackVI.h:449
void transform(Tensor6View y, double(&my_func)(double), ConstTensor6View x)
A generic transform function for tensors, which can be used to implement mathematical functions opera...
Definition: matpackVI.cc:2964
Index mstride
Stride.
Definition: matpackVI.h:138
A constant view of a Tensor4.
Definition: matpackIV.h:141
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:429
Tensor5View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:77
Numeric max(const ConstTensor6View &x)
Max function, tensor version.
Definition: matpackVI.cc:2988
virtual ~ConstTensor6View()
Definition: matpackVI.h:400
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:256
Range mpr
The page range of mdata that is actually used.
Definition: matpackV.h:258
Numeric debug_tensor6view_get_elem(Tensor6View &tv, Index v, Index s, Index b, Index p, Index r, Index c)
Helper function to access tensor elements.
Definition: matpackVI.cc:3053
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:264
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
The Tensor3View class.
Definition: matpackIII.h:232
const ConstTensor5View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:129
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:433
const ConstTensor5View & operator*() const
Dereferencing.
Definition: matpackVI.h:132
Iterator6D(const Tensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:45
ConstIterator6D(const ConstTensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:97
A constant view of a Tensor5.
Definition: matpackV.h:152
Tensor5View msv
Current position.
Definition: matpackVI.h:84
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Implementation of Tensors of Rank 7.
Definition: matpackVII.h:36
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:254
The Tensor5View class.
Definition: matpackV.h:276
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:437
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVI.h:425
Iterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:50
#define ns
Definition: continua.cc:21931
Const version of Iterator7D.
Definition: matpackVII.h:90
A constant view of a Tensor3.
Definition: matpackIII.h:139
The Tensor6 class.
Definition: matpackVI.h:950
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:260
A constant view of a Vector.
Definition: matpackI.h:292
Range mpr
The page range of mdata that is actually used.
Definition: matpackVI.h:431
A constant view of a Matrix.
Definition: matpackI.h:596
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2729
std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:1007
virtual ~Tensor6View()
Definition: matpackVI.h:920
ConstTensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Definition: matpackVI.cc:72
ConstIterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:102