ARTS 2.5.0 (git: 9ee3ac6c)
matpackIV.cc
Go to the documentation of this file.
1/* Copyright (C) 2002-2012 Stefan Buehler <sbuehler@ltu.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
25#include "matpackIV.h"
26#include "exceptions.h"
27
31
34
38
41
42// Functions for ConstTensor4View:
43// ------------------------------
44
46
51 return (nbooks() == 0 || npages() == 0 || nrows() == 0 || ncols() == 0);
52}
53
56
59
62
65
70 const Range& p,
71 const Range& r,
72 const Range& c) const {
73 return ConstTensor4View(mdata, mbr, mpr, mrr, mcr, b, p, r, c);
74}
75
79 const Range& p,
80 const Range& r,
81 Index c) const {
82 // Check that c is valid:
83 ARTS_ASSERT(0 <= c);
85
86 return ConstTensor3View(
87 mdata + mcr.mstart + c * mcr.mstride, mbr, mpr, mrr, b, p, r);
88}
89
93 const Range& p,
94 Index r,
95 const Range& c) const {
96 // Check that r is valid:
97 ARTS_ASSERT(0 <= r);
99
100 return ConstTensor3View(
101 mdata + mrr.mstart + r * mrr.mstride, mbr, mpr, mcr, b, p, c);
102}
103
107 Index p,
108 const Range& r,
109 const Range& c) const {
110 // Check that p is valid:
111 ARTS_ASSERT(0 <= p);
113
114 return ConstTensor3View(
115 mdata + mpr.mstart + p * mpr.mstride, mbr, mrr, mcr, b, r, c);
116}
117
121 const Range& p,
122 const Range& r,
123 const Range& c) const {
124 // Check that b is valid:
125 ARTS_ASSERT(0 <= b);
127
128 return ConstTensor3View(
129 mdata + mbr.mstart + b * mbr.mstride, mpr, mrr, mcr, p, r, c);
130}
131
135 const Range& p,
136 Index r,
137 Index c) const {
138 // Check that r and c are valid:
139 ARTS_ASSERT(0 <= r);
140 ARTS_ASSERT(0 <= c);
143
144 return ConstMatrixView(
146 mbr,
147 mpr,
148 b,
149 p);
150}
151
155 Index p,
156 const Range& r,
157 Index c) const {
158 // Check that p and c are valid:
159 ARTS_ASSERT(0 <= p);
160 ARTS_ASSERT(0 <= c);
163
164 return ConstMatrixView(
166 mbr,
167 mrr,
168 b,
169 r);
170}
171
175 Index p,
176 Index r,
177 const Range& c) const {
178 // Check that p and r are valid:
179 ARTS_ASSERT(0 <= p);
180 ARTS_ASSERT(0 <= r);
183
184 return ConstMatrixView(
185 mdata + mpr.mstart + p * mpr.mstride + mrr.mstart + r * mrr.mstride,
186 mbr,
187 mcr,
188 b,
189 c);
190}
191
195 const Range& p,
196 Index r,
197 const Range& c) const {
198 // Check that b and r are valid:
199 ARTS_ASSERT(0 <= b);
200 ARTS_ASSERT(0 <= r);
203
204 return ConstMatrixView(
206 mpr,
207 mcr,
208 p,
209 c);
210}
211
215 const Range& p,
216 const Range& r,
217 Index c) const {
218 // Check that b and c are valid:
219 ARTS_ASSERT(0 <= b);
220 ARTS_ASSERT(0 <= c);
223
224 return ConstMatrixView(
226 mpr,
228 p,
229 r);
230}
231
235 Index p,
236 const Range& r,
237 const Range& c) const {
238 // Check that b and p are valid:
239 ARTS_ASSERT(0 <= b);
240 ARTS_ASSERT(0 <= p);
243
244 return ConstMatrixView(
246 mrr,
247 mcr,
248 r,
249 c);
250}
251
255 Index p,
256 Index r,
257 Index c) const {
258 // Check that p, r and c are valid:
259 ARTS_ASSERT(0 <= p);
260 ARTS_ASSERT(0 <= r);
261 ARTS_ASSERT(0 <= c);
265
267 r * mrr.mstride + mcr.mstart + c * mcr.mstride,
268 mbr,
269 b);
270}
271
275 const Range& p,
276 Index r,
277 Index c) const {
278 // Check that b, r and c are valid:
279 ARTS_ASSERT(0 <= b);
280 ARTS_ASSERT(0 <= r);
281 ARTS_ASSERT(0 <= c);
285
287 r * mrr.mstride + mcr.mstart + c * mcr.mstride,
288 mpr,
289 p);
290}
291
295 Index p,
296 const Range& r,
297 Index c) const {
298 // Check that b, p and c are valid:
299 ARTS_ASSERT(0 <= b);
300 ARTS_ASSERT(0 <= p);
301 ARTS_ASSERT(0 <= c);
305
307 p * mpr.mstride + mcr.mstart + c * mcr.mstride,
308 mrr,
309 r);
310}
311
315 Index p,
316 Index r,
317 const Range& c) const {
318 // Check that b, p and r are valid:
319 ARTS_ASSERT(0 <= b);
320 ARTS_ASSERT(0 <= p);
321 ARTS_ASSERT(0 <= r);
325
327 p * mpr.mstride + mrr.mstart + r * mrr.mstride,
328 mcr,
329 c);
330}
331
339 ARTS_ASSERT (not (mbr.mstart != 0 ||
341 mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
342 mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
343 mcr.mstride != 1),
344 "A Tensor4View can only be converted to a plain C-array if it's pointing to a continuous block of data");
345 return mdata;
346}
347
355 ARTS_ASSERT (not (mbr.mstart != 0 ||
357 mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
358 mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
359 mcr.mstride != 1),
360 "A Tensor4View can only be converted to a plain C-array if it's pointing to a continuous block of data");
361 return mdata;
362}
363
367 mbr.mstride);
368}
369
372 return ConstIterator4D(
375 mbr.mstride);
376}
377
380 : mbr(0, 1, a.mpr.mextent * a.mrr.mextent * a.mcr.mextent),
381 mpr(a.mpr),
382 mrr(a.mrr),
383 mcr(a.mcr),
384 mdata(a.mdata) {
385 // Nothing to do here.
386}
387
393 const Range& br,
394 const Range& pr,
395 const Range& rr,
396 const Range& cr)
397 : mbr(br), mpr(pr), mrr(rr), mcr(cr), mdata(data) {
398 // Nothing to do here.
399}
400
409 const Range& pb,
410 const Range& pp,
411 const Range& pr,
412 const Range& pc,
413 const Range& nb,
414 const Range& np,
415 const Range& nr,
416 const Range& nc)
417 : mbr(pb, nb), mpr(pp, np), mrr(pr, nr), mcr(pc, nc), mdata(data) {
418 // Nothing to do here.
419}
420
424std::ostream& operator<<(std::ostream& os, const ConstTensor4View& v) {
425 // Page iterators:
426 ConstIterator4D ib = v.begin();
427 const ConstIterator4D end_book = v.end();
428
429 if (ib != end_book) {
430 os << *ib;
431 ++ib;
432 }
433
434 for (; ib != end_book; ++ib) {
435 os << "\n\n";
436 os << *ib;
437 }
438
439 return os;
440}
441
442// Functions for Tensor4View:
443// -------------------------
444
449 const Range& p,
450 const Range& r,
451 const Range& c) {
452 return Tensor4View(mdata, mbr, mpr, mrr, mcr, b, p, r, c);
453}
454
458 const Range& p,
459 const Range& r,
460 Index c) {
461 // Check that c is valid:
462 ARTS_ASSERT(0 <= c);
464
465 return Tensor3View(
466 mdata + mcr.mstart + c * mcr.mstride, mbr, mpr, mrr, b, p, r);
467}
468
472 const Range& p,
473 Index r,
474 const Range& c) {
475 // Check that r is valid:
476 ARTS_ASSERT(0 <= r);
478
479 return Tensor3View(
480 mdata + mrr.mstart + r * mrr.mstride, mbr, mpr, mcr, b, p, c);
481}
482
486 Index p,
487 const Range& r,
488 const Range& c) {
489 // Check that p is valid:
490 ARTS_ASSERT(0 <= p);
492
493 return Tensor3View(
494 mdata + mpr.mstart + p * mpr.mstride, mbr, mrr, mcr, b, r, c);
495}
496
500 const Range& p,
501 const Range& r,
502 const Range& c) {
503 // Check that b is valid:
504 ARTS_ASSERT(0 <= b);
506
507 return Tensor3View(
508 mdata + mbr.mstart + b * mbr.mstride, mpr, mrr, mcr, p, r, c);
509}
510
514 const Range& p,
515 Index r,
516 Index c) {
517 // Check that r and c are valid:
518 ARTS_ASSERT(0 <= r);
519 ARTS_ASSERT(0 <= c);
522
523 return MatrixView(
525 mbr,
526 mpr,
527 b,
528 p);
529}
530
534 Index p,
535 const Range& r,
536 Index c) {
537 // Check that p and c are valid:
538 ARTS_ASSERT(0 <= p);
539 ARTS_ASSERT(0 <= c);
542
543 return MatrixView(
545 mbr,
546 mrr,
547 b,
548 r);
549}
550
554 Index p,
555 Index r,
556 const Range& c) {
557 // Check that p and r are valid:
558 ARTS_ASSERT(0 <= p);
559 ARTS_ASSERT(0 <= r);
562
563 return MatrixView(
564 mdata + mpr.mstart + p * mpr.mstride + mrr.mstart + r * mrr.mstride,
565 mbr,
566 mcr,
567 b,
568 c);
569}
570
574 const Range& p,
575 Index r,
576 const Range& c) {
577 // Check that b and r are valid:
578 ARTS_ASSERT(0 <= b);
579 ARTS_ASSERT(0 <= r);
582
583 return MatrixView(
585 mpr,
586 mcr,
587 p,
588 c);
589}
590
594 const Range& p,
595 const Range& r,
596 Index c) {
597 // Check that b and c are valid:
598 ARTS_ASSERT(0 <= b);
599 ARTS_ASSERT(0 <= c);
602
603 return MatrixView(
605 mpr,
606 mrr,
607 p,
608 r);
609}
610
614 Index p,
615 const Range& r,
616 const Range& c) {
617 // Check that b and p are valid:
618 ARTS_ASSERT(0 <= b);
619 ARTS_ASSERT(0 <= p);
622
623 return MatrixView(
625 mrr,
626 mcr,
627 r,
628 c);
629}
630
634 // Check that p, r and c are valid:
635 ARTS_ASSERT(0 <= p);
636 ARTS_ASSERT(0 <= r);
637 ARTS_ASSERT(0 <= c);
641
642 return VectorView(mdata + mpr.mstart + p * mpr.mstride + mrr.mstart +
643 r * mrr.mstride + mcr.mstart + c * mcr.mstride,
644 mbr,
645 b);
646}
647
651 // Check that b, r and c are valid:
652 ARTS_ASSERT(0 <= b);
653 ARTS_ASSERT(0 <= r);
654 ARTS_ASSERT(0 <= c);
658
659 return VectorView(mdata + mbr.mstart + b * mbr.mstride + mrr.mstart +
660 r * mrr.mstride + mcr.mstart + c * mcr.mstride,
661 mpr,
662 p);
663}
664
668 // Check that b, p and c are valid:
669 ARTS_ASSERT(0 <= b);
670 ARTS_ASSERT(0 <= p);
671 ARTS_ASSERT(0 <= c);
675
676 return VectorView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
677 p * mpr.mstride + mcr.mstart + c * mcr.mstride,
678 mrr,
679 r);
680}
681
685 // Check that b, p and r are valid:
686 ARTS_ASSERT(0 <= b);
687 ARTS_ASSERT(0 <= p);
688 ARTS_ASSERT(0 <= r);
692
693 return VectorView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
694 p * mpr.mstride + mrr.mstart + r * mrr.mstride,
695 mcr,
696 c);
697}
698
702 mbr.mstride);
703}
704
707 return Iterator4D(
710 mbr.mstride);
711}
712
718 // Check that sizes are compatible:
723
724 copy(m.begin(), m.end(), begin());
725 return *this;
726}
727
734 // Check that sizes are compatible:
739
740 copy(m.begin(), m.end(), begin());
741 return *this;
742}
743
748 // Check that sizes are compatible:
753
754 copy(m.begin(), m.end(), begin());
755 return *this;
756}
757
761 copy(x, begin(), end());
762 return *this;
763}
764
765// Some little helper functions:
766//------------------------------
767
770 const Iterator4D eb = end();
771 for (Iterator4D b = begin(); b != eb; ++b) {
772 *b *= x;
773 }
774 return *this;
775}
776
779 const Iterator4D eb = end();
780 for (Iterator4D b = begin(); b != eb; ++b) {
781 *b /= x;
782 }
783 return *this;
784}
785
788 const Iterator4D eb = end();
789 for (Iterator4D b = begin(); b != eb; ++b) {
790 *b += x;
791 }
792 return *this;
793}
794
797 const Iterator4D eb = end();
798 for (Iterator4D b = begin(); b != eb; ++b) {
799 *b -= x;
800 }
801 return *this;
802}
803
806 ARTS_ASSERT(nbooks() == x.nbooks());
807 ARTS_ASSERT(npages() == x.npages());
808 ARTS_ASSERT(nrows() == x.nrows());
809 ARTS_ASSERT(ncols() == x.ncols());
810 ConstIterator4D xb = x.begin();
811 Iterator4D b = begin();
812 const Iterator4D eb = end();
813 for (; b != eb; ++b, ++xb) {
814 *b *= *xb;
815 }
816 return *this;
817}
818
821 ARTS_ASSERT(nbooks() == x.nbooks());
822 ARTS_ASSERT(npages() == x.npages());
823 ARTS_ASSERT(nrows() == x.nrows());
824 ARTS_ASSERT(ncols() == x.ncols());
825 ConstIterator4D xb = x.begin();
826 Iterator4D b = begin();
827 const Iterator4D eb = end();
828 for (; b != eb; ++b, ++xb) {
829 *b /= *xb;
830 }
831 return *this;
832}
833
836 ARTS_ASSERT(nbooks() == x.nbooks());
837 ARTS_ASSERT(npages() == x.npages());
838 ARTS_ASSERT(nrows() == x.nrows());
839 ARTS_ASSERT(ncols() == x.ncols());
840 ConstIterator4D xb = x.begin();
841 Iterator4D b = begin();
842 const Iterator4D eb = end();
843 for (; b != eb; ++b, ++xb) {
844 *b += *xb;
845 }
846 return *this;
847}
848
851 ARTS_ASSERT(nbooks() == x.nbooks());
852 ARTS_ASSERT(npages() == x.npages());
853 ARTS_ASSERT(nrows() == x.nrows());
854 ARTS_ASSERT(ncols() == x.ncols());
855 ConstIterator4D xb = x.begin();
856 Iterator4D b = begin();
857 const Iterator4D eb = end();
858 for (; b != eb; ++b, ++xb) {
859 *b -= *xb;
860 }
861 return *this;
862}
863
867 a.mdata,
868 Range(0, 1, a.mpr.mextent * a.mrr.mextent * a.mcr.mextent),
869 a.mpr,
870 a.mrr,
871 a.mcr) {
872 // Nothing to do here.
873}
874
879 const Range& br,
880 const Range& pr,
881 const Range& rr,
882 const Range& cr)
883 : ConstTensor4View(data, br, pr, rr, cr) {
884 // Nothing to do here.
885}
886
906 const Range& pb,
907 const Range& pp,
908 const Range& pr,
909 const Range& pc,
910 const Range& nb,
911 const Range& np,
912 const Range& nr,
913 const Range& nc)
914 : ConstTensor4View(data, pb, pp, pr, pc, nb, np, nr, nc) {
915 // Nothing to do here.
916}
917
923 const ConstIterator4D& end,
924 Iterator4D target) {
925 for (; origin != end; ++origin, ++target) {
926 // We use the copy function for the next smaller rank of tensor
927 // recursively:
928 copy(origin->begin(), origin->end(), target->begin());
929 }
930}
931
933void copy(Numeric x, Iterator4D target, const Iterator4D& end) {
934 for (; target != end; ++target) {
935 // We use the copy function for the next smaller rank of tensor
936 // recursively:
937 copy(x, target->begin(), target->end());
938 }
939}
940
941// Functions for Tensor4:
942// ---------------------
943
947 : Tensor4View(new Numeric[b * p * r * c],
948 Range(0, b, p * r * c),
949 Range(0, p, r * c),
950 Range(0, r, c),
951 Range(0, c)) {
952 // Nothing to do here.
953}
954
957 : Tensor4View(new Numeric[b * p * r * c],
958 Range(0, b, p * r * c),
959 Range(0, p, r * c),
960 Range(0, r, c),
961 Range(0, c)) {
962 // Here we can access the raw memory directly, for slightly
963 // increased efficiency:
964 std::fill_n(mdata, b * p * r * c, fill);
965}
966
970 : Tensor4View(new Numeric[m.nbooks() * m.npages() * m.nrows() * m.ncols()],
971 Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
972 Range(0, m.npages(), m.nrows() * m.ncols()),
973 Range(0, m.nrows(), m.ncols()),
974 Range(0, m.ncols())) {
975 copy(m.begin(), m.end(), begin());
976}
977
981 : Tensor4View(new Numeric[m.nbooks() * m.npages() * m.nrows() * m.ncols()],
982 Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
983 Range(0, m.npages(), m.nrows() * m.ncols()),
984 Range(0, m.nrows(), m.ncols()),
985 Range(0, m.ncols())) {
986 // There is a catch here: If m is an empty tensor, then it will have
987 // dimensions of size 0. But these are used to initialize the stride
988 // for higher dimensions! Thus, this method has to be consistent
989 // with the behaviour of Range::Range. For now, Range::Range allows
990 // also stride 0.
991 std::memcpy(mdata,
992 m.mdata,
993 nbooks() * npages() * nrows() * ncols() * sizeof(Numeric));
994}
995
997
1021 if (this != &x) {
1022 resize(x.nbooks(), x.npages(), x.nrows(), x.ncols());
1023 std::memcpy(mdata,
1024 x.mdata,
1025 nbooks() * npages() * nrows() * ncols() * sizeof(Numeric));
1026 }
1027 return *this;
1028}
1029
1032 if (this != &x) {
1033 delete[] mdata;
1034 mdata = x.mdata;
1035 mbr = x.mbr;
1036 mpr = x.mpr;
1037 mrr = x.mrr;
1038 mcr = x.mcr;
1039 x.mbr = Range(0, 0);
1040 x.mpr = Range(0, 0);
1041 x.mrr = Range(0, 0);
1042 x.mcr = Range(0, 0);
1043 x.mdata = nullptr;
1044 }
1045 return *this;
1046}
1047
1051 std::fill_n(mdata, nbooks() * npages() * nrows() * ncols(), x);
1052 return *this;
1053}
1054
1059 ARTS_ASSERT(0 <= b);
1060 ARTS_ASSERT(0 <= p);
1061 ARTS_ASSERT(0 <= r);
1062 ARTS_ASSERT(0 <= c);
1063
1064 if (mbr.mextent != b || mpr.mextent != p || mrr.mextent != r ||
1065 mcr.mextent != c) {
1066 delete[] mdata;
1067 mdata = new Numeric[b * p * r * c];
1068
1069 mbr.mstart = 0;
1070 mbr.mextent = b;
1071 mbr.mstride = p * r * c;
1072
1073 mpr.mstart = 0;
1074 mpr.mextent = p;
1075 mpr.mstride = r * c;
1076
1077 mrr.mstart = 0;
1078 mrr.mextent = r;
1079 mrr.mstride = c;
1080
1081 mcr.mstart = 0;
1082 mcr.mextent = c;
1083 mcr.mstride = 1;
1084 }
1085}
1086
1088void swap(Tensor4& t1, Tensor4& t2) {
1089 std::swap(t1.mbr, t2.mbr);
1090 std::swap(t1.mpr, t2.mpr);
1091 std::swap(t1.mrr, t2.mrr);
1092 std::swap(t1.mcr, t2.mcr);
1093 std::swap(t1.mdata, t2.mdata);
1094}
1095
1099 // cout << "Destroying a Tensor4:\n"
1100 // << *this << "\n........................................\n";
1101 delete[] mdata;
1102}
1103
1119void transform(Tensor4View y, double (&my_func)(double), ConstTensor4View x) {
1120 // Check dimensions:
1121 ARTS_ASSERT(y.nbooks() == x.nbooks());
1122 ARTS_ASSERT(y.npages() == x.npages());
1123 ARTS_ASSERT(y.nrows() == x.nrows());
1124 ARTS_ASSERT(y.ncols() == x.ncols());
1125
1126 const ConstIterator4D xe = x.end();
1127 ConstIterator4D xi = x.begin();
1128 Iterator4D yi = y.begin();
1129 for (; xi != xe; ++xi, ++yi) {
1130 // Use the transform function of lower dimensional tensors
1131 // recursively:
1132 transform(*yi, my_func, *xi);
1133 }
1134}
1135
1138 const ConstIterator4D xe = x.end();
1139 ConstIterator4D xi = x.begin();
1140
1141 // Initial value for max:
1142 Numeric themax = max(*xi);
1143 ++xi;
1144
1145 for (; xi != xe; ++xi) {
1146 // Use the max function of lower dimensional tensors
1147 // recursively:
1148 Numeric maxi = max(*xi);
1149 if (maxi > themax) themax = maxi;
1150 }
1151
1152 return themax;
1153}
1154
1157 const ConstIterator4D xe = x.end();
1158 ConstIterator4D xi = x.begin();
1159
1160 // Initial value for min:
1161 Numeric themin = min(*xi);
1162 ++xi;
1163
1164 for (; xi != xe; ++xi) {
1165 // Use the min function of lower dimensional tensors
1166 // recursively:
1167 Numeric mini = min(*xi);
1168 if (mini < themin) themin = mini;
1169 }
1170
1171 return themin;
1172}
1173
1175// Helper function for debugging
1176#ifndef NDEBUG
1177
1194 Tensor4View& tv, Index b, Index p, Index r, Index c) {
1195 return tv(b, p, r, c);
1196}
1197
1198#endif
Index nrows
Index nbooks
Index npages
void * data
Index ncols
Const version of Iterator4D.
Definition: matpackIV.h:77
const ConstTensor3View & operator*() const
Dereferencing.
Definition: matpackIV.cc:40
const ConstTensor3View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
Definition: matpackIV.cc:37
ConstTensor3View msv
Current position.
Definition: matpackIV.h:113
A constant view of a Matrix.
Definition: matpackI.h:1014
A constant view of a Tensor3.
Definition: matpackIII.h:132
ConstIterator3D begin() const
Return const iterator to first page.
Definition: matpackIII.cc:137
ConstIterator3D end() const
Return const iterator behind last page.
Definition: matpackIII.cc:143
A constant view of a Tensor4.
Definition: matpackIV.h:133
Range mrr
The row range of mdata that is actually used.
Definition: matpackIV.h:268
ConstTensor4View()=default
Range mbr
The book range of mdata that is actually used.
Definition: matpackIV.h:264
ConstTensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c) const
Const index operator for subrange.
Definition: matpackIV.cc:69
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:58
Range mcr
The column range of mdata that is actually used.
Definition: matpackIV.h:270
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackIV.h:272
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:55
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:64
Range mpr
The page range of mdata that is actually used.
Definition: matpackIV.h:266
ConstIterator4D end() const
Return const iterator behind last book.
Definition: matpackIV.cc:371
ConstIterator4D begin() const
Return const iterator to first book.
Definition: matpackIV.cc:365
bool empty() const
Check if variable is empty.
Definition: matpackIV.cc:50
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:61
A constant view of a Vector.
Definition: matpackI.h:489
Implementation of Tensors of Rank 4.
Definition: matpackIV.h:38
Tensor3View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 3D iterators.
Definition: matpackIV.cc:30
Tensor3View & operator*()
Dereferencing.
Definition: matpackIV.cc:33
Tensor3View msv
Current position.
Definition: matpackIV.h:71
The MatrixView class.
Definition: matpackI.h:1125
The range class.
Definition: matpackI.h:165
Index mstart
The start index.
Definition: matpackI.h:351
Index mstride
The stride.
Definition: matpackI.h:360
Index mextent
The number of elements.
Definition: matpackI.h:358
The Tensor3View class.
Definition: matpackIII.h:239
Iterator3D begin()
Return iterator to first page.
Definition: matpackIII.cc:326
Iterator3D end()
Return iterator behind last page.
Definition: matpackIII.cc:331
The Tensor4View class.
Definition: matpackIV.h:284
Iterator4D begin()
Return iterator to first book.
Definition: matpackIV.cc:700
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Definition: matpackIV.cc:354
Tensor4View & operator+=(Numeric x)
Addition of scalar.
Definition: matpackIV.cc:787
Tensor4View operator()(const Range &b, const Range &p, const Range &r, const Range &c)
Index operator for subrange.
Definition: matpackIV.cc:448
Tensor4View & operator-=(Numeric x)
Subtraction of scalar.
Definition: matpackIV.cc:796
Tensor4View & operator=(const ConstTensor4View &v)
Assignment operator.
Definition: matpackIV.cc:717
Iterator4D end()
Return iterator behind last book.
Definition: matpackIV.cc:706
Tensor4View & operator/=(Numeric x)
Division by scalar.
Definition: matpackIV.cc:778
Tensor4View & operator*=(Numeric x)
Multiplication by scalar.
Definition: matpackIV.cc:769
Tensor4View()=default
The Tensor4 class.
Definition: matpackIV.h:421
virtual ~Tensor4()
Destructor for Tensor4.
Definition: matpackIV.cc:1098
void resize(Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackIV.cc:1058
Tensor4()=default
Tensor4 & operator=(const Tensor4 &x)
Assignment operator from another tensor.
Definition: matpackIV.cc:1020
The VectorView class.
Definition: matpackI.h:626
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
The declarations of all the exception classes.
#define eb
void copy(ConstIterator4D origin, const ConstIterator4D &end, Iterator4D target)
Copy data between begin and end to target.
Definition: matpackIV.cc:922
Numeric debug_tensor4view_get_elem(Tensor4View &tv, Index b, Index p, Index r, Index c)
Helper function to access tensor elements.
Definition: matpackIV.cc:1193
Numeric max(const ConstTensor4View &x)
Max function, tensor version.
Definition: matpackIV.cc:1137
Numeric min(const ConstTensor4View &x)
Min function, tensor version.
Definition: matpackIV.cc:1156
std::ostream & operator<<(std::ostream &os, const ConstTensor4View &v)
Output operator.
Definition: matpackIV.cc:424
void transform(Tensor4View y, double(&my_func)(double), ConstTensor4View x)
A generic transform function for tensors, which can be used to implement mathematical functions opera...
Definition: matpackIV.cc:1119
void swap(Tensor4 &t1, Tensor4 &t2)
Swaps two objects.
Definition: matpackIV.cc:1088
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:109
#define v
#define a
#define c
#define b