ARTS  2.3.1285(git:92a29ea9-dirty)
matpackVI.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-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 
25 #include "matpackVI.h"
26 #include "exceptions.h"
27 
28 // Functions for ConstTensor6View:
29 // ------------------------------
30 
32 
37  return (nvitrines() == 0 || nshelves() == 0 || nbooks() == 0 ||
38  npages() == 0 || nrows() == 0 || ncols() == 0);
39 }
40 
43 
46 
49 
52 
55 
58 
59 // Const index operators:
60 
61 // Result 6D (1 combination)
62 // ------
64  const Range& s,
65  const Range& b,
66  const Range& p,
67  const Range& r,
68  const Range& c) const {
69  return ConstTensor6View(
70  mdata, mvr, msr, mbr, mpr, mrr, mcr, v, s, b, p, r, c);
71 }
72 
73 // Result 5D (6 combinations)
74 // -----|
76  const Range& s,
77  const Range& b,
78  const Range& p,
79  const Range& r,
80  Index c) const {
81  CHECK(c);
82  return ConstTensor5View(
83  mdata + OFFSET(c), mvr, msr, mbr, mpr, mrr, v, s, b, p, r);
84 }
85 
86 // ----|-
88  const Range& s,
89  const Range& b,
90  const Range& p,
91  Index r,
92  const Range& c) const {
93  CHECK(r);
94  return ConstTensor5View(
95  mdata + OFFSET(r), mvr, msr, mbr, mpr, mcr, v, s, b, p, c);
96 }
97 
98 // ---|--
100  const Range& s,
101  const Range& b,
102  Index p,
103  const Range& r,
104  const Range& c) const {
105  CHECK(p);
106  return ConstTensor5View(
107  mdata + OFFSET(p), mvr, msr, mbr, mrr, mcr, v, s, b, r, c);
108 }
109 
110 // --|---
112  const Range& s,
113  Index b,
114  const Range& p,
115  const Range& r,
116  const Range& c) const {
117  CHECK(b);
118  return ConstTensor5View(
119  mdata + OFFSET(b), mvr, msr, mpr, mrr, mcr, v, s, p, r, c);
120 }
121 
122 // -|----
124  Index s,
125  const Range& b,
126  const Range& p,
127  const Range& r,
128  const Range& c) const {
129  CHECK(s);
130  return ConstTensor5View(
131  mdata + OFFSET(s), mvr, mbr, mpr, mrr, mcr, v, b, p, r, c);
132 }
133 
134 // |-----
136  const Range& s,
137  const Range& b,
138  const Range& p,
139  const Range& r,
140  const Range& c) const {
141  CHECK(v);
142  return ConstTensor5View(
143  mdata + OFFSET(v), msr, mbr, mpr, mrr, mcr, s, b, p, r, c);
144 }
145 
146 // Result 4D (5+4+3+2+1 = 15 combinations)
147 // ----||
149  const Range& s,
150  const Range& b,
151  const Range& p,
152  Index r,
153  Index c) const {
154  CHECK(r);
155  CHECK(c);
156  return ConstTensor4View(
157  mdata + OFFSET(r) + OFFSET(c), mvr, msr, mbr, mpr, v, s, b, p);
158 }
159 
160 // ---|-|
162  const Range& s,
163  const Range& b,
164  Index p,
165  const Range& r,
166  Index c) const {
167  CHECK(p);
168  CHECK(c);
169  return ConstTensor4View(
170  mdata + OFFSET(p) + OFFSET(c), mvr, msr, mbr, mrr, v, s, b, r);
171 }
172 
173 // --|--|
175  const Range& s,
176  Index b,
177  const Range& p,
178  const Range& r,
179  Index c) const {
180  CHECK(b);
181  CHECK(c);
182  return ConstTensor4View(
183  mdata + OFFSET(b) + OFFSET(c), mvr, msr, mpr, mrr, v, s, p, r);
184 }
185 
186 // -|---|
188  Index s,
189  const Range& b,
190  const Range& p,
191  const Range& r,
192  Index c) const {
193  CHECK(s);
194  CHECK(c);
195  return ConstTensor4View(
196  mdata + OFFSET(s) + OFFSET(c), mvr, mbr, mpr, mrr, v, b, p, r);
197 }
198 
199 // |----|
201  const Range& s,
202  const Range& b,
203  const Range& p,
204  const Range& r,
205  Index c) const {
206  CHECK(v);
207  CHECK(c);
208  return ConstTensor4View(
209  mdata + OFFSET(v) + OFFSET(c), msr, mbr, mpr, mrr, s, b, p, r);
210 }
211 
212 // ---||-
214  const Range& s,
215  const Range& b,
216  Index p,
217  Index r,
218  const Range& c) const {
219  CHECK(p);
220  CHECK(r);
221  return ConstTensor4View(
222  mdata + OFFSET(p) + OFFSET(r), mvr, msr, mbr, mcr, v, s, b, c);
223 }
224 
225 // --|-|-
227  const Range& s,
228  Index b,
229  const Range& p,
230  Index r,
231  const Range& c) const {
232  CHECK(b);
233  CHECK(r);
234  return ConstTensor4View(
235  mdata + OFFSET(b) + OFFSET(r), mvr, msr, mpr, mcr, v, s, p, c);
236 }
237 
238 // -|--|-
240  Index s,
241  const Range& b,
242  const Range& p,
243  Index r,
244  const Range& c) const {
245  CHECK(s);
246  CHECK(r);
247  return ConstTensor4View(
248  mdata + OFFSET(s) + OFFSET(r), mvr, mbr, mpr, mcr, v, b, p, c);
249 }
250 
251 // |---|-
253  const Range& s,
254  const Range& b,
255  const Range& p,
256  Index r,
257  const Range& c) const {
258  CHECK(v);
259  CHECK(r);
260  return ConstTensor4View(
261  mdata + OFFSET(v) + OFFSET(r), msr, mbr, mpr, mcr, s, b, p, c);
262 }
263 
264 // --||--
266  const Range& s,
267  Index b,
268  Index p,
269  const Range& r,
270  const Range& c) const {
271  CHECK(b);
272  CHECK(p);
273  return ConstTensor4View(
274  mdata + OFFSET(b) + OFFSET(p), mvr, msr, mrr, mcr, v, s, r, c);
275 }
276 
277 // -|-|--
279  Index s,
280  const Range& b,
281  Index p,
282  const Range& r,
283  const Range& c) const {
284  CHECK(s);
285  CHECK(p);
286  return ConstTensor4View(
287  mdata + OFFSET(s) + OFFSET(p), mvr, mbr, mrr, mcr, v, b, r, c);
288 }
289 
290 // |--|--
292  const Range& s,
293  const Range& b,
294  Index p,
295  const Range& r,
296  const Range& c) const {
297  CHECK(v);
298  CHECK(p);
299  return ConstTensor4View(
300  mdata + OFFSET(v) + OFFSET(p), msr, mbr, mrr, mcr, s, b, r, c);
301 }
302 
303 // -||---
305  Index s,
306  Index b,
307  const Range& p,
308  const Range& r,
309  const Range& c) const {
310  CHECK(s);
311  CHECK(b);
312  return ConstTensor4View(
313  mdata + OFFSET(s) + OFFSET(b), mvr, mpr, mrr, mcr, v, p, r, c);
314 }
315 
316 // |-|---
318  const Range& s,
319  Index b,
320  const Range& p,
321  const Range& r,
322  const Range& c) const {
323  CHECK(v);
324  CHECK(b);
325  return ConstTensor4View(
326  mdata + OFFSET(v) + OFFSET(b), msr, mpr, mrr, mcr, s, p, r, c);
327 }
328 
329 // ||----
331  Index s,
332  const Range& b,
333  const Range& p,
334  const Range& r,
335  const Range& c) const {
336  CHECK(v);
337  CHECK(s);
338  return ConstTensor4View(
339  mdata + OFFSET(v) + OFFSET(s), mbr, mpr, mrr, mcr, b, p, r, c);
340 }
341 
342 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
343 // ---|||
345  const Range& s,
346  const Range& b,
347  Index p,
348  Index r,
349  Index c) const {
350  CHECK(p);
351  CHECK(r);
352  CHECK(c);
353  return ConstTensor3View(
354  mdata + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, msr, mbr, v, s, b);
355 }
356 
357 // --|-||
359  const Range& s,
360  Index b,
361  const Range& p,
362  Index r,
363  Index c) const {
364  CHECK(b);
365  CHECK(r);
366  CHECK(c);
367  return ConstTensor3View(
368  mdata + OFFSET(b) + OFFSET(r) + OFFSET(c), mvr, msr, mpr, v, s, p);
369 }
370 
371 // -|--||
373  Index s,
374  const Range& b,
375  const Range& p,
376  Index r,
377  Index c) const {
378  CHECK(s);
379  CHECK(r);
380  CHECK(c);
381  return ConstTensor3View(
382  mdata + OFFSET(s) + OFFSET(r) + OFFSET(c), mvr, mbr, mpr, v, b, p);
383 }
384 
385 // |---||
387  const Range& s,
388  const Range& b,
389  const Range& p,
390  Index r,
391  Index c) const {
392  CHECK(v);
393  CHECK(r);
394  CHECK(c);
395  return ConstTensor3View(
396  mdata + OFFSET(v) + OFFSET(r) + OFFSET(c), msr, mbr, mpr, s, b, p);
397 }
398 
399 // --||-|
401  const Range& s,
402  Index b,
403  Index p,
404  const Range& r,
405  Index c) const {
406  CHECK(b);
407  CHECK(p);
408  CHECK(c);
409  return ConstTensor3View(
410  mdata + OFFSET(b) + OFFSET(p) + OFFSET(c), mvr, msr, mrr, v, s, r);
411 }
412 
413 // -|-|-|
415  Index s,
416  const Range& b,
417  Index p,
418  const Range& r,
419  Index c) const {
420  CHECK(s);
421  CHECK(p);
422  CHECK(c);
423  return ConstTensor3View(
424  mdata + OFFSET(s) + OFFSET(p) + OFFSET(c), mvr, mbr, mrr, v, b, r);
425 }
426 
427 // |--|-|
429  const Range& s,
430  const Range& b,
431  Index p,
432  const Range& r,
433  Index c) const {
434  CHECK(v);
435  CHECK(p);
436  CHECK(c);
437  return ConstTensor3View(
438  mdata + OFFSET(v) + OFFSET(p) + OFFSET(c), msr, mbr, mrr, s, b, r);
439 }
440 
441 // -||--|
443  Index s,
444  Index b,
445  const Range& p,
446  const Range& r,
447  Index c) const {
448  CHECK(s);
449  CHECK(b);
450  CHECK(c);
451  return ConstTensor3View(
452  mdata + OFFSET(s) + OFFSET(b) + OFFSET(c), mvr, mpr, mrr, v, p, r);
453 }
454 
455 // |-|--|
457  const Range& s,
458  Index b,
459  const Range& p,
460  const Range& r,
461  Index c) const {
462  CHECK(v);
463  CHECK(b);
464  CHECK(c);
465  return ConstTensor3View(
466  mdata + OFFSET(v) + OFFSET(b) + OFFSET(c), msr, mpr, mrr, s, p, r);
467 }
468 
469 // ||---|
471  Index s,
472  const Range& b,
473  const Range& p,
474  const Range& r,
475  Index c) const {
476  CHECK(v);
477  CHECK(s);
478  CHECK(c);
479  return ConstTensor3View(
480  mdata + OFFSET(v) + OFFSET(s) + OFFSET(c), mbr, mpr, mrr, b, p, r);
481 }
482 
483 // --|||-
485  const Range& s,
486  Index b,
487  Index p,
488  Index r,
489  const Range& c) const {
490  CHECK(b);
491  CHECK(p);
492  CHECK(r);
493  return ConstTensor3View(
494  mdata + OFFSET(b) + OFFSET(p) + OFFSET(r), mvr, msr, mcr, v, s, c);
495 }
496 
497 // -|-||-
499  Index s,
500  const Range& b,
501  Index p,
502  Index r,
503  const Range& c) const {
504  CHECK(s);
505  CHECK(p);
506  CHECK(r);
507  return ConstTensor3View(
508  mdata + OFFSET(s) + OFFSET(p) + OFFSET(r), mvr, mbr, mcr, v, b, c);
509 }
510 
511 // |--||-
513  const Range& s,
514  const Range& b,
515  Index p,
516  Index r,
517  const Range& c) const {
518  CHECK(v);
519  CHECK(p);
520  CHECK(r);
521  return ConstTensor3View(
522  mdata + OFFSET(v) + OFFSET(p) + OFFSET(r), msr, mbr, mcr, s, b, c);
523 }
524 
525 // -||-|-
527  Index s,
528  Index b,
529  const Range& p,
530  Index r,
531  const Range& c) const {
532  CHECK(s);
533  CHECK(b);
534  CHECK(r);
535  return ConstTensor3View(
536  mdata + OFFSET(s) + OFFSET(b) + OFFSET(r), mvr, mpr, mcr, v, p, c);
537 }
538 
539 // |-|-|-
541  const Range& s,
542  Index b,
543  const Range& p,
544  Index r,
545  const Range& c) const {
546  CHECK(v);
547  CHECK(b);
548  CHECK(r);
549  return ConstTensor3View(
550  mdata + OFFSET(v) + OFFSET(b) + OFFSET(r), msr, mpr, mcr, s, p, c);
551 }
552 
553 // ||--|-
555  Index s,
556  const Range& b,
557  const Range& p,
558  Index r,
559  const Range& c) const {
560  CHECK(v);
561  CHECK(s);
562  CHECK(r);
563  return ConstTensor3View(
564  mdata + OFFSET(v) + OFFSET(s) + OFFSET(r), mbr, mpr, mcr, b, p, c);
565 }
566 
567 // -|||--
569  Index s,
570  Index b,
571  Index p,
572  const Range& r,
573  const Range& c) const {
574  CHECK(s);
575  CHECK(b);
576  CHECK(p);
577  return ConstTensor3View(
578  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p), mvr, mrr, mcr, v, r, c);
579 }
580 
581 // |-||--
583  const Range& s,
584  Index b,
585  Index p,
586  const Range& r,
587  const Range& c) const {
588  CHECK(v);
589  CHECK(b);
590  CHECK(p);
591  return ConstTensor3View(
592  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p), msr, mrr, mcr, s, r, c);
593 }
594 
595 // ||-|--
597  Index s,
598  const Range& b,
599  Index p,
600  const Range& r,
601  const Range& c) const {
602  CHECK(v);
603  CHECK(s);
604  CHECK(p);
605  return ConstTensor3View(
606  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p), mbr, mrr, mcr, b, r, c);
607 }
608 
609 // |||---
611  Index s,
612  Index b,
613  const Range& p,
614  const Range& r,
615  const Range& c) const {
616  CHECK(v);
617  CHECK(s);
618  CHECK(b);
619  return ConstTensor3View(
620  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b), mpr, mrr, mcr, p, r, c);
621 }
622 
623 // Result 2D (15 combinations)
624 // IIII--
626  Index v, Index s, Index b, Index p, const Range& r, const Range& c) const {
627  CHECK(v);
628  CHECK(s);
629  CHECK(b);
630  CHECK(p);
631  return ConstMatrixView(
632  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p), mrr, mcr, r, c);
633 }
634 
635 // III-I-
637  Index v, Index s, Index b, const Range& p, Index r, const Range& c) const {
638  CHECK(v);
639  CHECK(s);
640  CHECK(b);
641  CHECK(r);
642  return ConstMatrixView(
643  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(r), mpr, mcr, p, c);
644 }
645 
646 // II-II-
648  Index v, Index s, const Range& b, Index p, Index r, const Range& c) const {
649  CHECK(v);
650  CHECK(s);
651  CHECK(p);
652  CHECK(r);
653  return ConstMatrixView(
654  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(r), mbr, mcr, b, c);
655 }
656 
657 // I-III-
659  Index v, const Range& s, Index b, Index p, Index r, const Range& c) const {
660  CHECK(v);
661  CHECK(b);
662  CHECK(p);
663  CHECK(r);
664  return ConstMatrixView(
665  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(r), msr, mcr, s, c);
666 }
667 
668 // -IIII-
670  const Range& v, Index s, Index b, Index p, Index r, const Range& c) const {
671  CHECK(s);
672  CHECK(b);
673  CHECK(p);
674  CHECK(r);
675  return ConstMatrixView(
676  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r), mvr, mcr, v, c);
677 }
678 
679 // III--I
681  Index v, Index s, Index b, const Range& p, const Range& r, Index c) const {
682  CHECK(v);
683  CHECK(s);
684  CHECK(b);
685  CHECK(c);
686  return ConstMatrixView(
687  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(c), mpr, mrr, p, r);
688 }
689 
690 // II-I-I
692  Index v, Index s, const Range& b, Index p, const Range& r, Index c) const {
693  CHECK(v);
694  CHECK(s);
695  CHECK(p);
696  CHECK(c);
697  return ConstMatrixView(
698  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(c), mbr, mrr, b, r);
699 }
700 
701 // I-II-I
703  Index v, const Range& s, Index b, Index p, const Range& r, Index c) const {
704  CHECK(v);
705  CHECK(b);
706  CHECK(p);
707  CHECK(c);
708  return ConstMatrixView(
709  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(c), msr, mrr, s, r);
710 }
711 
712 // -III-I
714  const Range& v, Index s, Index b, Index p, const Range& r, Index c) const {
715  CHECK(s);
716  CHECK(b);
717  CHECK(p);
718  CHECK(c);
719  return ConstMatrixView(
720  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(c), mvr, mrr, v, r);
721 }
722 
723 // II--II
725  Index v, Index s, const Range& b, const Range& p, Index r, Index c) const {
726  CHECK(v);
727  CHECK(s);
728  CHECK(r);
729  CHECK(c);
730  return ConstMatrixView(
731  mdata + OFFSET(v) + OFFSET(s) + OFFSET(r) + OFFSET(c), mbr, mpr, b, p);
732 }
733 
734 // I-I-II
736  Index v, const Range& s, Index b, const Range& p, Index r, Index c) const {
737  CHECK(v);
738  CHECK(b);
739  CHECK(r);
740  CHECK(c);
741  return ConstMatrixView(
742  mdata + OFFSET(v) + OFFSET(b) + OFFSET(r) + OFFSET(c), msr, mpr, s, p);
743 }
744 
745 // -II-II
747  const Range& v, Index s, Index b, const Range& p, Index r, Index c) const {
748  CHECK(s);
749  CHECK(b);
750  CHECK(r);
751  CHECK(c);
752  return ConstMatrixView(
753  mdata + OFFSET(s) + OFFSET(b) + OFFSET(r) + OFFSET(c), mvr, mpr, v, p);
754 }
755 
756 // I--III
758  Index v, const Range& s, const Range& b, Index p, Index r, Index c) const {
759  CHECK(v);
760  CHECK(p);
761  CHECK(r);
762  CHECK(c);
763  return ConstMatrixView(
764  mdata + OFFSET(v) + OFFSET(p) + OFFSET(r) + OFFSET(c), msr, mbr, s, b);
765 }
766 
767 // -I-III
769  const Range& v, Index s, const Range& b, Index p, Index r, Index c) const {
770  CHECK(s);
771  CHECK(p);
772  CHECK(r);
773  CHECK(c);
774  return ConstMatrixView(
775  mdata + OFFSET(s) + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, mbr, v, b);
776 }
777 
778 // --IIII
780  const Range& v, const Range& s, Index b, Index p, Index r, Index c) const {
781  CHECK(b);
782  CHECK(p);
783  CHECK(r);
784  CHECK(c);
785  return ConstMatrixView(
786  mdata + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, msr, v, s);
787 }
788 
789 // Result 1D (6 combinations)
790 // IIIII-
792  Index v, Index s, Index b, Index p, Index r, const Range& c) const {
793  CHECK(v);
794  CHECK(s);
795  CHECK(b);
796  CHECK(p);
797  CHECK(r);
798  return ConstVectorView(
799  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r),
800  mcr,
801  c);
802 }
803 
804 // IIII-I
806  Index v, Index s, Index b, Index p, const Range& r, Index c) const {
807  CHECK(v);
808  CHECK(s);
809  CHECK(b);
810  CHECK(p);
811  CHECK(c);
812  return ConstVectorView(
813  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(c),
814  mrr,
815  r);
816 }
817 
818 // III-II
820  Index v, Index s, Index b, const Range& p, Index r, Index c) const {
821  CHECK(v);
822  CHECK(s);
823  CHECK(b);
824  CHECK(r);
825  CHECK(c);
826  return ConstVectorView(
827  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(r) + OFFSET(c),
828  mpr,
829  p);
830 }
831 
832 // II-III
834  Index v, Index s, const Range& b, Index p, Index r, Index c) const {
835  CHECK(v);
836  CHECK(s);
837  CHECK(p);
838  CHECK(r);
839  CHECK(c);
840  return ConstVectorView(
841  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(r) + OFFSET(c),
842  mbr,
843  b);
844 }
845 
846 // I-IIII
848  Index v, const Range& s, Index b, Index p, Index r, Index c) const {
849  CHECK(v);
850  CHECK(b);
851  CHECK(p);
852  CHECK(r);
853  CHECK(c);
854  return ConstVectorView(
855  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c),
856  msr,
857  s);
858 }
859 
860 // -IIIII
862  const Range& v, Index s, Index b, Index p, Index r, Index c) const {
863  CHECK(s);
864  CHECK(b);
865  CHECK(p);
866  CHECK(r);
867  CHECK(c);
868  return ConstVectorView(
869  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c),
870  mvr,
871  v);
872 }
873 
876  return ConstIterator6D(
878  mvr.mstride);
879 }
880 
883  return ConstIterator6D(
885  msr,
886  mbr,
887  mpr,
888  mrr,
889  mcr),
890  mvr.mstride);
891 }
892 
895  : mvr(0,
896  1,
897  a.msr.mextent * a.mbr.mextent * a.mpr.mextent * a.mrr.mextent *
898  a.mcr.mextent),
899  msr(a.msr),
900  mbr(a.mbr),
901  mpr(a.mpr),
902  mrr(a.mrr),
903  mcr(a.mcr),
904  mdata(a.mdata) {
905  // Nothing to do here.
906 }
907 
913  const Range& v,
914  const Range& s,
915  const Range& b,
916  const Range& p,
917  const Range& r,
918  const Range& c)
919  : mvr(v), msr(s), mbr(b), mpr(p), mrr(r), mcr(c), mdata(data) {
920  // Nothing to do here.
921 }
922 
931  const Range& pv,
932  const Range& ps,
933  const Range& pb,
934  const Range& pp,
935  const Range& pr,
936  const Range& pc,
937  const Range& nv,
938  const Range& ns,
939  const Range& nb,
940  const Range& np,
941  const Range& nr,
942  const Range& nc)
943  : mvr(pv, nv),
944  msr(ps, ns),
945  mbr(pb, nb),
946  mpr(pp, np),
947  mrr(pr, nr),
948  mcr(pc, nc),
949  mdata(data) {
950  // Nothing to do here.
951 }
952 
956 std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v) {
957  // Page iterators:
958  ConstIterator6D ip = v.begin();
959  const ConstIterator6D end_page = v.end();
960 
961  if (ip != end_page) {
962  os << *ip;
963  ++ip;
964  }
965 
966  for (; ip != end_page; ++ip) {
967  os << "\n\n";
968  os << *ip;
969  }
970 
971  return os;
972 }
973 
974 // Functions for Tensor6View:
975 // -------------------------
976 
977 // Non-const index operators:
978 
979 // Result 6D (1 combination)
980 // ------
982  const Range& s,
983  const Range& b,
984  const Range& p,
985  const Range& r,
986  const Range& c) {
987  return Tensor6View(mdata, mvr, msr, mbr, mpr, mrr, mcr, v, s, b, p, r, c);
988 }
989 
990 // Result 5D (6 combinations)
991 // -----|
993  const Range& s,
994  const Range& b,
995  const Range& p,
996  const Range& r,
997  Index c) {
998  CHECK(c);
999  return Tensor5View(mdata + OFFSET(c), mvr, msr, mbr, mpr, mrr, v, s, b, p, r);
1000 }
1001 
1002 // ----|-
1004  const Range& s,
1005  const Range& b,
1006  const Range& p,
1007  Index r,
1008  const Range& c) {
1009  CHECK(r);
1010  return Tensor5View(mdata + OFFSET(r), mvr, msr, mbr, mpr, mcr, v, s, b, p, c);
1011 }
1012 
1013 // ---|--
1015  const Range& s,
1016  const Range& b,
1017  Index p,
1018  const Range& r,
1019  const Range& c) {
1020  CHECK(p);
1021  return Tensor5View(mdata + OFFSET(p), mvr, msr, mbr, mrr, mcr, v, s, b, r, c);
1022 }
1023 
1024 // --|---
1026  const Range& s,
1027  Index b,
1028  const Range& p,
1029  const Range& r,
1030  const Range& c) {
1031  CHECK(b);
1032  return Tensor5View(mdata + OFFSET(b), mvr, msr, mpr, mrr, mcr, v, s, p, r, c);
1033 }
1034 
1035 // -|----
1037  Index s,
1038  const Range& b,
1039  const Range& p,
1040  const Range& r,
1041  const Range& c) {
1042  CHECK(s);
1043  return Tensor5View(mdata + OFFSET(s), mvr, mbr, mpr, mrr, mcr, v, b, p, r, c);
1044 }
1045 
1046 // |-----
1048  const Range& s,
1049  const Range& b,
1050  const Range& p,
1051  const Range& r,
1052  const Range& c) {
1053  CHECK(v);
1054  return Tensor5View(mdata + OFFSET(v), msr, mbr, mpr, mrr, mcr, s, b, p, r, c);
1055 }
1056 
1057 // Result 4D (5+4+3+2+1 = 15 combinations)
1058 // ----||
1060  const Range& s,
1061  const Range& b,
1062  const Range& p,
1063  Index r,
1064  Index c) {
1065  CHECK(r);
1066  CHECK(c);
1067  return Tensor4View(
1068  mdata + OFFSET(r) + OFFSET(c), mvr, msr, mbr, mpr, v, s, b, p);
1069 }
1070 
1071 // ---|-|
1073  const Range& s,
1074  const Range& b,
1075  Index p,
1076  const Range& r,
1077  Index c) {
1078  CHECK(p);
1079  CHECK(c);
1080  return Tensor4View(
1081  mdata + OFFSET(p) + OFFSET(c), mvr, msr, mbr, mrr, v, s, b, r);
1082 }
1083 
1084 // --|--|
1086  const Range& s,
1087  Index b,
1088  const Range& p,
1089  const Range& r,
1090  Index c) {
1091  CHECK(b);
1092  CHECK(c);
1093  return Tensor4View(
1094  mdata + OFFSET(b) + OFFSET(c), mvr, msr, mpr, mrr, v, s, p, r);
1095 }
1096 
1097 // -|---|
1099  Index s,
1100  const Range& b,
1101  const Range& p,
1102  const Range& r,
1103  Index c) {
1104  CHECK(s);
1105  CHECK(c);
1106  return Tensor4View(
1107  mdata + OFFSET(s) + OFFSET(c), mvr, mbr, mpr, mrr, v, b, p, r);
1108 }
1109 
1110 // |----|
1112  const Range& s,
1113  const Range& b,
1114  const Range& p,
1115  const Range& r,
1116  Index c) {
1117  CHECK(v);
1118  CHECK(c);
1119  return Tensor4View(
1120  mdata + OFFSET(v) + OFFSET(c), msr, mbr, mpr, mrr, s, b, p, r);
1121 }
1122 
1123 // ---||-
1125  const Range& s,
1126  const Range& b,
1127  Index p,
1128  Index r,
1129  const Range& c) {
1130  CHECK(p);
1131  CHECK(r);
1132  return Tensor4View(
1133  mdata + OFFSET(p) + OFFSET(r), mvr, msr, mbr, mcr, v, s, b, c);
1134 }
1135 
1136 // --|-|-
1138  const Range& s,
1139  Index b,
1140  const Range& p,
1141  Index r,
1142  const Range& c) {
1143  CHECK(b);
1144  CHECK(r);
1145  return Tensor4View(
1146  mdata + OFFSET(b) + OFFSET(r), mvr, msr, mpr, mcr, v, s, p, c);
1147 }
1148 
1149 // -|--|-
1151  Index s,
1152  const Range& b,
1153  const Range& p,
1154  Index r,
1155  const Range& c) {
1156  CHECK(s);
1157  CHECK(r);
1158  return Tensor4View(
1159  mdata + OFFSET(s) + OFFSET(r), mvr, mbr, mpr, mcr, v, b, p, c);
1160 }
1161 
1162 // |---|-
1164  const Range& s,
1165  const Range& b,
1166  const Range& p,
1167  Index r,
1168  const Range& c) {
1169  CHECK(v);
1170  CHECK(r);
1171  return Tensor4View(
1172  mdata + OFFSET(v) + OFFSET(r), msr, mbr, mpr, mcr, s, b, p, c);
1173 }
1174 
1175 // --||--
1177  const Range& s,
1178  Index b,
1179  Index p,
1180  const Range& r,
1181  const Range& c) {
1182  CHECK(b);
1183  CHECK(p);
1184  return Tensor4View(
1185  mdata + OFFSET(b) + OFFSET(p), mvr, msr, mrr, mcr, v, s, r, c);
1186 }
1187 
1188 // -|-|--
1190  Index s,
1191  const Range& b,
1192  Index p,
1193  const Range& r,
1194  const Range& c) {
1195  CHECK(s);
1196  CHECK(p);
1197  return Tensor4View(
1198  mdata + OFFSET(s) + OFFSET(p), mvr, mbr, mrr, mcr, v, b, r, c);
1199 }
1200 
1201 // |--|--
1203  const Range& s,
1204  const Range& b,
1205  Index p,
1206  const Range& r,
1207  const Range& c) {
1208  CHECK(v);
1209  CHECK(p);
1210  return Tensor4View(
1211  mdata + OFFSET(v) + OFFSET(p), msr, mbr, mrr, mcr, s, b, r, c);
1212 }
1213 
1214 // -||---
1216  Index s,
1217  Index b,
1218  const Range& p,
1219  const Range& r,
1220  const Range& c) {
1221  CHECK(s);
1222  CHECK(b);
1223  return Tensor4View(
1224  mdata + OFFSET(s) + OFFSET(b), mvr, mpr, mrr, mcr, v, p, r, c);
1225 }
1226 
1227 // |-|---
1229  const Range& s,
1230  Index b,
1231  const Range& p,
1232  const Range& r,
1233  const Range& c) {
1234  CHECK(v);
1235  CHECK(b);
1236  return Tensor4View(
1237  mdata + OFFSET(v) + OFFSET(b), msr, mpr, mrr, mcr, s, p, r, c);
1238 }
1239 
1240 // ||----
1242  Index s,
1243  const Range& b,
1244  const Range& p,
1245  const Range& r,
1246  const Range& c) {
1247  CHECK(v);
1248  CHECK(s);
1249  return Tensor4View(
1250  mdata + OFFSET(v) + OFFSET(s), mbr, mpr, mrr, mcr, b, p, r, c);
1251 }
1252 
1253 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
1254 // ---|||
1256  const Range& v, const Range& s, const Range& b, Index p, Index r, Index c) {
1257  CHECK(p);
1258  CHECK(r);
1259  CHECK(c);
1260  return Tensor3View(
1261  mdata + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, msr, mbr, v, s, b);
1262 }
1263 
1264 // --|-||
1266  const Range& v, const Range& s, Index b, const Range& p, Index r, Index c) {
1267  CHECK(b);
1268  CHECK(r);
1269  CHECK(c);
1270  return Tensor3View(
1271  mdata + OFFSET(b) + OFFSET(r) + OFFSET(c), mvr, msr, mpr, v, s, p);
1272 }
1273 
1274 // -|--||
1276  const Range& v, Index s, const Range& b, const Range& p, Index r, Index c) {
1277  CHECK(s);
1278  CHECK(r);
1279  CHECK(c);
1280  return Tensor3View(
1281  mdata + OFFSET(s) + OFFSET(r) + OFFSET(c), mvr, mbr, mpr, v, b, p);
1282 }
1283 
1284 // |---||
1286  Index v, const Range& s, const Range& b, const Range& p, Index r, Index c) {
1287  CHECK(v);
1288  CHECK(r);
1289  CHECK(c);
1290  return Tensor3View(
1291  mdata + OFFSET(v) + OFFSET(r) + OFFSET(c), msr, mbr, mpr, s, b, p);
1292 }
1293 
1294 // --||-|
1296  const Range& v, const Range& s, Index b, Index p, const Range& r, Index c) {
1297  CHECK(b);
1298  CHECK(p);
1299  CHECK(c);
1300  return Tensor3View(
1301  mdata + OFFSET(b) + OFFSET(p) + OFFSET(c), mvr, msr, mrr, v, s, r);
1302 }
1303 
1304 // -|-|-|
1306  const Range& v, Index s, const Range& b, Index p, const Range& r, Index c) {
1307  CHECK(s);
1308  CHECK(p);
1309  CHECK(c);
1310  return Tensor3View(
1311  mdata + OFFSET(s) + OFFSET(p) + OFFSET(c), mvr, mbr, mrr, v, b, r);
1312 }
1313 
1314 // |--|-|
1316  Index v, const Range& s, const Range& b, Index p, const Range& r, Index c) {
1317  CHECK(v);
1318  CHECK(p);
1319  CHECK(c);
1320  return Tensor3View(
1321  mdata + OFFSET(v) + OFFSET(p) + OFFSET(c), msr, mbr, mrr, s, b, r);
1322 }
1323 
1324 // -||--|
1326  const Range& v, Index s, Index b, const Range& p, const Range& r, Index c) {
1327  CHECK(s);
1328  CHECK(b);
1329  CHECK(c);
1330  return Tensor3View(
1331  mdata + OFFSET(s) + OFFSET(b) + OFFSET(c), mvr, mpr, mrr, v, p, r);
1332 }
1333 
1334 // |-|--|
1336  Index v, const Range& s, Index b, const Range& p, const Range& r, Index c) {
1337  CHECK(v);
1338  CHECK(b);
1339  CHECK(c);
1340  return Tensor3View(
1341  mdata + OFFSET(v) + OFFSET(b) + OFFSET(c), msr, mpr, mrr, s, p, r);
1342 }
1343 
1344 // ||---|
1346  Index v, Index s, const Range& b, const Range& p, const Range& r, Index c) {
1347  CHECK(v);
1348  CHECK(s);
1349  CHECK(c);
1350  return Tensor3View(
1351  mdata + OFFSET(v) + OFFSET(s) + OFFSET(c), mbr, mpr, mrr, b, p, r);
1352 }
1353 
1354 // --|||-
1356  const Range& v, const Range& s, Index b, Index p, Index r, const Range& c) {
1357  CHECK(b);
1358  CHECK(p);
1359  CHECK(r);
1360  return Tensor3View(
1361  mdata + OFFSET(b) + OFFSET(p) + OFFSET(r), mvr, msr, mcr, v, s, c);
1362 }
1363 
1364 // -|-||-
1366  const Range& v, Index s, const Range& b, Index p, Index r, const Range& c) {
1367  CHECK(s);
1368  CHECK(p);
1369  CHECK(r);
1370  return Tensor3View(
1371  mdata + OFFSET(s) + OFFSET(p) + OFFSET(r), mvr, mbr, mcr, v, b, c);
1372 }
1373 
1374 // |--||-
1376  Index v, const Range& s, const Range& b, Index p, Index r, const Range& c) {
1377  CHECK(v);
1378  CHECK(p);
1379  CHECK(r);
1380  return Tensor3View(
1381  mdata + OFFSET(v) + OFFSET(p) + OFFSET(r), msr, mbr, mcr, s, b, c);
1382 }
1383 
1384 // -||-|-
1386  const Range& v, Index s, Index b, const Range& p, Index r, const Range& c) {
1387  CHECK(s);
1388  CHECK(b);
1389  CHECK(r);
1390  return Tensor3View(
1391  mdata + OFFSET(s) + OFFSET(b) + OFFSET(r), mvr, mpr, mcr, v, p, c);
1392 }
1393 
1394 // |-|-|-
1396  Index v, const Range& s, Index b, const Range& p, Index r, const Range& c) {
1397  CHECK(v);
1398  CHECK(b);
1399  CHECK(r);
1400  return Tensor3View(
1401  mdata + OFFSET(v) + OFFSET(b) + OFFSET(r), msr, mpr, mcr, s, p, c);
1402 }
1403 
1404 // ||--|-
1406  Index v, Index s, const Range& b, const Range& p, Index r, const Range& c) {
1407  CHECK(v);
1408  CHECK(s);
1409  CHECK(r);
1410  return Tensor3View(
1411  mdata + OFFSET(v) + OFFSET(s) + OFFSET(r), mbr, mpr, mcr, b, p, c);
1412 }
1413 
1414 // -|||--
1416  const Range& v, Index s, Index b, Index p, const Range& r, const Range& c) {
1417  CHECK(s);
1418  CHECK(b);
1419  CHECK(p);
1420  return Tensor3View(
1421  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p), mvr, mrr, mcr, v, r, c);
1422 }
1423 
1424 // |-||--
1426  Index v, const Range& s, Index b, Index p, const Range& r, const Range& c) {
1427  CHECK(v);
1428  CHECK(b);
1429  CHECK(p);
1430  return Tensor3View(
1431  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p), msr, mrr, mcr, s, r, c);
1432 }
1433 
1434 // ||-|--
1436  Index v, Index s, const Range& b, Index p, const Range& r, const Range& c) {
1437  CHECK(v);
1438  CHECK(s);
1439  CHECK(p);
1440  return Tensor3View(
1441  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p), mbr, mrr, mcr, b, r, c);
1442 }
1443 
1444 // |||---
1446  Index v, Index s, Index b, const Range& p, const Range& r, const Range& c) {
1447  CHECK(v);
1448  CHECK(s);
1449  CHECK(b);
1450  return Tensor3View(
1451  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b), mpr, mrr, mcr, p, r, c);
1452 }
1453 
1454 // Result 2D (15 combinations)
1455 // IIII--
1457  Index v, Index s, Index b, Index p, const Range& r, const Range& c) {
1458  CHECK(v);
1459  CHECK(s);
1460  CHECK(b);
1461  CHECK(p);
1462  return MatrixView(
1463  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p), mrr, mcr, r, c);
1464 }
1465 
1466 // III-I-
1468  Index v, Index s, Index b, const Range& p, Index r, const Range& c) {
1469  CHECK(v);
1470  CHECK(s);
1471  CHECK(b);
1472  CHECK(r);
1473  return MatrixView(
1474  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(r), mpr, mcr, p, c);
1475 }
1476 
1477 // II-II-
1479  Index v, Index s, const Range& b, Index p, Index r, const Range& c) {
1480  CHECK(v);
1481  CHECK(s);
1482  CHECK(p);
1483  CHECK(r);
1484  return MatrixView(
1485  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(r), mbr, mcr, b, c);
1486 }
1487 
1488 // I-III-
1490  Index v, const Range& s, Index b, Index p, Index r, const Range& c) {
1491  CHECK(v);
1492  CHECK(b);
1493  CHECK(p);
1494  CHECK(r);
1495  return MatrixView(
1496  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(r), msr, mcr, s, c);
1497 }
1498 
1499 // -IIII-
1501  const Range& v, Index s, Index b, Index p, Index r, const Range& c) {
1502  CHECK(s);
1503  CHECK(b);
1504  CHECK(p);
1505  CHECK(r);
1506  return MatrixView(
1507  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r), mvr, mcr, v, c);
1508 }
1509 
1510 // III--I
1512  Index v, Index s, Index b, const Range& p, const Range& r, Index c) {
1513  CHECK(v);
1514  CHECK(s);
1515  CHECK(b);
1516  CHECK(c);
1517  return MatrixView(
1518  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(c), mpr, mrr, p, r);
1519 }
1520 
1521 // II-I-I
1523  Index v, Index s, const Range& b, Index p, const Range& r, Index c) {
1524  CHECK(v);
1525  CHECK(s);
1526  CHECK(p);
1527  CHECK(c);
1528  return MatrixView(
1529  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(c), mbr, mrr, b, r);
1530 }
1531 
1532 // I-II-I
1534  Index v, const Range& s, Index b, Index p, const Range& r, Index c) {
1535  CHECK(v);
1536  CHECK(b);
1537  CHECK(p);
1538  CHECK(c);
1539  return MatrixView(
1540  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(c), msr, mrr, s, r);
1541 }
1542 
1543 // -III-I
1545  const Range& v, Index s, Index b, Index p, const Range& r, Index c) {
1546  CHECK(s);
1547  CHECK(b);
1548  CHECK(p);
1549  CHECK(c);
1550  return MatrixView(
1551  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(c), mvr, mrr, v, r);
1552 }
1553 
1554 // II--II
1556  Index v, Index s, const Range& b, const Range& p, Index r, Index c) {
1557  CHECK(v);
1558  CHECK(s);
1559  CHECK(r);
1560  CHECK(c);
1561  return MatrixView(
1562  mdata + OFFSET(v) + OFFSET(s) + OFFSET(r) + OFFSET(c), mbr, mpr, b, p);
1563 }
1564 
1565 // I-I-II
1567  Index v, const Range& s, Index b, const Range& p, Index r, Index c) {
1568  CHECK(v);
1569  CHECK(b);
1570  CHECK(r);
1571  CHECK(c);
1572  return MatrixView(
1573  mdata + OFFSET(v) + OFFSET(b) + OFFSET(r) + OFFSET(c), msr, mpr, s, p);
1574 }
1575 
1576 // -II-II
1578  const Range& v, Index s, Index b, const Range& p, Index r, Index c) {
1579  CHECK(s);
1580  CHECK(b);
1581  CHECK(r);
1582  CHECK(c);
1583  return MatrixView(
1584  mdata + OFFSET(s) + OFFSET(b) + OFFSET(r) + OFFSET(c), mvr, mpr, v, p);
1585 }
1586 
1587 // I--III
1589  Index v, const Range& s, const Range& b, Index p, Index r, Index c) {
1590  CHECK(v);
1591  CHECK(p);
1592  CHECK(r);
1593  CHECK(c);
1594  return MatrixView(
1595  mdata + OFFSET(v) + OFFSET(p) + OFFSET(r) + OFFSET(c), msr, mbr, s, b);
1596 }
1597 
1598 // -I-III
1600  const Range& v, Index s, const Range& b, Index p, Index r, Index c) {
1601  CHECK(s);
1602  CHECK(p);
1603  CHECK(r);
1604  CHECK(c);
1605  return MatrixView(
1606  mdata + OFFSET(s) + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, mbr, v, b);
1607 }
1608 
1609 // --IIII
1611  const Range& v, const Range& s, Index b, Index p, Index r, Index c) {
1612  CHECK(b);
1613  CHECK(p);
1614  CHECK(r);
1615  CHECK(c);
1616  return MatrixView(
1617  mdata + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c), mvr, msr, v, s);
1618 }
1619 
1620 // Result 1D (6 combinations)
1621 // IIIII-
1623  Index v, Index s, Index b, Index p, Index r, const Range& c) {
1624  CHECK(v);
1625  CHECK(s);
1626  CHECK(b);
1627  CHECK(p);
1628  CHECK(r);
1629  return VectorView(
1630  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r),
1631  mcr,
1632  c);
1633 }
1634 
1635 // IIII-I
1637  Index v, Index s, Index b, Index p, const Range& r, Index c) {
1638  CHECK(v);
1639  CHECK(s);
1640  CHECK(b);
1641  CHECK(p);
1642  CHECK(c);
1643  return VectorView(
1644  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(c),
1645  mrr,
1646  r);
1647 }
1648 
1649 // III-II
1651  Index v, Index s, Index b, const Range& p, Index r, Index c) {
1652  CHECK(v);
1653  CHECK(s);
1654  CHECK(b);
1655  CHECK(r);
1656  CHECK(c);
1657  return VectorView(
1658  mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(r) + OFFSET(c),
1659  mpr,
1660  p);
1661 }
1662 
1663 // II-III
1665  Index v, Index s, const Range& b, Index p, Index r, Index c) {
1666  CHECK(v);
1667  CHECK(s);
1668  CHECK(p);
1669  CHECK(r);
1670  CHECK(c);
1671  return VectorView(
1672  mdata + OFFSET(v) + OFFSET(s) + OFFSET(p) + OFFSET(r) + OFFSET(c),
1673  mbr,
1674  b);
1675 }
1676 
1677 // I-IIII
1679  Index v, const Range& s, Index b, Index p, Index r, Index c) {
1680  CHECK(v);
1681  CHECK(b);
1682  CHECK(p);
1683  CHECK(r);
1684  CHECK(c);
1685  return VectorView(
1686  mdata + OFFSET(v) + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c),
1687  msr,
1688  s);
1689 }
1690 
1691 // -IIIII
1693  const Range& v, Index s, Index b, Index p, Index r, Index c) {
1694  CHECK(s);
1695  CHECK(b);
1696  CHECK(p);
1697  CHECK(r);
1698  CHECK(c);
1699  return VectorView(
1700  mdata + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) + OFFSET(c),
1701  mvr,
1702  v);
1703 }
1704 
1712  if (mvr.mstart != 0 ||
1713  mvr.mstride !=
1715  msr.mstart != 0 ||
1717  mbr.mstart != 0 ||
1719  mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
1720  mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
1721  mcr.mstride != 1)
1722  throw std::runtime_error(
1723  "A Tensor6View can only be converted to a plain C-array if it's pointing to a continuous block of data");
1724 
1725  return mdata;
1726 }
1727 
1735  if (mvr.mstart != 0 ||
1736  mvr.mstride !=
1738  msr.mstart != 0 ||
1740  mbr.mstart != 0 ||
1742  mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
1743  mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
1744  mcr.mstride != 1)
1745  throw std::runtime_error(
1746  "A Tensor6View can only be converted to a plain C-array if it's pointing to a continuous block of data");
1747 
1748  return mdata;
1749 }
1750 
1754  mvr.mstride);
1755 }
1756 
1759  return Iterator6D(
1761  msr,
1762  mbr,
1763  mpr,
1764  mrr,
1765  mcr),
1766  mvr.mstride);
1767 }
1768 
1774  // Check that sizes are compatible:
1775  assert(mvr.mextent == m.mvr.mextent);
1776  assert(msr.mextent == m.msr.mextent);
1777  assert(mbr.mextent == m.mbr.mextent);
1778  assert(mpr.mextent == m.mpr.mextent);
1779  assert(mrr.mextent == m.mrr.mextent);
1780  assert(mcr.mextent == m.mcr.mextent);
1781 
1782  copy(m.begin(), m.end(), begin());
1783  return *this;
1784 }
1785 
1792  // Check that sizes are compatible:
1793  assert(mvr.mextent == m.mvr.mextent);
1794  assert(msr.mextent == m.msr.mextent);
1795  assert(mbr.mextent == m.mbr.mextent);
1796  assert(mpr.mextent == m.mpr.mextent);
1797  assert(mrr.mextent == m.mrr.mextent);
1798  assert(mcr.mextent == m.mcr.mextent);
1799 
1800  copy(m.begin(), m.end(), begin());
1801  return *this;
1802 }
1803 
1808  // Check that sizes are compatible:
1809  assert(mvr.mextent == m.mvr.mextent);
1810  assert(msr.mextent == m.msr.mextent);
1811  assert(mbr.mextent == m.mbr.mextent);
1812  assert(mpr.mextent == m.mpr.mextent);
1813  assert(mrr.mextent == m.mrr.mextent);
1814  assert(mcr.mextent == m.mcr.mextent);
1815 
1816  copy(m.begin(), m.end(), begin());
1817  return *this;
1818 }
1819 
1823  copy(x, begin(), end());
1824  return *this;
1825 }
1826 
1827 // Some little helper functions:
1828 //------------------------------
1829 
1832  const Iterator6D ep = end();
1833  for (Iterator6D p = begin(); p != ep; ++p) {
1834  *p *= x;
1835  }
1836  return *this;
1837 }
1838 
1841  const Iterator6D ep = end();
1842  for (Iterator6D p = begin(); p != ep; ++p) {
1843  *p /= x;
1844  }
1845  return *this;
1846 }
1847 
1850  const Iterator6D ep = end();
1851  for (Iterator6D p = begin(); p != ep; ++p) {
1852  *p += x;
1853  }
1854  return *this;
1855 }
1856 
1859  const Iterator6D ep = end();
1860  for (Iterator6D p = begin(); p != ep; ++p) {
1861  *p -= x;
1862  }
1863  return *this;
1864 }
1865 
1868  assert(nvitrines() == x.nvitrines());
1869  assert(nshelves() == x.nshelves());
1870  assert(nbooks() == x.nbooks());
1871  assert(npages() == x.npages());
1872  assert(nrows() == x.nrows());
1873  assert(ncols() == x.ncols());
1874  ConstIterator6D xp = x.begin();
1875  Iterator6D p = begin();
1876  const Iterator6D ep = end();
1877  for (; p != ep; ++p, ++xp) {
1878  *p *= *xp;
1879  }
1880  return *this;
1881 }
1882 
1885  assert(nvitrines() == x.nvitrines());
1886  assert(nshelves() == x.nshelves());
1887  assert(nbooks() == x.nbooks());
1888  assert(npages() == x.npages());
1889  assert(nrows() == x.nrows());
1890  assert(ncols() == x.ncols());
1891  ConstIterator6D xp = x.begin();
1892  Iterator6D p = begin();
1893  const Iterator6D ep = end();
1894  for (; p != ep; ++p, ++xp) {
1895  *p /= *xp;
1896  }
1897  return *this;
1898 }
1899 
1902  assert(nvitrines() == x.nvitrines());
1903  assert(nshelves() == x.nshelves());
1904  assert(nbooks() == x.nbooks());
1905  assert(npages() == x.npages());
1906  assert(nrows() == x.nrows());
1907  assert(ncols() == x.ncols());
1908  ConstIterator6D xp = x.begin();
1909  Iterator6D p = begin();
1910  const Iterator6D ep = end();
1911  for (; p != ep; ++p, ++xp) {
1912  *p += *xp;
1913  }
1914  return *this;
1915 }
1916 
1919  assert(nvitrines() == x.nvitrines());
1920  assert(nshelves() == x.nshelves());
1921  assert(nbooks() == x.nbooks());
1922  assert(npages() == x.npages());
1923  assert(nrows() == x.nrows());
1924  assert(ncols() == x.ncols());
1925  ConstIterator6D xp = x.begin();
1926  Iterator6D p = begin();
1927  const Iterator6D ep = end();
1928  for (; p != ep; ++p, ++xp) {
1929  *p -= *xp;
1930  }
1931  return *this;
1932 }
1933 
1936  : ConstTensor6View(a.mdata,
1937  Range(0,
1938  1,
1939  a.msr.mextent * a.mbr.mextent * a.mpr.mextent *
1940  a.mrr.mextent * a.mcr.mextent),
1941  a.msr,
1942  a.mbr,
1943  a.mpr,
1944  a.mrr,
1945  a.mcr) {
1946  // Nothing to do here.
1947 }
1948 
1953  const Range& v,
1954  const Range& s,
1955  const Range& b,
1956  const Range& p,
1957  const Range& r,
1958  const Range& c)
1959  : ConstTensor6View(data, v, s, b, p, r, c) {
1960  // Nothing to do here.
1961 }
1962 
1986  const Range& pv,
1987  const Range& ps,
1988  const Range& pb,
1989  const Range& pp,
1990  const Range& pr,
1991  const Range& pc,
1992  const Range& nv,
1993  const Range& ns,
1994  const Range& nb,
1995  const Range& np,
1996  const Range& nr,
1997  const Range& nc)
1998  : ConstTensor6View(data, pv, ps, pb, pp, pr, pc, nv, ns, nb, np, nr, nc) {
1999  // Nothing to do here.
2000 }
2001 
2006 void copy(ConstIterator6D origin,
2007  const ConstIterator6D& end,
2008  Iterator6D target) {
2009  for (; origin != end; ++origin, ++target) {
2010  // We use the copy function for the next smaller rank of tensor
2011  // recursively:
2012  copy(origin->begin(), origin->end(), target->begin());
2013  }
2014 }
2015 
2017 void copy(Numeric x, Iterator6D target, const Iterator6D& end) {
2018  for (; target != end; ++target) {
2019  // We use the copy function for the next smaller rank of tensor
2020  // recursively:
2021  copy(x, target->begin(), target->end());
2022  }
2023 }
2024 
2025 // Functions for Tensor6:
2026 // ---------------------
2027 
2031  : Tensor6View(new Numeric[v * s * b * p * r * c],
2032  Range(0, v, s * b * p * r * c),
2033  Range(0, s, b * p * r * c),
2034  Range(0, b, p * r * c),
2035  Range(0, p, r * c),
2036  Range(0, r, c),
2037  Range(0, c)) {
2038  // Nothing to do here.
2039 }
2040 
2043  Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill)
2044  : Tensor6View(new Numeric[v * s * b * p * r * c],
2045  Range(0, v, s * b * p * r * c),
2046  Range(0, s, b * p * r * c),
2047  Range(0, b, p * r * c),
2048  Range(0, p, r * c),
2049  Range(0, r, c),
2050  Range(0, c)) {
2051  // Here we can access the raw memory directly, for slightly
2052  // increased efficiency:
2053  std::fill_n(mdata, v * s * b * p * r * c, fill);
2054 }
2055 
2059  : Tensor6View(
2060  new Numeric[m.nvitrines() * m.nshelves() * m.nbooks() * m.npages() *
2061  m.nrows() * m.ncols()],
2062  Range(0,
2063  m.nvitrines(),
2064  m.nshelves() * m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2065  Range(
2066  0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2067  Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
2068  Range(0, m.npages(), m.nrows() * m.ncols()),
2069  Range(0, m.nrows(), m.ncols()),
2070  Range(0, m.ncols())) {
2071  copy(m.begin(), m.end(), begin());
2072 }
2073 
2077  : Tensor6View(
2078  new Numeric[m.nvitrines() * m.nshelves() * m.nbooks() * m.npages() *
2079  m.nrows() * m.ncols()],
2080  Range(0,
2081  m.nvitrines(),
2082  m.nshelves() * m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2083  Range(
2084  0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2085  Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
2086  Range(0, m.npages(), m.nrows() * m.ncols()),
2087  Range(0, m.nrows(), m.ncols()),
2088  Range(0, m.ncols())) {
2089  // There is a catch here: If m is an empty tensor, then it will have
2090  // dimensions of size 0. But these are used to initialize the stride
2091  // for higher dimensions! Thus, this method has to be consistent
2092  // with the behaviour of Range::Range. For now, Range::Range allows
2093  // also stride 0.
2094  std::memcpy(mdata,
2095  m.mdata,
2096  nvitrines() * nshelves() * nbooks() * npages() * nrows() *
2097  ncols() * sizeof(Numeric));
2098 }
2099 
2101 
2125  if (this != &x) {
2126  resize(x.nvitrines(),
2127  x.nshelves(),
2128  x.nbooks(),
2129  x.npages(),
2130  x.nrows(),
2131  x.ncols());
2132  std::memcpy(mdata,
2133  x.mdata,
2134  nvitrines() * nshelves() * nbooks() * npages() * nrows() *
2135  ncols() * sizeof(Numeric));
2136  }
2137  return *this;
2138 }
2139 
2142  if (this != &x) {
2143  delete[] mdata;
2144  mdata = x.mdata;
2145  mvr = x.mvr;
2146  msr = x.msr;
2147  mbr = x.mbr;
2148  mpr = x.mpr;
2149  mrr = x.mrr;
2150  mcr = x.mcr;
2151  x.mvr = Range(0, 0);
2152  x.msr = Range(0, 0);
2153  x.mbr = Range(0, 0);
2154  x.mpr = Range(0, 0);
2155  x.mrr = Range(0, 0);
2156  x.mcr = Range(0, 0);
2157  x.mdata = nullptr;
2158  }
2159  return *this;
2160 }
2161 
2165  std::fill_n(
2166  mdata,
2167  nvitrines() * nshelves() * nbooks() * npages() * nrows() * ncols(),
2168  x);
2169  return *this;
2170 }
2171 
2176  assert(0 <= v);
2177  assert(0 <= s);
2178  assert(0 <= b);
2179  assert(0 <= p);
2180  assert(0 <= r);
2181  assert(0 <= c);
2182 
2183  if (mvr.mextent != v || msr.mextent != s || mbr.mextent != b ||
2184  mpr.mextent != p || mrr.mextent != r || mcr.mextent != c) {
2185  delete[] mdata;
2186  mdata = new Numeric[v * s * b * p * r * c];
2187 
2188  mvr.mstart = 0;
2189  mvr.mextent = v;
2190  mvr.mstride = s * b * p * r * c;
2191 
2192  msr.mstart = 0;
2193  msr.mextent = s;
2194  msr.mstride = b * p * r * c;
2195 
2196  mbr.mstart = 0;
2197  mbr.mextent = b;
2198  mbr.mstride = p * r * c;
2199 
2200  mpr.mstart = 0;
2201  mpr.mextent = p;
2202  mpr.mstride = r * c;
2203 
2204  mrr.mstart = 0;
2205  mrr.mextent = r;
2206  mrr.mstride = c;
2207 
2208  mcr.mstart = 0;
2209  mcr.mextent = c;
2210  mcr.mstride = 1;
2211  }
2212 }
2213 
2215 void swap(Tensor6& t1, Tensor6& t2) {
2216  std::swap(t1.mvr, t2.mvr);
2217  std::swap(t1.msr, t2.msr);
2218  std::swap(t1.mbr, t2.mbr);
2219  std::swap(t1.mpr, t2.mpr);
2220  std::swap(t1.mrr, t2.mrr);
2221  std::swap(t1.mcr, t2.mcr);
2222  std::swap(t1.mdata, t2.mdata);
2223 }
2224 
2228  // cout << "Destroying a Tensor6:\n"
2229  // << *this << "\n........................................\n";
2230  delete[] mdata;
2231 }
2232 
2248 void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x) {
2249  // Check dimensions:
2250  assert(y.nvitrines() == x.nvitrines());
2251  assert(y.nshelves() == x.nshelves());
2252  assert(y.nbooks() == x.nbooks());
2253  assert(y.npages() == x.npages());
2254  assert(y.nrows() == x.nrows());
2255  assert(y.ncols() == x.ncols());
2256 
2257  const ConstIterator6D xe = x.end();
2258  ConstIterator6D xi = x.begin();
2259  Iterator6D yi = y.begin();
2260  for (; xi != xe; ++xi, ++yi) {
2261  // Use the transform function of lower dimensional tensors
2262  // recursively:
2263  transform(*yi, my_func, *xi);
2264  }
2265 }
2266 
2269  const ConstIterator6D xe = x.end();
2270  ConstIterator6D xi = x.begin();
2271 
2272  // Initial value for max:
2273  Numeric themax = max(*xi);
2274  ++xi;
2275 
2276  for (; xi != xe; ++xi) {
2277  // Use the max function of lower dimensional tensors
2278  // recursively:
2279  Numeric maxi = max(*xi);
2280  if (maxi > themax) themax = maxi;
2281  }
2282 
2283  return themax;
2284 }
2285 
2288  const ConstIterator6D xe = x.end();
2289  ConstIterator6D xi = x.begin();
2290 
2291  // Initial value for min:
2292  Numeric themin = min(*xi);
2293  ++xi;
2294 
2295  for (; xi != xe; ++xi) {
2296  // Use the min function of lower dimensional tensors
2297  // recursively:
2298  Numeric mini = min(*xi);
2299  if (mini < themin) themin = mini;
2300  }
2301 
2302  return themin;
2303 }
2304 
2306 // Helper function for debugging
2307 #ifndef NDEBUG
2308 
2327  Tensor6View& tv, Index v, Index s, Index b, Index p, Index r, Index c) {
2328  return tv(v, s, b, p, r, c);
2329 }
2330 
2331 #endif
2332 
friend class Tensor6View
Definition: matpackVI.h:564
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
#define OFFSET(x)
Definition: matpackVI.h:36
The VectorView class.
Definition: matpackI.h:610
Tensor6View()=default
#define ns
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:40
Index mstride
The stride.
Definition: matpackI.h:355
The Tensor4View class.
Definition: matpackIV.h:284
Iterator6D end()
Return iterator behind last sub-tensor.
Definition: matpackVI.cc:1758
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:607
Index mstart
The start index.
Definition: matpackI.h:346
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:2326
The MatrixView class.
Definition: matpackI.h:1093
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
A constant view of a Tensor6.
Definition: matpackVI.h:149
Tensor6View & operator/=(Numeric x)
Division by scalar.
Definition: matpackVI.cc:1840
The range class.
Definition: matpackI.h:160
Const version of Iterator6D.
Definition: matpackVI.h:87
virtual ~Tensor6()
Destructor for Tensor6.
Definition: matpackVI.cc:2227
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:882
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVI.h:599
void swap(Tensor6 &t1, Tensor6 &t2)
Swaps two objects.
Definition: matpackVI.cc:2215
The Tensor6View class.
Definition: matpackVI.h:621
ConstTensor6View()=default
Tensor6 & operator=(const Tensor6 &x)
Assignment operator from another tensor.
Definition: matpackVI.cc:2124
friend void swap(Tensor6 &t1, Tensor6 &t2)
Swaps two objects.
Definition: matpackVI.cc:2215
ConstIterator5D end() const
Return const iterator behind last shelf.
Definition: matpackV.cc:696
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Iterator5D end()
Return iterator behind last shelf.
Definition: matpackV.cc:1362
A constant view of a Tensor4.
Definition: matpackIV.h:133
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:601
Tensor6View & operator*=(Numeric x)
Multiplication by scalar.
Definition: matpackVI.cc:1831
Iterator6D begin()
Return iterator to first sub-tensor.
Definition: matpackVI.cc:1752
Tensor6View & operator+=(Numeric x)
Addition of scalar.
Definition: matpackVI.cc:1849
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
The Tensor3View class.
Definition: matpackIII.h:239
Numeric max(const ConstTensor6View &x)
Max function, tensor version.
Definition: matpackVI.cc:2268
std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:956
The declarations of all the exception classes.
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:605
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:54
Tensor6View & operator-=(Numeric x)
Subtraction of scalar.
Definition: matpackVI.cc:1858
A constant view of a Tensor5.
Definition: matpackV.h:143
Tensor6View & operator=(const ConstTensor6View &v)
Assignment operator.
Definition: matpackVI.cc:1773
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ConstIterator5D begin() const
Return const iterator to first shelf.
Definition: matpackV.cc:690
Index mextent
The number of elements.
Definition: matpackI.h:353
The Tensor5View class.
Definition: matpackV.h:333
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:875
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:45
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:57
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:609
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVI.h:597
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2006
bool empty() const
Check if variable is empty.
Definition: matpackVI.cc:36
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackVI.cc:1734
A constant view of a Tensor3.
Definition: matpackIII.h:132
The Tensor6 class.
Definition: matpackVI.h:1088
A constant view of a Vector.
Definition: matpackI.h:476
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:51
Range mpr
The page range of mdata that is actually used.
Definition: matpackVI.h:603
A constant view of a Matrix.
Definition: matpackI.h:982
Tensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c)
Definition: matpackVI.cc:981
void resize(Index v, Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackVI.cc:2175
Numeric min(const ConstTensor6View &x)
Min function, tensor version.
Definition: matpackVI.cc:2287
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:2248
ConstTensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Definition: matpackVI.cc:63
Iterator5D begin()
Return iterator to first shelf.
Definition: matpackV.cc:1356
Tensor6()=default
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:48