ARTS 2.5.4 (git: 4c0d3b4d)
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 // Special constructor to make a Tensor6 view of a Tensor5.
578
579 protected:
580 // Constructors:
581 ConstTensor6View() = default;
583 const Range& v,
584 const Range& s,
585 const Range& b,
586 const Range& p,
587 const Range& r,
588 const Range& c);
590 const Range& pv,
591 const Range& ps,
592 const Range& pb,
593 const Range& pp,
594 const Range& pr,
595 const Range& pc,
596 const Range& nv,
597 const Range& ns,
598 const Range& nb,
599 const Range& np,
600 const Range& nr,
601 const Range& nc);
602
603 // Data members:
604 // -------------
606 Range mvr{0, 0, 1};
608 Range msr{0, 0, 1};
610 Range mbr{0, 0, 1};
612 Range mpr{0, 0, 1};
614 Range mrr{0, 0, 1};
616 Range mcr{0, 0, 1};
618 Numeric* mdata{nullptr};
619};
620
631 public:
632 // Make const methods visible from base class
635 using ConstTensor6View::operator();
637
638 constexpr Tensor6View(const Tensor6View&) = default;
639
640 // Non-const index operators:
641
642 // Result 6D (1 combination)
643 // ------
645 const Range& s,
646 const Range& b,
647 const Range& p,
648 const Range& r,
649 const Range& c);
650
651 // Result 5D (6 combinations)
652 // -----|
654 const Range& s,
655 const Range& b,
656 const Range& p,
657 const Range& r,
658 Index c);
659 // ----|-
661 const Range& s,
662 const Range& b,
663 const Range& p,
664 Index r,
665 const Range& c);
666 // ---|--
668 const Range& s,
669 const Range& b,
670 Index p,
671 const Range& r,
672 const Range& c);
673 // --|---
675 const Range& s,
676 Index b,
677 const Range& p,
678 const Range& r,
679 const Range& c);
680 // -|----
682 Index s,
683 const Range& b,
684 const Range& p,
685 const Range& r,
686 const Range& c);
687 // |-----
689 const Range& s,
690 const Range& b,
691 const Range& p,
692 const Range& r,
693 const Range& c);
694
695 // Result 4D (5+4+3+2+1 = 15 combinations)
696 // ----||
698 const Range& s,
699 const Range& b,
700 const Range& p,
701 Index r,
702 Index c);
703 // ---|-|
705 const Range& s,
706 const Range& b,
707 Index p,
708 const Range& r,
709 Index c);
710 // --|--|
712 const Range& s,
713 Index b,
714 const Range& p,
715 const Range& r,
716 Index c);
717 // -|---|
719 Index s,
720 const Range& b,
721 const Range& p,
722 const Range& r,
723 Index c);
724 // |----|
726 const Range& s,
727 const Range& b,
728 const Range& p,
729 const Range& r,
730 Index c);
731 // ---||-
733 const Range& s,
734 const Range& b,
735 Index p,
736 Index r,
737 const Range& c);
738 // --|-|-
740 const Range& s,
741 Index b,
742 const Range& p,
743 Index r,
744 const Range& c);
745 // -|--|-
747 Index s,
748 const Range& b,
749 const Range& p,
750 Index r,
751 const Range& c);
752 // |---|-
754 const Range& s,
755 const Range& b,
756 const Range& p,
757 Index r,
758 const Range& c);
759 // --||--
761 const Range& s,
762 Index b,
763 Index p,
764 const Range& r,
765 const Range& c);
766 // -|-|--
768 Index s,
769 const Range& b,
770 Index p,
771 const Range& r,
772 const Range& c);
773 // |--|--
775 const Range& s,
776 const Range& b,
777 Index p,
778 const Range& r,
779 const Range& c);
780 // -||---
782 Index s,
783 Index b,
784 const Range& p,
785 const Range& r,
786 const Range& c);
787 // |-|---
789 const Range& s,
790 Index b,
791 const Range& p,
792 const Range& r,
793 const Range& c);
794 // ||----
796 Index s,
797 const Range& b,
798 const Range& p,
799 const Range& r,
800 const Range& c);
801
802 // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
803 // ---|||
805 const Range& s,
806 const Range& b,
807 Index p,
808 Index r,
809 Index c);
810 // --|-||
812 const Range& s,
813 Index b,
814 const Range& p,
815 Index r,
816 Index c);
817 // -|--||
819 Index s,
820 const Range& b,
821 const Range& p,
822 Index r,
823 Index c);
824 // |---||
826 const Range& s,
827 const Range& b,
828 const Range& p,
829 Index r,
830 Index c);
831 // --||-|
833 const Range& s,
834 Index b,
835 Index p,
836 const Range& r,
837 Index c);
838 // -|-|-|
840 Index s,
841 const Range& b,
842 Index p,
843 const Range& r,
844 Index c);
845 // |--|-|
847 const Range& s,
848 const Range& b,
849 Index p,
850 const Range& r,
851 Index c);
852 // -||--|
854 Index s,
855 Index b,
856 const Range& p,
857 const Range& r,
858 Index c);
859 // |-|--|
861 const Range& s,
862 Index b,
863 const Range& p,
864 const Range& r,
865 Index c);
866 // ||---|
868 Index s,
869 const Range& b,
870 const Range& p,
871 const Range& r,
872 Index c);
873 // --|||-
875 const Range& s,
876 Index b,
877 Index p,
878 Index r,
879 const Range& c);
880 // -|-||-
882 Index s,
883 const Range& b,
884 Index p,
885 Index r,
886 const Range& c);
887 // |--||-
889 const Range& s,
890 const Range& b,
891 Index p,
892 Index r,
893 const Range& c);
894 // -||-|-
896 Index s,
897 Index b,
898 const Range& p,
899 Index r,
900 const Range& c);
901 // |-|-|-
903 const Range& s,
904 Index b,
905 const Range& p,
906 Index r,
907 const Range& c);
908 // ||--|-
910 Index s,
911 const Range& b,
912 const Range& p,
913 Index r,
914 const Range& c);
915 // -|||--
917 Index s,
918 Index b,
919 Index p,
920 const Range& r,
921 const Range& c);
922 // |-||--
924 const Range& s,
925 Index b,
926 Index p,
927 const Range& r,
928 const Range& c);
929 // ||-|--
931 Index s,
932 const Range& b,
933 Index p,
934 const Range& r,
935 const Range& c);
936 // |||---
938 Index s,
939 Index b,
940 const Range& p,
941 const Range& r,
942 const Range& c);
943
944 // Result 2D (15 combinations)
945 // IIII--
947 Index v, Index s, Index b, Index p, const Range& r, const Range& c);
948 // III-I-
950 Index v, Index s, Index b, const Range& p, Index r, const Range& c);
951 // II-II-
953 Index v, Index s, const Range& b, Index p, Index r, const Range& c);
954 // I-III-
956 Index v, const Range& s, Index b, Index p, Index r, const Range& c);
957 // -IIII-
959 const Range& v, Index s, Index b, Index p, Index r, const Range& c);
960 // III--I
962 Index v, Index s, Index b, const Range& p, const Range& r, Index c);
963 // II-I-I
965 Index v, Index s, const Range& b, Index p, const Range& r, Index c);
966 // I-II-I
968 Index v, const Range& s, Index b, Index p, const Range& r, Index c);
969 // -III-I
971 const Range& v, Index s, Index b, Index p, const Range& r, Index c);
972 // II--II
974 Index v, Index s, const Range& b, const Range& p, Index r, Index c);
975 // I-I-II
977 Index v, const Range& s, Index b, const Range& p, Index r, Index c);
978 // -II-II
980 const Range& v, Index s, Index b, const Range& p, Index r, Index c);
981 // I--III
983 Index v, const Range& s, const Range& b, Index p, Index r, Index c);
984 // -I-III
986 const Range& v, Index s, const Range& b, Index p, Index r, Index c);
987 // --IIII
989 const Range& v, const Range& s, Index b, Index p, Index r, Index c);
990
991 // Result 1D (6 combinations)
992 // IIIII-
994 Index v, Index s, Index b, Index p, Index r, const Range& c);
995 // IIII-I
997 Index v, Index s, Index b, Index p, const Range& r, Index c);
998 // III-II
1000 Index v, Index s, Index b, const Range& p, Index r, Index c);
1001 // II-III
1003 Index v, Index s, const Range& b, Index p, Index r, Index c);
1004 // I-IIII
1006 Index v, const Range& s, Index b, Index p, Index r, Index c);
1007 // -IIIII
1009 const Range& v, Index s, Index b, Index p, Index r, Index c);
1010
1011 // Result scalar (1 combination)
1012 // IIIIII
1014 CHECK(v);
1015 CHECK(s);
1016 CHECK(b);
1017 CHECK(p);
1018 CHECK(r);
1019 CHECK(c);
1020 return get(v, s, b, p, r, c);
1021 }
1022
1025 return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
1026 OFFSET(c));
1027 }
1028
1029 // Conversion to a plain C-array
1030 [[nodiscard]] const Numeric* get_c_array() const ARTS_NOEXCEPT;
1032
1033 // Functions returning iterators:
1034 Iterator6D begin();
1035 Iterator6D end();
1036
1037 // Assignment operators:
1038 Tensor6View& operator=(const ConstTensor6View& v);
1039 Tensor6View& operator=(const Tensor6View& v);
1040 Tensor6View& operator=(const Tensor6& v);
1041 Tensor6View& operator=(Numeric x);
1042
1043 // Other operators:
1044 Tensor6View& operator*=(Numeric x);
1045 Tensor6View& operator/=(Numeric x);
1046 Tensor6View& operator+=(Numeric x);
1047 Tensor6View& operator-=(Numeric x);
1048
1049 Tensor6View& operator*=(const ConstTensor6View& x);
1050 Tensor6View& operator/=(const ConstTensor6View& x);
1051 Tensor6View& operator+=(const ConstTensor6View& x);
1052 Tensor6View& operator-=(const ConstTensor6View& x);
1053
1054 // Destructor:
1055 virtual ~Tensor6View() = default;
1056
1057 // Friends:
1058 friend class Iterator7D;
1059 friend class Tensor7View;
1060
1061 // Special constructor to make a Tensor6 view of a Tensor5.
1062 Tensor6View(const Tensor5View& a);
1063
1064 protected:
1065 // Constructors:
1066 Tensor6View() = default;
1067 Tensor6View(Numeric* data,
1068 const Range& v,
1069 const Range& s,
1070 const Range& b,
1071 const Range& p,
1072 const Range& r,
1073 const Range& c);
1074 Tensor6View(Numeric* data,
1075 const Range& pv,
1076 const Range& ps,
1077 const Range& pb,
1078 const Range& pp,
1079 const Range& pr,
1080 const Range& pc,
1081 const Range& nv,
1082 const Range& ns,
1083 const Range& nb,
1084 const Range& np,
1085 const Range& nr,
1086 const Range& nc);
1087};
1088
1097class Tensor6 : public Tensor6View {
1098 public:
1099 // Constructors:
1100 Tensor6() = default;
1101 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c);
1102 Tensor6(Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill);
1103 Tensor6(const ConstTensor6View& v);
1104 Tensor6(const Tensor6& v);
1105 Tensor6(Tensor6&& v) noexcept : Tensor6View(std::forward<Tensor6View>(v)) {
1106 v.mdata = nullptr;
1107 }
1108
1123 const Range& r0,
1124 const Range& r1,
1125 const Range& r2,
1126 const Range& r3,
1127 const Range& r4,
1128 const Range& r5) ARTS_NOEXCEPT
1129 : Tensor6View(d, r0, r1, r2, r3, r4, r5) {
1130 ARTS_ASSERT(not(r0.get_extent() < 0), "Must have size");
1131 ARTS_ASSERT(not(r1.get_extent() < 0), "Must have size");
1132 ARTS_ASSERT(not(r2.get_extent() < 0), "Must have size");
1133 ARTS_ASSERT(not(r3.get_extent() < 0), "Must have size");
1134 ARTS_ASSERT(not(r4.get_extent() < 0), "Must have size");
1135 ARTS_ASSERT(not(r5.get_extent() < 0), "Must have size");
1136 }
1137
1138 // Assignment operators:
1139 Tensor6& operator=(const Tensor6& x);
1140 Tensor6& operator=(Tensor6&& x) noexcept;
1142
1143 // Resize function:
1144 void resize(Index v, Index s, Index b, Index p, Index r, Index c);
1145
1146 // Swap function:
1147 friend void swap(Tensor6& t1, Tensor6& t2);
1148
1149 // Destructor:
1150 virtual ~Tensor6();
1151
1153 template <std::size_t dim0>
1155 static_assert(dim0 < 6, "Bad Dimension, Out-of-Bounds");
1156
1157 Range r0(0,
1158 dim0 == 0 ? nvitrines()
1159 : dim0 == 1 ? nshelves()
1160 : dim0 == 2 ? nbooks()
1161 : dim0 == 3 ? npages()
1162 : dim0 == 4 ? nrows()
1163 : ncols());
1164
1165 Vector out(mdata, r0);
1166 ARTS_ASSERT(size() == out.size(),
1167 "Can only reduce size on same size input");
1168 mdata = nullptr;
1169 return out;
1170 }
1171
1173 template <std::size_t dim0, std::size_t dim1>
1175 static_assert(dim1 < 6, "Bad Dimension, Out-of-Bounds");
1176 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1177
1178 const Range r1(0,
1179 dim1 == 1 ? nshelves()
1180 : dim1 == 2 ? nbooks()
1181 : dim1 == 3 ? npages()
1182 : dim1 == 4 ? nrows()
1183 : ncols());
1184 const Range r0(0,
1185 dim0 == 0 ? nvitrines()
1186 : dim0 == 1 ? nshelves()
1187 : dim0 == 2 ? nbooks()
1188 : dim0 == 3 ? npages()
1189 : nrows(),
1190 r1.get_extent());
1191
1192 Matrix out(mdata, r0, r1);
1193 ARTS_ASSERT(size() == out.size(),
1194 "Can only reduce size on same size input");
1195 mdata = nullptr;
1196 return out;
1197 }
1198
1200 template <std::size_t dim0, std::size_t dim1, std::size_t dim2>
1202 static_assert(dim2 < 6, "Bad Dimension, Out-of-Bounds");
1203 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1204 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1205
1206 const Range r2(0,
1207 dim2 == 2 ? nbooks()
1208 : dim2 == 3 ? npages()
1209 : dim2 == 4 ? nrows()
1210 : ncols());
1211 const Range r1(0,
1212 dim1 == 1 ? nshelves()
1213 : dim1 == 2 ? nbooks()
1214 : dim1 == 3 ? npages()
1215 : nrows(),
1216 r2.get_extent());
1217 const Range r0(0,
1218 dim0 == 0 ? nvitrines()
1219 : dim0 == 1 ? nshelves()
1220 : dim0 == 2 ? nbooks()
1221 : npages(),
1222 r1.get_extent() * r2.get_extent());
1223
1224 Tensor3 out(mdata, r0, r1, r2);
1225 ARTS_ASSERT(size() == out.size(),
1226 "Can only reduce size on same size input");
1227 mdata = nullptr;
1228 return out;
1229 }
1230
1232 template <std::size_t dim0,
1233 std::size_t dim1,
1234 std::size_t dim2,
1235 std::size_t dim3>
1237 static_assert(dim3 < 6, "Bad Dimension, Out-of-Bounds");
1238 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1239 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1240 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1241
1242 const Range r3(0, dim3 == 3 ? npages() : dim3 == 4 ? nrows() : ncols());
1243 const Range r2(0,
1244 dim2 == 2 ? nbooks()
1245 : dim2 == 3 ? npages()
1246 : nrows(),
1247 r3.get_extent());
1248 const Range r1(0,
1249 dim1 == 1 ? nshelves()
1250 : dim1 == 2 ? nbooks()
1251 : npages(),
1252 r2.get_extent() * r3.get_extent());
1253 const Range r0(0,
1254 dim0 == 0 ? nvitrines()
1255 : dim0 == 1 ? nshelves()
1256 : nbooks(),
1257 r1.get_extent() * r2.get_extent() * r3.get_extent());
1258
1259 Tensor4 out(mdata, r0, r1, r2, r3);
1260 ARTS_ASSERT(size() == out.size(),
1261 "Can only reduce size on same size input");
1262 mdata = nullptr;
1263 return out;
1264 }
1265
1267 template <std::size_t dim0,
1268 std::size_t dim1,
1269 std::size_t dim2,
1270 std::size_t dim3,
1271 std::size_t dim4>
1273 static_assert(dim4 < 6, "Bad Dimension, Out-of-Bounds");
1274 static_assert(dim0 < dim1, "Bad Dimensions, dim1 must be larger than dim0");
1275 static_assert(dim1 < dim2, "Bad Dimensions, dim2 must be larger than dim1");
1276 static_assert(dim2 < dim3, "Bad Dimensions, dim3 must be larger than dim2");
1277 static_assert(dim3 < dim4, "Bad Dimensions, dim4 must be larger than dim3");
1278
1279 const Range r4(0, dim4 == 4 ? nrows() : ncols());
1280 const Range r3(0, dim3 == 3 ? npages() : nrows(), r4.get_extent());
1281 const Range r2(
1282 0, dim2 == 2 ? nbooks() : npages(), r3.get_extent() * r4.get_extent());
1283 const Range r1(0,
1284 dim1 == 1 ? nshelves() : nbooks(),
1285 r2.get_extent() * r3.get_extent() * r4.get_extent());
1286 const Range r0(
1287 0,
1288 dim0 == 0 ? nvitrines() : nshelves(),
1289 r1.get_extent() * r2.get_extent() * r3.get_extent() * r4.get_extent());
1290
1291 Tensor5 out(mdata, r0, r1, r2, r3, r4);
1292 ARTS_ASSERT(size() == out.size(),
1293 "Can only reduce size on same size input");
1294 mdata = nullptr;
1295 return out;
1296 }
1297
1298 template <class F>
1299 void transform_elementwise(F&& func) {
1300 std::transform(mdata, mdata + size(), mdata, func);
1301 }
1302};
1303
1304// Function declarations:
1305// ----------------------
1306
1307void copy(ConstIterator6D origin,
1308 const ConstIterator6D& end,
1309 Iterator6D target);
1310
1311void copy(Numeric x, Iterator6D target, const Iterator6D& end);
1312
1313void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x);
1314
1315Numeric max(const ConstTensor6View& x);
1316
1317Numeric min(const ConstTensor6View& x);
1318
1319std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v);
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
1331#endif // matpackVI_h
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:1050
Index size() const noexcept
Definition: matpackI.h:1065
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:323
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:327
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:329
Index size() const noexcept
Definition: matpackV.h:156
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:321
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:319
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:325
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:606
Range mcr
The column range of mdata that is actually used.
Definition: matpackVI.h:616
Range mbr
The book range of mdata that is actually used.
Definition: matpackVI.h:610
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:618
Range mrr
The row range of mdata that is actually used.
Definition: matpackVI.h:614
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
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:612
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:608
ConstTensor6View()=default
A constant view of a Tensor7.
Definition: matpackVII.h:145
A constant view of a Vector.
Definition: matpackI.h:517
Index size() const noexcept
Definition: matpackI.h:544
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:1169
The Matrix class.
Definition: matpackI.h:1270
The range class.
Definition: matpackI.h:166
Index mstart
The start index.
Definition: matpackI.h:368
constexpr Index get_extent() const noexcept
Returns the extent of the range.
Definition: matpackI.h:349
Index mextent
The number of elements.
Definition: matpackI.h:375
The Tensor3View class.
Definition: matpackIII.h:244
The Tensor3 class.
Definition: matpackIII.h:344
The Tensor4View class.
Definition: matpackIV.h:290
The Tensor4 class.
Definition: matpackIV.h:427
The Tensor5View class.
Definition: matpackV.h:341
The Tensor5 class.
Definition: matpackV.h:514
The Tensor6View class.
Definition: matpackVI.h:630
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:1013
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:1024
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:1097
Tensor5 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1272
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:1122
void transform_elementwise(F &&func)
Definition: matpackVI.h:1299
Tensor6()=default
Tensor3 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1201
Vector reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1154
Tensor4 reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1236
Tensor6(Tensor6 &&v) noexcept
Definition: matpackVI.h:1105
Matrix reduce_rank() &&ARTS_NOEXCEPT
Definition: matpackVI.h:1174
The Tensor7View class.
Definition: matpackVII.h:1301
The VectorView class.
Definition: matpackI.h:658
The Vector class.
Definition: matpackI.h:908
#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
std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:929
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
#define d
#define v
#define a
#define c
#define b
Helper shape class.
Definition: matpackI.h:382