ARTS 2.5.0 (git: 9ee3ac6c)
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
956std::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 ARTS_ASSERT (not (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 "A Tensor6View can only be converted to a plain C-array if it's pointing to a continuous block of data");
1723 return mdata;
1724}
1725
1733 ARTS_ASSERT (not (mvr.mstart != 0 ||
1734 mvr.mstride !=
1736 msr.mstart != 0 ||
1738 mbr.mstart != 0 ||
1740 mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
1741 mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
1742 mcr.mstride != 1),
1743 "A Tensor6View can only be converted to a plain C-array if it's pointing to a continuous block of data");
1744 return mdata;
1745}
1746
1750 mvr.mstride);
1751}
1752
1755 return Iterator6D(
1757 msr,
1758 mbr,
1759 mpr,
1760 mrr,
1761 mcr),
1762 mvr.mstride);
1763}
1764
1770 // Check that sizes are compatible:
1777
1778 copy(m.begin(), m.end(), begin());
1779 return *this;
1780}
1781
1788 // Check that sizes are compatible:
1795
1796 copy(m.begin(), m.end(), begin());
1797 return *this;
1798}
1799
1804 // Check that sizes are compatible:
1811
1812 copy(m.begin(), m.end(), begin());
1813 return *this;
1814}
1815
1819 copy(x, begin(), end());
1820 return *this;
1821}
1822
1823// Some little helper functions:
1824//------------------------------
1825
1828 const Iterator6D ep = end();
1829 for (Iterator6D p = begin(); p != ep; ++p) {
1830 *p *= x;
1831 }
1832 return *this;
1833}
1834
1837 const Iterator6D ep = end();
1838 for (Iterator6D p = begin(); p != ep; ++p) {
1839 *p /= x;
1840 }
1841 return *this;
1842}
1843
1846 const Iterator6D ep = end();
1847 for (Iterator6D p = begin(); p != ep; ++p) {
1848 *p += x;
1849 }
1850 return *this;
1851}
1852
1855 const Iterator6D ep = end();
1856 for (Iterator6D p = begin(); p != ep; ++p) {
1857 *p -= x;
1858 }
1859 return *this;
1860}
1861
1865 ARTS_ASSERT(nshelves() == x.nshelves());
1866 ARTS_ASSERT(nbooks() == x.nbooks());
1867 ARTS_ASSERT(npages() == x.npages());
1868 ARTS_ASSERT(nrows() == x.nrows());
1869 ARTS_ASSERT(ncols() == x.ncols());
1870 ConstIterator6D xp = x.begin();
1871 Iterator6D p = begin();
1872 const Iterator6D ep = end();
1873 for (; p != ep; ++p, ++xp) {
1874 *p *= *xp;
1875 }
1876 return *this;
1877}
1878
1882 ARTS_ASSERT(nshelves() == x.nshelves());
1883 ARTS_ASSERT(nbooks() == x.nbooks());
1884 ARTS_ASSERT(npages() == x.npages());
1885 ARTS_ASSERT(nrows() == x.nrows());
1886 ARTS_ASSERT(ncols() == x.ncols());
1887 ConstIterator6D xp = x.begin();
1888 Iterator6D p = begin();
1889 const Iterator6D ep = end();
1890 for (; p != ep; ++p, ++xp) {
1891 *p /= *xp;
1892 }
1893 return *this;
1894}
1895
1899 ARTS_ASSERT(nshelves() == x.nshelves());
1900 ARTS_ASSERT(nbooks() == x.nbooks());
1901 ARTS_ASSERT(npages() == x.npages());
1902 ARTS_ASSERT(nrows() == x.nrows());
1903 ARTS_ASSERT(ncols() == x.ncols());
1904 ConstIterator6D xp = x.begin();
1905 Iterator6D p = begin();
1906 const Iterator6D ep = end();
1907 for (; p != ep; ++p, ++xp) {
1908 *p += *xp;
1909 }
1910 return *this;
1911}
1912
1916 ARTS_ASSERT(nshelves() == x.nshelves());
1917 ARTS_ASSERT(nbooks() == x.nbooks());
1918 ARTS_ASSERT(npages() == x.npages());
1919 ARTS_ASSERT(nrows() == x.nrows());
1920 ARTS_ASSERT(ncols() == x.ncols());
1921 ConstIterator6D xp = x.begin();
1922 Iterator6D p = begin();
1923 const Iterator6D ep = end();
1924 for (; p != ep; ++p, ++xp) {
1925 *p -= *xp;
1926 }
1927 return *this;
1928}
1929
1932 : ConstTensor6View(a.mdata,
1933 Range(0,
1934 1,
1935 a.msr.mextent * a.mbr.mextent * a.mpr.mextent *
1936 a.mrr.mextent * a.mcr.mextent),
1937 a.msr,
1938 a.mbr,
1939 a.mpr,
1940 a.mrr,
1941 a.mcr) {
1942 // Nothing to do here.
1943}
1944
1949 const Range& v,
1950 const Range& s,
1951 const Range& b,
1952 const Range& p,
1953 const Range& r,
1954 const Range& c)
1955 : ConstTensor6View(data, v, s, b, p, r, c) {
1956 // Nothing to do here.
1957}
1958
1982 const Range& pv,
1983 const Range& ps,
1984 const Range& pb,
1985 const Range& pp,
1986 const Range& pr,
1987 const Range& pc,
1988 const Range& nv,
1989 const Range& ns,
1990 const Range& nb,
1991 const Range& np,
1992 const Range& nr,
1993 const Range& nc)
1994 : ConstTensor6View(data, pv, ps, pb, pp, pr, pc, nv, ns, nb, np, nr, nc) {
1995 // Nothing to do here.
1996}
1997
2003 const ConstIterator6D& end,
2004 Iterator6D target) {
2005 for (; origin != end; ++origin, ++target) {
2006 // We use the copy function for the next smaller rank of tensor
2007 // recursively:
2008 copy(origin->begin(), origin->end(), target->begin());
2009 }
2010}
2011
2013void copy(Numeric x, Iterator6D target, const Iterator6D& end) {
2014 for (; target != end; ++target) {
2015 // We use the copy function for the next smaller rank of tensor
2016 // recursively:
2017 copy(x, target->begin(), target->end());
2018 }
2019}
2020
2021// Functions for Tensor6:
2022// ---------------------
2023
2027 : Tensor6View(new Numeric[v * s * b * p * r * c],
2028 Range(0, v, s * b * p * r * c),
2029 Range(0, s, b * p * r * c),
2030 Range(0, b, p * r * c),
2031 Range(0, p, r * c),
2032 Range(0, r, c),
2033 Range(0, c)) {
2034 // Nothing to do here.
2035}
2036
2039 Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill)
2040 : Tensor6View(new Numeric[v * s * b * p * r * c],
2041 Range(0, v, s * b * p * r * c),
2042 Range(0, s, b * p * r * c),
2043 Range(0, b, p * r * c),
2044 Range(0, p, r * c),
2045 Range(0, r, c),
2046 Range(0, c)) {
2047 // Here we can access the raw memory directly, for slightly
2048 // increased efficiency:
2049 std::fill_n(mdata, v * s * b * p * r * c, fill);
2050}
2051
2055 : Tensor6View(
2056 new Numeric[m.nvitrines() * m.nshelves() * m.nbooks() * m.npages() *
2057 m.nrows() * m.ncols()],
2058 Range(0,
2059 m.nvitrines(),
2060 m.nshelves() * m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2061 Range(
2062 0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2063 Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
2064 Range(0, m.npages(), m.nrows() * m.ncols()),
2065 Range(0, m.nrows(), m.ncols()),
2066 Range(0, m.ncols())) {
2067 copy(m.begin(), m.end(), begin());
2068}
2069
2073 : Tensor6View(
2074 new Numeric[m.nvitrines() * m.nshelves() * m.nbooks() * m.npages() *
2075 m.nrows() * m.ncols()],
2076 Range(0,
2077 m.nvitrines(),
2078 m.nshelves() * m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2079 Range(
2080 0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
2081 Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
2082 Range(0, m.npages(), m.nrows() * m.ncols()),
2083 Range(0, m.nrows(), m.ncols()),
2084 Range(0, m.ncols())) {
2085 // There is a catch here: If m is an empty tensor, then it will have
2086 // dimensions of size 0. But these are used to initialize the stride
2087 // for higher dimensions! Thus, this method has to be consistent
2088 // with the behaviour of Range::Range. For now, Range::Range allows
2089 // also stride 0.
2090 std::memcpy(mdata,
2091 m.mdata,
2092 nvitrines() * nshelves() * nbooks() * npages() * nrows() *
2093 ncols() * sizeof(Numeric));
2094}
2095
2097
2121 if (this != &x) {
2122 resize(x.nvitrines(),
2123 x.nshelves(),
2124 x.nbooks(),
2125 x.npages(),
2126 x.nrows(),
2127 x.ncols());
2128 std::memcpy(mdata,
2129 x.mdata,
2130 nvitrines() * nshelves() * nbooks() * npages() * nrows() *
2131 ncols() * sizeof(Numeric));
2132 }
2133 return *this;
2134}
2135
2138 if (this != &x) {
2139 delete[] mdata;
2140 mdata = x.mdata;
2141 mvr = x.mvr;
2142 msr = x.msr;
2143 mbr = x.mbr;
2144 mpr = x.mpr;
2145 mrr = x.mrr;
2146 mcr = x.mcr;
2147 x.mvr = Range(0, 0);
2148 x.msr = Range(0, 0);
2149 x.mbr = Range(0, 0);
2150 x.mpr = Range(0, 0);
2151 x.mrr = Range(0, 0);
2152 x.mcr = Range(0, 0);
2153 x.mdata = nullptr;
2154 }
2155 return *this;
2156}
2157
2161 std::fill_n(
2162 mdata,
2163 nvitrines() * nshelves() * nbooks() * npages() * nrows() * ncols(),
2164 x);
2165 return *this;
2166}
2167
2172 ARTS_ASSERT(0 <= v);
2173 ARTS_ASSERT(0 <= s);
2174 ARTS_ASSERT(0 <= b);
2175 ARTS_ASSERT(0 <= p);
2176 ARTS_ASSERT(0 <= r);
2177 ARTS_ASSERT(0 <= c);
2178
2179 if (mvr.mextent != v || msr.mextent != s || mbr.mextent != b ||
2180 mpr.mextent != p || mrr.mextent != r || mcr.mextent != c) {
2181 delete[] mdata;
2182 mdata = new Numeric[v * s * b * p * r * c];
2183
2184 mvr.mstart = 0;
2185 mvr.mextent = v;
2186 mvr.mstride = s * b * p * r * c;
2187
2188 msr.mstart = 0;
2189 msr.mextent = s;
2190 msr.mstride = b * p * r * c;
2191
2192 mbr.mstart = 0;
2193 mbr.mextent = b;
2194 mbr.mstride = p * r * c;
2195
2196 mpr.mstart = 0;
2197 mpr.mextent = p;
2198 mpr.mstride = r * c;
2199
2200 mrr.mstart = 0;
2201 mrr.mextent = r;
2202 mrr.mstride = c;
2203
2204 mcr.mstart = 0;
2205 mcr.mextent = c;
2206 mcr.mstride = 1;
2207 }
2208}
2209
2211void swap(Tensor6& t1, Tensor6& t2) {
2212 std::swap(t1.mvr, t2.mvr);
2213 std::swap(t1.msr, t2.msr);
2214 std::swap(t1.mbr, t2.mbr);
2215 std::swap(t1.mpr, t2.mpr);
2216 std::swap(t1.mrr, t2.mrr);
2217 std::swap(t1.mcr, t2.mcr);
2218 std::swap(t1.mdata, t2.mdata);
2219}
2220
2224 // cout << "Destroying a Tensor6:\n"
2225 // << *this << "\n........................................\n";
2226 delete[] mdata;
2227}
2228
2244void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x) {
2245 // Check dimensions:
2246 ARTS_ASSERT(y.nvitrines() == x.nvitrines());
2247 ARTS_ASSERT(y.nshelves() == x.nshelves());
2248 ARTS_ASSERT(y.nbooks() == x.nbooks());
2249 ARTS_ASSERT(y.npages() == x.npages());
2250 ARTS_ASSERT(y.nrows() == x.nrows());
2251 ARTS_ASSERT(y.ncols() == x.ncols());
2252
2253 const ConstIterator6D xe = x.end();
2254 ConstIterator6D xi = x.begin();
2255 Iterator6D yi = y.begin();
2256 for (; xi != xe; ++xi, ++yi) {
2257 // Use the transform function of lower dimensional tensors
2258 // recursively:
2259 transform(*yi, my_func, *xi);
2260 }
2261}
2262
2265 const ConstIterator6D xe = x.end();
2266 ConstIterator6D xi = x.begin();
2267
2268 // Initial value for max:
2269 Numeric themax = max(*xi);
2270 ++xi;
2271
2272 for (; xi != xe; ++xi) {
2273 // Use the max function of lower dimensional tensors
2274 // recursively:
2275 Numeric maxi = max(*xi);
2276 if (maxi > themax) themax = maxi;
2277 }
2278
2279 return themax;
2280}
2281
2284 const ConstIterator6D xe = x.end();
2285 ConstIterator6D xi = x.begin();
2286
2287 // Initial value for min:
2288 Numeric themin = min(*xi);
2289 ++xi;
2290
2291 for (; xi != xe; ++xi) {
2292 // Use the min function of lower dimensional tensors
2293 // recursively:
2294 Numeric mini = min(*xi);
2295 if (mini < themin) themin = mini;
2296 }
2297
2298 return themin;
2299}
2300
2302// Helper function for debugging
2303#ifndef NDEBUG
2304
2323 Tensor6View& tv, Index v, Index s, Index b, Index p, Index r, Index c) {
2324 return tv(v, s, b, p, r, c);
2325}
2326
2327#endif
Index nrows
Index nbooks
Index npages
void * data
Index nvitrines
Index nshelves
Index ncols
Const version of Iterator6D.
Definition: matpackVI.h:87
A constant view of a Matrix.
Definition: matpackI.h:1014
A constant view of a Tensor3.
Definition: matpackIII.h:132
A constant view of a Tensor4.
Definition: matpackIV.h:133
A constant view of a Tensor5.
Definition: matpackV.h:143
ConstIterator5D end() const
Return const iterator behind last shelf.
Definition: matpackV.cc:694
ConstIterator5D begin() const
Return const iterator to first shelf.
Definition: matpackV.cc:688
A constant view of a Tensor6.
Definition: matpackVI.h:149
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:875
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:57
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:51
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:54
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:882
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVI.h:597
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:607
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:45
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:601
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:609
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:48
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:605
bool empty() const
Check if variable is empty.
Definition: matpackVI.cc:36
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
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
Range mpr
The page range of mdata that is actually used.
Definition: matpackVI.h:603
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVI.h:599
ConstTensor6View()=default
A constant view of a Vector.
Definition: matpackI.h:489
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:40
The MatrixView class.
Definition: matpackI.h:1125
The range class.
Definition: matpackI.h:165
Index mstart
The start index.
Definition: matpackI.h:351
Index mstride
The stride.
Definition: matpackI.h:360
Index mextent
The number of elements.
Definition: matpackI.h:358
The Tensor3View class.
Definition: matpackIII.h:239
The Tensor4View class.
Definition: matpackIV.h:284
The Tensor5View class.
Definition: matpackV.h:333
Iterator5D end()
Return iterator behind last shelf.
Definition: matpackV.cc:1360
Iterator5D begin()
Return iterator to first shelf.
Definition: matpackV.cc:1354
The Tensor6View class.
Definition: matpackVI.h:621
Tensor6View & operator-=(Numeric x)
Subtraction of scalar.
Definition: matpackVI.cc:1854
Tensor6View & operator/=(Numeric x)
Division by scalar.
Definition: matpackVI.cc:1836
Iterator6D end()
Return iterator behind last sub-tensor.
Definition: matpackVI.cc:1754
Iterator6D begin()
Return iterator to first sub-tensor.
Definition: matpackVI.cc:1748
Tensor6View()=default
Tensor6View & operator=(const ConstTensor6View &v)
Assignment operator.
Definition: matpackVI.cc:1769
Tensor6View & operator+=(Numeric x)
Addition of scalar.
Definition: matpackVI.cc:1845
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Definition: matpackVI.cc:1732
Tensor6View & operator*=(Numeric x)
Multiplication by scalar.
Definition: matpackVI.cc:1827
Tensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c)
Definition: matpackVI.cc:981
The Tensor6 class.
Definition: matpackVI.h:1088
void resize(Index v, Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackVI.cc:2171
Tensor6()=default
Tensor6 & operator=(const Tensor6 &x)
Assignment operator from another tensor.
Definition: matpackVI.cc:2120
virtual ~Tensor6()
Destructor for Tensor6.
Definition: matpackVI.cc:2223
The VectorView class.
Definition: matpackI.h:626
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
The declarations of all the exception classes.
#define ns
void swap(Tensor6 &t1, Tensor6 &t2)
Swaps two objects.
Definition: matpackVI.cc:2211
Numeric max(const ConstTensor6View &x)
Max function, tensor version.
Definition: matpackVI.cc:2264
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2002
Numeric min(const ConstTensor6View &x)
Min function, tensor version.
Definition: matpackVI.cc:2283
std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:956
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:2244
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:2322
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
#define OFFSET(x)
Definition: matpackVI.h:36
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:109
#define v
#define a
#define c
#define b