ARTS  2.3.1285(git:92a29ea9-dirty)
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  assert(0 <= x); \
35  assert(x < m##x##r.mextent)
36 #define OFFSET(x) m##x##r.mstart + x* m##x##r.mstride
37 
40 class Iterator6D {
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 {
64  msv.mrr.mstart + msv.mcr.mstart !=
65  other.msv.mdata + other.msv.msr.mstart + other.msv.mbr.mstart +
66  other.msv.mpr.mstart + other.msv.mrr.mstart + other.msv.mcr.mstart)
67  return true;
68  else
69  return false;
70  }
71 
74  Tensor5View* operator->() { return &msv; }
75 
77  Tensor5View& operator*() { return msv; }
78 
79  private:
84 };
85 
88  public:
89  // Constructors:
91  ConstIterator6D() = default;
92 
95  : msv(x), mstride(stride) { /* Nothing to do here. */
96  }
97 
98  // Operators:
101  msv.mdata += mstride;
102  return *this;
103  }
104 
109  bool operator!=(const ConstIterator6D& other) const {
111  msv.mrr.mstart + msv.mcr.mstart !=
112  other.msv.mdata + other.msv.msr.mstart + other.msv.mbr.mstart +
113  other.msv.mpr.mstart + other.msv.mrr.mstart + other.msv.mcr.mstart)
114  return true;
115  else
116  return false;
117  }
118 
121  const ConstTensor5View* operator->() const { return &msv; }
122 
124  const ConstTensor5View& operator*() const { return msv; }
125 
126  private:
131 };
132 
133 // Declare class Tensor6:
134 class Tensor6;
135 
150  public:
151  constexpr ConstTensor6View(const ConstTensor6View&) = default;
152  constexpr ConstTensor6View(ConstTensor6View&&) = default;
153  ConstTensor6View& operator=(const ConstTensor6View&) = default;
154  ConstTensor6View& operator=(ConstTensor6View&&) = default;
155 
156  // Member functions:
157  bool empty() const;
158  Index nvitrines() const;
159  Index nshelves() const;
160  Index nbooks() const;
161  Index npages() const;
162  Index nrows() const;
163  Index ncols() const;
164 
165  // Const index operators:
166 
167  // Result 6D (1 combination)
168  // ------
169  ConstTensor6View operator()(const Range& v,
170  const Range& s,
171  const Range& b,
172  const Range& p,
173  const Range& r,
174  const Range& c) const;
175 
176  // Result 5D (6 combinations)
177  // -----|
178  ConstTensor5View operator()(const Range& v,
179  const Range& s,
180  const Range& b,
181  const Range& p,
182  const Range& r,
183  Index c) const;
184  // ----|-
185  ConstTensor5View operator()(const Range& v,
186  const Range& s,
187  const Range& b,
188  const Range& p,
189  Index r,
190  const Range& c) const;
191  // ---|--
192  ConstTensor5View operator()(const Range& v,
193  const Range& s,
194  const Range& b,
195  Index p,
196  const Range& r,
197  const Range& c) const;
198  // --|---
199  ConstTensor5View operator()(const Range& v,
200  const Range& s,
201  Index b,
202  const Range& p,
203  const Range& r,
204  const Range& c) const;
205  // -|----
206  ConstTensor5View operator()(const Range& v,
207  Index s,
208  const Range& b,
209  const Range& p,
210  const Range& r,
211  const Range& c) const;
212  // |-----
213  ConstTensor5View operator()(Index v,
214  const Range& s,
215  const Range& b,
216  const Range& p,
217  const Range& r,
218  const Range& c) const;
219 
220  // Result 4D (5+4+3+2+1 = 15 combinations)
221  // ----||
222  ConstTensor4View operator()(const Range& v,
223  const Range& s,
224  const Range& b,
225  const Range& p,
226  Index r,
227  Index c) const;
228  // ---|-|
229  ConstTensor4View operator()(const Range& v,
230  const Range& s,
231  const Range& b,
232  Index p,
233  const Range& r,
234  Index c) const;
235  // --|--|
236  ConstTensor4View operator()(const Range& v,
237  const Range& s,
238  Index b,
239  const Range& p,
240  const Range& r,
241  Index c) const;
242  // -|---|
243  ConstTensor4View operator()(const Range& v,
244  Index s,
245  const Range& b,
246  const Range& p,
247  const Range& r,
248  Index c) const;
249  // |----|
250  ConstTensor4View operator()(Index v,
251  const Range& s,
252  const Range& b,
253  const Range& p,
254  const Range& r,
255  Index c) const;
256  // ---||-
257  ConstTensor4View operator()(const Range& v,
258  const Range& s,
259  const Range& b,
260  Index p,
261  Index r,
262  const Range& c) const;
263  // --|-|-
264  ConstTensor4View operator()(const Range& v,
265  const Range& s,
266  Index b,
267  const Range& p,
268  Index r,
269  const Range& c) const;
270  // -|--|-
271  ConstTensor4View operator()(const Range& v,
272  Index s,
273  const Range& b,
274  const Range& p,
275  Index r,
276  const Range& c) const;
277  // |---|-
278  ConstTensor4View operator()(Index v,
279  const Range& s,
280  const Range& b,
281  const Range& p,
282  Index r,
283  const Range& c) const;
284  // --||--
285  ConstTensor4View operator()(const Range& v,
286  const Range& s,
287  Index b,
288  Index p,
289  const Range& r,
290  const Range& c) const;
291  // -|-|--
292  ConstTensor4View operator()(const Range& v,
293  Index s,
294  const Range& b,
295  Index p,
296  const Range& r,
297  const Range& c) const;
298  // |--|--
299  ConstTensor4View operator()(Index v,
300  const Range& s,
301  const Range& b,
302  Index p,
303  const Range& r,
304  const Range& c) const;
305  // -||---
306  ConstTensor4View operator()(const Range& v,
307  Index s,
308  Index b,
309  const Range& p,
310  const Range& r,
311  const Range& c) const;
312  // |-|---
313  ConstTensor4View operator()(Index v,
314  const Range& s,
315  Index b,
316  const Range& p,
317  const Range& r,
318  const Range& c) const;
319  // ||----
320  ConstTensor4View operator()(Index v,
321  Index s,
322  const Range& b,
323  const Range& p,
324  const Range& r,
325  const Range& c) const;
326 
327  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
328  // ---|||
329  ConstTensor3View operator()(const Range& v,
330  const Range& s,
331  const Range& b,
332  Index p,
333  Index r,
334  Index c) const;
335  // --|-||
336  ConstTensor3View operator()(const Range& v,
337  const Range& s,
338  Index b,
339  const Range& p,
340  Index r,
341  Index c) const;
342  // -|--||
343  ConstTensor3View operator()(const Range& v,
344  Index s,
345  const Range& b,
346  const Range& p,
347  Index r,
348  Index c) const;
349  // |---||
350  ConstTensor3View operator()(Index v,
351  const Range& s,
352  const Range& b,
353  const Range& p,
354  Index r,
355  Index c) const;
356  // --||-|
357  ConstTensor3View operator()(const Range& v,
358  const Range& s,
359  Index b,
360  Index p,
361  const Range& r,
362  Index c) const;
363  // -|-|-|
364  ConstTensor3View operator()(const Range& v,
365  Index s,
366  const Range& b,
367  Index p,
368  const Range& r,
369  Index c) const;
370  // |--|-|
371  ConstTensor3View operator()(Index v,
372  const Range& s,
373  const Range& b,
374  Index p,
375  const Range& r,
376  Index c) const;
377  // -||--|
378  ConstTensor3View operator()(const Range& v,
379  Index s,
380  Index b,
381  const Range& p,
382  const Range& r,
383  Index c) const;
384  // |-|--|
385  ConstTensor3View operator()(Index v,
386  const Range& s,
387  Index b,
388  const Range& p,
389  const Range& r,
390  Index c) const;
391  // ||---|
392  ConstTensor3View operator()(Index v,
393  Index s,
394  const Range& b,
395  const Range& p,
396  const Range& r,
397  Index c) const;
398  // --|||-
399  ConstTensor3View operator()(const Range& v,
400  const Range& s,
401  Index b,
402  Index p,
403  Index r,
404  const Range& c) const;
405  // -|-||-
406  ConstTensor3View operator()(const Range& v,
407  Index s,
408  const Range& b,
409  Index p,
410  Index r,
411  const Range& c) const;
412  // |--||-
413  ConstTensor3View operator()(Index v,
414  const Range& s,
415  const Range& b,
416  Index p,
417  Index r,
418  const Range& c) const;
419  // -||-|-
420  ConstTensor3View operator()(const Range& v,
421  Index s,
422  Index b,
423  const Range& p,
424  Index r,
425  const Range& c) const;
426  // |-|-|-
427  ConstTensor3View operator()(Index v,
428  const Range& s,
429  Index b,
430  const Range& p,
431  Index r,
432  const Range& c) const;
433  // ||--|-
434  ConstTensor3View operator()(Index v,
435  Index s,
436  const Range& b,
437  const Range& p,
438  Index r,
439  const Range& c) const;
440  // -|||--
441  ConstTensor3View operator()(const Range& v,
442  Index s,
443  Index b,
444  Index p,
445  const Range& r,
446  const Range& c) const;
447  // |-||--
448  ConstTensor3View operator()(Index v,
449  const Range& s,
450  Index b,
451  Index p,
452  const Range& r,
453  const Range& c) const;
454  // ||-|--
455  ConstTensor3View operator()(Index v,
456  Index s,
457  const Range& b,
458  Index p,
459  const Range& r,
460  const Range& c) const;
461  // |||---
462  ConstTensor3View operator()(Index v,
463  Index s,
464  Index b,
465  const Range& p,
466  const Range& r,
467  const Range& c) const;
468 
469  // Result 2D (15 combinations)
470  // IIII--
471  ConstMatrixView operator()(
472  Index v, Index s, Index b, Index p, const Range& r, const Range& c) const;
473  // III-I-
474  ConstMatrixView operator()(
475  Index v, Index s, Index b, const Range& p, Index r, const Range& c) const;
476  // II-II-
477  ConstMatrixView operator()(
478  Index v, Index s, const Range& b, Index p, Index r, const Range& c) const;
479  // I-III-
480  ConstMatrixView operator()(
481  Index v, const Range& s, Index b, Index p, Index r, const Range& c) const;
482  // -IIII-
483  ConstMatrixView operator()(
484  const Range& v, Index s, Index b, Index p, Index r, const Range& c) const;
485  // III--I
486  ConstMatrixView operator()(
487  Index v, Index s, Index b, const Range& p, const Range& r, Index c) const;
488  // II-I-I
489  ConstMatrixView operator()(
490  Index v, Index s, const Range& b, Index p, const Range& r, Index c) const;
491  // I-II-I
492  ConstMatrixView operator()(
493  Index v, const Range& s, Index b, Index p, const Range& r, Index c) const;
494  // -III-I
495  ConstMatrixView operator()(
496  const Range& v, Index s, Index b, Index p, const Range& r, Index c) const;
497  // II--II
498  ConstMatrixView operator()(
499  Index v, Index s, const Range& b, const Range& p, Index r, Index c) const;
500  // I-I-II
501  ConstMatrixView operator()(
502  Index v, const Range& s, Index b, const Range& p, Index r, Index c) const;
503  // -II-II
504  ConstMatrixView operator()(
505  const Range& v, Index s, Index b, const Range& p, Index r, Index c) const;
506  // I--III
507  ConstMatrixView operator()(
508  Index v, const Range& s, const Range& b, Index p, Index r, Index c) const;
509  // -I-III
510  ConstMatrixView operator()(
511  const Range& v, Index s, const Range& b, Index p, Index r, Index c) const;
512  // --IIII
513  ConstMatrixView operator()(
514  const Range& v, const Range& s, Index b, Index p, Index r, Index c) const;
515 
516  // Result 1D (6 combinations)
517  // IIIII-
518  ConstVectorView operator()(
519  Index v, Index s, Index b, Index p, Index r, const Range& c) const;
520  // IIII-I
521  ConstVectorView operator()(
522  Index v, Index s, Index b, Index p, const Range& r, Index c) const;
523  // III-II
524  ConstVectorView operator()(
525  Index v, Index s, Index b, const Range& p, Index r, Index c) const;
526  // II-III
527  ConstVectorView operator()(
528  Index v, Index s, const Range& b, Index p, Index r, Index c) const;
529  // I-IIII
530  ConstVectorView operator()(
531  Index v, const Range& s, Index b, Index p, Index r, Index c) const;
532  // -IIIII
533  ConstVectorView operator()(
534  const Range& v, Index s, Index b, Index p, Index r, Index c) const;
535 
536  // Result scalar (1 combination)
537  // IIIIII
539  Index v, Index s, Index b, Index p, Index r, Index c) const {
540  CHECK(v);
541  CHECK(s);
542  CHECK(b);
543  CHECK(p);
544  CHECK(r);
545  CHECK(c);
546  return get(v, s, b, p, r, c);
547  }
548 
550  Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const {
551  return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
552  OFFSET(c));
553  }
554 
555  // Functions returning iterators:
556  ConstIterator6D begin() const;
557  ConstIterator6D end() const;
558 
559  // Destructor:
560  virtual ~ConstTensor6View() = default;
561 
562  // Friends:
563  friend class ConstIterator7D;
564  friend class Tensor6View;
565  friend class ConstTensor7View;
566 
567  // Special constructor to make a Tensor6 view of a Tensor5.
569 
570  protected:
571  // Constructors:
572  ConstTensor6View() = default;
574  const Range& v,
575  const Range& s,
576  const Range& b,
577  const Range& p,
578  const Range& r,
579  const Range& c);
581  const Range& pv,
582  const Range& ps,
583  const Range& pb,
584  const Range& pp,
585  const Range& pr,
586  const Range& pc,
587  const Range& nv,
588  const Range& ns,
589  const Range& nb,
590  const Range& np,
591  const Range& nr,
592  const Range& nc);
593 
594  // Data members:
595  // -------------
597  Range mvr{0, 0, 1};
599  Range msr{0, 0, 1};
601  Range mbr{0, 0, 1};
603  Range mpr{0, 0, 1};
605  Range mrr{0, 0, 1};
607  Range mcr{0, 0, 1};
609  Numeric* mdata{nullptr};
610 };
611 
622  public:
623  // Make const methods visible from base class
625  using ConstTensor6View::end;
626  using ConstTensor6View::operator();
627  using ConstTensor6View::get;
628 
629  constexpr Tensor6View(const Tensor6View&) = default;
630 
631  // Non-const index operators:
632 
633  // Result 6D (1 combination)
634  // ------
635  Tensor6View operator()(const Range& v,
636  const Range& s,
637  const Range& b,
638  const Range& p,
639  const Range& r,
640  const Range& c);
641 
642  // Result 5D (6 combinations)
643  // -----|
644  Tensor5View operator()(const Range& v,
645  const Range& s,
646  const Range& b,
647  const Range& p,
648  const Range& r,
649  Index c);
650  // ----|-
651  Tensor5View operator()(const Range& v,
652  const Range& s,
653  const Range& b,
654  const Range& p,
655  Index r,
656  const Range& c);
657  // ---|--
658  Tensor5View operator()(const Range& v,
659  const Range& s,
660  const Range& b,
661  Index p,
662  const Range& r,
663  const Range& c);
664  // --|---
665  Tensor5View operator()(const Range& v,
666  const Range& s,
667  Index b,
668  const Range& p,
669  const Range& r,
670  const Range& c);
671  // -|----
672  Tensor5View operator()(const Range& v,
673  Index s,
674  const Range& b,
675  const Range& p,
676  const Range& r,
677  const Range& c);
678  // |-----
679  Tensor5View operator()(Index v,
680  const Range& s,
681  const Range& b,
682  const Range& p,
683  const Range& r,
684  const Range& c);
685 
686  // Result 4D (5+4+3+2+1 = 15 combinations)
687  // ----||
688  Tensor4View operator()(const Range& v,
689  const Range& s,
690  const Range& b,
691  const Range& p,
692  Index r,
693  Index c);
694  // ---|-|
695  Tensor4View operator()(const Range& v,
696  const Range& s,
697  const Range& b,
698  Index p,
699  const Range& r,
700  Index c);
701  // --|--|
702  Tensor4View operator()(const Range& v,
703  const Range& s,
704  Index b,
705  const Range& p,
706  const Range& r,
707  Index c);
708  // -|---|
709  Tensor4View operator()(const Range& v,
710  Index s,
711  const Range& b,
712  const Range& p,
713  const Range& r,
714  Index c);
715  // |----|
716  Tensor4View operator()(Index v,
717  const Range& s,
718  const Range& b,
719  const Range& p,
720  const Range& r,
721  Index c);
722  // ---||-
723  Tensor4View operator()(const Range& v,
724  const Range& s,
725  const Range& b,
726  Index p,
727  Index r,
728  const Range& c);
729  // --|-|-
730  Tensor4View operator()(const Range& v,
731  const Range& s,
732  Index b,
733  const Range& p,
734  Index r,
735  const Range& c);
736  // -|--|-
737  Tensor4View operator()(const Range& v,
738  Index s,
739  const Range& b,
740  const Range& p,
741  Index r,
742  const Range& c);
743  // |---|-
744  Tensor4View operator()(Index v,
745  const Range& s,
746  const Range& b,
747  const Range& p,
748  Index r,
749  const Range& c);
750  // --||--
751  Tensor4View operator()(const Range& v,
752  const Range& s,
753  Index b,
754  Index p,
755  const Range& r,
756  const Range& c);
757  // -|-|--
758  Tensor4View operator()(const Range& v,
759  Index s,
760  const Range& b,
761  Index p,
762  const Range& r,
763  const Range& c);
764  // |--|--
765  Tensor4View operator()(Index v,
766  const Range& s,
767  const Range& b,
768  Index p,
769  const Range& r,
770  const Range& c);
771  // -||---
772  Tensor4View operator()(const Range& v,
773  Index s,
774  Index b,
775  const Range& p,
776  const Range& r,
777  const Range& c);
778  // |-|---
779  Tensor4View operator()(Index v,
780  const Range& s,
781  Index b,
782  const Range& p,
783  const Range& r,
784  const Range& c);
785  // ||----
786  Tensor4View operator()(Index v,
787  Index s,
788  const Range& b,
789  const Range& p,
790  const Range& r,
791  const Range& c);
792 
793  // Result 3D (4+3+2+1+ 3+2+1+ 2+1 +1 = 20 combinations)
794  // ---|||
795  Tensor3View operator()(const Range& v,
796  const Range& s,
797  const Range& b,
798  Index p,
799  Index r,
800  Index c);
801  // --|-||
802  Tensor3View operator()(const Range& v,
803  const Range& s,
804  Index b,
805  const Range& p,
806  Index r,
807  Index c);
808  // -|--||
809  Tensor3View operator()(const Range& v,
810  Index s,
811  const Range& b,
812  const Range& p,
813  Index r,
814  Index c);
815  // |---||
816  Tensor3View operator()(Index v,
817  const Range& s,
818  const Range& b,
819  const Range& p,
820  Index r,
821  Index c);
822  // --||-|
823  Tensor3View operator()(const Range& v,
824  const Range& s,
825  Index b,
826  Index p,
827  const Range& r,
828  Index c);
829  // -|-|-|
830  Tensor3View operator()(const Range& v,
831  Index s,
832  const Range& b,
833  Index p,
834  const Range& r,
835  Index c);
836  // |--|-|
837  Tensor3View operator()(Index v,
838  const Range& s,
839  const Range& b,
840  Index p,
841  const Range& r,
842  Index c);
843  // -||--|
844  Tensor3View operator()(const Range& v,
845  Index s,
846  Index b,
847  const Range& p,
848  const Range& r,
849  Index c);
850  // |-|--|
851  Tensor3View operator()(Index v,
852  const Range& s,
853  Index b,
854  const Range& p,
855  const Range& r,
856  Index c);
857  // ||---|
858  Tensor3View operator()(Index v,
859  Index s,
860  const Range& b,
861  const Range& p,
862  const Range& r,
863  Index c);
864  // --|||-
865  Tensor3View operator()(const Range& v,
866  const Range& s,
867  Index b,
868  Index p,
869  Index r,
870  const Range& c);
871  // -|-||-
872  Tensor3View operator()(const Range& v,
873  Index s,
874  const Range& b,
875  Index p,
876  Index r,
877  const Range& c);
878  // |--||-
879  Tensor3View operator()(Index v,
880  const Range& s,
881  const Range& b,
882  Index p,
883  Index r,
884  const Range& c);
885  // -||-|-
886  Tensor3View operator()(const Range& v,
887  Index s,
888  Index b,
889  const Range& p,
890  Index r,
891  const Range& c);
892  // |-|-|-
893  Tensor3View operator()(Index v,
894  const Range& s,
895  Index b,
896  const Range& p,
897  Index r,
898  const Range& c);
899  // ||--|-
900  Tensor3View operator()(Index v,
901  Index s,
902  const Range& b,
903  const Range& p,
904  Index r,
905  const Range& c);
906  // -|||--
907  Tensor3View operator()(const Range& v,
908  Index s,
909  Index b,
910  Index p,
911  const Range& r,
912  const Range& c);
913  // |-||--
914  Tensor3View operator()(Index v,
915  const Range& s,
916  Index b,
917  Index p,
918  const Range& r,
919  const Range& c);
920  // ||-|--
921  Tensor3View operator()(Index v,
922  Index s,
923  const Range& b,
924  Index p,
925  const Range& r,
926  const Range& c);
927  // |||---
928  Tensor3View operator()(Index v,
929  Index s,
930  Index b,
931  const Range& p,
932  const Range& r,
933  const Range& c);
934 
935  // Result 2D (15 combinations)
936  // IIII--
937  MatrixView operator()(
938  Index v, Index s, Index b, Index p, const Range& r, const Range& c);
939  // III-I-
940  MatrixView operator()(
941  Index v, Index s, Index b, const Range& p, Index r, const Range& c);
942  // II-II-
943  MatrixView operator()(
944  Index v, Index s, const Range& b, Index p, Index r, const Range& c);
945  // I-III-
946  MatrixView operator()(
947  Index v, const Range& s, Index b, Index p, Index r, const Range& c);
948  // -IIII-
949  MatrixView operator()(
950  const Range& v, Index s, Index b, Index p, Index r, const Range& c);
951  // III--I
952  MatrixView operator()(
953  Index v, Index s, Index b, const Range& p, const Range& r, Index c);
954  // II-I-I
955  MatrixView operator()(
956  Index v, Index s, const Range& b, Index p, const Range& r, Index c);
957  // I-II-I
958  MatrixView operator()(
959  Index v, const Range& s, Index b, Index p, const Range& r, Index c);
960  // -III-I
961  MatrixView operator()(
962  const Range& v, Index s, Index b, Index p, const Range& r, Index c);
963  // II--II
964  MatrixView operator()(
965  Index v, Index s, const Range& b, const Range& p, Index r, Index c);
966  // I-I-II
967  MatrixView operator()(
968  Index v, const Range& s, Index b, const Range& p, Index r, Index c);
969  // -II-II
970  MatrixView operator()(
971  const Range& v, Index s, Index b, const Range& p, Index r, Index c);
972  // I--III
973  MatrixView operator()(
974  Index v, const Range& s, const Range& b, Index p, Index r, Index c);
975  // -I-III
976  MatrixView operator()(
977  const Range& v, Index s, const Range& b, Index p, Index r, Index c);
978  // --IIII
979  MatrixView operator()(
980  const Range& v, const Range& s, Index b, Index p, Index r, Index c);
981 
982  // Result 1D (6 combinations)
983  // IIIII-
984  VectorView operator()(
985  Index v, Index s, Index b, Index p, Index r, const Range& c);
986  // IIII-I
987  VectorView operator()(
988  Index v, Index s, Index b, Index p, const Range& r, Index c);
989  // III-II
990  VectorView operator()(
991  Index v, Index s, Index b, const Range& p, Index r, Index c);
992  // II-III
993  VectorView operator()(
994  Index v, Index s, const Range& b, Index p, Index r, Index c);
995  // I-IIII
996  VectorView operator()(
997  Index v, const Range& s, Index b, Index p, Index r, Index c);
998  // -IIIII
999  VectorView operator()(
1000  const Range& v, Index s, Index b, Index p, Index r, Index c);
1001 
1002  // Result scalar (1 combination)
1003  // IIIIII
1005  CHECK(v);
1006  CHECK(s);
1007  CHECK(b);
1008  CHECK(p);
1009  CHECK(r);
1010  CHECK(c);
1011  return get(v, s, b, p, r, c);
1012  }
1013 
1015  Numeric& get(Index v, Index s, Index b, Index p, Index r, Index c) {
1016  return *(mdata + OFFSET(v) + OFFSET(s) + OFFSET(b) + OFFSET(p) + OFFSET(r) +
1017  OFFSET(c));
1018  }
1019 
1020  // Conversion to a plain C-array
1021  const Numeric* get_c_array() const;
1022  Numeric* get_c_array();
1023 
1024  // Functions returning iterators:
1025  Iterator6D begin();
1026  Iterator6D end();
1027 
1028  // Assignment operators:
1029  Tensor6View& operator=(const ConstTensor6View& v);
1030  Tensor6View& operator=(const Tensor6View& v);
1031  Tensor6View& operator=(const Tensor6& v);
1032  Tensor6View& operator=(Numeric x);
1033 
1034  // Other operators:
1035  Tensor6View& operator*=(Numeric x);
1036  Tensor6View& operator/=(Numeric x);
1038  Tensor6View& operator-=(Numeric x);
1039 
1040  Tensor6View& operator*=(const ConstTensor6View& x);
1041  Tensor6View& operator/=(const ConstTensor6View& x);
1043  Tensor6View& operator-=(const ConstTensor6View& x);
1044 
1045  // Destructor:
1046  virtual ~Tensor6View() = default;
1047 
1048  // Friends:
1049  friend class Iterator7D;
1050  friend class Tensor7View;
1051 
1052  // Special constructor to make a Tensor6 view of a Tensor5.
1053  Tensor6View(const Tensor5View& a);
1054 
1055  protected:
1056  // Constructors:
1057  Tensor6View() = default;
1059  const Range& v,
1060  const Range& s,
1061  const Range& b,
1062  const Range& p,
1063  const Range& r,
1064  const Range& c);
1066  const Range& pv,
1067  const Range& ps,
1068  const Range& pb,
1069  const Range& pp,
1070  const Range& pr,
1071  const Range& pc,
1072  const Range& nv,
1073  const Range& ns,
1074  const Range& nb,
1075  const Range& np,
1076  const Range& nr,
1077  const Range& nc);
1078 };
1079 
1088 class Tensor6 : public Tensor6View {
1089  public:
1090  // Constructors:
1091  Tensor6() = default;
1092  Tensor6(Index v, Index s, Index b, Index p, Index r, Index c);
1093  Tensor6(Index v, Index s, Index b, Index p, Index r, Index c, Numeric fill);
1094  Tensor6(const ConstTensor6View& v);
1095  Tensor6(const Tensor6& v);
1096  Tensor6(Tensor6&& v) noexcept : Tensor6View(std::forward<Tensor6View>(v)) {
1097  v.mdata = nullptr;
1098  }
1099 
1100  // Assignment operators:
1101  Tensor6& operator=(const Tensor6& x);
1102  Tensor6& operator=(Tensor6&& x) noexcept;
1103  Tensor6& operator=(Numeric x);
1104 
1105  // Resize function:
1106  void resize(Index v, Index s, Index b, Index p, Index r, Index c);
1107 
1108  // Swap function:
1109  friend void swap(Tensor6& t1, Tensor6& t2);
1110 
1111  // Destructor:
1112  virtual ~Tensor6();
1113 };
1114 
1115 // Function declarations:
1116 // ----------------------
1117 
1118 void copy(ConstIterator6D origin,
1119  const ConstIterator6D& end,
1120  Iterator6D target);
1121 
1122 void copy(Numeric x, Iterator6D target, const Iterator6D& end);
1123 
1124 void transform(Tensor6View y, double (&my_func)(double), ConstTensor6View x);
1125 
1126 Numeric max(const ConstTensor6View& x);
1127 
1128 Numeric min(const ConstTensor6View& x);
1129 
1130 std::ostream& operator<<(std::ostream& os, const ConstTensor6View& v);
1131 
1133 // Helper function for debugging
1134 #ifndef NDEBUG
1135 
1137  Tensor6View& tv, Index v, Index s, Index b, Index p, Index r, Index c);
1138 
1139 #endif
1140 
1142 #endif // matpackVI_h
Index mstride
Stride.
Definition: matpackVI.h:83
Range mcr
The column range of mdata that is actually used.
Definition: matpackV.h:319
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
#define OFFSET(x)
Definition: matpackVI.h:36
bool operator!=(const Iterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:62
The VectorView class.
Definition: matpackI.h:610
#define ns
The outermost iterator class for rank 6 tensors.
Definition: matpackVI.h:40
The Tensor4View class.
Definition: matpackIV.h:284
ConstTensor5View msv
Current position.
Definition: matpackVI.h:128
bool operator!=(const ConstIterator6D &other) const
Not equal operator, needed for algorithms like copy.
Definition: matpackVI.h:109
A constant view of a Tensor7.
Definition: matpackVII.h:147
The Tensor7View class.
Definition: matpackVII.h:1286
Index mstart
The start index.
Definition: matpackI.h:346
Numeric get(Index v, Index s, Index b, Index p, Index r, Index c) const
Get element implementation without assertions.
Definition: matpackVI.h:550
The MatrixView class.
Definition: matpackI.h:1093
A constant view of a Tensor6.
Definition: matpackVI.h:149
Tensor5View & operator*()
Dereferencing.
Definition: matpackVI.h:77
The range class.
Definition: matpackI.h:160
Const version of Iterator6D.
Definition: matpackVI.h:87
Tensor6(Tensor6 &&v) noexcept
Definition: matpackVI.h:1096
Numeric min(const ConstTensor6View &x)
Min function, tensor version.
Definition: matpackVI.cc:2287
ConstIterator6D end() const
Return const iterator behind last sub-tensor.
Definition: matpackVI.cc:882
Numeric operator()(Index v, Index s, Index b, Index p, Index r, Index c) const
Definition: matpackVI.h:538
The Tensor6View class.
Definition: matpackVI.h:621
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:2248
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
A constant view of a Tensor4.
Definition: matpackIV.h:133
Tensor5View * operator->()
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:74
Numeric max(const ConstTensor6View &x)
Max function, tensor version.
Definition: matpackVI.cc:2268
void swap(ComplexVector &v1, ComplexVector &v2)
Swaps two objects.
Definition: complex.cc:731
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
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:2326
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackV.h:321
#define CHECK(x)
Implementation of Tensors of Rank 6.
Definition: matpackVI.h:33
The Tensor3View class.
Definition: matpackIII.h:239
Range mrr
The row range of mdata that is actually used.
Definition: matpackVII.h:1270
Range mcr
The column range of mdata that is actually used.
Definition: matpackVII.h:1272
const ConstTensor5View * operator->() const
The -> operator is needed, so that we can write i->begin() to get the 1D iterators.
Definition: matpackVI.h:121
const ConstTensor5View & operator*() const
Dereferencing.
Definition: matpackVI.h:124
Iterator6D(const Tensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:47
ConstIterator6D(const ConstTensor5View &x, Index stride)
Explicit constructor.
Definition: matpackVI.h:94
A constant view of a Tensor5.
Definition: matpackV.h:143
Tensor5View msv
Current position.
Definition: matpackVI.h:81
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Iterator6D()=default
Default constructor.
Implementation of Tensors of Rank 7.
Definition: matpackVII.h:36
Range msr
The shelf range of mdata that is actually used.
Definition: matpackV.h:311
The Tensor5View class.
Definition: matpackV.h:333
ConstIterator6D begin() const
Return const iterator to first sub-tensor.
Definition: matpackVI.cc:875
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVI.h:609
Range msr
The shelf range of mdata that is actually used.
Definition: matpackVII.h:1264
Iterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:53
Numeric * mdata
Pointer to the plain C array that holds the data.
Definition: matpackVII.h:1274
Const version of Iterator7D.
Definition: matpackVII.h:84
A constant view of a Tensor3.
Definition: matpackIII.h:132
The Tensor6 class.
Definition: matpackVI.h:1088
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
Numeric & operator()(Index v, Index s, Index b, Index p, Index r, Index c)
Definition: matpackVI.h:1004
Range mpr
The page range of mdata that is actually used.
Definition: matpackVII.h:1268
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:108
void copy(ConstIterator6D origin, const ConstIterator6D &end, Iterator6D target)
Copy data between begin and end to target.
Definition: matpackVI.cc:2006
std::ostream & operator<<(std::ostream &os, const ConstTensor6View &v)
Output operator.
Definition: matpackVI.cc:956
ConstIterator6D & operator++()
Prefix increment operator.
Definition: matpackVI.h:100
Range mbr
The book range of mdata that is actually used.
Definition: matpackVII.h:1266
MatrixView & operator+=(MatrixView &A, const Block &B)
Range mvr
The vitrine range of mdata that is actually used.
Definition: matpackVII.h:1262