ARTS  2.0.49
matpackVI.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2008 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 
46  { /* Nothing to do here. */ }
47 
49  Iterator6D(const Tensor5View& x, Index stride) : msv(x), mstride(stride)
50  { /* Nothing to do here. */ }
51 
52  // Operators:
54  Iterator6D& operator++() { msv.mdata += mstride; return *this; }
55 
60  bool operator!=(const Iterator6D& other) const
61  { if ( msv.mdata +
62  msv.msr.mstart +
63  msv.mbr.mstart +
64  msv.mpr.mstart +
65  msv.mrr.mstart +
66  msv.mcr.mstart
67  !=
68  other.msv.mdata +
69  other.msv.msr.mstart +
70  other.msv.mbr.mstart +
71  other.msv.mpr.mstart +
72  other.msv.mrr.mstart +
73  other.msv.mcr.mstart )
74  return true;
75  else
76  return false;
77  }
78 
81  Tensor5View* operator->() { return &msv; }
82 
84  Tensor5View& operator*() { return msv; }
85 
86 private:
91 };
92 
95 public:
96  // Constructors:
98  ConstIterator6D() : msv(), mstride(0) { /* Nothing to do here. */ }
99 
102  { /* Nothing to do here. */ }
103 
105  ConstIterator6D(const ConstTensor5View& x, Index stride) : msv(x), mstride(stride)
106  { /* Nothing to do here. */ }
107 
108  // Operators:
110  ConstIterator6D& operator++() { msv.mdata += mstride; return *this; }
111 
116  bool operator!=(const ConstIterator6D& other) const
117  { if ( msv.mdata +
118  msv.msr.mstart +
119  msv.mbr.mstart +
120  msv.mpr.mstart +
121  msv.mrr.mstart +
122  msv.mcr.mstart
123  !=
124  other.msv.mdata +
125  other.msv.msr.mstart +
126  other.msv.mbr.mstart +
127  other.msv.mpr.mstart +
128  other.msv.mrr.mstart +
129  other.msv.mcr.mstart )
130  return true;
131  else
132  return false;
133  }
134 
137  const ConstTensor5View* operator->() const { return &msv; }
138 
140  const ConstTensor5View& operator*() const { return msv; }
141 
142 private:
147 };
148 
149 
150 // Declare class Tensor6:
151 class Tensor6;
152 
153 
168 public:
169  // Member functions:
170  Index nvitrines() const;
171  Index nshelves() const;
172  Index nbooks() const;
173  Index npages() const;
174  Index nrows() const;
175  Index ncols() const;
176 
177  // Const index operators:
178 
179  // Result 6D (1 combination)
180  // ------
181  ConstTensor6View operator()( const Range& v, const Range& s, const Range& b,
182  const Range& p, const Range& r, const Range& c) const;
183 
184  // Result 5D (6 combinations)
185  // -----|
186  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
187  const Range& p, const Range& r, Index c) const;
188  // ----|-
189  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
190  const Range& p, Index r, const Range& c) const;
191  // ---|--
192  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
193  Index p, const Range& r, const Range& c) const;
194  // --|---
195  ConstTensor5View operator()( const Range& v, const Range& s, Index b,
196  const Range& p, const Range& r, const Range& c) const;
197  // -|----
198  ConstTensor5View operator()( const Range& v, Index s, const Range& b,
199  const Range& p, const Range& r, const Range& c) const;
200  // |-----
201  ConstTensor5View operator()( Index v, const Range& s, const Range& b,
202  const Range& p, const Range& r, const Range& c) const;
203 
204  // Result 4D (5+4+3+2+1 = 15 combinations)
205  // ----||
206  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
207  const Range& p, Index r, Index c) const;
208  // ---|-|
209  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
210  Index p, const Range& r, Index c) const;
211  // --|--|
212  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
213  const Range& p, const Range& r, Index c) const;
214  // -|---|
215  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
216  const Range& p, const Range& r, Index c) const;
217  // |----|
218  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
219  const Range& p, const Range& r, Index c) const;
220  // ---||-
221  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
222  Index p, Index r, const Range& c) const;
223  // --|-|-
224  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
225  const Range& p, Index r, const Range& c) const;
226  // -|--|-
227  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
228  const Range& p, Index r, const Range& c) const;
229  // |---|-
230  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
231  const Range& p, Index r, const Range& c) const;
232  // --||--
233  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
234  Index p, const Range& r, const Range& c) const;
235  // -|-|--
236  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
237  Index p, const Range& r, const Range& c) const;
238  // |--|--
239  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
240  Index p, const Range& r, const Range& c) const;
241  // -||---
242  ConstTensor4View operator()( const Range& v, Index s, Index b,
243  const Range& p, const Range& r, const Range& c) const;
244  // |-|---
245  ConstTensor4View operator()( Index v, const Range& s, Index b,
246  const Range& p, const Range& r, const Range& c) const;
247  // ||----
248  ConstTensor4View operator()( Index v, Index s, const Range& b,
249  const Range& p, const Range& r, const Range& c) const;
250 
251  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
252  // ---|||
253  ConstTensor3View operator()( const Range& v, const Range& s, const Range& b,
254  Index p, Index r, Index c) const;
255  // --|-||
256  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
257  const Range& p, Index r, Index c) const;
258  // -|--||
259  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
260  const Range& p, Index r, Index c) const;
261  // |---||
262  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
263  const Range& p, Index r, Index c) const;
264  // --||-|
265  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
266  Index p, const Range& r, Index c) const;
267  // -|-|-|
268  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
269  Index p, const Range& r, Index c) const;
270  // |--|-|
271  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
272  Index p, const Range& r, Index c) const;
273  // -||--|
274  ConstTensor3View operator()( const Range& v, Index s, Index b,
275  const Range& p, const Range& r, Index c) const;
276  // |-|--|
277  ConstTensor3View operator()( Index v, const Range& s, Index b,
278  const Range& p, const Range& r, Index c) const;
279  // ||---|
280  ConstTensor3View operator()( Index v, Index s, const Range& b,
281  const Range& p, const Range& r, Index c) const;
282  // --|||-
283  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
284  Index p, Index r, const Range& c) const;
285  // -|-||-
286  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
287  Index p, Index r, const Range& c) const;
288  // |--||-
289  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
290  Index p, Index r, const Range& c) const;
291  // -||-|-
292  ConstTensor3View operator()( const Range& v, Index s, Index b,
293  const Range& p, Index r, const Range& c) const;
294  // |-|-|-
295  ConstTensor3View operator()( Index v, const Range& s, Index b,
296  const Range& p, Index r, const Range& c) const;
297  // ||--|-
298  ConstTensor3View operator()( Index v, Index s, const Range& b,
299  const Range& p, Index r, const Range& c) const;
300  // -|||--
301  ConstTensor3View operator()( const Range& v, Index s, Index b,
302  Index p, const Range& r, const Range& c) const;
303  // |-||--
304  ConstTensor3View operator()( Index v, const Range& s, Index b,
305  Index p, const Range& r, const Range& c) const;
306  // ||-|--
307  ConstTensor3View operator()( Index v, Index s, const Range& b,
308  Index p, const Range& r, const Range& c) const;
309  // |||---
311  const Range& p, const Range& r, const Range& c) const;
312 
313  // Result 2D (15 combinations)
314  // IIII--
316  Index p, const Range& r, const Range& c) const;
317  // III-I-
319  const Range& p, Index r, const Range& c) const;
320  // II-II-
321  ConstMatrixView operator()( Index v, Index s, const Range& b,
322  Index p, Index r, const Range& c) const;
323  // I-III-
324  ConstMatrixView operator()( Index v, const Range& s, Index b,
325  Index p, Index r, const Range& c) const;
326  // -IIII-
327  ConstMatrixView operator()( const Range& v, Index s, Index b,
328  Index p, Index r, const Range& c) const;
329  // III--I
331  const Range& p, const Range& r, Index c) const;
332  // II-I-I
333  ConstMatrixView operator()( Index v, Index s, const Range& b,
334  Index p, const Range& r, Index c) const;
335  // I-II-I
336  ConstMatrixView operator()( Index v, const Range& s, Index b,
337  Index p, const Range& r, Index c) const;
338  // -III-I
339  ConstMatrixView operator()( const Range& v, Index s, Index b,
340  Index p, const Range& r, Index c) const;
341  // II--II
342  ConstMatrixView operator()( Index v, Index s, const Range& b,
343  const Range& p, Index r, Index c) const;
344  // I-I-II
345  ConstMatrixView operator()( Index v, const Range& s, Index b,
346  const Range& p, Index r, Index c) const;
347  // -II-II
348  ConstMatrixView operator()( const Range& v, Index s, Index b,
349  const Range& p, Index r, Index c) const;
350  // I--III
351  ConstMatrixView operator()( Index v, const Range& s, const Range& b,
352  Index p, Index r, Index c) const;
353  // -I-III
354  ConstMatrixView operator()( const Range& v, Index s, const Range& b,
355  Index p, Index r, Index c) const;
356  // --IIII
357  ConstMatrixView operator()( const Range& v, const Range& s, Index b,
358  Index p, Index r, Index c) const;
359 
360  // Result 1D (6 combinations)
361  // IIIII-
363  Index p, Index r, const Range& c) const;
364  // IIII-I
366  Index p, const Range& r, Index c) const;
367  // III-II
369  const Range& p, Index r, Index c) const;
370  // II-III
371  ConstVectorView operator()( Index v, Index s, const Range& b,
372  Index p, Index r, Index c) const;
373  // I-IIII
374  ConstVectorView operator()( Index v, const Range& s, Index b,
375  Index p, Index r, Index c) const;
376  // -IIIII
377  ConstVectorView operator()( const Range& v, Index s, Index b,
378  Index p, Index r, Index c) const;
379 
380  // Result scalar (1 combination)
381  // IIIIII
383  Index p, Index r, Index c) const
384  { CHECK(v);
385  CHECK(s);
386  CHECK(b);
387  CHECK(p);
388  CHECK(r);
389  CHECK(c);
390  return *(mdata +
391  OFFSET(v) + OFFSET(s) + OFFSET(b) +
392  OFFSET(p) + OFFSET(r) + OFFSET(c) );
393  }
394 
395 
396  // Functions returning iterators:
397  ConstIterator6D begin() const;
398  ConstIterator6D end() const;
399 
400  // Destructor:
401  virtual ~ConstTensor6View() {}
402 
403  // Friends:
404  friend class ConstIterator7D;
405  friend class Tensor6View;
406  friend class ConstTensor7View;
407 
408  // Special constructor to make a Tensor6 view of a Tensor5.
410 
411 protected:
412  // Constructors:
415  const Range& v, const Range& s, const Range& b,
416  const Range& p, const Range& r, const Range& c);
418  const Range& pv, const Range& ps, const Range& pb,
419  const Range& pp, const Range& pr, const Range& pc,
420  const Range& nv, const Range& ns, const Range& nb,
421  const Range& np, const Range& nr, const Range& nc);
422 
423  // Data members:
424  // -------------
439 };
440 
451 public:
452 
453  // Const index operators:
454 
455  // Result 6D (1 combination)
456  // ------
457  ConstTensor6View operator()( const Range& v, const Range& s, const Range& b,
458  const Range& p, const Range& r, const Range& c) const;
459 
460  // Result 5D (6 combinations)
461  // -----|
462  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
463  const Range& p, const Range& r, Index c) const;
464  // ----|-
465  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
466  const Range& p, Index r, const Range& c) const;
467  // ---|--
468  ConstTensor5View operator()( const Range& v, const Range& s, const Range& b,
469  Index p, const Range& r, const Range& c) const;
470  // --|---
471  ConstTensor5View operator()( const Range& v, const Range& s, Index b,
472  const Range& p, const Range& r, const Range& c) const;
473  // -|----
474  ConstTensor5View operator()( const Range& v, Index s, const Range& b,
475  const Range& p, const Range& r, const Range& c) const;
476  // |-----
477  ConstTensor5View operator()( Index v, const Range& s, const Range& b,
478  const Range& p, const Range& r, const Range& c) const;
479 
480  // Result 4D (5+4+3+2+1 = 15 combinations)
481  // ----||
482  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
483  const Range& p, Index r, Index c) const;
484  // ---|-|
485  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
486  Index p, const Range& r, Index c) const;
487  // --|--|
488  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
489  const Range& p, const Range& r, Index c) const;
490  // -|---|
491  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
492  const Range& p, const Range& r, Index c) const;
493  // |----|
494  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
495  const Range& p, const Range& r, Index c) const;
496  // ---||-
497  ConstTensor4View operator()( const Range& v, const Range& s, const Range& b,
498  Index p, Index r, const Range& c) const;
499  // --|-|-
500  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
501  const Range& p, Index r, const Range& c) const;
502  // -|--|-
503  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
504  const Range& p, Index r, const Range& c) const;
505  // |---|-
506  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
507  const Range& p, Index r, const Range& c) const;
508  // --||--
509  ConstTensor4View operator()( const Range& v, const Range& s, Index b,
510  Index p, const Range& r, const Range& c) const;
511  // -|-|--
512  ConstTensor4View operator()( const Range& v, Index s, const Range& b,
513  Index p, const Range& r, const Range& c) const;
514  // |--|--
515  ConstTensor4View operator()( Index v, const Range& s, const Range& b,
516  Index p, const Range& r, const Range& c) const;
517  // -||---
518  ConstTensor4View operator()( const Range& v, Index s, Index b,
519  const Range& p, const Range& r, const Range& c) const;
520  // |-|---
521  ConstTensor4View operator()( Index v, const Range& s, Index b,
522  const Range& p, const Range& r, const Range& c) const;
523  // ||----
524  ConstTensor4View operator()( Index v, Index s, const Range& b,
525  const Range& p, const Range& r, const Range& c) const;
526 
527  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
528  // ---|||
529  ConstTensor3View operator()( const Range& v, const Range& s, const Range& b,
530  Index p, Index r, Index c) const;
531  // --|-||
532  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
533  const Range& p, Index r, Index c) const;
534  // -|--||
535  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
536  const Range& p, Index r, Index c) const;
537  // |---||
538  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
539  const Range& p, Index r, Index c) const;
540  // --||-|
541  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
542  Index p, const Range& r, Index c) const;
543  // -|-|-|
544  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
545  Index p, const Range& r, Index c) const;
546  // |--|-|
547  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
548  Index p, const Range& r, Index c) const;
549  // -||--|
550  ConstTensor3View operator()( const Range& v, Index s, Index b,
551  const Range& p, const Range& r, Index c) const;
552  // |-|--|
553  ConstTensor3View operator()( Index v, const Range& s, Index b,
554  const Range& p, const Range& r, Index c) const;
555  // ||---|
556  ConstTensor3View operator()( Index v, Index s, const Range& b,
557  const Range& p, const Range& r, Index c) const;
558  // --|||-
559  ConstTensor3View operator()( const Range& v, const Range& s, Index b,
560  Index p, Index r, const Range& c) const;
561  // -|-||-
562  ConstTensor3View operator()( const Range& v, Index s, const Range& b,
563  Index p, Index r, const Range& c) const;
564  // |--||-
565  ConstTensor3View operator()( Index v, const Range& s, const Range& b,
566  Index p, Index r, const Range& c) const;
567  // -||-|-
568  ConstTensor3View operator()( const Range& v, Index s, Index b,
569  const Range& p, Index r, const Range& c) const;
570  // |-|-|-
571  ConstTensor3View operator()( Index v, const Range& s, Index b,
572  const Range& p, Index r, const Range& c) const;
573  // ||--|-
574  ConstTensor3View operator()( Index v, Index s, const Range& b,
575  const Range& p, Index r, const Range& c) const;
576  // -|||--
577  ConstTensor3View operator()( const Range& v, Index s, Index b,
578  Index p, const Range& r, const Range& c) const;
579  // |-||--
580  ConstTensor3View operator()( Index v, const Range& s, Index b,
581  Index p, const Range& r, const Range& c) const;
582  // ||-|--
583  ConstTensor3View operator()( Index v, Index s, const Range& b,
584  Index p, const Range& r, const Range& c) const;
585  // |||---
587  const Range& p, const Range& r, const Range& c) const;
588 
589  // Result 2D (15 combinations)
590  // IIII--
592  Index p, const Range& r, const Range& c) const;
593  // III-I-
595  const Range& p, Index r, const Range& c) const;
596  // II-II-
597  ConstMatrixView operator()( Index v, Index s, const Range& b,
598  Index p, Index r, const Range& c) const;
599  // I-III-
600  ConstMatrixView operator()( Index v, const Range& s, Index b,
601  Index p, Index r, const Range& c) const;
602  // -IIII-
603  ConstMatrixView operator()( const Range& v, Index s, Index b,
604  Index p, Index r, const Range& c) const;
605  // III--I
607  const Range& p, const Range& r, Index c) const;
608  // II-I-I
609  ConstMatrixView operator()( Index v, Index s, const Range& b,
610  Index p, const Range& r, Index c) const;
611  // I-II-I
612  ConstMatrixView operator()( Index v, const Range& s, Index b,
613  Index p, const Range& r, Index c) const;
614  // -III-I
615  ConstMatrixView operator()( const Range& v, Index s, Index b,
616  Index p, const Range& r, Index c) const;
617  // II--II
618  ConstMatrixView operator()( Index v, Index s, const Range& b,
619  const Range& p, Index r, Index c) const;
620  // I-I-II
621  ConstMatrixView operator()( Index v, const Range& s, Index b,
622  const Range& p, Index r, Index c) const;
623  // -II-II
624  ConstMatrixView operator()( const Range& v, Index s, Index b,
625  const Range& p, Index r, Index c) const;
626  // I--III
627  ConstMatrixView operator()( Index v, const Range& s, const Range& b,
628  Index p, Index r, Index c) const;
629  // -I-III
630  ConstMatrixView operator()( const Range& v, Index s, const Range& b,
631  Index p, Index r, Index c) const;
632  // --IIII
633  ConstMatrixView operator()( const Range& v, const Range& s, Index b,
634  Index p, Index r, Index c) const;
635 
636  // Result 1D (6 combinations)
637  // IIIII-
639  Index p, Index r, const Range& c) const;
640  // IIII-I
642  Index p, const Range& r, Index c) const;
643  // III-II
645  const Range& p, Index r, Index c) const;
646  // II-III
647  ConstVectorView operator()( Index v, Index s, const Range& b,
648  Index p, Index r, Index c) const;
649  // I-IIII
650  ConstVectorView operator()( Index v, const Range& s, Index b,
651  Index p, Index r, Index c) const;
652  // -IIIII
653  ConstVectorView operator()( const Range& v, Index s, Index b,
654  Index p, Index r, Index c) const;
655 
656  // Result scalar (1 combination)
657  // IIIIII
659  Index p, Index r, Index c) const
660  { return ConstTensor6View::operator()(v,s,b,p,r,c); }
661 
662 
663  // Non-const index operators:
664 
665  // Result 6D (1 combination)
666  // ------
667  Tensor6View operator()( const Range& v, const Range& s, const Range& b,
668  const Range& p, const Range& r, const Range& c);
669 
670  // Result 5D (6 combinations)
671  // -----|
672  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
673  const Range& p, const Range& r, Index c);
674  // ----|-
675  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
676  const Range& p, Index r, const Range& c);
677  // ---|--
678  Tensor5View operator()( const Range& v, const Range& s, const Range& b,
679  Index p, const Range& r, const Range& c);
680  // --|---
681  Tensor5View operator()( const Range& v, const Range& s, Index b,
682  const Range& p, const Range& r, const Range& c);
683  // -|----
684  Tensor5View operator()( const Range& v, Index s, const Range& b,
685  const Range& p, const Range& r, const Range& c);
686  // |-----
687  Tensor5View operator()( Index v, const Range& s, const Range& b,
688  const Range& p, const Range& r, const Range& c);
689 
690  // Result 4D (5+4+3+2+1 = 15 combinations)
691  // ----||
692  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
693  const Range& p, Index r, Index c);
694  // ---|-|
695  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
696  Index p, const Range& r, Index c);
697  // --|--|
698  Tensor4View operator()( const Range& v, const Range& s, Index b,
699  const Range& p, const Range& r, Index c);
700  // -|---|
701  Tensor4View operator()( const Range& v, Index s, const Range& b,
702  const Range& p, const Range& r, Index c);
703  // |----|
704  Tensor4View operator()( Index v, const Range& s, const Range& b,
705  const Range& p, const Range& r, Index c);
706  // ---||-
707  Tensor4View operator()( const Range& v, const Range& s, const Range& b,
708  Index p, Index r, const Range& c);
709  // --|-|-
710  Tensor4View operator()( const Range& v, const Range& s, Index b,
711  const Range& p, Index r, const Range& c);
712  // -|--|-
713  Tensor4View operator()( const Range& v, Index s, const Range& b,
714  const Range& p, Index r, const Range& c);
715  // |---|-
716  Tensor4View operator()( Index v, const Range& s, const Range& b,
717  const Range& p, Index r, const Range& c);
718  // --||--
719  Tensor4View operator()( const Range& v, const Range& s, Index b,
720  Index p, const Range& r, const Range& c);
721  // -|-|--
722  Tensor4View operator()( const Range& v, Index s, const Range& b,
723  Index p, const Range& r, const Range& c);
724  // |--|--
725  Tensor4View operator()( Index v, const Range& s, const Range& b,
726  Index p, const Range& r, const Range& c);
727  // -||---
728  Tensor4View operator()( const Range& v, Index s, Index b,
729  const Range& p, const Range& r, const Range& c);
730  // |-|---
731  Tensor4View operator()( Index v, const Range& s, Index b,
732  const Range& p, const Range& r, const Range& c);
733  // ||----
734  Tensor4View operator()( Index v, Index s, const Range& b,
735  const Range& p, const Range& r, const Range& c);
736 
737  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
738  // ---|||
739  Tensor3View operator()( const Range& v, const Range& s, const Range& b,
740  Index p, Index r, Index c);
741  // --|-||
742  Tensor3View operator()( const Range& v, const Range& s, Index b,
743  const Range& p, Index r, Index c);
744  // -|--||
745  Tensor3View operator()( const Range& v, Index s, const Range& b,
746  const Range& p, Index r, Index c);
747  // |---||
748  Tensor3View operator()( Index v, const Range& s, const Range& b,
749  const Range& p, Index r, Index c);
750  // --||-|
751  Tensor3View operator()( const Range& v, const Range& s, Index b,
752  Index p, const Range& r, Index c);
753  // -|-|-|
754  Tensor3View operator()( const Range& v, Index s, const Range& b,
755  Index p, const Range& r, Index c);
756  // |--|-|
757  Tensor3View operator()( Index v, const Range& s, const Range& b,
758  Index p, const Range& r, Index c);
759  // -||--|
760  Tensor3View operator()( const Range& v, Index s, Index b,
761  const Range& p, const Range& r, Index c);
762  // |-|--|
763  Tensor3View operator()( Index v, const Range& s, Index b,
764  const Range& p, const Range& r, Index c);
765  // ||---|
766  Tensor3View operator()( Index v, Index s, const Range& b,
767  const Range& p, const Range& r, Index c);
768  // --|||-
769  Tensor3View operator()( const Range& v, const Range& s, Index b,
770  Index p, Index r, const Range& c);
771  // -|-||-
772  Tensor3View operator()( const Range& v, Index s, const Range& b,
773  Index p, Index r, const Range& c);
774  // |--||-
775  Tensor3View operator()( Index v, const Range& s, const Range& b,
776  Index p, Index r, const Range& c);
777  // -||-|-
778  Tensor3View operator()( const Range& v, Index s, Index b,
779  const Range& p, Index r, const Range& c);
780  // |-|-|-
781  Tensor3View operator()( Index v, const Range& s, Index b,
782  const Range& p, Index r, const Range& c);
783  // ||--|-
784  Tensor3View operator()( Index v, Index s, const Range& b,
785  const Range& p, Index r, const Range& c);
786  // -|||--
787  Tensor3View operator()( const Range& v, Index s, Index b,
788  Index p, const Range& r, const Range& c);
789  // |-||--
790  Tensor3View operator()( Index v, const Range& s, Index b,
791  Index p, const Range& r, const Range& c);
792  // ||-|--
793  Tensor3View operator()( Index v, Index s, const Range& b,
794  Index p, const Range& r, const Range& c);
795  // |||---
797  const Range& p, const Range& r, const Range& c);
798 
799  // Result 2D (15 combinations)
800  // IIII--
802  Index p, const Range& r, const Range& c);
803  // III-I-
805  const Range& p, Index r, const Range& c);
806  // II-II-
807  MatrixView operator()( Index v, Index s, const Range& b,
808  Index p, Index r, const Range& c);
809  // I-III-
810  MatrixView operator()( Index v, const Range& s, Index b,
811  Index p, Index r, const Range& c);
812  // -IIII-
813  MatrixView operator()( const Range& v, Index s, Index b,
814  Index p, Index r, const Range& c);
815  // III--I
817  const Range& p, const Range& r, Index c);
818  // II-I-I
819  MatrixView operator()( Index v, Index s, const Range& b,
820  Index p, const Range& r, Index c);
821  // I-II-I
822  MatrixView operator()( Index v, const Range& s, Index b,
823  Index p, const Range& r, Index c);
824  // -III-I
825  MatrixView operator()( const Range& v, Index s, Index b,
826  Index p, const Range& r, Index c);
827  // II--II
828  MatrixView operator()( Index v, Index s, const Range& b,
829  const Range& p, Index r, Index c);
830  // I-I-II
831  MatrixView operator()( Index v, const Range& s, Index b,
832  const Range& p, Index r, Index c);
833  // -II-II
834  MatrixView operator()( const Range& v, Index s, Index b,
835  const Range& p, Index r, Index c);
836  // I--III
837  MatrixView operator()( Index v, const Range& s, const Range& b,
838  Index p, Index r, Index c);
839  // -I-III
840  MatrixView operator()( const Range& v, Index s, const Range& b,
841  Index p, Index r, Index c);
842  // --IIII
843  MatrixView operator()( const Range& v, const Range& s, Index b,
844  Index p, Index r, Index c);
845 
846  // Result 1D (6 combinations)
847  // IIIII-
849  Index p, Index r, const Range& c);
850  // IIII-I
852  Index p, const Range& r, Index c);
853  // III-II
855  const Range& p, Index r, Index c);
856  // II-III
857  VectorView operator()( Index v, Index s, const Range& b,
858  Index p, Index r, Index c);
859  // I-IIII
860  VectorView operator()( Index v, const Range& s, Index b,
861  Index p, Index r, Index c);
862  // -IIIII
863  VectorView operator()( const Range& v, Index s, Index b,
864  Index p, Index r, Index c);
865 
866  // Result scalar (1 combination)
867  // IIIIII
869  Index p, Index r, Index c)
870  { CHECK(v);
871  CHECK(s);
872  CHECK(b);
873  CHECK(p);
874  CHECK(r);
875  CHECK(c);
876  return *(mdata +
877  OFFSET(v) + OFFSET(s) + OFFSET(b) +
878  OFFSET(p) + OFFSET(r) + OFFSET(c) );
879  }
880 
881 
882  // Functions returning const iterators:
883  ConstIterator6D begin() const;
884  ConstIterator6D end() const;
885  // Functions returning iterators:
886  Iterator6D begin();
887  Iterator6D end();
888 
889  // Assignment operators:
891  Tensor6View& operator=(const Tensor6View& v);
892  Tensor6View& operator=(const Tensor6& v);
894 
895  // Other operators:
900 
905 
906  // Destructor:
907  virtual ~Tensor6View() {}
908 
909  // Friends:
910  friend class Iterator7D;
911  friend class Tensor7View;
912 
913  // Special constructor to make a Tensor6 view of a Tensor5.
914  Tensor6View(const Tensor5View& a);
915 
916 protected:
917  // Constructors:
918  Tensor6View();
919  Tensor6View(Numeric *data,
920  const Range& v, const Range& s, const Range& b,
921  const Range& p, const Range& r, const Range& c);
922  Tensor6View(Numeric *data,
923  const Range& pv, const Range& ps, const Range& pb,
924  const Range& pp, const Range& pr, const Range& pc,
925  const Range& nv, const Range& ns, const Range& nb,
926  const Range& np, const Range& nr, const Range& nc);
927 };
928 
937 class Tensor6 : public Tensor6View {
938 public:
939  // Constructors:
940  Tensor6();
941  Tensor6(Index v, Index s, Index b,
942  Index p, Index r, Index c);
943  Tensor6(Index v, Index s, Index b,
944  Index p, Index r, Index c,
945  Numeric fill);
946  Tensor6(const ConstTensor6View& v);
947  Tensor6(const Tensor6& v);
948 
949  // Assignment operators:
950  Tensor6& operator=(const Tensor6& x);
952 
953  // Resize function:
954  void resize(Index v, Index s, Index b,
955  Index p, Index r, Index c);
956 
957  // Destructor:
958  virtual ~Tensor6();
959 };
960 
961 
962 // Function declarations:
963 // ----------------------
964 
965 void copy(ConstIterator6D origin,
966  const ConstIterator6D& end,
967  Iterator6D target);
968 
969 void copy(Numeric x,
970  Iterator6D target,
971  const Iterator6D& end);
972 
973 void transform( Tensor6View y,
974  double (&my_func)(double),
975  ConstTensor6View x );
976 
977 Numeric max(const ConstTensor6View& x);
978 
979 Numeric min(const ConstTensor6View& x);
980 
981 ostream& operator<<(ostream& os, const ConstTensor6View& v);
982 
984 // Helper function for debugging
985 #ifndef NDEBUG
986 
988  Index p, Index r, Index c);
989 
990 #endif
991 
993 #endif // matpackVI_h
ConstIterator6D::ConstIterator6D
ConstIterator6D(const ConstIterator6D &o)
Copy constructor.
Definition: matpackVI.h:101
ConstIterator7D
Const version of Iterator7D.
Definition: matpackVII.h:93
Tensor7View
The Tensor7View class.
Definition: matpackVII.h:779
Iterator6D::Iterator6D
Iterator6D()
Default constructor.
Definition: matpackVI.h:42
ConstTensor6View::begin
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:898
ConstTensor6View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:37
MatrixView
The MatrixView class.
Definition: matpackI.h:668
ConstIterator6D::operator->
const ConstTensor5View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:137
Tensor6::resize
void resize(Index v, Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackVI.cc:2845
ConstTensor6View::mvr
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVI.h:426
ConstTensor6View::mbr
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:430
ConstTensor6View::npages
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:49
ConstTensor7View
A constant view of a Tensor7.
Definition: matpackVII.h:169
Iterator6D::msv
Tensor5View msv
Current position.
Definition: matpackVI.h:88
OFFSET
#define OFFSET(x)
Definition: matpackVI.h:34
Iterator6D::operator!=
bool operator!=(const Iterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:60
ConstTensor5View::mbr
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:258
Iterator7D
Implementation of Tensors of Rank 7.
Definition: matpackVII.h:35
ConstIterator6D::ConstIterator6D
ConstIterator6D(const ConstTensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:105
Tensor6::operator=
Tensor6 & operator=(const Tensor6 &x)
Assignment operator from another tensor.
Definition: matpackVI.cc:2823
ConstTensor6View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:55
Tensor6View::operator/=
Tensor6View & operator/=(Numeric x)
Division by scalar.
Definition: matpackVI.cc:2497
ConstIterator6D::operator++
ConstIterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:110
Iterator6D::operator++
Iterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:54
Range::mstart
Index mstart
The start index.
Definition: matpackI.h:204
ConstTensor5View::msr
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:256
min
Numeric min(const ConstTensor6View &x)
Min function, tensor version.
Definition: matpackVI.cc:2962
CHECK
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
ConstTensor6View::mrr
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:434
Tensor6View::operator+=
Tensor6View & operator+=(Numeric x)
Addition of scalar.
Definition: matpackVI.cc:2508
Iterator6D::mstride
Index mstride
Stride.
Definition: matpackVI.h:90
ConstTensor4View
A constant view of a Tensor4.
Definition: matpackIV.h:149
Tensor3View
The Tensor3View class.
Definition: matpackIII.h:234
Tensor6View::operator*=
Tensor6View & operator*=(Numeric x)
Multiplication by scalar.
Definition: matpackVI.cc:2486
operator<<
ostream & operator<<(ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:1006
Tensor6View::operator-=
Tensor6View & operator-=(Numeric x)
Subtraction of scalar.
Definition: matpackVI.cc:2519
Tensor6View::operator()
ConstTensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Definition: matpackVI.cc:1036
ConstTensor6View::nvitrines
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:31
Iterator6D::operator*
Tensor5View & operator*()
Dereferencing.
Definition: matpackVI.h:84
ConstTensor6View::mdata
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:438
ConstTensor6View::mpr
Range mpr
The page range of mdata that is actually used.
Definition: matpackVI.h:432
ConstIterator6D
Const version of Iterator6D.
Definition: matpackVI.h:94
ConstTensor6View::end
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:910
Tensor6View::Tensor6View
Tensor6View()
Default constructor.
Definition: matpackVI.cc:2625
Tensor6View::end
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:2390
ConstTensor5View::mrr
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:262
VectorView
The VectorView class.
Definition: matpackI.h:373
ConstTensor6View::msr
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVI.h:428
ns
#define ns
Definition: continua.cc:14564
debug_tensor6view_get_elem
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:3005
ConstTensor6View
A constant view of a Tensor6.
Definition: matpackVI.h:167
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Tensor5View
The Tensor5View class.
Definition: matpackV.h:278
ConstTensor6View::operator()
ConstTensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Definition: matpackVI.cc:71
Iterator6D::Iterator6D
Iterator6D(const Iterator6D &o)
Copy constructor.
Definition: matpackVI.h:45
ConstIterator6D::msv
ConstTensor5View msv
Current position.
Definition: matpackVI.h:144
ConstIterator6D::operator!=
bool operator!=(const ConstIterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:116
ConstTensor5View::mcr
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:264
Iterator6D::operator->
Tensor5View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:81
Tensor6View::operator=
Tensor6View & operator=(const ConstTensor6View &v)
Assignment operator.
Definition: matpackVI.cc:2424
Iterator6D
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:38
ConstTensor6View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:43
ConstMatrixView
A constant view of a Matrix.
Definition: matpackI.h:591
ConstTensor6View::~ConstTensor6View
virtual ~ConstTensor6View()
Definition: matpackVI.h:401
Range
The range class.
Definition: matpackI.h:148
ConstTensor6View::ConstTensor6View
ConstTensor6View()
Default constructor.
Definition: matpackVI.cc:942
matpackV.h
ConstTensor5View::mpr
Range mpr
The page range of mdata that is actually used.
Definition: matpackV.h:260
ConstTensor6View::mcr
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:436
ConstTensor3View
A constant view of a Tensor3.
Definition: matpackIII.h:147
Tensor6View::~Tensor6View
virtual ~Tensor6View()
Definition: matpackVI.h:907
Tensor4View
The Tensor4View class.
Definition: matpackIV.h:245
ConstIterator6D::operator*
const ConstTensor5View & operator*() const
Dereferencing.
Definition: matpackVI.h:140
transform
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:2916
ConstTensor5View::mdata
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:266
ConstIterator6D::mstride
Index mstride
Stride.
Definition: matpackVI.h:146
copy
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2690
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Tensor6View::begin
ConstIterator6D begin() const
Return const iterator to sub-tensor.
Definition: matpackVI.cc:2384
Tensor6
The Tensor6 class.
Definition: matpackVI.h:937
max
Numeric max(const ConstTensor6View &x)
Max function, tensor version.
Definition: matpackVI.cc:2940
Tensor6::~Tensor6
virtual ~Tensor6()
Destructor for Tensor6.
Definition: matpackVI.cc:2893
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:300
Iterator6D::Iterator6D
Iterator6D(const Tensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:49
ConstTensor6View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:61
Tensor6::Tensor6
Tensor6()
Default constructor.
Definition: matpackVI.cc:2722
ConstTensor5View
A constant view of a Tensor5.
Definition: matpackV.h:160
Tensor6View
The Tensor6View class.
Definition: matpackVI.h:450
ConstIterator6D::ConstIterator6D
ConstIterator6D()
Default constructor.
Definition: matpackVI.h:98