ARTS  2.3.1285(git:92a29ea9-dirty)
matpackV.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 "matpackV.h"
26 #include "exceptions.h"
27 
28 using std::runtime_error;
29 
30 // Functions for ConstTensor5View:
31 // ------------------------------
32 
34 
39  return (nshelves() == 0 || nbooks() == 0 || npages() == 0 || nrows() == 0 ||
40  ncols() == 0);
41 }
42 
45 
48 
51 
54 
57 
62  const Range& b,
63  const Range& p,
64  const Range& r,
65  const Range& c) const {
66  return ConstTensor5View(mdata, msr, mbr, mpr, mrr, mcr, s, b, p, r, c);
67 }
68 
72  const Range& b,
73  const Range& p,
74  const Range& r,
75  Index c) const {
76  // Check that c is valid:
77  assert(0 <= c);
78  assert(c < mcr.mextent);
79 
80  return ConstTensor4View(
81  mdata + mcr.mstart + c * mcr.mstride, msr, mbr, mpr, mrr, s, b, p, r);
82 }
83 
87  const Range& b,
88  const Range& p,
89  Index r,
90  const Range& c) const {
91  // Check that r is valid:
92  assert(0 <= r);
93  assert(r < mrr.mextent);
94 
95  return ConstTensor4View(
96  mdata + mrr.mstart + r * mrr.mstride, msr, mbr, mpr, mcr, s, b, p, c);
97 }
98 
102  const Range& b,
103  Index p,
104  const Range& r,
105  const Range& c) const {
106  // Check that p is valid:
107  assert(0 <= p);
108  assert(p < mpr.mextent);
109 
110  return ConstTensor4View(
111  mdata + mpr.mstart + p * mpr.mstride, msr, mbr, mrr, mcr, s, b, r, c);
112 }
113 
117  Index b,
118  const Range& p,
119  const Range& r,
120  const Range& c) const {
121  // Check that b is valid:
122  assert(0 <= b);
123  assert(b < mbr.mextent);
124 
125  return ConstTensor4View(
126  mdata + mbr.mstart + b * mbr.mstride, msr, mpr, mrr, mcr, s, p, r, c);
127 }
128 
132  const Range& b,
133  const Range& p,
134  const Range& r,
135  const Range& c) const {
136  // Check that s is valid:
137  assert(0 <= s);
138  assert(s < msr.mextent);
139 
140  return ConstTensor4View(
141  mdata + msr.mstart + s * msr.mstride, mbr, mpr, mrr, mcr, b, p, r, c);
142 }
143 
147  const Range& s, const Range& b, const Range& p, Index r, Index c) const {
148  // Check that r and c is valid:
149  assert(0 <= r);
150  assert(0 <= c);
151  assert(r < mrr.mextent);
152  assert(c < mcr.mextent);
153 
154  return ConstTensor3View(
155  mdata + mrr.mstart + r * mrr.mstride + mcr.mstart + c * mcr.mstride,
156  msr,
157  mbr,
158  mpr,
159  s,
160  b,
161  p);
162 }
163 
167  const Range& s, const Range& b, Index p, const Range& r, Index c) const {
168  // Check that p and c are valid:
169  assert(0 <= p);
170  assert(0 <= c);
171  assert(p < mpr.mextent);
172  assert(c < mcr.mextent);
173 
174  return ConstTensor3View(
175  mdata + mpr.mstart + p * mpr.mstride + mcr.mstart + c * mcr.mstride,
176  msr,
177  mbr,
178  mrr,
179  s,
180  b,
181  r);
182 }
183 
187  const Range& s, const Range& b, Index p, Index r, const Range& c) const {
188  // Check that p and r are valid:
189  assert(0 <= p);
190  assert(0 <= r);
191  assert(p < mpr.mextent);
192  assert(r < mrr.mextent);
193 
194  return ConstTensor3View(
195  mdata + mpr.mstart + p * mpr.mstride + mrr.mstart + r * mrr.mstride,
196  msr,
197  mbr,
198  mcr,
199  s,
200  b,
201  c);
202 }
203 
207  const Range& s, Index b, const Range& p, Index r, const Range& c) const {
208  // Check that b and r are valid:
209  assert(0 <= b);
210  assert(0 <= r);
211  assert(b < mbr.mextent);
212  assert(r < mrr.mextent);
213 
214  return ConstTensor3View(
215  mdata + mbr.mstart + b * mbr.mstride + mrr.mstart + r * mrr.mstride,
216  msr,
217  mpr,
218  mcr,
219  s,
220  p,
221  c);
222 }
223 
227  const Range& s, Index b, const Range& p, const Range& r, Index c) const {
228  // Check that b and c are valid:
229  assert(0 <= b);
230  assert(0 <= c);
231  assert(b < mbr.mextent);
232  assert(c < mcr.mextent);
233 
234  return ConstTensor3View(
235  mdata + mbr.mstart + b * mbr.mstride + mcr.mstart + c * mcr.mstride,
236  msr,
237  mpr,
238  mrr,
239  s,
240  p,
241  r);
242 }
243 
247  const Range& s, Index b, Index p, const Range& r, const Range& c) const {
248  // Check that b and p are valid:
249  assert(0 <= b);
250  assert(0 <= p);
251  assert(b < mbr.mextent);
252  assert(p < mpr.mextent);
253 
254  return ConstTensor3View(
255  mdata + mbr.mstart + b * mbr.mstride + mpr.mstart + p * mpr.mstride,
256  msr,
257  mrr,
258  mcr,
259  s,
260  r,
261  c);
262 }
263 
267  Index s, const Range& b, Index p, const Range& r, const Range& c) const {
268  // Check that s and p are valid:
269  assert(0 <= s);
270  assert(0 <= p);
271  assert(s < msr.mextent);
272  assert(p < mpr.mextent);
273 
274  return ConstTensor3View(
275  mdata + msr.mstart + s * msr.mstride + mpr.mstart + p * mpr.mstride,
276  mbr,
277  mrr,
278  mcr,
279  b,
280  r,
281  c);
282 }
283 
287  Index s, const Range& b, const Range& p, Index r, const Range& c) const {
288  // Check that s and r are valid:
289  assert(0 <= s);
290  assert(0 <= r);
291  assert(s < msr.mextent);
292  assert(r < mrr.mextent);
293 
294  return ConstTensor3View(
295  mdata + msr.mstart + s * msr.mstride + mrr.mstart + r * mrr.mstride,
296  mbr,
297  mpr,
298  mcr,
299  b,
300  p,
301  c);
302 }
303 
307  Index s, const Range& b, const Range& p, const Range& r, Index c) const {
308  // Check that s and c are valid:
309  assert(0 <= s);
310  assert(0 <= c);
311  assert(s < msr.mextent);
312  assert(c < mcr.mextent);
313 
314  return ConstTensor3View(
315  mdata + msr.mstart + s * msr.mstride + mcr.mstart + c * mcr.mstride,
316  mbr,
317  mpr,
318  mrr,
319  b,
320  p,
321  r);
322 }
323 
327  Index s, Index b, const Range& p, const Range& r, const Range& c) const {
328  // Check that s and b are valid:
329  assert(0 <= s);
330  assert(0 <= b);
331  assert(s < msr.mextent);
332  assert(b < mbr.mextent);
333 
334  return ConstTensor3View(
335  mdata + msr.mstart + s * msr.mstride + mbr.mstart + b * mbr.mstride,
336  mpr,
337  mrr,
338  mcr,
339  p,
340  r,
341  c);
342 }
343 
347  const Range& s, const Range& b, Index p, Index r, Index c) const {
348  // Check that p, r and c are valid:
349  assert(0 <= p);
350  assert(0 <= r);
351  assert(0 <= c);
352  assert(p < mpr.mextent);
353  assert(r < mrr.mextent);
354  assert(c < mcr.mextent);
355 
356  return ConstMatrixView(mdata + mpr.mstart + p * mpr.mstride + mrr.mstart +
357  r * mrr.mstride + mcr.mstart + c * mcr.mstride,
358  msr,
359  mbr,
360  s,
361  b);
362 }
363 
367  const Range& s, Index b, const Range& p, Index r, Index c) const {
368  // Check that b, r and c are valid:
369  assert(0 <= b);
370  assert(0 <= r);
371  assert(0 <= c);
372  assert(b < mbr.mextent);
373  assert(r < mrr.mextent);
374  assert(c < mcr.mextent);
375 
376  return ConstMatrixView(mdata + mbr.mstart + b * mbr.mstride + mrr.mstart +
377  r * mpr.mstride + mcr.mstart + c * mcr.mstride,
378  msr,
379  mpr,
380  s,
381  p);
382 }
383 
387  const Range& s, Index b, Index p, const Range& r, Index c) const {
388  // Check that b, p and c are valid:
389  assert(0 <= b);
390  assert(0 <= p);
391  assert(0 <= c);
392  assert(b < mbr.mextent);
393  assert(p < mpr.mextent);
394  assert(c < mcr.mextent);
395 
396  return ConstMatrixView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
397  p * mpr.mstride + mcr.mstart + c * mcr.mstride,
398  msr,
399  mrr,
400  s,
401  r);
402 }
403 
407  const Range& s, Index b, Index p, Index r, const Range& c) const {
408  // Check that b, p and r are valid:
409  assert(0 <= b);
410  assert(0 <= p);
411  assert(0 <= r);
412  assert(b < mbr.mextent);
413  assert(p < mpr.mextent);
414  assert(r < mrr.mextent);
415 
416  return ConstMatrixView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
417  p * mpr.mstride + mrr.mstart + r * mrr.mstride,
418  msr,
419  mcr,
420  s,
421  c);
422 }
423 
427  Index s, const Range& b, Index p, Index r, const Range& c) const {
428  // Check that s, p and r are valid:
429  assert(0 <= s);
430  assert(0 <= p);
431  assert(0 <= r);
432  assert(s < msr.mextent);
433  assert(p < mpr.mextent);
434  assert(r < mrr.mextent);
435 
436  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
437  p * mpr.mstride + mrr.mstart + r * mrr.mstride,
438  mbr,
439  mcr,
440  b,
441  c);
442 }
443 
447  Index s, const Range& b, Index p, const Range& r, Index c) const {
448  // Check that s, p and c are valid:
449  assert(0 <= s);
450  assert(0 <= p);
451  assert(0 <= c);
452  assert(s < msr.mextent);
453  assert(p < mpr.mextent);
454  assert(c < mcr.mextent);
455 
456  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
457  p * mpr.mstride + mcr.mstart + c * mcr.mstride,
458  mbr,
459  mrr,
460  b,
461  r);
462 }
463 
467  Index s, const Range& b, const Range& p, Index r, Index c) const {
468  // Check that s, r and c are valid:
469  assert(0 <= s);
470  assert(0 <= r);
471  assert(0 <= c);
472  assert(s < msr.mextent);
473  assert(r < mrr.mextent);
474  assert(c < mcr.mextent);
475 
476  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mrr.mstart +
477  r * mrr.mstride + mcr.mstart + c * mcr.mstride,
478  mbr,
479  mpr,
480  b,
481  p);
482 }
483 
487  Index s, Index b, const Range& p, const Range& r, Index c) const {
488  // Check that s, b and c are valid:
489  assert(0 <= s);
490  assert(0 <= b);
491  assert(0 <= c);
492  assert(s < msr.mextent);
493  assert(b < mbr.mextent);
494  assert(c < mcr.mextent);
495 
496  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
497  b * mbr.mstride + mcr.mstart + c * mcr.mstride,
498  mpr,
499  mrr,
500  p,
501  r);
502 }
503 
507  Index s, Index b, const Range& p, Index r, const Range& c) const {
508  // Check that s, b and r are valid:
509  assert(0 <= s);
510  assert(0 <= b);
511  assert(0 <= r);
512  assert(s < msr.mextent);
513  assert(b < mbr.mextent);
514  assert(r < mrr.mextent);
515 
516  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
517  b * mbr.mstride + mrr.mstart + r * mrr.mstride,
518  mpr,
519  mcr,
520  p,
521  c);
522 }
523 
527  Index s, Index b, Index p, const Range& r, const Range& c) const {
528  // Check that s, b and p are valid:
529  assert(0 <= s);
530  assert(0 <= b);
531  assert(0 <= p);
532  assert(s < msr.mextent);
533  assert(b < mbr.mextent);
534  assert(p < mpr.mextent);
535 
536  return ConstMatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
537  b * mbr.mstride + mpr.mstart + p * mpr.mstride,
538  mrr,
539  mcr,
540  r,
541  c);
542 }
543 
547  const Range& s, Index b, Index p, Index r, Index c) const {
548  // Check that b, p, r and c are valid:
549  assert(0 <= b);
550  assert(0 <= p);
551  assert(0 <= r);
552  assert(0 <= c);
553  assert(b < mbr.mextent);
554  assert(p < mpr.mextent);
555  assert(r < mrr.mextent);
556  assert(c < mcr.mextent);
557 
558  return ConstVectorView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
559  p * mpr.mstride + mrr.mstart + r * mrr.mstride +
560  mcr.mstart + c * mcr.mstride,
561  msr,
562  s);
563 }
564 
568  Index s, const Range& b, Index p, Index r, Index c) const {
569  // Check that s, p, r and c are valid:
570  assert(0 <= s);
571  assert(0 <= p);
572  assert(0 <= r);
573  assert(0 <= c);
574  assert(s < msr.mextent);
575  assert(p < mpr.mextent);
576  assert(r < mrr.mextent);
577  assert(c < mcr.mextent);
578 
579  return ConstVectorView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
580  p * mpr.mstride + mrr.mstart + r * mrr.mstride +
581  mcr.mstart + c * mcr.mstride,
582  mbr,
583  b);
584 }
585 
589  Index s, Index b, const Range& p, Index r, Index c) const {
590  // Check that s, b, r and c are valid:
591  assert(0 <= s);
592  assert(0 <= b);
593  assert(0 <= r);
594  assert(0 <= c);
595  assert(s < msr.mextent);
596  assert(b < mbr.mextent);
597  assert(r < mrr.mextent);
598  assert(c < mcr.mextent);
599 
600  return ConstVectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
601  b * mbr.mstride + mrr.mstart + r * mrr.mstride +
602  mcr.mstart + c * mcr.mstride,
603  mpr,
604  p);
605 }
606 
610  Index s, Index b, Index p, const Range& r, Index c) const {
611  // Check that s, b, p and c are valid:
612  assert(0 <= s);
613  assert(0 <= b);
614  assert(0 <= p);
615  assert(0 <= c);
616  assert(s < msr.mextent);
617  assert(b < mbr.mextent);
618  assert(p < mpr.mextent);
619  assert(c < mcr.mextent);
620 
621  return ConstVectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
622  b * mbr.mstride + mpr.mstart + p * mpr.mstride +
623  mcr.mstart + c * mcr.mstride,
624  mrr,
625  r);
626 }
627 
631  Index s, Index b, Index p, Index r, const Range& c) const {
632  // Check that s, b, p and r are valid:
633  assert(0 <= s);
634  assert(0 <= b);
635  assert(0 <= p);
636  assert(0 <= r);
637  assert(s < msr.mextent);
638  assert(b < mbr.mextent);
639  assert(p < mpr.mextent);
640  assert(r < mrr.mextent);
641 
642  return ConstVectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
643  b * mbr.mstride + mpr.mstart + p * mpr.mstride +
644  mrr.mstart + r * mrr.mstride,
645  mcr,
646  c);
647 }
648 
656  if (msr.mstart != 0 ||
658  mbr.mstart != 0 ||
660  mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
661  mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
662  mcr.mstride != 1)
663  throw std::runtime_error(
664  "A Tensor5View can only be converted to a plain C-array if it's pointing to a continuous block of data");
665 
666  return mdata;
667 }
668 
676  if (msr.mstart != 0 ||
678  mbr.mstart != 0 ||
680  mpr.mstart != 0 || mpr.mstride != mrr.mextent * mcr.mextent ||
681  mrr.mstart != 0 || mrr.mstride != mcr.mextent || mcr.mstart != 0 ||
682  mcr.mstride != 1)
683  throw std::runtime_error(
684  "A Tensor5View can only be converted to a plain C-array if it's pointing to a continuous block of data");
685 
686  return mdata;
687 }
688 
691  return ConstIterator5D(
693 }
694 
697  return ConstIterator5D(
699  mdata + msr.mstart + (msr.mextent) * msr.mstride, mbr, mpr, mrr, mcr),
700  msr.mstride);
701 }
702 
705  : msr(0, 1, a.mbr.mextent * a.mpr.mextent * a.mrr.mextent * a.mcr.mextent),
706  mbr(a.mbr),
707  mpr(a.mpr),
708  mrr(a.mrr),
709  mcr(a.mcr),
710  mdata(a.mdata) {
711  // Nothing to do here.
712 }
713 
719  const Range& sr,
720  const Range& br,
721  const Range& pr,
722  const Range& rr,
723  const Range& cr)
724  : msr(sr), mbr(br), mpr(pr), mrr(rr), mcr(cr), mdata(data) {
725  // Nothing to do here.
726 }
727 
736  const Range& ps,
737  const Range& pb,
738  const Range& pp,
739  const Range& pr,
740  const Range& pc,
741  const Range& ns,
742  const Range& nb,
743  const Range& np,
744  const Range& nr,
745  const Range& nc)
746  : msr(ps, ns),
747  mbr(pb, nb),
748  mpr(pp, np),
749  mrr(pr, nr),
750  mcr(pc, nc),
751  mdata(data) {
752  // Nothing to do here.
753 }
754 
758 std::ostream& operator<<(std::ostream& os, const ConstTensor5View& v) {
759  // Page iterators:
760  ConstIterator5D is = v.begin();
761  const ConstIterator5D end_shelf = v.end();
762 
763  if (is != end_shelf) {
764  os << *is;
765  ++is;
766  }
767 
768  for (; is != end_shelf; ++is) {
769  os << "\n\n";
770  os << *is;
771  }
772 
773  return os;
774 }
775 
776 // Functions for Tensor5View:
777 // -------------------------
778 
783  const Range& b,
784  const Range& p,
785  const Range& r,
786  const Range& c) {
787  return Tensor5View(mdata, msr, mbr, mpr, mrr, mcr, s, b, p, r, c);
788 }
789 
793  const Range& s, const Range& b, const Range& p, const Range& r, Index c) {
794  // Check that c is valid:
795  assert(0 <= c);
796  assert(c < mcr.mextent);
797 
798  return Tensor4View(
799  mdata + mcr.mstart + c * mcr.mstride, msr, mbr, mpr, mrr, s, b, p, r);
800 }
801 
805  const Range& s, const Range& b, const Range& p, Index r, const Range& c) {
806  // Check that r is valid:
807  assert(0 <= r);
808  assert(r < mrr.mextent);
809 
810  return Tensor4View(
811  mdata + mrr.mstart + r * mrr.mstride, msr, mbr, mpr, mcr, s, b, p, c);
812 }
813 
817  const Range& s, const Range& b, Index p, const Range& r, const Range& c) {
818  // Check that p is valid:
819  assert(0 <= p);
820  assert(p < mpr.mextent);
821 
822  return Tensor4View(
823  mdata + mpr.mstart + p * mpr.mstride, msr, mbr, mrr, mcr, s, b, r, c);
824 }
825 
829  const Range& s, Index b, const Range& p, const Range& r, const Range& c) {
830  // Check that b is valid:
831  assert(0 <= b);
832  assert(b < mbr.mextent);
833 
834  return Tensor4View(
835  mdata + mbr.mstart + b * mbr.mstride, msr, mpr, mrr, mcr, s, p, r, c);
836 }
837 
841  Index s, const Range& b, const Range& p, const Range& r, const Range& c) {
842  // Check that s is valid:
843  assert(0 <= s);
844  assert(s < msr.mextent);
845 
846  return Tensor4View(
847  mdata + msr.mstart + s * msr.mstride, mbr, mpr, mrr, mcr, b, p, r, c);
848 }
849 
853  const Range& s, const Range& b, const Range& p, Index r, Index c) {
854  // Check that r and c is valid:
855  assert(0 <= r);
856  assert(0 <= c);
857  assert(r < mrr.mextent);
858  assert(c < mcr.mextent);
859 
860  return Tensor3View(
861  mdata + mrr.mstart + r * mrr.mstride + mcr.mstart + c * mcr.mstride,
862  msr,
863  mbr,
864  mpr,
865  s,
866  b,
867  p);
868 }
869 
873  const Range& s, const Range& b, Index p, const Range& r, Index c) {
874  // Check that p and c are valid:
875  assert(0 <= p);
876  assert(0 <= c);
877  assert(p < mpr.mextent);
878  assert(c < mcr.mextent);
879 
880  return Tensor3View(
881  mdata + mpr.mstart + p * mpr.mstride + mcr.mstart + c * mcr.mstride,
882  msr,
883  mbr,
884  mrr,
885  s,
886  b,
887  r);
888 }
889 
893  const Range& s, const Range& b, Index p, Index r, const Range& c) {
894  // Check that p and r are valid:
895  assert(0 <= p);
896  assert(0 <= r);
897  assert(p < mpr.mextent);
898  assert(r < mrr.mextent);
899 
900  return Tensor3View(
901  mdata + mpr.mstart + p * mpr.mstride + mrr.mstart + r * mrr.mstride,
902  msr,
903  mbr,
904  mcr,
905  s,
906  b,
907  c);
908 }
909 
913  const Range& s, Index b, const Range& p, Index r, const Range& c) {
914  // Check that b and r are valid:
915  assert(0 <= b);
916  assert(0 <= r);
917  assert(b < mbr.mextent);
918  assert(r < mrr.mextent);
919 
920  return Tensor3View(
921  mdata + mbr.mstart + b * mbr.mstride + mrr.mstart + r * mrr.mstride,
922  msr,
923  mpr,
924  mcr,
925  s,
926  p,
927  c);
928 }
929 
933  const Range& s, Index b, const Range& p, const Range& r, Index c) {
934  // Check that b and c are valid:
935  assert(0 <= b);
936  assert(0 <= c);
937  assert(b < mbr.mextent);
938  assert(c < mcr.mextent);
939 
940  return Tensor3View(
941  mdata + mbr.mstart + b * mbr.mstride + mcr.mstart + c * mcr.mstride,
942  msr,
943  mpr,
944  mrr,
945  s,
946  p,
947  r);
948 }
949 
953  const Range& s, Index b, Index p, const Range& r, const Range& c) {
954  // Check that b and p are valid:
955  assert(0 <= b);
956  assert(0 <= p);
957  assert(b < mbr.mextent);
958  assert(p < mpr.mextent);
959 
960  return Tensor3View(
961  mdata + mbr.mstart + b * mbr.mstride + mpr.mstart + p * mpr.mstride,
962  msr,
963  mrr,
964  mcr,
965  s,
966  r,
967  c);
968 }
969 
973  Index s, const Range& b, Index p, const Range& r, const Range& c) {
974  // Check that s and p are valid:
975  assert(0 <= s);
976  assert(0 <= p);
977  assert(s < msr.mextent);
978  assert(p < mpr.mextent);
979 
980  return Tensor3View(
981  mdata + msr.mstart + s * msr.mstride + mpr.mstart + p * mpr.mstride,
982  mbr,
983  mrr,
984  mcr,
985  b,
986  r,
987  c);
988 }
989 
993  Index s, const Range& b, const Range& p, Index r, const Range& c) {
994  // Check that s and r are valid:
995  assert(0 <= s);
996  assert(0 <= r);
997  assert(s < msr.mextent);
998  assert(r < mrr.mextent);
999 
1000  return Tensor3View(
1001  mdata + msr.mstart + s * msr.mstride + mrr.mstart + r * mrr.mstride,
1002  mbr,
1003  mpr,
1004  mcr,
1005  b,
1006  p,
1007  c);
1008 }
1009 
1013  Index s, const Range& b, const Range& p, const Range& r, Index c) {
1014  // Check that s and c are valid:
1015  assert(0 <= s);
1016  assert(0 <= c);
1017  assert(s < msr.mextent);
1018  assert(c < mcr.mextent);
1019 
1020  return Tensor3View(
1021  mdata + msr.mstart + s * msr.mstride + mcr.mstart + c * mcr.mstride,
1022  mbr,
1023  mpr,
1024  mrr,
1025  b,
1026  p,
1027  r);
1028 }
1029 
1033  Index s, Index b, const Range& p, const Range& r, const Range& c) {
1034  // Check that s and b are valid:
1035  assert(0 <= s);
1036  assert(0 <= b);
1037  assert(s < msr.mextent);
1038  assert(b < mbr.mextent);
1039 
1040  return Tensor3View(
1041  mdata + msr.mstart + s * msr.mstride + mbr.mstart + b * mbr.mstride,
1042  mpr,
1043  mrr,
1044  mcr,
1045  p,
1046  r,
1047  c);
1048 }
1049 
1053  const Range& s, const Range& b, Index p, Index r, Index c) {
1054  // Check that p, r and c are valid:
1055  assert(0 <= p);
1056  assert(0 <= r);
1057  assert(0 <= c);
1058  assert(p < mpr.mextent);
1059  assert(r < mrr.mextent);
1060  assert(c < mcr.mextent);
1061 
1062  return MatrixView(mdata + mpr.mstart + p * mpr.mstride + mrr.mstart +
1063  r * mrr.mstride + mcr.mstart + c * mcr.mstride,
1064  msr,
1065  mbr,
1066  s,
1067  b);
1068 }
1069 
1073  const Range& s, Index b, const Range& p, Index r, Index c) {
1074  // Check that b, r and c are valid:
1075  assert(0 <= b);
1076  assert(0 <= r);
1077  assert(0 <= c);
1078  assert(b < mbr.mextent);
1079  assert(r < mrr.mextent);
1080  assert(c < mcr.mextent);
1081 
1082  return MatrixView(mdata + mbr.mstart + b * mbr.mstride + mrr.mstart +
1083  r * mpr.mstride + mcr.mstart + c * mcr.mstride,
1084  msr,
1085  mpr,
1086  s,
1087  p);
1088 }
1089 
1093  const Range& s, Index b, Index p, const Range& r, Index c) {
1094  // Check that b, p and c are valid:
1095  assert(0 <= b);
1096  assert(0 <= p);
1097  assert(0 <= c);
1098  assert(b < mbr.mextent);
1099  assert(p < mpr.mextent);
1100  assert(c < mcr.mextent);
1101 
1102  return MatrixView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
1103  p * mpr.mstride + mcr.mstart + c * mcr.mstride,
1104  msr,
1105  mrr,
1106  s,
1107  r);
1108 }
1109 
1113  const Range& s, Index b, Index p, Index r, const Range& c) {
1114  // Check that b, p and r are valid:
1115  assert(0 <= b);
1116  assert(0 <= p);
1117  assert(0 <= r);
1118  assert(b < mbr.mextent);
1119  assert(p < mpr.mextent);
1120  assert(r < mrr.mextent);
1121 
1122  return MatrixView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
1123  p * mpr.mstride + mrr.mstart + r * mrr.mstride,
1124  msr,
1125  mcr,
1126  s,
1127  c);
1128 }
1129 
1133  Index s, const Range& b, Index p, Index r, const Range& c) {
1134  // Check that s, p and r are valid:
1135  assert(0 <= s);
1136  assert(0 <= p);
1137  assert(0 <= r);
1138  assert(s < msr.mextent);
1139  assert(p < mpr.mextent);
1140  assert(r < mrr.mextent);
1141 
1142  return MatrixView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
1143  p * mpr.mstride + mrr.mstart + r * mrr.mstride,
1144  mbr,
1145  mcr,
1146  b,
1147  c);
1148 }
1149 
1153  Index s, const Range& b, Index p, const Range& r, Index c) {
1154  // Check that s, p and c are valid:
1155  assert(0 <= s);
1156  assert(0 <= p);
1157  assert(0 <= c);
1158  assert(s < msr.mextent);
1159  assert(p < mpr.mextent);
1160  assert(c < mcr.mextent);
1161 
1162  return MatrixView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
1163  p * mpr.mstride + mcr.mstart + c * mcr.mstride,
1164  mbr,
1165  mrr,
1166  b,
1167  r);
1168 }
1169 
1173  Index s, const Range& b, const Range& p, Index r, Index c) {
1174  // Check that s, r and c are valid:
1175  assert(0 <= s);
1176  assert(0 <= r);
1177  assert(0 <= c);
1178  assert(s < msr.mextent);
1179  assert(r < mrr.mextent);
1180  assert(c < mcr.mextent);
1181 
1182  return MatrixView(mdata + msr.mstart + s * msr.mstride + mrr.mstart +
1183  r * mrr.mstride + mcr.mstart + c * mcr.mstride,
1184  mbr,
1185  mpr,
1186  b,
1187  p);
1188 }
1189 
1193  Index s, Index b, const Range& p, const Range& r, Index c) {
1194  // Check that s, b and c are valid:
1195  assert(0 <= s);
1196  assert(0 <= b);
1197  assert(0 <= c);
1198  assert(s < msr.mextent);
1199  assert(b < mbr.mextent);
1200  assert(c < mcr.mextent);
1201 
1202  return MatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1203  b * mbr.mstride + mcr.mstart + c * mcr.mstride,
1204  mpr,
1205  mrr,
1206  p,
1207  r);
1208 }
1209 
1213  Index s, Index b, const Range& p, Index r, const Range& c) {
1214  // Check that s, b and r are valid:
1215  assert(0 <= s);
1216  assert(0 <= b);
1217  assert(0 <= r);
1218  assert(s < msr.mextent);
1219  assert(b < mbr.mextent);
1220  assert(r < mrr.mextent);
1221 
1222  return MatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1223  b * mbr.mstride + mrr.mstart + r * mrr.mstride,
1224  mpr,
1225  mcr,
1226  p,
1227  c);
1228 }
1229 
1233  Index s, Index b, Index p, const Range& r, const Range& c) {
1234  // Check that s, b and p are valid:
1235  assert(0 <= s);
1236  assert(0 <= b);
1237  assert(0 <= p);
1238  assert(s < msr.mextent);
1239  assert(b < mbr.mextent);
1240  assert(p < mpr.mextent);
1241 
1242  return MatrixView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1243  b * mbr.mstride + mpr.mstart + p * mpr.mstride,
1244  mrr,
1245  mcr,
1246  r,
1247  c);
1248 }
1249 
1253  const Range& s, Index b, Index p, Index r, Index c) {
1254  // Check that b, p, r and c are valid:
1255  assert(0 <= b);
1256  assert(0 <= p);
1257  assert(0 <= r);
1258  assert(0 <= c);
1259  assert(b < mbr.mextent);
1260  assert(p < mpr.mextent);
1261  assert(r < mrr.mextent);
1262  assert(c < mcr.mextent);
1263 
1264  return VectorView(mdata + mbr.mstart + b * mbr.mstride + mpr.mstart +
1265  p * mpr.mstride + mrr.mstart + r * mrr.mstride +
1266  mcr.mstart + c * mcr.mstride,
1267  msr,
1268  s);
1269 }
1270 
1274  Index s, const Range& b, Index p, Index r, Index c) {
1275  // Check that s, p, r and c are valid:
1276  assert(0 <= s);
1277  assert(0 <= p);
1278  assert(0 <= r);
1279  assert(0 <= c);
1280  assert(s < msr.mextent);
1281  assert(p < mpr.mextent);
1282  assert(r < mrr.mextent);
1283  assert(c < mcr.mextent);
1284 
1285  return VectorView(mdata + msr.mstart + s * msr.mstride + mpr.mstart +
1286  p * mpr.mstride + mrr.mstart + r * mrr.mstride +
1287  mcr.mstart + c * mcr.mstride,
1288  mbr,
1289  b);
1290 }
1291 
1295  Index s, Index b, const Range& p, Index r, Index c) {
1296  // Check that s, b, r and c are valid:
1297  assert(0 <= s);
1298  assert(0 <= b);
1299  assert(0 <= r);
1300  assert(0 <= c);
1301  assert(s < msr.mextent);
1302  assert(b < mbr.mextent);
1303  assert(r < mrr.mextent);
1304  assert(c < mcr.mextent);
1305 
1306  return VectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1307  b * mbr.mstride + mrr.mstart + r * mrr.mstride +
1308  mcr.mstart + c * mcr.mstride,
1309  mpr,
1310  p);
1311 }
1312 
1316  Index s, Index b, Index p, const Range& r, Index c) {
1317  // Check that s, b, p and c are valid:
1318  assert(0 <= s);
1319  assert(0 <= b);
1320  assert(0 <= p);
1321  assert(0 <= c);
1322  assert(s < msr.mextent);
1323  assert(b < mbr.mextent);
1324  assert(p < mpr.mextent);
1325  assert(c < mcr.mextent);
1326 
1327  return VectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1328  b * mbr.mstride + mpr.mstart + p * mpr.mstride +
1329  mcr.mstart + c * mcr.mstride,
1330  mrr,
1331  r);
1332 }
1333 
1337  Index s, Index b, Index p, Index r, const Range& c) {
1338  // Check that s, b, p and r are valid:
1339  assert(0 <= s);
1340  assert(0 <= b);
1341  assert(0 <= p);
1342  assert(0 <= r);
1343  assert(s < msr.mextent);
1344  assert(b < mbr.mextent);
1345  assert(p < mpr.mextent);
1346  assert(r < mrr.mextent);
1347 
1348  return VectorView(mdata + msr.mstart + s * msr.mstride + mbr.mstart +
1349  b * mbr.mstride + mpr.mstart + p * mpr.mstride +
1350  mrr.mstart + r * mrr.mstride,
1351  mcr,
1352  c);
1353 }
1354 
1358  msr.mstride);
1359 }
1360 
1363  return Iterator5D(
1364  Tensor4View(
1365  mdata + msr.mstart + (msr.mextent) * msr.mstride, mbr, mpr, mrr, mcr),
1366  msr.mstride);
1367 }
1368 
1374  // Check that sizes are compatible:
1375  assert(msr.mextent == m.msr.mextent);
1376  assert(mbr.mextent == m.mbr.mextent);
1377  assert(mpr.mextent == m.mpr.mextent);
1378  assert(mrr.mextent == m.mrr.mextent);
1379  assert(mcr.mextent == m.mcr.mextent);
1380 
1381  copy(m.begin(), m.end(), begin());
1382  return *this;
1383 }
1384 
1391  // Check that sizes are compatible:
1392  assert(msr.mextent == m.msr.mextent);
1393  assert(mbr.mextent == m.mbr.mextent);
1394  assert(mpr.mextent == m.mpr.mextent);
1395  assert(mrr.mextent == m.mrr.mextent);
1396  assert(mcr.mextent == m.mcr.mextent);
1397 
1398  copy(m.begin(), m.end(), begin());
1399  return *this;
1400 }
1401 
1406  // Check that sizes are compatible:
1407  assert(msr.mextent == m.msr.mextent);
1408  assert(mbr.mextent == m.mbr.mextent);
1409  assert(mpr.mextent == m.mpr.mextent);
1410  assert(mrr.mextent == m.mrr.mextent);
1411  assert(mcr.mextent == m.mcr.mextent);
1412 
1413  copy(m.begin(), m.end(), begin());
1414  return *this;
1415 }
1416 
1420  copy(x, begin(), end());
1421  return *this;
1422 }
1423 
1424 // Some little helper functions:
1425 //------------------------------
1426 
1429  const Iterator5D es = end();
1430  for (Iterator5D s = begin(); s != es; ++s) {
1431  *s *= x;
1432  }
1433  return *this;
1434 }
1435 
1438  const Iterator5D es = end();
1439  for (Iterator5D s = begin(); s != es; ++s) {
1440  *s /= x;
1441  }
1442  return *this;
1443 }
1444 
1447  const Iterator5D es = end();
1448  for (Iterator5D s = begin(); s != es; ++s) {
1449  *s += x;
1450  }
1451  return *this;
1452 }
1453 
1456  const Iterator5D es = end();
1457  for (Iterator5D s = begin(); s != es; ++s) {
1458  *s -= x;
1459  }
1460  return *this;
1461 }
1462 
1465  assert(nshelves() == x.nshelves());
1466  assert(nbooks() == x.nbooks());
1467  assert(npages() == x.npages());
1468  assert(nrows() == x.nrows());
1469  assert(ncols() == x.ncols());
1470  ConstIterator5D xs = x.begin();
1471  Iterator5D s = begin();
1472  const Iterator5D es = end();
1473  for (; s != es; ++s, ++xs) {
1474  *s *= *xs;
1475  }
1476  return *this;
1477 }
1478 
1481  assert(nshelves() == x.nshelves());
1482  assert(nbooks() == x.nbooks());
1483  assert(npages() == x.npages());
1484  assert(nrows() == x.nrows());
1485  assert(ncols() == x.ncols());
1486  ConstIterator5D xs = x.begin();
1487  Iterator5D s = begin();
1488  const Iterator5D es = end();
1489  for (; s != es; ++s, ++xs) {
1490  *s /= *xs;
1491  }
1492  return *this;
1493 }
1494 
1497  assert(nshelves() == x.nshelves());
1498  assert(nbooks() == x.nbooks());
1499  assert(npages() == x.npages());
1500  assert(nrows() == x.nrows());
1501  assert(ncols() == x.ncols());
1502  ConstIterator5D xs = x.begin();
1503  Iterator5D s = begin();
1504  const Iterator5D es = end();
1505  for (; s != es; ++s, ++xs) {
1506  *s += *xs;
1507  }
1508  return *this;
1509 }
1510 
1513  assert(nshelves() == x.nshelves());
1514  assert(nbooks() == x.nbooks());
1515  assert(npages() == x.npages());
1516  assert(nrows() == x.nrows());
1517  assert(ncols() == x.ncols());
1518  ConstIterator5D xs = x.begin();
1519  Iterator5D s = begin();
1520  const Iterator5D es = end();
1521  for (; s != es; ++s, ++xs) {
1522  *s -= *xs;
1523  }
1524  return *this;
1525 }
1526 
1529  : ConstTensor5View(
1530  a.mdata,
1531  Range(0,
1532  1,
1533  a.mbr.mextent * a.mpr.mextent * a.mrr.mextent * a.mcr.mextent),
1534  a.mbr,
1535  a.mpr,
1536  a.mrr,
1537  a.mcr) {
1538  // Nothing to do here.
1539 }
1540 
1545  const Range& sr,
1546  const Range& br,
1547  const Range& pr,
1548  const Range& rr,
1549  const Range& cr)
1550  : ConstTensor5View(data, sr, br, pr, rr, cr) {
1551  // Nothing to do here.
1552 }
1553 
1575  const Range& ps,
1576  const Range& pb,
1577  const Range& pp,
1578  const Range& pr,
1579  const Range& pc,
1580  const Range& ns,
1581  const Range& nb,
1582  const Range& np,
1583  const Range& nr,
1584  const Range& nc)
1585  : ConstTensor5View(data, ps, pb, pp, pr, pc, ns, nb, np, nr, nc) {
1586  // Nothing to do here.
1587 }
1588 
1593 void copy(ConstIterator5D origin,
1594  const ConstIterator5D& end,
1595  Iterator5D target) {
1596  for (; origin != end; ++origin, ++target) {
1597  // We use the copy function for the next smaller rank of tensor
1598  // recursively:
1599  copy(origin->begin(), origin->end(), target->begin());
1600  }
1601 }
1602 
1604 void copy(Numeric x, Iterator5D target, const Iterator5D& end) {
1605  for (; target != end; ++target) {
1606  // We use the copy function for the next smaller rank of tensor
1607  // recursively:
1608  copy(x, target->begin(), target->end());
1609  }
1610 }
1611 
1612 // Functions for Tensor5:
1613 // ---------------------
1614 
1618  : Tensor5View(new Numeric[s * b * p * r * c],
1619  Range(0, s, b * p * r * c),
1620  Range(0, b, p * r * c),
1621  Range(0, p, r * c),
1622  Range(0, r, c),
1623  Range(0, c)) {
1624  // Nothing to do here.
1625 }
1626 
1629  : Tensor5View(new Numeric[s * b * p * r * c],
1630  Range(0, s, b * p * r * c),
1631  Range(0, b, p * r * c),
1632  Range(0, p, r * c),
1633  Range(0, r, c),
1634  Range(0, c)) {
1635  // Here we can access the raw memory directly, for slightly
1636  // increased efficiency:
1637  std::fill_n(mdata, s * b * p * r * c, fill);
1638 }
1639 
1643  : Tensor5View(
1644  new Numeric[m.nshelves() * m.nbooks() * m.npages() * m.nrows() *
1645  m.ncols()],
1646  Range(
1647  0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
1648  Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
1649  Range(0, m.npages(), m.nrows() * m.ncols()),
1650  Range(0, m.nrows(), m.ncols()),
1651  Range(0, m.ncols())) {
1652  copy(m.begin(), m.end(), begin());
1653 }
1654 
1658  : Tensor5View(
1659  new Numeric[m.nshelves() * m.nbooks() * m.npages() * m.nrows() *
1660  m.ncols()],
1661  Range(
1662  0, m.nshelves(), m.nbooks() * m.npages() * m.nrows() * m.ncols()),
1663  Range(0, m.nbooks(), m.npages() * m.nrows() * m.ncols()),
1664  Range(0, m.npages(), m.nrows() * m.ncols()),
1665  Range(0, m.nrows(), m.ncols()),
1666  Range(0, m.ncols())) {
1667  // There is a catch here: If m is an empty tensor, then it will have
1668  // dimensions of size 0. But these are used to initialize the stride
1669  // for higher dimensions! Thus, this method has to be consistent
1670  // with the behaviour of Range::Range. For now, Range::Range allows
1671  // also stride 0.
1672  std::memcpy(
1673  mdata,
1674  m.mdata,
1675  nshelves() * nbooks() * npages() * nrows() * ncols() * sizeof(Numeric));
1676 }
1677 
1679 
1703  if (this != &x) {
1704  resize(x.nshelves(), x.nbooks(), x.npages(), x.nrows(), x.ncols());
1705  std::memcpy(
1706  mdata,
1707  x.mdata,
1708  nshelves() * nbooks() * npages() * nrows() * ncols() * sizeof(Numeric));
1709  }
1710  return *this;
1711 }
1712 
1715  if (this != &x) {
1716  delete[] mdata;
1717  mdata = x.mdata;
1718  msr = x.msr;
1719  mbr = x.mbr;
1720  mpr = x.mpr;
1721  mrr = x.mrr;
1722  mcr = x.mcr;
1723  x.msr = Range(0, 0);
1724  x.mbr = Range(0, 0);
1725  x.mpr = Range(0, 0);
1726  x.mrr = Range(0, 0);
1727  x.mcr = Range(0, 0);
1728  x.mdata = nullptr;
1729  }
1730  return *this;
1731 }
1732 
1736  std::fill_n(mdata, nshelves() * nbooks() * npages() * nrows() * ncols(), x);
1737  return *this;
1738 }
1739 
1744  assert(0 <= s);
1745  assert(0 <= b);
1746  assert(0 <= p);
1747  assert(0 <= r);
1748  assert(0 <= c);
1749 
1750  if (msr.mextent != s || mbr.mextent != b || mpr.mextent != p ||
1751  mrr.mextent != r || mcr.mextent != c) {
1752  delete[] mdata;
1753  mdata = new Numeric[s * b * p * r * c];
1754 
1755  msr.mstart = 0;
1756  msr.mextent = s;
1757  msr.mstride = b * p * r * c;
1758 
1759  mbr.mstart = 0;
1760  mbr.mextent = b;
1761  mbr.mstride = p * r * c;
1762 
1763  mpr.mstart = 0;
1764  mpr.mextent = p;
1765  mpr.mstride = r * c;
1766 
1767  mrr.mstart = 0;
1768  mrr.mextent = r;
1769  mrr.mstride = c;
1770 
1771  mcr.mstart = 0;
1772  mcr.mextent = c;
1773  mcr.mstride = 1;
1774  }
1775 }
1776 
1778 void swap(Tensor5& t1, Tensor5& t2) {
1779  std::swap(t1.msr, t2.msr);
1780  std::swap(t1.mbr, t2.mbr);
1781  std::swap(t1.mpr, t2.mpr);
1782  std::swap(t1.mrr, t2.mrr);
1783  std::swap(t1.mcr, t2.mcr);
1784  std::swap(t1.mdata, t2.mdata);
1785 }
1786 
1790  // cout << "Destroying a Tensor5:\n"
1791  // << *this << "\n........................................\n";
1792  delete[] mdata;
1793 }
1794 
1810 void transform(Tensor5View y, double (&my_func)(double), ConstTensor5View x) {
1811  // Check dimensions:
1812  assert(y.nshelves() == x.nshelves());
1813  assert(y.nbooks() == x.nbooks());
1814  assert(y.npages() == x.npages());
1815  assert(y.nrows() == x.nrows());
1816  assert(y.ncols() == x.ncols());
1817 
1818  const ConstIterator5D xe = x.end();
1819  ConstIterator5D xi = x.begin();
1820  Iterator5D yi = y.begin();
1821  for (; xi != xe; ++xi, ++yi) {
1822  // Use the transform function of lower dimensional tensors
1823  // recursively:
1824  transform(*yi, my_func, *xi);
1825  }
1826 }
1827 
1830  const ConstIterator5D xe = x.end();
1831  ConstIterator5D xi = x.begin();
1832 
1833  // Initial value for max:
1834  Numeric themax = max(*xi);
1835  ++xi;
1836 
1837  for (; xi != xe; ++xi) {
1838  // Use the max function of lower dimensional tensors
1839  // recursively:
1840  Numeric maxi = max(*xi);
1841  if (maxi > themax) themax = maxi;
1842  }
1843 
1844  return themax;
1845 }
1846 
1849  const ConstIterator5D xe = x.end();
1850  ConstIterator5D xi = x.begin();
1851 
1852  // Initial value for min:
1853  Numeric themin = min(*xi);
1854  ++xi;
1855 
1856  for (; xi != xe; ++xi) {
1857  // Use the min function of lower dimensional tensors
1858  // recursively:
1859  Numeric mini = min(*xi);
1860  if (mini < themin) themin = mini;
1861  }
1862 
1863  return themin;
1864 }
1865 
1867 // Helper function for debugging
1868 #ifndef NDEBUG
1869 
1887  Tensor5View& tv, Index s, Index b, Index p, Index r, Index c) {
1888  return tv(s, b, p, r, c);
1889 }
1890 
1891 #endif
1892 
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:319
Index npages() const
Returns the number of pages.
Definition: matpackV.cc:50
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Tensor5View & operator+=(Numeric x)
Addition of scalar.
Definition: matpackV.cc:1446
The VectorView class.
Definition: matpackI.h:610
Index nrows() const
Returns the number of rows.
Definition: matpackV.cc:53
#define ns
bool empty() const
Check if variable is empty.
Definition: matpackV.cc:38
Index mstride
The stride.
Definition: matpackI.h:355
The Tensor4View class.
Definition: matpackIV.h:284
void resize(Index s, Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackV.cc:1743
std::ostream & operator<<(std::ostream &os, const ConstTensor5View &v)
Output operator.
Definition: matpackV.cc:758
Index mstart
The start index.
Definition: matpackI.h:346
Tensor5View & operator-=(Numeric x)
Subtraction of scalar.
Definition: matpackV.cc:1455
The MatrixView class.
Definition: matpackI.h:1093
ConstIterator4D begin() const
Return const iterator to first book.
Definition: matpackIV.cc:371
void transform(Tensor5View y, double(&my_func)(double), ConstTensor5View x)
A generic transform function for tensors, which can be used to implement mathematical functions opera...
Definition: matpackV.cc:1810
Iterator4D begin()
Return iterator to first book.
Definition: matpackIV.cc:706
virtual ~Tensor5()
Destructor for Tensor5.
Definition: matpackV.cc:1789
The range class.
Definition: matpackI.h:160
void swap(Tensor5 &t1, Tensor5 &t2)
Swaps two objects.
Definition: matpackV.cc:1778
Index nbooks() const
Returns the number of books.
Definition: matpackV.cc:47
ConstIterator5D end() const
Return const iterator behind last shelf.
Definition: matpackV.cc:696
void copy(ConstIterator5D origin, const ConstIterator5D &end, Iterator5D target)
Copy data between begin and end to target.
Definition: matpackV.cc:1593
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Iterator5D end()
Return iterator behind last shelf.
Definition: matpackV.cc:1362
ConstTensor5View()=default
Tensor5View()=default
Numeric max(const ConstTensor5View &x)
Max function, tensor version.
Definition: matpackV.cc:1829
A constant view of a Tensor4.
Definition: matpackIV.h:133
friend void swap(Tensor5 &t1, Tensor5 &t2)
Swaps two objects.
Definition: matpackV.cc:1778
Tensor5View & operator/=(Numeric x)
Division by scalar.
Definition: matpackV.cc:1437
Index nshelves() const
Returns the number of shelves.
Definition: matpackV.cc:44
Range mbr
The book range of mdata that is actually used.
Definition: matpackV.h:313
Range mpr
The page range of mdata that is actually used.
Definition: matpackV.h:315
Iterator4D end()
Return iterator behind last book.
Definition: matpackIV.cc:712
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:321
The Tensor3View class.
Definition: matpackIII.h:239
The declarations of all the exception classes.
ConstTensor5View operator()(const Range &s, const Range &b, const Range &p, const Range &r, const Range &c) const
Const index operator for subrange.
Definition: matpackV.cc:61
A constant view of a Tensor5.
Definition: matpackV.h:143
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ConstIterator5D begin() const
Return const iterator to first shelf.
Definition: matpackV.cc:690
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:311
const Numeric * get_c_array() const
Conversion to plain C-array.
Definition: matpackV.cc:675
Index mextent
The number of elements.
Definition: matpackI.h:353
Const version of Iterator5D.
Definition: matpackV.h:85
Tensor5View & operator=(const ConstTensor5View &v)
Assignment operator.
Definition: matpackV.cc:1373
The Tensor5View class.
Definition: matpackV.h:333
Implementation of Tensors of Rank 5.
Definition: matpackV.h:38
ConstIterator4D end() const
Return const iterator behind last book.
Definition: matpackIV.cc:377
Numeric debug_tensor5view_get_elem(Tensor5View &tv, Index s, Index b, Index p, Index r, Index c)
Helper function to access tensor elements.
Definition: matpackV.cc:1886
Numeric min(const ConstTensor5View &x)
Min function, tensor version.
Definition: matpackV.cc:1848
A constant view of a Tensor3.
Definition: matpackIII.h:132
Range mrr
The row range of mdata that is actually used.
Definition: matpackV.h:317
A constant view of a Vector.
Definition: matpackI.h:476
A constant view of a Matrix.
Definition: matpackI.h:982
Tensor5()=default
Index ncols() const
Returns the number of columns.
Definition: matpackV.cc:56
Tensor5View operator()(const Range &s, const Range &b, const Range &p, const Range &r, const Range &c)
Index operator for subrange.
Definition: matpackV.cc:782
Tensor5View & operator*=(Numeric x)
Multiplication by scalar.
Definition: matpackV.cc:1428
Iterator5D begin()
Return iterator to first shelf.
Definition: matpackV.cc:1356
friend class Tensor5View
Definition: matpackV.h:279
The Tensor5 class.
Definition: matpackV.h:506
Tensor5 & operator=(const Tensor5 &x)
Assignment operator from another tensor.
Definition: matpackV.cc:1702