ARTS 2.5.0 (git: 9ee3ac6c)
matpackVI.h
Go to the documentation of this file.
1/* Copyright (C) 2001-2012 Stefan Buehler <sbuehler@ltu.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
28#ifndef matpackVI_h
29#define matpackVI_h
30
31#include "matpackV.h"
32
33#define CHECK(x) \
34 ARTS_ASSERT(0 <= x); \
35 ARTS_ASSERT(x < m##x##r.mextent)
36#define OFFSET(x) m##x##r.mstart + x* m##x##r.mstride
37
41 public:
42 // Constructors:
44 Iterator6D() = default;
45
47 Iterator6D(const Tensor5View& x, Index stride)
48 : msv(x), mstride(stride) { /* Nothing to do here. */
49 }
50
51 // Operators:
54 msv.mdata += mstride;
55 return *this;
56 }
57
62 bool operator!=(const Iterator6D& other) const {
65 other.msv.mdata + other.msv.msr.mstart + other.msv.mbr.mstart +
66 other.msv.mpr.mstart + other.msv.mrr.mstart + other.msv.mcr.mstart)
67 return true;
68 else
69 return false;
70 }
71
74 Tensor5View* operator->() { return &msv; }
75
77 Tensor5View& operator*() { return msv; }
78
79 private:
84};
85
88 public:
89 // Constructors:
91 ConstIterator6D() = default;
92
95 : msv(x), mstride(stride) { /* Nothing to do here. */
96 }
97
98 // Operators:
101 msv.mdata += mstride;
102 return *this;
103 }
104
109 bool operator!=(const ConstIterator6D& other) const {
112 other.msv.mdata + other.msv.msr.mstart + other.msv.mbr.mstart +
113 other.msv.mpr.mstart + other.msv.mrr.mstart + other.msv.mcr.mstart)
114 return true;
115 else
116 return false;
117 }
118
121 const ConstTensor5View* operator->() const { return &msv; }
122
124 const ConstTensor5View& operator*() const { return msv; }
125
126 private:
131};
132
133// Declare class Tensor6:
134class Tensor6;
135
150 public:
151 constexpr ConstTensor6View(const ConstTensor6View&) = default;
152 constexpr ConstTensor6View(ConstTensor6View&&) = default;
155
156 // Member functions:
157 bool empty() const;
158 Index nvitrines() const;
159 Index nshelves() const;
160 Index nbooks() const;
161 Index npages() const;
162 Index nrows() const;
163 Index ncols() const;
164
165 // Const index operators:
166
167 // Result 6D (1 combination)
168 // ------
170 const Range& s,
171 const Range& b,
172 const Range& p,
173 const Range& r,
174 const Range& c) const;
175
176 // Result 5D (6 combinations)
177 // -----|
179 const Range& s,
180 const Range& b,
181 const Range& p,
182 const Range& r,
183 Index c) const;
184 // ----|-
186 const Range& s,
187 const Range& b,
188 const Range& p,
189 Index r,
190 const Range& c) const;
191 // ---|--
193 const Range& s,
194 const Range& b,
195 Index p,
196 const Range& r,
197 const Range& c) const;
198 // --|---
200 const Range& s,
201 Index b,
202 const Range& p,
203 const Range& r,
204 const Range& c) const;
205 // -|----
207 Index s,
208 const Range& b,
209 const Range& p,
210 const Range& r,
211 const Range& c) const;
212 // |-----
214 const Range& s,
215 const Range& b,
216 const Range& p,
217 const Range& r,
218 const Range& c) const;
219
220 // Result 4D (5+4+3+2+1 = 15 combinations)
221 // ----||
223 const Range& s,
224 const Range& b,
225 const Range& p,
226 Index r,
227 Index c) const;
228 // ---|-|
230 const Range& s,
231 const Range& b,
232 Index p,
233 const Range& r,
234 Index c) const;
235 // --|--|
237 const Range& s,
238 Index b,
239 const Range& p,
240 const Range& r,
241 Index c) const;
242 // -|---|
244 Index s,
245 const Range& b,
246 const Range& p,
247 const Range& r,
248 Index c) const;
249 // |----|
251 const Range& s,
252 const Range& b,
253 const Range& p,
254 const Range& r,
255 Index c) const;
256 // ---||-
258 const Range& s,
259 const Range& b,
260 Index p,
261 Index r,
262 const Range& c) const;
263 // --|-|-
265 const Range& s,
266 Index b,
267 const Range& p,
268 Index r,
269 const Range& c) const;
270 // -|--|-
272 Index s,
273 const Range& b,
274 const Range& p,
275 Index r,
276 const Range& c) const;
277 // |---|-
279 const Range& s,
280 const Range& b,
281 const Range& p,
282 Index r,
283 const Range& c) const;
284 // --||--
286 const Range& s,
287 Index b,
288 Index p,
289 const Range& r,
290 const Range& c) const;
291 // -|-|--
293 Index s,
294 const Range& b,
295 Index p,
296 const Range& r,
297 const Range& c) const;
298 // |--|--
300 const Range& s,
301 const Range& b,
302 Index p,
303 const Range& r,
304 const Range& c) const;
305 // -||---
307 Index s,
308 Index b,
309 const Range& p,
310 const Range& r,
311 const Range& c) const;
312 // |-|---
314 const Range& s,
315 Index b,
316 const Range& p,
317 const Range& r,
318 const Range& c) const;
319 // ||----
321 Index s,
322 const Range& b,
323 const Range& p,
324 const Range& r,
325 const Range& c) const;
326
327 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
328 // ---|||
330 const Range& s,
331 const Range& b,
332 Index p,
333 Index r,
334 Index c) const;
335 // --|-||
337 const Range& s,
338 Index b,
339 const Range& p,
340 Index r,
341 Index c) const;
342 // -|--||
344 Index s,
345 const Range& b,
346 const Range& p,
347 Index r,
348 Index c) const;
349 // |---||
351 const Range& s,
352 const Range& b,
353 const Range& p,
354 Index r,
355 Index c) const;
356 // --||-|
358 const Range& s,
359 Index b,
360 Index p,
361 const Range& r,
362 Index c) const;
363 // -|-|-|
365 Index s,
366 const Range& b,
367 Index p,
368 const Range& r,
369 Index c) const;
370 // |--|-|
372 const Range& s,
373 const Range& b,
374 Index p,
375 const Range& r,
376 Index c) const;
377 // -||--|
379 Index s,
380 Index b,
381 const Range& p,
382 const Range& r,
383 Index c) const;
384 // |-|--|
386 const Range& s,
387 Index b,
388 const Range& p,
389 const Range& r,
390 Index c) const;
391 // ||---|
393 Index s,
394 const Range& b,
395 const Range& p,
396 const Range& r,
397 Index c) const;
398 // --|||-
400 const Range& s,
401 Index b,
402 Index p,
403 Index r,
404 const Range& c) const;
405 // -|-||-
407 Index s,
408 const Range& b,
409 Index p,
410 Index r,
411 const Range& c) const;
412 // |--||-
414 const Range& s,
415 const Range& b,
416 Index p,
417 Index r,
418 const Range& c) const;
419 // -||-|-
421 Index s,
422 Index b,
423 const Range& p,
424 Index r,
425 const Range& c) const;
426 // |-|-|-
428 const Range& s,
429 Index b,
430 const Range& p,
431 Index r,
432 const Range& c) const;
433 // ||--|-
435 Index s,
436 const Range& b,
437 const Range& p,
438 Index r,
439 const Range& c) const;
440 // -|||--
442 Index s,
443 Index b,
444 Index p,
445 const Range& r,
446 const Range& c) const;
447 // |-||--
449 const Range& s,
450 Index b,
451 Index p,
452 const Range& r,
453 const Range& c) const;
454 // ||-|--
456 Index s,
457 const Range& b,
458 Index p,
459 const Range& r,
460 const Range& c) const;
461 // |||---
463 Index s,
464 Index b,
465 const Range& p,
466 const Range& r,
467 const Range& c) const;
468
469 // Result 2D (15 combinations)
470 // IIII--
472 Index v, Index s, Index b, Index p, const Range& r, const Range& c) const;
473 // III-I-
475 Index v, Index s, Index b, const Range& p, Index r, const Range& c) const;
476 // II-II-
478 Index v, Index s, const Range& b, Index p, Index r, const Range& c) const;
479 // I-III-
481 Index v, const Range& s, Index b, Index p, Index r, const Range& c) const;
482 // -IIII-
484 const Range& v, Index s, Index b, Index p, Index r, const Range& c) const;
485 // III--I
487 Index v, Index s, Index b, const Range& p, const Range& r, Index c) const;
488 // II-I-I
490 Index v, Index s, const Range& b, Index p, const Range& r, Index c) const;
491 // I-II-I
493 Index v, const Range& s, Index b, Index p, const Range& r, Index c) const;
494 // -III-I
496 const Range& v, Index s, Index b, Index p, const Range& r, Index c) const;
497 // II--II
499 Index v, Index s, const Range& b, const Range& p, Index r, Index c) const;
500 // I-I-II
502 Index v, const Range& s, Index b, const Range& p, Index r, Index c) const;
503 // -II-II
505 const Range& v, Index s, Index b, const Range& p, Index r, Index c) const;
506 // I--III
508 Index v, const Range& s, const Range& b, Index p, Index r, Index c) const;
509 // -I-III
511 const Range& v, Index s, const Range& b, Index p, Index r, Index c) const;
512 // --IIII
514 const Range& v, const Range& s, Index b, Index p, Index r, Index c) const;
515
516 // Result 1D (6 combinations)
517 // IIIII-
519 Index v, Index s, Index b, Index p, Index r, const Range& c) const;
520 // IIII-I
522 Index v, Index s, Index b, Index p, const Range& r, Index c) const;
523 // III-II
525 Index v, Index s, Index b, const Range& p, Index r, Index c) const;
526 // II-III
528 Index v, Index s, const Range& b, Index p, Index r, Index c) const;
529 // I-IIII
531 Index v, const Range& s, Index b, Index p, Index r, Index c) const;
532 // -IIIII
534 const Range& v, Index s, Index b, Index p, Index r, Index c) const;
535
536 // Result scalar (1 combination)
537 // IIIIII
539 Index v, Index s, Index b, Index p, Index r, Index c) const {
540 CHECK(v);
541 CHECK(s);
542 CHECK(b);
543 CHECK(p);
544 CHECK(r);
545 CHECK(c);
546 return get(v, s, b, p, r, c);
547 }
548
551 return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
552 OFFSET(c));
553 }
554
555 // Functions returning iterators:
556 ConstIterator6D begin() const;
557 ConstIterator6D end() const;
558
559 // Destructor:
560 virtual ~ConstTensor6View() = default;
561
562 // Friends:
563 friend class ConstIterator7D;
564 friend class Tensor6View;
565 friend class ConstTensor7View;
566
567 // Special constructor to make a Tensor6 view of a Tensor5.
569
570 protected:
571 // Constructors:
572 ConstTensor6View() = default;
574 const Range& v,
575 const Range& s,
576 const Range& b,
577 const Range& p,
578 const Range& r,
579 const Range& c);
581 const Range& pv,
582 const Range& ps,
583 const Range& pb,
584 const Range& pp,
585 const Range& pr,
586 const Range& pc,
587 const Range& nv,
588 const Range& ns,
589 const Range& nb,
590 const Range& np,
591 const Range& nr,
592 const Range& nc);
593
594 // Data members:
595 // -------------
597 Range mvr{0, 0, 1};
599 Range msr{0, 0, 1};
601 Range mbr{0, 0, 1};
603 Range mpr{0, 0, 1};
605 Range mrr{0, 0, 1};
607 Range mcr{0, 0, 1};
609 Numeric* mdata{nullptr};
610};
611
622 public:
623 // Make const methods visible from base class
626 using ConstTensor6View::operator();
628
629 constexpr Tensor6View(const Tensor6View&) = default;
630
631 // Non-const index operators:
632
633 // Result 6D (1 combination)
634 // ------
636 const Range& s,
637 const Range& b,
638 const Range& p,
639 const Range& r,
640 const Range& c);
641
642 // Result 5D (6 combinations)
643 // -----|
645 const Range& s,
646 const Range& b,
647 const Range& p,
648 const Range& r,
649 Index c);
650 // ----|-
652 const Range& s,
653 const Range& b,
654 const Range& p,
655 Index r,
656 const Range& c);
657 // ---|--
659 const Range& s,
660 const Range& b,
661 Index p,
662 const Range& r,
663 const Range& c);
664 // --|---
666 const Range& s,
667 Index b,
668 const Range& p,
669 const Range& r,
670 const Range& c);
671 // -|----
673 Index s,
674 const Range& b,
675 const Range& p,
676 const Range& r,
677 const Range& c);
678 // |-----
680 const Range& s,
681 const Range& b,
682 const Range& p,
683 const Range& r,
684 const Range& c);
685
686 // Result 4D (5+4+3+2+1 = 15 combinations)
687 // ----||
689 const Range& s,
690 const Range& b,
691 const Range& p,
692 Index r,
693 Index c);
694 // ---|-|
696 const Range& s,
697 const Range& b,
698 Index p,
699 const Range& r,
700 Index c);
701 // --|--|
703 const Range& s,
704 Index b,
705 const Range& p,
706 const Range& r,
707 Index c);
708 // -|---|
710 Index s,
711 const Range& b,
712 const Range& p,
713 const Range& r,
714 Index c);
715 // |----|
717 const Range& s,
718 const Range& b,
719 const Range& p,
720 const Range& r,
721 Index c);
722 // ---||-
724 const Range& s,
725 const Range& b,
726 Index p,
727 Index r,
728 const Range& c);
729 // --|-|-
731 const Range& s,
732 Index b,
733 const Range& p,
734 Index r,
735 const Range& c);
736 // -|--|-
738 Index s,
739 const Range& b,
740 const Range& p,
741 Index r,
742 const Range& c);
743 // |---|-
745 const Range& s,
746 const Range& b,
747 const Range& p,
748 Index r,
749 const Range& c);
750 // --||--
752 const Range& s,
753 Index b,
754 Index p,
755 const Range& r,
756 const Range& c);
757 // -|-|--
759 Index s,
760 const Range& b,
761 Index p,
762 const Range& r,
763 const Range& c);
764 // |--|--
766 const Range& s,
767 const Range& b,
768 Index p,
769 const Range& r,
770 const Range& c);
771 // -||---
773 Index s,
774 Index b,
775 const Range& p,
776 const Range& r,
777 const Range& c);
778 // |-|---
780 const Range& s,
781 Index b,
782 const Range& p,
783 const Range& r,
784 const Range& c);
785 // ||----
787 Index s,
788 const Range& b,
789 const Range& p,
790 const Range& r,
791 const Range& c);
792
793 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
794 // ---|||
796 const Range& s,
797 const Range& b,
798 Index p,
799 Index r,
800 Index c);
801 // --|-||
803 const Range& s,
804 Index b,
805 const Range& p,
806 Index r,
807 Index c);
808 // -|--||
810 Index s,
811 const Range& b,
812 const Range& p,
813 Index r,
814 Index c);
815 // |---||
817 const Range& s,
818 const Range& b,
819 const Range& p,
820 Index r,
821 Index c);
822 // --||-|
824 const Range& s,
825 Index b,
826 Index p,
827 const Range& r,
828 Index c);
829 // -|-|-|
831 Index s,
832 const Range& b,
833 Index p,
834 const Range& r,
835 Index c);
836 // |--|-|
838 const Range& s,
839 const Range& b,
840 Index p,
841 const Range& r,
842 Index c);
843 // -||--|
845 Index s,
846 Index b,
847 const Range& p,
848 const Range& r,
849 Index c);
850 // |-|--|
852 const Range& s,
853 Index b,
854 const Range& p,
855 const Range& r,
856 Index c);
857 // ||---|
859 Index s,
860 const Range& b,
861 const Range& p,
862 const Range& r,
863 Index c);
864 // --|||-
866 const Range& s,
867 Index b,
868 Index p,
869 Index r,
870 const Range& c);
871 // -|-||-
873 Index s,
874 const Range& b,
875 Index p,
876 Index r,
877 const Range& c);
878 // |--||-
880 const Range& s,
881 const Range& b,
882 Index p,
883 Index r,
884 const Range& c);
885 // -||-|-
887 Index s,
888 Index b,
889 const Range& p,
890 Index r,
891 const Range& c);
892 // |-|-|-
894 const Range& s,
895 Index b,
896 const Range& p,
897 Index r,
898 const Range& c);
899 // ||--|-
901 Index s,
902 const Range& b,
903 const Range& p,
904 Index r,
905 const Range& c);
906 // -|||--
908 Index s,
909 Index b,
910 Index p,
911 const Range& r,
912 const Range& c);
913 // |-||--
915 const Range& s,
916 Index b,
917 Index p,
918 const Range& r,
919 const Range& c);
920 // ||-|--
922 Index s,
923 const Range& b,
924 Index p,
925 const Range& r,
926 const Range& c);
927 // |||---
929 Index s,
930 Index b,
931 const Range& p,
932 const Range& r,
933 const Range& c);
934
935 // Result 2D (15 combinations)
936 // IIII--
938 Index v, Index s, Index b, Index p, const Range& r, const Range& c);
939 // III-I-
941 Index v, Index s, Index b, const Range& p, Index r, const Range& c);
942 // II-II-
944 Index v, Index s, const Range& b, Index p, Index r, const Range& c);
945 // I-III-
947 Index v, const Range& s, Index b, Index p, Index r, const Range& c);
948 // -IIII-
950 const Range& v, Index s, Index b, Index p, Index r, const Range& c);
951 // III--I
953 Index v, Index s, Index b, const Range& p, const Range& r, Index c);
954 // II-I-I
956 Index v, Index s, const Range& b, Index p, const Range& r, Index c);
957 // I-II-I
959 Index v, const Range& s, Index b, Index p, const Range& r, Index c);
960 // -III-I
962 const Range& v, Index s, Index b, Index p, const Range& r, Index c);
963 // II--II
965 Index v, Index s, const Range& b, const Range& p, Index r, Index c);
966 // I-I-II
968 Index v, const Range& s, Index b, const Range& p, Index r, Index c);
969 // -II-II
971 const Range& v, Index s, Index b, const Range& p, Index r, Index c);
972 // I--III
974 Index v, const Range& s, const Range& b, Index p, Index r, Index c);
975 // -I-III
977 const Range& v, Index s, const Range& b, Index p, Index r, Index c);
978 // --IIII
980 const Range& v, const Range& s, Index b, Index p, Index r, Index c);
981
982 // Result 1D (6 combinations)
983 // IIIII-
985 Index v, Index s, Index b, Index p, Index r, const Range& c);
986 // IIII-I
988 Index v, Index s, Index b, Index p, const Range& r, Index c);
989 // III-II
991 Index v, Index s, Index b, const Range& p, Index r, Index c);
992 // II-III
994 Index v, Index s, const Range& b, Index p, Index r, Index c);
995 // I-IIII
997 Index v, const Range& s, Index b, Index p, Index r, Index c);
998 // -IIIII
1000 const Range& v, Index s, Index b, Index p, Index r, Index c);
1001
1002 // Result scalar (1 combination)
1003 // IIIIII
1005 CHECK(v);
1006 CHECK(s);
1007 CHECK(b);
1008 CHECK(p);
1009 CHECK(r);
1010 CHECK(c);
1011 return get(v, s, b, p, r, c);
1012 }
1013
1016 return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
1017 OFFSET(c));
1018 }
1019
1020 // Conversion to a plain C-array
1021 const Numeric* get_c_array() const ARTS_NOEXCEPT;
1023
1024 // Functions returning iterators:
1025 Iterator6D begin();
1026 Iterator6D end();
1027
1028 // Assignment operators:
1029 Tensor6View& operator=(const ConstTensor6View& v);
1030 Tensor6View& operator=(const Tensor6View& v);
1031 Tensor6View& operator=(const Tensor6& v);
1032 Tensor6View& operator=(Numeric x);
1033
1034 // Other operators:
1035 Tensor6View& operator*=(Numeric x);
1036 Tensor6View& operator/=(Numeric x);
1037 Tensor6View& operator+=(Numeric x);
1038 Tensor6View& operator-=(Numeric x);
1039
1040 Tensor6View& operator*=(const ConstTensor6View& x);
1041 Tensor6View& operator/=(const ConstTensor6View& x);
1042 Tensor6View& operator+=(const ConstTensor6View& x);
1043 Tensor6View& operator-=(const ConstTensor6View& x);
1044
1045 // Destructor:
1046 virtual ~Tensor6View() = default;
1047
1048 // Friends:
1049 friend class Iterator7D;
1050 friend class Tensor7View;
1051
1052 // Special constructor to make a Tensor6 view of a Tensor5.
1053 Tensor6View(const Tensor5View& a);
1054
1055 protected:
1056 // Constructors:
1057 Tensor6View() = default;
1059 const Range& v,
1060 const Range& s,
1061 const Range& b,
1062 const Range& p,
1063 const Range& r,
1064 const Range& c);
1066 const Range& pv,
1067 const Range& ps,
1068 const Range& pb,
1069 const Range& pp,
1070 const Range& pr,
1071 const Range& pc,
1072 const Range& nv,
1073 const Range& ns,
1074 const Range& nb,
1075 const Range& np,
1076 const Range& nr,
1077 const Range& nc);
1078};
1079
1088class Tensor6 : public Tensor6View {
1089 public:
1090 // Constructors:
1091 Tensor6() = default;
1092 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c);
1093 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill);
1094 Tensor6(const ConstTensor6View& v);
1095 Tensor6(const Tensor6& v);
1096 Tensor6(Tensor6&& v) noexcept : Tensor6View(std::forward<Tensor6View>(v)) {
1097 v.mdata = nullptr;
1098 }
1099
1113 Tensor6(Numeric* d, const Range& r0, const Range& r1, const Range& r2, const Range& r3, const Range& r4, const Range& r5) ARTS_NOEXCEPT
1114 : Tensor6View(d, r0, r1, r2, r3, r4, r5) {
1115 ARTS_ASSERT (not (r0.get_extent() < 0), "Must have size");
1116 ARTS_ASSERT (not (r1.get_extent() < 0), "Must have size");
1117 ARTS_ASSERT (not (r2.get_extent() < 0), "Must have size");
1118 ARTS_ASSERT (not (r3.get_extent() < 0), "Must have size");
1119 ARTS_ASSERT (not (r4.get_extent() < 0), "Must have size");
1120 ARTS_ASSERT (not (r5.get_extent() < 0), "Must have size");
1121 }
1122
1123 // Assignment operators:
1124 Tensor6& operator=(const Tensor6& x);
1125 Tensor6& operator=(Tensor6&& x) noexcept;
1127
1128 // Resize function:
1129 void resize(Index v, Index s, Index b, Index p, Index r, Index c);
1130
1131 // Swap function:
1132 friend void swap(Tensor6& t1, Tensor6& t2);
1133
1134 // Destructor:
1135 virtual ~Tensor6();
1136
1137 // Total size
1138 Index size() const noexcept {return nvitrines() * nshelves() * nbooks() * npages() * nrows() * ncols();}
1139
1141 template <std::size_t dim0>
1143 static_assert(dim0 < 6, "Bad Dimension, Out-of-Bounds");
1144
1145 Range r0(0, dim0 == 0 ? nvitrines() : dim0 == 1 ? nshelves() : dim0 == 2 ? nbooks() : dim0 == 3 ? npages() : dim0 == 4 ? nrows() : ncols());
1146
1147 Vector out(mdata, r0);
1148 ARTS_ASSERT (size() == out.size(), "Can only reduce size on same size input");
1149 mdata = nullptr;
1150 return out;
1151 }
1152
1154 template <std::size_t dim0, std::size_t dim1>
1156 static_assert(dim1 < 6, "Bad Dimension, Out-of-Bounds");
1157 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1158
1159 const Range r1(0, dim1 == 1 ? nshelves() : dim1 == 2 ? nbooks() : dim1 == 3 ? npages() : dim1 == 4 ? nrows() : ncols());
1160 const Range r0(0, dim0 == 0 ? nvitrines() : dim0 == 1 ? nshelves() : dim0 == 2 ? nbooks() : dim0 == 3 ? npages() : nrows(), r1.get_extent());
1161
1162 Matrix out(mdata, r0, r1);
1163 ARTS_ASSERT (size() == out.size(), "Can only reduce size on same size input");
1164 mdata = nullptr;
1165 return out;
1166 }
1167
1169 template <std::size_t dim0, std::size_t dim1, std::size_t dim2>
1171 static_assert(dim2 < 6, "Bad Dimension, Out-of-Bounds");
1172 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1173 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1174
1175 const Range r2(0, dim2 == 2 ? nbooks() : dim2 == 3 ? npages() : dim2 == 4 ? nrows() : ncols());
1176 const Range r1(0, dim1 == 1 ? nshelves() : dim1 == 2 ? nbooks() : dim1 == 3 ? npages() : nrows(), r2.get_extent());
1177 const Range r0(0, dim0 == 0 ? nvitrines() : dim0 == 1 ? nshelves() : dim0 == 2 ? nbooks() : npages(), r1.get_extent() * r2.get_extent());
1178
1179 Tensor3 out(mdata, r0, r1, r2);
1180 ARTS_ASSERT (size() == out.size(), "Can only reduce size on same size input");
1181 mdata = nullptr;
1182 return out;
1183 }
1184
1186 template <std::size_t dim0, std::size_t dim1, std::size_t dim2, std::size_t dim3>
1188 static_assert(dim3 < 6, "Bad Dimension, Out-of-Bounds");
1189 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1190 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1191 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1192
1193 const Range r3(0, dim3 == 3 ? npages() : dim3 == 4 ? nrows() : ncols());
1194 const Range r2(0, dim2 == 2 ? nbooks() : dim2 == 3 ? npages() : nrows(), r3.get_extent());
1195 const Range r1(0, dim1 == 1 ? nshelves() : dim1 == 2 ? nbooks() : npages(), r2.get_extent() * r3.get_extent());
1196 const Range r0(0, dim0 == 0 ? nvitrines() : dim0 == 1 ? nshelves() : nbooks(), r1.get_extent() * r2.get_extent() * r3.get_extent());
1197
1198 Tensor4 out(mdata, r0, r1, r2, r3);
1199 ARTS_ASSERT (size() == out.size(), "Can only reduce size on same size input");
1200 mdata = nullptr;
1201 return out;
1202 }
1203
1205 template <std::size_t dim0, std::size_t dim1, std::size_t dim2, std::size_t dim3, std::size_t dim4>
1207 static_assert(dim4 < 6, "Bad Dimension, Out-of-Bounds");
1208 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1209 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1210 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1211 static_assert(dim3 < dim4, "Bad Dimensions, dim4 must be larger than dim3");
1212
1213 const Range r4(0, dim4 == 4 ? nrows() : ncols());
1214 const Range r3(0, dim3 == 3 ? npages() : nrows(), r4.get_extent());
1215 const Range r2(0, dim2 == 2 ? nbooks() : npages(), r3.get_extent() * r4.get_extent());
1216 const Range r1(0, dim1 == 1 ? nshelves() : nbooks(), r2.get_extent() * r3.get_extent() * r4.get_extent());
1217 const Range r0(0, dim0 == 0 ? nvitrines() : nshelves(), r1.get_extent() * r2.get_extent() * r3.get_extent() * r4.get_extent());
1218
1219 Tensor5 out(mdata, r0, r1, r2, r3, r4);
1220 ARTS_ASSERT (size() == out.size(), "Can only reduce size on same size input");
1221 mdata = nullptr;
1222 return out;
1223 }
1224};
1225
1226// Function declarations:
1227// ----------------------
1228
1229void copy(ConstIterator6D origin,
1230 const ConstIterator6D& end,
1231 Iterator6D target);
1232
1233void copy(Numeric x, Iterator6D target, const Iterator6D& end);
1234
1235void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x);
1236
1237Numeric max(const ConstTensor6View& x);
1238
1239Numeric min(const ConstTensor6View& x);
1240
1241std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v);
1242
1244// Helper function for debugging
1245#ifndef NDEBUG
1246
1248 Tensor6View& tv, Index v, Index s, Index b, Index p, Index r, Index c);
1249
1250#endif
1252
1253#endif // matpackVI_h
void * data
Const version of Iterator6D.
Definition: matpackVI.h:87
ConstTensor5View msv
Current position.
Definition: matpackVI.h:128
const ConstTensor5View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:121
ConstIterator6D(const ConstTensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:94
ConstIterator6D()=default
Default constructor.
Index mstride
Stride.
Definition: matpackVI.h:130
ConstIterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:100
const ConstTensor5View & operator*() const
Dereferencing.
Definition: matpackVI.h:124
bool operator!=(const ConstIterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:109
Const version of Iterator7D.
Definition: matpackVII.h:84
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
Range mpr
The page range of mdata that is actually used.
Definition: matpackV.h:315
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:319
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:321
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:313
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:311
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:317
A constant view of a Tensor6.
Definition: matpackVI.h:149
constexpr ConstTensor6View(ConstTensor6View &&)=default
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:875
ConstTensor6View & operator=(ConstTensor6View &&)=default
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
virtual ~ConstTensor6View()=default
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
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Definition: matpackVI.h:550
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
constexpr ConstTensor6View(const ConstTensor6View &)=default
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
Numeric operator()(Index v, Index s, Index b, Index p, Index r, Index c) const
Definition: matpackVI.h:538
ConstTensor6View & operator=(const ConstTensor6View &)=default
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 Tensor7.
Definition: matpackVII.h:147
A constant view of a Vector.
Definition: matpackI.h:489
Index size() const ARTS_NOEXCEPT
Definition: matpackI.cc:50
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:40
Iterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:53
Iterator6D(const Tensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:47
bool operator!=(const Iterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:62
Tensor5View & operator*()
Dereferencing.
Definition: matpackVI.h:77
Tensor5View msv
Current position.
Definition: matpackVI.h:81
Tensor5View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:74
Iterator6D()=default
Default constructor.
Index mstride
Stride.
Definition: matpackVI.h:83
Implementation of Tensors of Rank 7.
Definition: matpackVII.h:36
The MatrixView class.
Definition: matpackI.h:1125
The Matrix class.
Definition: matpackI.h:1225
Index size() const noexcept
Definition: matpackI.h:1268
The range class.
Definition: matpackI.h:165
Index mstart
The start index.
Definition: matpackI.h:351
constexpr Index get_extent() const ARTS_NOEXCEPT
Returns the extent of the range.
Definition: matpackI.h:334
The Tensor3View class.
Definition: matpackIII.h:239
The Tensor3 class.
Definition: matpackIII.h:339
Index size() const noexcept
Definition: matpackIII.h:383
The Tensor4View class.
Definition: matpackIV.h:284
The Tensor4 class.
Definition: matpackIV.h:421
Index size() const noexcept
Definition: matpackIV.h:467
The Tensor5View class.
Definition: matpackV.h:333
The Tensor5 class.
Definition: matpackV.h:506
Index size() const noexcept
Definition: matpackV.h:554
The Tensor6View class.
Definition: matpackVI.h:621
Iterator6D end()
Return iterator behind last sub-tensor.
Definition: matpackVI.cc:1754
Numeric & operator()(Index v, Index s, Index b, Index p, Index r, Index c)
Definition: matpackVI.h:1004
Iterator6D begin()
Return iterator to first sub-tensor.
Definition: matpackVI.cc:1748
Tensor6View()=default
Numeric & get(Index v, Index s, Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Definition: matpackVI.h:1015
Tensor6View & operator=(const ConstTensor6View &v)
Assignment operator.
Definition: matpackVI.cc:1769
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Definition: matpackVI.cc:1732
constexpr Tensor6View(const Tensor6View &)=default
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
Tensor5 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1206
Tensor6(Numeric *d, const Range &r0, const Range &r1, const Range &r2, const Range &r3, const Range &r4, const Range &r5) ARTS_NOEXCEPT
Definition: matpackVI.h:1113
Index size() const noexcept
Definition: matpackVI.h:1138
Tensor6()=default
Tensor3 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1170
Vector reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1142
Tensor4 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1187
Tensor6(Tensor6 &&v) noexcept
Definition: matpackVI.h:1096
Matrix reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1155
The Tensor7View class.
Definition: matpackVII.h:1286
The VectorView class.
Definition: matpackI.h:626
The Vector class.
Definition: matpackI.h:876
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
#define ns
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
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
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 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
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
constexpr Numeric r0
The reference radius in IGRF13.
Definition: igrf13.cc:203
#define d
#define v
#define a
#define c
#define b