ARTS 2.5.4 (git: 31ce4f0e)
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 return false;
69 }
70
73 Tensor5View* operator->() { return &msv; }
74
76 Tensor5View& operator*() { return msv; }
77
78 private:
83};
84
87 public:
88 // Constructors:
90 ConstIterator6D() = default;
91
94 : msv(x), mstride(stride) { /* Nothing to do here. */
95 }
96
97 // Operators:
100 msv.mdata += mstride;
101 return *this;
102 }
103
108 bool operator!=(const ConstIterator6D& other) const {
111 other.msv.mdata + other.msv.msr.mstart + other.msv.mbr.mstart +
112 other.msv.mpr.mstart + other.msv.mrr.mstart + other.msv.mcr.mstart)
113 return true;
114 return false;
115 }
116
119 const ConstTensor5View* operator->() const { return &msv; }
120
122 const ConstTensor5View& operator*() const { return msv; }
123
124 private:
129};
130
131// Declare class Tensor6:
132class Tensor6;
133
148 public:
149 constexpr ConstTensor6View(const ConstTensor6View&) = default;
150 constexpr ConstTensor6View(ConstTensor6View&&) = default;
153
154 // Member functions:
155 [[nodiscard]] Index nvitrines() const noexcept { return mvr.mextent; }
156 [[nodiscard]] Index nshelves() const noexcept { return msr.mextent; }
157 [[nodiscard]] Index nbooks() const noexcept { return mbr.mextent; }
158 [[nodiscard]] Index npages() const noexcept { return mpr.mextent; }
159 [[nodiscard]] Index nrows() const noexcept { return mrr.mextent; }
160 [[nodiscard]] Index ncols() const noexcept { return mcr.mextent; }
161
162 // Total size
163 [[nodiscard]] Index size() const noexcept {
164 return nvitrines() * nshelves() * nbooks() * npages() * nrows() * ncols();
165 }
166 [[nodiscard]] bool empty() const noexcept { return size() == 0; }
167
169 [[nodiscard]] Shape<6> shape() const {
170 return {nvitrines(), nshelves(), nbooks(), npages(), nrows(), ncols()};
171 }
172
173 // Const index operators:
174
175 // Result 6D (1 combination)
176 // ------
178 const Range& s,
179 const Range& b,
180 const Range& p,
181 const Range& r,
182 const Range& c) const;
183
184 // Result 5D (6 combinations)
185 // -----|
187 const Range& s,
188 const Range& b,
189 const Range& p,
190 const Range& r,
191 Index c) const;
192 // ----|-
194 const Range& s,
195 const Range& b,
196 const Range& p,
197 Index r,
198 const Range& c) const;
199 // ---|--
201 const Range& s,
202 const Range& b,
203 Index p,
204 const Range& r,
205 const Range& c) const;
206 // --|---
208 const Range& s,
209 Index b,
210 const Range& p,
211 const Range& r,
212 const Range& c) const;
213 // -|----
215 Index s,
216 const Range& b,
217 const Range& p,
218 const Range& r,
219 const Range& c) const;
220 // |-----
222 const Range& s,
223 const Range& b,
224 const Range& p,
225 const Range& r,
226 const Range& c) const;
227
228 // Result 4D (5+4+3+2+1 = 15 combinations)
229 // ----||
231 const Range& s,
232 const Range& b,
233 const Range& p,
234 Index r,
235 Index c) const;
236 // ---|-|
238 const Range& s,
239 const Range& b,
240 Index p,
241 const Range& r,
242 Index c) const;
243 // --|--|
245 const Range& s,
246 Index b,
247 const Range& p,
248 const Range& r,
249 Index c) const;
250 // -|---|
252 Index s,
253 const Range& b,
254 const Range& p,
255 const Range& r,
256 Index c) const;
257 // |----|
259 const Range& s,
260 const Range& b,
261 const Range& p,
262 const Range& r,
263 Index c) const;
264 // ---||-
266 const Range& s,
267 const Range& b,
268 Index p,
269 Index r,
270 const Range& c) const;
271 // --|-|-
273 const Range& s,
274 Index b,
275 const Range& p,
276 Index r,
277 const Range& c) const;
278 // -|--|-
280 Index s,
281 const Range& b,
282 const Range& p,
283 Index r,
284 const Range& c) const;
285 // |---|-
287 const Range& s,
288 const Range& b,
289 const Range& p,
290 Index r,
291 const Range& c) const;
292 // --||--
294 const Range& s,
295 Index b,
296 Index p,
297 const Range& r,
298 const Range& c) const;
299 // -|-|--
301 Index s,
302 const Range& b,
303 Index p,
304 const Range& r,
305 const Range& c) const;
306 // |--|--
308 const Range& s,
309 const Range& b,
310 Index p,
311 const Range& r,
312 const Range& c) const;
313 // -||---
315 Index s,
316 Index b,
317 const Range& p,
318 const Range& r,
319 const Range& c) const;
320 // |-|---
322 const Range& s,
323 Index b,
324 const Range& p,
325 const Range& r,
326 const Range& c) const;
327 // ||----
329 Index s,
330 const Range& b,
331 const Range& p,
332 const Range& r,
333 const Range& c) const;
334
335 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
336 // ---|||
338 const Range& s,
339 const Range& b,
340 Index p,
341 Index r,
342 Index c) const;
343 // --|-||
345 const Range& s,
346 Index b,
347 const Range& p,
348 Index r,
349 Index c) const;
350 // -|--||
352 Index s,
353 const Range& b,
354 const Range& p,
355 Index r,
356 Index c) const;
357 // |---||
359 const Range& s,
360 const Range& b,
361 const Range& p,
362 Index r,
363 Index c) const;
364 // --||-|
366 const Range& s,
367 Index b,
368 Index p,
369 const Range& r,
370 Index c) const;
371 // -|-|-|
373 Index s,
374 const Range& b,
375 Index p,
376 const Range& r,
377 Index c) const;
378 // |--|-|
380 const Range& s,
381 const Range& b,
382 Index p,
383 const Range& r,
384 Index c) const;
385 // -||--|
387 Index s,
388 Index b,
389 const Range& p,
390 const Range& r,
391 Index c) const;
392 // |-|--|
394 const Range& s,
395 Index b,
396 const Range& p,
397 const Range& r,
398 Index c) const;
399 // ||---|
401 Index s,
402 const Range& b,
403 const Range& p,
404 const Range& r,
405 Index c) const;
406 // --|||-
408 const Range& s,
409 Index b,
410 Index p,
411 Index r,
412 const Range& c) const;
413 // -|-||-
415 Index s,
416 const Range& b,
417 Index p,
418 Index r,
419 const Range& c) const;
420 // |--||-
422 const Range& s,
423 const Range& b,
424 Index p,
425 Index r,
426 const Range& c) const;
427 // -||-|-
429 Index s,
430 Index b,
431 const Range& p,
432 Index r,
433 const Range& c) const;
434 // |-|-|-
436 const Range& s,
437 Index b,
438 const Range& p,
439 Index r,
440 const Range& c) const;
441 // ||--|-
443 Index s,
444 const Range& b,
445 const Range& p,
446 Index r,
447 const Range& c) const;
448 // -|||--
450 Index s,
451 Index b,
452 Index p,
453 const Range& r,
454 const Range& c) const;
455 // |-||--
457 const Range& s,
458 Index b,
459 Index p,
460 const Range& r,
461 const Range& c) const;
462 // ||-|--
464 Index s,
465 const Range& b,
466 Index p,
467 const Range& r,
468 const Range& c) const;
469 // |||---
471 Index s,
472 Index b,
473 const Range& p,
474 const Range& r,
475 const Range& c) const;
476
477 // Result 2D (15 combinations)
478 // IIII--
480 Index v, Index s, Index b, Index p, const Range& r, const Range& c) const;
481 // III-I-
483 Index v, Index s, Index b, const Range& p, Index r, const Range& c) const;
484 // II-II-
486 Index v, Index s, const Range& b, Index p, Index r, const Range& c) const;
487 // I-III-
489 Index v, const Range& s, Index b, Index p, Index r, const Range& c) const;
490 // -IIII-
492 const Range& v, Index s, Index b, Index p, Index r, const Range& c) const;
493 // III--I
495 Index v, Index s, Index b, const Range& p, const Range& r, Index c) const;
496 // II-I-I
498 Index v, Index s, const Range& b, Index p, const Range& r, Index c) const;
499 // I-II-I
501 Index v, const Range& s, Index b, Index p, const Range& r, Index c) const;
502 // -III-I
504 const Range& v, Index s, Index b, Index p, const Range& r, Index c) const;
505 // II--II
507 Index v, Index s, const Range& b, const Range& p, Index r, Index c) const;
508 // I-I-II
510 Index v, const Range& s, Index b, const Range& p, Index r, Index c) const;
511 // -II-II
513 const Range& v, Index s, Index b, const Range& p, Index r, Index c) const;
514 // I--III
516 Index v, const Range& s, const Range& b, Index p, Index r, Index c) const;
517 // -I-III
519 const Range& v, Index s, const Range& b, Index p, Index r, Index c) const;
520 // --IIII
522 const Range& v, const Range& s, Index b, Index p, Index r, Index c) const;
523
524 // Result 1D (6 combinations)
525 // IIIII-
527 Index v, Index s, Index b, Index p, Index r, const Range& c) const;
528 // IIII-I
530 Index v, Index s, Index b, Index p, const Range& r, Index c) const;
531 // III-II
533 Index v, Index s, Index b, const Range& p, Index r, Index c) const;
534 // II-III
536 Index v, Index s, const Range& b, Index p, Index r, Index c) const;
537 // I-IIII
539 Index v, const Range& s, Index b, Index p, Index r, Index c) const;
540 // -IIIII
542 const Range& v, Index s, Index b, Index p, Index r, Index c) const;
543
544 // Result scalar (1 combination)
545 // IIIIII
547 Index v, Index s, Index b, Index p, Index r, Index c) const {
548 CHECK(v);
549 CHECK(s);
550 CHECK(b);
551 CHECK(p);
552 CHECK(r);
553 CHECK(c);
554 return get(v, s, b, p, r, c);
555 }
556
558 [[nodiscard]] Numeric get(
559 Index v, Index s, Index b, Index p, Index r, Index c) const {
560 return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
561 OFFSET(c));
562 }
563
564 // Functions returning iterators:
565 [[nodiscard]] ConstIterator6D begin() const;
566 [[nodiscard]] ConstIterator6D end() const;
567
568 // Destructor:
569 virtual ~ConstTensor6View() = default;
570
571 // Friends:
572 friend class ConstIterator7D;
573 friend class Tensor6View;
574 friend class ConstTensor7View;
575
576 friend std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v);
577
578 // Special constructor to make a Tensor6 view of a Tensor5.
580
581 protected:
582 // Constructors:
583 ConstTensor6View() = default;
585 const Range& v,
586 const Range& s,
587 const Range& b,
588 const Range& p,
589 const Range& r,
590 const Range& c);
592 const Range& pv,
593 const Range& ps,
594 const Range& pb,
595 const Range& pp,
596 const Range& pr,
597 const Range& pc,
598 const Range& nv,
599 const Range& ns,
600 const Range& nb,
601 const Range& np,
602 const Range& nr,
603 const Range& nc);
604
605 // Data members:
606 // -------------
608 Range mvr{0, 0, 1};
610 Range msr{0, 0, 1};
612 Range mbr{0, 0, 1};
614 Range mpr{0, 0, 1};
616 Range mrr{0, 0, 1};
618 Range mcr{0, 0, 1};
620 Numeric* mdata{nullptr};
621};
622
633 public:
634 // Make const methods visible from base class
637 using ConstTensor6View::operator();
639
640 constexpr Tensor6View(const Tensor6View&) = default;
641
642 // Non-const index operators:
643
644 // Result 6D (1 combination)
645 // ------
647 const Range& s,
648 const Range& b,
649 const Range& p,
650 const Range& r,
651 const Range& c);
652
653 // Result 5D (6 combinations)
654 // -----|
656 const Range& s,
657 const Range& b,
658 const Range& p,
659 const Range& r,
660 Index c);
661 // ----|-
663 const Range& s,
664 const Range& b,
665 const Range& p,
666 Index r,
667 const Range& c);
668 // ---|--
670 const Range& s,
671 const Range& b,
672 Index p,
673 const Range& r,
674 const Range& c);
675 // --|---
677 const Range& s,
678 Index b,
679 const Range& p,
680 const Range& r,
681 const Range& c);
682 // -|----
684 Index s,
685 const Range& b,
686 const Range& p,
687 const Range& r,
688 const Range& c);
689 // |-----
691 const Range& s,
692 const Range& b,
693 const Range& p,
694 const Range& r,
695 const Range& c);
696
697 // Result 4D (5+4+3+2+1 = 15 combinations)
698 // ----||
700 const Range& s,
701 const Range& b,
702 const Range& p,
703 Index r,
704 Index c);
705 // ---|-|
707 const Range& s,
708 const Range& b,
709 Index p,
710 const Range& r,
711 Index c);
712 // --|--|
714 const Range& s,
715 Index b,
716 const Range& p,
717 const Range& r,
718 Index c);
719 // -|---|
721 Index s,
722 const Range& b,
723 const Range& p,
724 const Range& r,
725 Index c);
726 // |----|
728 const Range& s,
729 const Range& b,
730 const Range& p,
731 const Range& r,
732 Index c);
733 // ---||-
735 const Range& s,
736 const Range& b,
737 Index p,
738 Index r,
739 const Range& c);
740 // --|-|-
742 const Range& s,
743 Index b,
744 const Range& p,
745 Index r,
746 const Range& c);
747 // -|--|-
749 Index s,
750 const Range& b,
751 const Range& p,
752 Index r,
753 const Range& c);
754 // |---|-
756 const Range& s,
757 const Range& b,
758 const Range& p,
759 Index r,
760 const Range& c);
761 // --||--
763 const Range& s,
764 Index b,
765 Index p,
766 const Range& r,
767 const Range& c);
768 // -|-|--
770 Index s,
771 const Range& b,
772 Index p,
773 const Range& r,
774 const Range& c);
775 // |--|--
777 const Range& s,
778 const Range& b,
779 Index p,
780 const Range& r,
781 const Range& c);
782 // -||---
784 Index s,
785 Index b,
786 const Range& p,
787 const Range& r,
788 const Range& c);
789 // |-|---
791 const Range& s,
792 Index b,
793 const Range& p,
794 const Range& r,
795 const Range& c);
796 // ||----
798 Index s,
799 const Range& b,
800 const Range& p,
801 const Range& r,
802 const Range& c);
803
804 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
805 // ---|||
807 const Range& s,
808 const Range& b,
809 Index p,
810 Index r,
811 Index c);
812 // --|-||
814 const Range& s,
815 Index b,
816 const Range& p,
817 Index r,
818 Index c);
819 // -|--||
821 Index s,
822 const Range& b,
823 const Range& p,
824 Index r,
825 Index c);
826 // |---||
828 const Range& s,
829 const Range& b,
830 const Range& p,
831 Index r,
832 Index c);
833 // --||-|
835 const Range& s,
836 Index b,
837 Index p,
838 const Range& r,
839 Index c);
840 // -|-|-|
842 Index s,
843 const Range& b,
844 Index p,
845 const Range& r,
846 Index c);
847 // |--|-|
849 const Range& s,
850 const Range& b,
851 Index p,
852 const Range& r,
853 Index c);
854 // -||--|
856 Index s,
857 Index b,
858 const Range& p,
859 const Range& r,
860 Index c);
861 // |-|--|
863 const Range& s,
864 Index b,
865 const Range& p,
866 const Range& r,
867 Index c);
868 // ||---|
870 Index s,
871 const Range& b,
872 const Range& p,
873 const Range& r,
874 Index c);
875 // --|||-
877 const Range& s,
878 Index b,
879 Index p,
880 Index r,
881 const Range& c);
882 // -|-||-
884 Index s,
885 const Range& b,
886 Index p,
887 Index r,
888 const Range& c);
889 // |--||-
891 const Range& s,
892 const Range& b,
893 Index p,
894 Index r,
895 const Range& c);
896 // -||-|-
898 Index s,
899 Index b,
900 const Range& p,
901 Index r,
902 const Range& c);
903 // |-|-|-
905 const Range& s,
906 Index b,
907 const Range& p,
908 Index r,
909 const Range& c);
910 // ||--|-
912 Index s,
913 const Range& b,
914 const Range& p,
915 Index r,
916 const Range& c);
917 // -|||--
919 Index s,
920 Index b,
921 Index p,
922 const Range& r,
923 const Range& c);
924 // |-||--
926 const Range& s,
927 Index b,
928 Index p,
929 const Range& r,
930 const Range& c);
931 // ||-|--
933 Index s,
934 const Range& b,
935 Index p,
936 const Range& r,
937 const Range& c);
938 // |||---
940 Index s,
941 Index b,
942 const Range& p,
943 const Range& r,
944 const Range& c);
945
946 // Result 2D (15 combinations)
947 // IIII--
949 Index v, Index s, Index b, Index p, const Range& r, const Range& c);
950 // III-I-
952 Index v, Index s, Index b, const Range& p, Index r, const Range& c);
953 // II-II-
955 Index v, Index s, const Range& b, Index p, Index r, const Range& c);
956 // I-III-
958 Index v, const Range& s, Index b, Index p, Index r, const Range& c);
959 // -IIII-
961 const Range& v, Index s, Index b, Index p, Index r, const Range& c);
962 // III--I
964 Index v, Index s, Index b, const Range& p, const Range& r, Index c);
965 // II-I-I
967 Index v, Index s, const Range& b, Index p, const Range& r, Index c);
968 // I-II-I
970 Index v, const Range& s, Index b, Index p, const Range& r, Index c);
971 // -III-I
973 const Range& v, Index s, Index b, Index p, const Range& r, Index c);
974 // II--II
976 Index v, Index s, const Range& b, const Range& p, Index r, Index c);
977 // I-I-II
979 Index v, const Range& s, Index b, const Range& p, Index r, Index c);
980 // -II-II
982 const Range& v, Index s, Index b, const Range& p, Index r, Index c);
983 // I--III
985 Index v, const Range& s, const Range& b, Index p, Index r, Index c);
986 // -I-III
988 const Range& v, Index s, const Range& b, Index p, Index r, Index c);
989 // --IIII
991 const Range& v, const Range& s, Index b, Index p, Index r, Index c);
992
993 // Result 1D (6 combinations)
994 // IIIII-
996 Index v, Index s, Index b, Index p, Index r, const Range& c);
997 // IIII-I
999 Index v, Index s, Index b, Index p, const Range& r, Index c);
1000 // III-II
1002 Index v, Index s, Index b, const Range& p, Index r, Index c);
1003 // II-III
1005 Index v, Index s, const Range& b, Index p, Index r, Index c);
1006 // I-IIII
1008 Index v, const Range& s, Index b, Index p, Index r, Index c);
1009 // -IIIII
1011 const Range& v, Index s, Index b, Index p, Index r, Index c);
1012
1013 // Result scalar (1 combination)
1014 // IIIIII
1016 CHECK(v);
1017 CHECK(s);
1018 CHECK(b);
1019 CHECK(p);
1020 CHECK(r);
1021 CHECK(c);
1022 return get(v, s, b, p, r, c);
1023 }
1024
1027 return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
1028 OFFSET(c));
1029 }
1030
1031 // Conversion to a plain C-array
1032 [[nodiscard]] const Numeric* get_c_array() const ARTS_NOEXCEPT;
1034
1035 // Functions returning iterators:
1036 Iterator6D begin();
1037 Iterator6D end();
1038
1039 // Assignment operators:
1040 Tensor6View& operator=(const ConstTensor6View& v);
1041 Tensor6View& operator=(const Tensor6View& v);
1042 Tensor6View& operator=(const Tensor6& v);
1043 Tensor6View& operator=(Numeric x);
1044
1045 // Other operators:
1046 Tensor6View& operator*=(Numeric x);
1047 Tensor6View& operator/=(Numeric x);
1048 Tensor6View& operator+=(Numeric x);
1049 Tensor6View& operator-=(Numeric x);
1050
1051 Tensor6View& operator*=(const ConstTensor6View& x);
1052 Tensor6View& operator/=(const ConstTensor6View& x);
1053 Tensor6View& operator+=(const ConstTensor6View& x);
1054 Tensor6View& operator-=(const ConstTensor6View& x);
1055
1056 // Destructor:
1057 virtual ~Tensor6View() = default;
1058
1059 // Friends:
1060 friend class Iterator7D;
1061 friend class Tensor7View;
1062
1063 // Special constructor to make a Tensor6 view of a Tensor5.
1064 Tensor6View(const Tensor5View& a);
1065
1066 protected:
1067 // Constructors:
1068 Tensor6View() = default;
1069 Tensor6View(Numeric* data,
1070 const Range& v,
1071 const Range& s,
1072 const Range& b,
1073 const Range& p,
1074 const Range& r,
1075 const Range& c);
1076 Tensor6View(Numeric* data,
1077 const Range& pv,
1078 const Range& ps,
1079 const Range& pb,
1080 const Range& pp,
1081 const Range& pr,
1082 const Range& pc,
1083 const Range& nv,
1084 const Range& ns,
1085 const Range& nb,
1086 const Range& np,
1087 const Range& nr,
1088 const Range& nc);
1089};
1090
1099class Tensor6 : public Tensor6View {
1100 public:
1101 // Constructors:
1102 Tensor6() = default;
1103 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c);
1104 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill);
1105 Tensor6(const ConstTensor6View& v);
1106 Tensor6(const Tensor6& v);
1107 Tensor6(Tensor6&& v) noexcept : Tensor6View(std::forward<Tensor6View>(v)) {
1108 v.mdata = nullptr;
1109 }
1110
1125 const Range& r0,
1126 const Range& r1,
1127 const Range& r2,
1128 const Range& r3,
1129 const Range& r4,
1130 const Range& r5) ARTS_NOEXCEPT
1131 : Tensor6View(d, r0, r1, r2, r3, r4, r5) {
1132 ARTS_ASSERT(not(r0.get_extent() < 0), "Must have size");
1133 ARTS_ASSERT(not(r1.get_extent() < 0), "Must have size");
1134 ARTS_ASSERT(not(r2.get_extent() < 0), "Must have size");
1135 ARTS_ASSERT(not(r3.get_extent() < 0), "Must have size");
1136 ARTS_ASSERT(not(r4.get_extent() < 0), "Must have size");
1137 ARTS_ASSERT(not(r5.get_extent() < 0), "Must have size");
1138 }
1139
1140 // Assignment operators:
1141 Tensor6& operator=(const Tensor6& x);
1142 Tensor6& operator=(Tensor6&& x) noexcept;
1144
1145 // Resize function:
1146 void resize(Index v, Index s, Index b, Index p, Index r, Index c);
1147
1148 // Swap function:
1149 friend void swap(Tensor6& t1, Tensor6& t2);
1150
1151 // Destructor:
1152 virtual ~Tensor6();
1153
1155 template <std::size_t dim0>
1157 static_assert(dim0 < 6, "Bad Dimension, Out-of-Bounds");
1158
1159 Range r0(0,
1160 dim0 == 0 ? nvitrines()
1161 : dim0 == 1 ? nshelves()
1162 : dim0 == 2 ? nbooks()
1163 : dim0 == 3 ? npages()
1164 : dim0 == 4 ? nrows()
1165 : ncols());
1166
1167 Vector out(mdata, r0);
1168 ARTS_ASSERT(size() == out.size(),
1169 "Can only reduce size on same size input");
1170 mdata = nullptr;
1171 return out;
1172 }
1173
1175 template <std::size_t dim0, std::size_t dim1>
1177 static_assert(dim1 < 6, "Bad Dimension, Out-of-Bounds");
1178 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1179
1180 const Range r1(0,
1181 dim1 == 1 ? nshelves()
1182 : dim1 == 2 ? nbooks()
1183 : dim1 == 3 ? npages()
1184 : dim1 == 4 ? nrows()
1185 : ncols());
1186 const Range r0(0,
1187 dim0 == 0 ? nvitrines()
1188 : dim0 == 1 ? nshelves()
1189 : dim0 == 2 ? nbooks()
1190 : dim0 == 3 ? npages()
1191 : nrows(),
1192 r1.get_extent());
1193
1194 Matrix out(mdata, r0, r1);
1195 ARTS_ASSERT(size() == out.size(),
1196 "Can only reduce size on same size input");
1197 mdata = nullptr;
1198 return out;
1199 }
1200
1202 template <std::size_t dim0, std::size_t dim1, std::size_t dim2>
1204 static_assert(dim2 < 6, "Bad Dimension, Out-of-Bounds");
1205 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1206 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1207
1208 const Range r2(0,
1209 dim2 == 2 ? nbooks()
1210 : dim2 == 3 ? npages()
1211 : dim2 == 4 ? nrows()
1212 : ncols());
1213 const Range r1(0,
1214 dim1 == 1 ? nshelves()
1215 : dim1 == 2 ? nbooks()
1216 : dim1 == 3 ? npages()
1217 : nrows(),
1218 r2.get_extent());
1219 const Range r0(0,
1220 dim0 == 0 ? nvitrines()
1221 : dim0 == 1 ? nshelves()
1222 : dim0 == 2 ? nbooks()
1223 : npages(),
1224 r1.get_extent() * r2.get_extent());
1225
1226 Tensor3 out(mdata, r0, r1, r2);
1227 ARTS_ASSERT(size() == out.size(),
1228 "Can only reduce size on same size input");
1229 mdata = nullptr;
1230 return out;
1231 }
1232
1234 template <std::size_t dim0,
1235 std::size_t dim1,
1236 std::size_t dim2,
1237 std::size_t dim3>
1239 static_assert(dim3 < 6, "Bad Dimension, Out-of-Bounds");
1240 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1241 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1242 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1243
1244 const Range r3(0, dim3 == 3 ? npages() : dim3 == 4 ? nrows() : ncols());
1245 const Range r2(0,
1246 dim2 == 2 ? nbooks()
1247 : dim2 == 3 ? npages()
1248 : nrows(),
1249 r3.get_extent());
1250 const Range r1(0,
1251 dim1 == 1 ? nshelves()
1252 : dim1 == 2 ? nbooks()
1253 : npages(),
1254 r2.get_extent() * r3.get_extent());
1255 const Range r0(0,
1256 dim0 == 0 ? nvitrines()
1257 : dim0 == 1 ? nshelves()
1258 : nbooks(),
1259 r1.get_extent() * r2.get_extent() * r3.get_extent());
1260
1261 Tensor4 out(mdata, r0, r1, r2, r3);
1262 ARTS_ASSERT(size() == out.size(),
1263 "Can only reduce size on same size input");
1264 mdata = nullptr;
1265 return out;
1266 }
1267
1269 template <std::size_t dim0,
1270 std::size_t dim1,
1271 std::size_t dim2,
1272 std::size_t dim3,
1273 std::size_t dim4>
1275 static_assert(dim4 < 6, "Bad Dimension, Out-of-Bounds");
1276 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1277 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1278 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1279 static_assert(dim3 < dim4, "Bad Dimensions, dim4 must be larger than dim3");
1280
1281 const Range r4(0, dim4 == 4 ? nrows() : ncols());
1282 const Range r3(0, dim3 == 3 ? npages() : nrows(), r4.get_extent());
1283 const Range r2(
1284 0, dim2 == 2 ? nbooks() : npages(), r3.get_extent() * r4.get_extent());
1285 const Range r1(0,
1286 dim1 == 1 ? nshelves() : nbooks(),
1287 r2.get_extent() * r3.get_extent() * r4.get_extent());
1288 const Range r0(
1289 0,
1290 dim0 == 0 ? nvitrines() : nshelves(),
1291 r1.get_extent() * r2.get_extent() * r3.get_extent() * r4.get_extent());
1292
1293 Tensor5 out(mdata, r0, r1, r2, r3, r4);
1294 ARTS_ASSERT(size() == out.size(),
1295 "Can only reduce size on same size input");
1296 mdata = nullptr;
1297 return out;
1298 }
1299
1300 template <class F>
1301 void transform_elementwise(F&& func) {
1302 std::transform(mdata, mdata + size(), mdata, func);
1303 }
1304};
1305
1306// Function declarations:
1307// ----------------------
1308
1309void copy(ConstIterator6D origin,
1310 const ConstIterator6D& end,
1311 Iterator6D target);
1312
1313void copy(Numeric x, Iterator6D target, const Iterator6D& end);
1314
1315void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x);
1316
1317Numeric max(const ConstTensor6View& x);
1318
1319Numeric min(const ConstTensor6View& x);
1320
1322// Helper function for debugging
1323#ifndef NDEBUG
1324
1326 Tensor6View& tv, Index v, Index s, Index b, Index p, Index r, Index c);
1327
1328#endif
1330
1333
1335
1336#endif // matpackVI_h
This can be used to make arrays out of anything.
Definition: array.h:48
Const version of Iterator6D.
Definition: matpackVI.h:86
ConstTensor5View msv
Current position.
Definition: matpackVI.h:126
const ConstTensor5View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:119
ConstIterator6D(const ConstTensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:93
ConstIterator6D()=default
Default constructor.
Index mstride
Stride.
Definition: matpackVI.h:128
ConstIterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:99
const ConstTensor5View & operator*() const
Dereferencing.
Definition: matpackVI.h:122
bool operator!=(const ConstIterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:108
Const version of Iterator7D.
Definition: matpackVII.h:83
A constant view of a Matrix.
Definition: matpackI.h:1043
Index size() const noexcept
Definition: matpackI.h:1061
A constant view of a Tensor3.
Definition: matpackIII.h:130
Index size() const noexcept
Definition: matpackIII.h:149
A constant view of a Tensor4.
Definition: matpackIV.h:131
Index size() const noexcept
Definition: matpackIV.h:145
A constant view of a Tensor5.
Definition: matpackV.h:141
Range mpr
The page range of mdata that is actually used.
Definition: matpackV.h:325
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:329
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:331
Index size() const noexcept
Definition: matpackV.h:156
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:323
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:321
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:327
A constant view of a Tensor6.
Definition: matpackVI.h:147
constexpr ConstTensor6View(ConstTensor6View &&)=default
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:848
ConstTensor6View & operator=(ConstTensor6View &&)=default
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:855
virtual ~ConstTensor6View()=default
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVI.h:608
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:618
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:612
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:620
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:616
Index size() const noexcept
Definition: matpackVI.h:163
Index nbooks() const noexcept
Definition: matpackVI.h:157
Index nvitrines() const noexcept
Definition: matpackVI.h:155
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Definition: matpackVI.h:558
bool empty() const noexcept
Definition: matpackVI.h:166
ConstTensor6View operator()(const Range &v, const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Definition: matpackVI.cc:36
Index ncols() const noexcept
Definition: matpackVI.h:160
constexpr ConstTensor6View(const ConstTensor6View &)=default
friend std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:929
Numeric operator()(Index v, Index s, Index b, Index p, Index r, Index c) const
Definition: matpackVI.h:546
Index npages() const noexcept
Definition: matpackVI.h:158
Index nshelves() const noexcept
Definition: matpackVI.h:156
ConstTensor6View & operator=(const ConstTensor6View &)=default
Range mpr
The page range of mdata that is actually used.
Definition: matpackVI.h:614
Index nrows() const noexcept
Definition: matpackVI.h:159
Shape< 6 > shape() const
Definition: matpackVI.h:169
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVI.h:610
ConstTensor6View()=default
A constant view of a Tensor7.
Definition: matpackVII.h:145
A constant view of a Vector.
Definition: matpackI.h:512
Index size() const noexcept
Definition: matpackI.h:539
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:76
Tensor5View msv
Current position.
Definition: matpackVI.h:80
Tensor5View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:73
Iterator6D()=default
Default constructor.
Index mstride
Stride.
Definition: matpackVI.h:82
Implementation of Tensors of Rank 7.
Definition: matpackVII.h:36
The MatrixView class.
Definition: matpackI.h:1164
The Matrix class.
Definition: matpackI.h:1261
The range class.
Definition: matpackI.h:159
Index mstart
The start index.
Definition: matpackI.h:367
constexpr Index get_extent() const noexcept
Returns the extent of the range.
Definition: matpackI.h:342
Index mextent
The number of elements.
Definition: matpackI.h:370
The Tensor3View class.
Definition: matpackIII.h:246
The Tensor3 class.
Definition: matpackIII.h:346
The Tensor4View class.
Definition: matpackIV.h:292
The Tensor4 class.
Definition: matpackIV.h:429
The Tensor5View class.
Definition: matpackV.h:343
The Tensor5 class.
Definition: matpackV.h:516
The Tensor6View class.
Definition: matpackVI.h:632
Iterator6D end()
Return iterator behind last sub-tensor.
Definition: matpackVI.cc:1759
Numeric & operator()(Index v, Index s, Index b, Index p, Index r, Index c)
Definition: matpackVI.h:1015
Iterator6D begin()
Return iterator to first sub-tensor.
Definition: matpackVI.cc:1753
Tensor6View()=default
Numeric & get(Index v, Index s, Index b, Index p, Index r, Index c)
Get element implementation without assertions.
Definition: matpackVI.h:1026
Tensor6View & operator=(const ConstTensor6View &v)
Assignment operator.
Definition: matpackVI.cc:1774
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Definition: matpackVI.cc:1721
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:954
The Tensor6 class.
Definition: matpackVI.h:1099
Tensor5 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1274
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:1124
void transform_elementwise(F &&func)
Definition: matpackVI.h:1301
Tensor6()=default
Tensor3 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1203
Vector reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1156
Tensor4 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1238
Tensor6(Tensor6 &&v) noexcept
Definition: matpackVI.h:1107
Matrix reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1176
The Tensor7View class.
Definition: matpackVII.h:1303
The VectorView class.
Definition: matpackI.h:663
The Vector class.
Definition: matpackI.h:899
#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:2269
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2007
#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:2288
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:2249
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:2327
#define OFFSET(x)
Definition: matpackVI.h:36
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
constexpr Numeric r0
The reference radius in IGRF13.
Definition: igrf13.cc:203
Helper shape class.
Definition: matpackI.h:377
#define d
#define v
#define a
#define c
#define b