ARTS  2.4.0(git:4fb77825)
propagationmatrix.h
Go to the documentation of this file.
1 /* Copyright (C) 2017
2  * Richard Larsson <ric.larsson@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2, or (at your option) any
7  * later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  * USA. */
18 
34 #ifndef propagationmatrix_h
35 #define propagationmatrix_h
36 
37 #include "complex.h"
38 #include "matpackIV.h"
39 
45 template <class base>
46 class LazyScale {
47  public:
48 
54  LazyScale(const base& t, const Numeric& x) : bas(t), scale(x) {}
55 
57  const base& bas;
58 
60  const Numeric& scale;
61 };
62 
88  public:
100  PropagationMatrix(const Index nr_frequencies = 0,
101  const Index stokes_dim = 1,
102  const Index nr_za = 1,
103  const Index nr_aa = 1,
104  const Numeric v = 0.0)
105  : mfreqs(nr_frequencies),
107  mza(nr_za),
108  maa(nr_aa),
109  mvectortype(false) {
110  assert(mstokes_dim < 5 and mstokes_dim > 0);
112  }
113 
119  : mfreqs(pm.mfreqs),
121  mza(pm.mza),
122  maa(pm.maa),
123  mdata(pm.mdata),
124  mvectortype(pm.mvectortype) {}
125 
131  : mfreqs(std::move(pm.mfreqs)),
132  mstokes_dim(std::move(pm.mstokes_dim)),
133  mza(std::move(pm.mza)),
134  maa(std::move(pm.maa)),
135  mdata(std::move(pm.mdata)),
136  mvectortype(std::move(pm.mvectortype)) {}
137 
143  : mfreqs(x.nrows()),
144  mza(x.npages()),
145  maa(x.nbooks()),
146  mdata(x),
147  mvectortype(false) {
148  switch (x.ncols()) {
149  case 7:
150  mstokes_dim = 4;
151  break;
152  case 4:
153  mstokes_dim = 3;
154  break;
155  case 2:
156  mstokes_dim = 2;
157  break;
158  case 1:
159  mstokes_dim = 1;
160  break;
161  default:
162  throw std::runtime_error(
163  "Tensor4 not representative of PropagationMatrix");
164  }
165  }
166 
172  explicit PropagationMatrix(ConstMatrixView x, const bool& assume_fit = false)
173  : mfreqs(1), mstokes_dim(x.ncols()), mza(1), maa(1) {
174  assert(mstokes_dim < 5 and mstokes_dim > 0);
175  mvectortype = false;
176 
177  if (not assume_fit) {
178  if (not FittingShape(x)) {
179  throw std::runtime_error("Matrix not fit as propagation matrix");
180  }
181  }
182 
183  mdata.resize(1, 1, 1, NumberOfNeededVectors());
184 
185  switch (mstokes_dim) {
186  case 4:
187  mdata(0, 0, 0, 5) = x(1, 3);
188  mdata(0, 0, 0, 6) = x(2, 3);
189  mdata(0, 0, 0, 3) = x(0, 3); /* FALLTHROUGH */
190  case 3:
191  mdata(0, 0, 0, mstokes_dim) = x(1, 2);
192  mdata(0, 0, 0, 2) = x(0, 2); /* FALLTHROUGH */
193  case 2:
194  mdata(0, 0, 0, 1) = x(0, 1); /* FALLTHROUGH */
195  case 1:
196  mdata(0, 0, 0, 0) = x(0, 0); /* FALLTHROUGH */
197  }
198  };
199 
201  Index StokesDimensions() const { return mstokes_dim; };
202 
204  Index NumberOfFrequencies() const { return mfreqs; };
205 
207  Index NumberOfZenithAngles() const { return mza; };
208 
210  Index NumberOfAzimuthAngles() const { return maa; };
211 
212  bool OK() const {return mdata.ncols() == NumberOfNeededVectors() and mdata.nrows() == mfreqs and mdata.npages() == mza and mdata.nbooks() == maa;}
213 
218  void SetVectorType(bool vectortype) { mvectortype = vectortype; }
219 
221  bool IsEmpty() const { return not mfreqs or not mza or not maa; };
222 
230  bool IsZero(const Index iv = 0,
231  const Index iz = 0,
232  const Index ia = 0) const {
233  // FIXME: matpack does not do pointers in a clear manner
234  // return std::any_of(mdata(ia, iz, iv, joker).begin(), mdata(ia, iz, iv, joker).end(), [](auto& x){return x not_eq 0;});
235  for (auto& n : mdata(ia, iz, iv, joker))
236  if (n not_eq 0) return false;
237  return true;
238  };
239 
247  bool IsRotational(const Index iv = 0,
248  const Index iz = 0,
249  const Index ia = 0) const {
250  if (mdata(ia, iz, iv, 0) == 0.0)
251  return true;
252  else
253  return false;
254  };
255 
258  if (not mvectortype) {
259  switch (mstokes_dim) {
260  case 1:
261  return 1;
262  break;
263  case 2:
264  return 2;
265  break;
266  case 3:
267  return 4;
268  break;
269  case 4:
270  return 7;
271  break;
272  default:
273  throw std::runtime_error(
274  "Cannot understand the input in PropagationMatrix");
275  }
276  } else {
277  return mstokes_dim;
278  }
279  }
280 
282  Numeric operator()(const Index iv = 0,
283  const Index is1 = 0,
284  const Index is2 = 0,
285  const Index iz = 0,
286  const Index ia = 0) const;
287 
297  void AddFaraday(const Numeric& rot,
298  const Index iv = 0,
299  const Index iz = 0,
300  const Index ia = 0) {
301  mdata(ia, iz, iv, mstokes_dim) += rot;
302  }
303 
313  void SetFaraday(const Numeric& rot,
314  const Index iv = 0,
315  const Index iz = 0,
316  const Index ia = 0) {
317  mdata(ia, iz, iv, mstokes_dim) = rot;
318  }
319 
327  void MatrixAtPosition(MatrixView ret,
328  const Index iv = 0,
329  const Index iz = 0,
330  const Index ia = 0) const;
331 
338  if (this != &pm) {
339  mfreqs = std::move(pm.mfreqs);
340  mstokes_dim = std::move(pm.mstokes_dim);
341  mza = std::move(pm.mza);
342  maa = std::move(pm.maa);
343  mdata = std::move(pm.mdata);
344  mvectortype = std::move(pm.mvectortype);
345  }
346  return *this;
347  }
348 
355  operator=(lpms.bas);
356  mdata *= lpms.scale;
357  return *this;
358  }
359 
366  mvectortype = other.mvectortype;
367  mstokes_dim = other.mstokes_dim;
368  mfreqs = other.mfreqs;
369  mza = other.mza;
370  maa = other.maa;
371  mdata = other.mdata;
372  return *this;
373  }
374 
381  mdata = x;
382  return *this;
383  }
384 
393  const Index iv = 0,
394  const Index iz = 0,
395  const Index ia = 0) {
396  mdata(ia, iz, iv, joker) = x.mdata(ia, iz, iv, joker);
397  }
398 
407  const Index iv = 0,
408  const Index iz = 0,
409  const Index ia = 0);
410 
411 
419  void SetAtPosition(const Numeric& x,
420  const Index iv = 0,
421  const Index iz = 0,
422  const Index ia = 0) {
423  mdata(ia, iz, iv, joker) = x;
424  }
425 
432  mdata /= other.mdata;
433  return *this;
434  }
435 
442  for (Index i = 0; i < NumberOfNeededVectors(); i++) {
443  for (Index j = 0; j < mza; j++) {
444  for (Index k = 0; k < maa; k++) {
445  mdata(k, j, joker, i) /= x;
446  }
447  }
448  }
449  return *this;
450  }
451 
458  mdata /= x;
459  return *this;
460  }
461 
470  const Index iv = 0,
471  const Index iz = 0,
472  const Index ia = 0) {
473  mdata(ia, iz, iv, joker) /= x.mdata(ia, iz, iv, joker);
474  }
475 
484  const Index iv = 0,
485  const Index iz = 0,
486  const Index ia = 0);
487 
496  const Index iv = 0,
497  const Index iz = 0,
498  const Index ia = 0) {
499  mdata(ia, iz, iv, joker) /= x;
500  }
501 
508  mdata *= other.mdata;
509  return *this;
510  }
511 
518  for (Index i = 0; i < NumberOfNeededVectors(); i++)
519  for (Index j = 0; j < mza; j++)
520  for (Index k = 0; k < maa; k++) mdata(k, j, joker, i) *= x;
521  return *this;
522  }
523 
530  mdata *= x;
531  return *this;
532  }
533 
542  const Index iv = 0,
543  const Index iz = 0,
544  const Index ia = 0) {
545  mdata(ia, iz, iv, joker) *= x.mdata(ia, iz, iv, joker);
546  }
547 
556  const Index iv = 0,
557  const Index iz = 0,
558  const Index ia = 0);
559 
568  const Index iv = 0,
569  const Index iz = 0,
570  const Index ia = 0) {
571  mdata(ia, iz, iv, joker) *= x;
572  }
573 
580  mdata += other.mdata;
581  return *this;
582  }
583 
590  MultiplyAndAdd(lpms.scale, lpms.bas);
591  return *this;
592  }
593 
600  for (Index i = 0; i < NumberOfNeededVectors(); i++)
601  for (Index j = 0; j < mza; j++)
602  for (Index k = 0; k < maa; k++) mdata(k, j, joker, i) += x;
603  return *this;
604  }
605 
612  mdata += x;
613  return *this;
614  }
615 
624  const Index iv = 0,
625  const Index iz = 0,
626  const Index ia = 0) {
627  mdata(ia, iz, iv, joker) += x.mdata(ia, iz, iv, joker);
628  }
629 
638  const Index iv = 0,
639  const Index iz = 0,
640  const Index ia = 0);
641 
649  void AddAtPosition(const Numeric& x,
650  const Index iv = 0,
651  const Index iz = 0,
652  const Index ia = 0) {
653  mdata(ia, iz, iv, joker) += x;
654  }
655 
662  mdata -= other.mdata;
663  return *this;
664  }
665 
672  for (Index i = 0; i < NumberOfNeededVectors(); i++) {
673  for (Index j = 0; j < mza; j++) {
674  for (Index k = 0; k < maa; k++) {
675  mdata(k, j, joker, i) -= x;
676  }
677  }
678  }
679  return *this;
680  }
681 
688  mdata -= x;
689  return *this;
690  }
691 
700  const Index iv = 0,
701  const Index iz = 0,
702  const Index ia = 0) {
703  mdata(ia, iz, iv, joker) -= x.mdata(ia, iz, iv, joker);
704  }
705 
714  const Index iv = 0,
715  const Index iz = 0,
716  const Index ia = 0);
717 
726  const Index iv = 0,
727  const Index iz = 0,
728  const Index ia = 0) {
729  mdata(ia, iz, iv, joker) -= x;
730  }
731 
740  const Index iv = 0,
741  const Index iz = 0,
742  const Index ia = 0) {
743  for (Index i = 0; i < mstokes_dim; i++) mdata(ia, iz, iv, i) += x[i];
744  }
745 
755  ConstMatrixView mat2,
756  const Index iv = 0,
757  const Index iz = 0,
758  const Index ia = 0);
759 
765  void MultiplyAndAdd(const Numeric x, const PropagationMatrix& y);
766 
775  const Index iv = 0,
776  const Index iz = 0,
777  const Index ia = 0) const;
778 
783  bool FittingShape(ConstMatrixView x) const;
784 
791  void GetTensor3(Tensor3View tensor3, const Index iz = 0, const Index ia = 0);
792 
799  VectorView Kjj(const Index iz = 0, const Index ia = 0) {
800  return mdata(ia, iz, joker, 0);
801  }
802 
809  VectorView K12(const Index iz = 0, const Index ia = 0) {
810  return mdata(ia, iz, joker, 1);
811  }
812 
819  VectorView K13(const Index iz = 0, const Index ia = 0) {
820  return mdata(ia, iz, joker, 2);
821  }
822 
829  VectorView K14(const Index iz = 0, const Index ia = 0) {
830  return mdata(ia, iz, joker, 3);
831  }
832 
839  VectorView K23(const Index iz = 0, const Index ia = 0) {
840  return mdata(ia, iz, joker, mstokes_dim);
841  }
842 
849  VectorView K24(const Index iz = 0, const Index ia = 0) {
850  return mdata(ia, iz, joker, 5);
851  }
852 
859  VectorView K34(const Index iz = 0, const Index ia = 0) {
860  return mdata(ia, iz, joker, 6);
861  }
862 
869  ConstVectorView Kjj(const Index iz = 0, const Index ia = 0) const {
870  return mdata(ia, iz, joker, 0);
871  }
872 
879  ConstVectorView K12(const Index iz = 0, const Index ia = 0) const {
880  return mdata(ia, iz, joker, 1);
881  }
882 
889  ConstVectorView K13(const Index iz = 0, const Index ia = 0) const {
890  return mdata(ia, iz, joker, 2);
891  }
892 
899  ConstVectorView K14(const Index iz = 0, const Index ia = 0) const {
900  return mdata(ia, iz, joker, 3);
901  }
902 
909  ConstVectorView K23(const Index iz = 0, const Index ia = 0) const {
910  return mdata(ia, iz, joker, mstokes_dim);
911  }
912 
919  ConstVectorView K24(const Index iz = 0, const Index ia = 0) const {
920  return mdata(ia, iz, joker, 5);
921  }
922 
929  ConstVectorView K34(const Index iz = 0, const Index ia = 0) const {
930  return mdata(ia, iz, joker, 6);
931  }
932 
934  void SetZero() { mdata = 0.0; }
935 
937  Tensor4& Data() { return mdata; }
938 
940  const Tensor4& Data() const { return mdata; }
941 
951  ConstMatrixView in,
952  const Index iv = 0,
953  const Index iz = 0,
954  const Index ia = 0) const;
955 
956 
966  ConstMatrixView in,
967  const Index iv = 0,
968  const Index iz = 0,
969  const Index ia = 0) const;
970 
971  protected:
976 };
977 
980 
998  const Numeric& r,
999  const PropagationMatrix& upper_level,
1000  const PropagationMatrix& lower_level,
1001  const Index iz = 0,
1002  const Index ia = 0);
1003 
1004 
1019  MatrixView T,
1020  const Numeric& r,
1021  const PropagationMatrix& averaged_propagation_matrix,
1022  const Index iv,
1023  const Index iz = 0,
1024  const Index ia = 0);
1025 
1050  Tensor3View T,
1051  Tensor4View dT_upper_level,
1052  Tensor4View dT_lower_level,
1053  const Numeric& r,
1054  const PropagationMatrix& upper_level,
1055  const PropagationMatrix& lower_level,
1056  const Array<PropagationMatrix>& dprop_mat_upper_level,
1057  const Array<PropagationMatrix>& dprop_mat_lower_level,
1058  const Numeric& dr_dTu = 0.0,
1059  const Numeric& dr_dTl = 0.0,
1060  const Index it = -1,
1061  const Index iz = 0,
1062  const Index ia = 0);
1063 
1065 std::ostream& operator<<(std::ostream& os, const PropagationMatrix& pm);
1066 
1068 std::ostream& operator<<(std::ostream& os, const ArrayOfPropagationMatrix& apm);
1069 
1071 std::ostream& operator<<(std::ostream& os,
1072  const ArrayOfArrayOfPropagationMatrix& aapm);
1073 
1075 class StokesVector final : public PropagationMatrix {
1076  public:
1077 
1089  StokesVector(const Index nr_frequencies = 0,
1090  const Index stokes_dim = 1,
1091  const Index nr_za = 1,
1092  const Index nr_aa = 1,
1093  const Numeric& v = 0.0) {
1094  mvectortype = true;
1095  mfreqs = nr_frequencies;
1097  mza = nr_za;
1098  maa = nr_aa;
1099  assert(mstokes_dim < 5 and mstokes_dim > 0);
1101  };
1102 
1108  mfreqs = x.nrows();
1109  mstokes_dim = x.ncols();
1110  mza = x.npages();
1111  maa = x.nbooks();
1112  mdata = x;
1113  mvectortype = true;
1114  if (mstokes_dim > 4 or mstokes_dim < 1)
1115  throw std::runtime_error("Tensor4 is bad for StokesVector");
1116  }
1117 
1123  mfreqs = 1;
1124  mstokes_dim = x.nelem();
1125  mza = 1;
1126  maa = 1;
1127  assert(mstokes_dim < 5 and mstokes_dim > 0);
1128  mvectortype = true;
1129  mdata.resize(1, 1, 1, mstokes_dim);
1130  for (Index i = 0; i < mstokes_dim; i++) mdata(0, 0, 0, i) = x[i];
1131  };
1132 
1140  const StokesVector& b,
1141  const Numeric& scale = 0.5) {
1144  mza = a.NumberOfZenithAngles();
1145  maa = a.NumberOfAzimuthAngles();
1147  mvectortype = true;
1148 
1149  for (Index i = 0; i < maa; i++)
1150  for (Index j = 0; j < mza; j++)
1151  for (Index k = 0; k < mfreqs; k++) {
1152  switch (mstokes_dim) {
1153  case 4:
1154  mdata(i, j, k, 3) = (a.mdata(i, j, k, 3) + b.mdata(i, j, k, 3)) *
1155  scale; /* FALLTHROUGH */
1156  case 3:
1157  mdata(i, j, k, 2) = (a.mdata(i, j, k, 2) + b.mdata(i, j, k, 2)) *
1158  scale; /* FALLTHROUGH */
1159  case 2:
1160  mdata(i, j, k, 1) = (a.mdata(i, j, k, 1) + b.mdata(i, j, k, 1)) *
1161  scale; /* FALLTHROUGH */
1162  case 1:
1163  mdata(i, j, k, 0) = (a.mdata(i, j, k, 0) + b.mdata(i, j, k, 0)) *
1164  scale; /* FALLTHROUGH */
1165  }
1166  }
1167  };
1168 
1171 
1178  mdata += x.Data()(joker, joker, joker, Range(0, mstokes_dim, 1));
1179  return *this;
1180  }
1181 
1188  MultiplyAndAdd(lpms.scale, lpms.bas);
1189  return *this;
1190  }
1191 
1198  mstokes_dim = x.StokesDimensions();
1199  mfreqs = x.NumberOfFrequencies();
1200  mza = x.NumberOfZenithAngles();
1201  maa = x.NumberOfAzimuthAngles();
1203  mdata(joker, joker, joker, Range(0, mstokes_dim, 1)) = x.Data()(joker, joker, joker, Range(0, mstokes_dim, 1));
1204  return *this;
1205  }
1206 
1213  operator=(lpms.bas);
1214  mdata *= lpms.scale;
1215  return *this;
1216  }
1217 
1224  mdata = x;
1225  return *this;
1226  }
1227 
1234  assert(mstokes_dim == y.StokesDimensions());
1235  assert(mfreqs == y.NumberOfFrequencies());
1236  assert(mza == y.NumberOfZenithAngles());
1237  assert(maa == y.NumberOfAzimuthAngles());
1238 
1239  const Tensor4& data = y.Data();
1240 
1241  for (Index i = 0; i < maa; i++) {
1242  for (Index j = 0; j < mza; j++) {
1243  for (Index k = 0; k < mfreqs; k++) {
1244  switch (mstokes_dim) {
1245  case 4:
1246  mdata(i, j, k, 3) += x * data(i, j, k, 3); /* FALLTHROUGH */
1247  case 3:
1248  mdata(i, j, k, 2) += x * data(i, j, k, 2); /* FALLTHROUGH */
1249  case 2:
1250  mdata(i, j, k, 1) += x * data(i, j, k, 1); /* FALLTHROUGH */
1251  case 1:
1252  mdata(i, j, k, 0) += x * data(i, j, k, 0); /* FALLTHROUGH */
1253  }
1254  }
1255  }
1256  }
1257  }
1258 
1267  const Index iz = 0,
1268  const Index ia = 0) {
1269  return mdata(ia, iz, iv, joker);
1270  }
1271 
1280  const Index iz = 0,
1281  const Index ia = 0) const {
1282  return mdata(ia, iz, iv, joker);
1283  }
1284 
1286  const Index iv = 0,
1287  const Index iz = 0,
1288  const Index ia = 0) {
1289  mdata(ia, iz, iv, joker) = x;
1290  }
1291 
1301  ConstVectorView vec2,
1302  const Index iv = 0,
1303  const Index iz = 0,
1304  const Index ia = 0) {
1305  switch (mstokes_dim) {
1306  case 4:
1307  mdata(ia, iz, iv, 3) += (vec1[3] + vec2[3]) * 0.5; /* FALLTHROUGH */
1308  case 3:
1309  mdata(ia, iz, iv, 2) += (vec1[2] + vec2[2]) * 0.5; /* FALLTHROUGH */
1310  case 2:
1311  mdata(ia, iz, iv, 1) += (vec1[1] + vec2[1]) * 0.5; /* FALLTHROUGH */
1312  case 1:
1313  mdata(ia, iz, iv, 0) += (vec1[0] + vec2[0]) * 0.5; /* FALLTHROUGH */
1314  }
1315  }
1316 
1325  bool IsPolarized(const Index iv = 0,
1326  const Index iz = 0,
1327  const Index ia = 0) const {
1328  switch (mstokes_dim) {
1329  case 4:
1330  if (K14(iz, ia)[iv] not_eq 0.0) return true; /* FALLTHROUGH */
1331  case 3:
1332  if (K13(iz, ia)[iv] not_eq 0.0) return true; /* FALLTHROUGH */
1333  case 2:
1334  if (K12(iz, ia)[iv] not_eq 0.0) return true; /* FALLTHROUGH */
1335  }
1336  return false;
1337  }
1338 
1347  bool IsUnpolarized(const Index iv = 0,
1348  const Index iz = 0,
1349  const Index ia = 0) const {
1350  return not IsPolarized(iv, iz, ia);
1351  }
1352 };
1353 
1357 
1358 std::ostream& operator<<(std::ostream& os, const StokesVector& pm);
1359 std::ostream& operator<<(std::ostream& os, const ArrayOfStokesVector& apm);
1360 std::ostream& operator<<(std::ostream& os,
1361  const ArrayOfArrayOfStokesVector& aapm);
1362 
1370  const Numeric& x) {
1371  return LazyScale<PropagationMatrix>(pm, x);
1372 }
1373 
1381  const PropagationMatrix& pm) {
1382  return LazyScale<PropagationMatrix>(pm, x);
1383 }
1384 
1385 #endif //propagationmatrix_h
LazyScale
Class to help with hidden temporary variables for operations of type Numeric times Class.
Definition: propagationmatrix.h:46
PropagationMatrix::MatrixAtPosition
void MatrixAtPosition(MatrixView ret, const Index iv=0, const Index iz=0, const Index ia=0) const
Sets the dense matrix.
Definition: propagationmatrix.cc:1928
PropagationMatrix::operator/=
PropagationMatrix & operator/=(const PropagationMatrix &other)
Divide operator.
Definition: propagationmatrix.h:431
PropagationMatrix::OK
bool OK() const
Definition: propagationmatrix.h:212
Tensor4::resize
void resize(Index b, Index p, Index r, Index c)
Resize function.
Definition: matpackIV.cc:1064
StokesVector
Stokes vector is as Propagation matrix but only has 4 possible values.
Definition: propagationmatrix.h:1075
PropagationMatrix::NumberOfNeededVectors
Index NumberOfNeededVectors() const
The number of required vectors to fill this PropagationMatrix.
Definition: propagationmatrix.h:257
MatrixView
The MatrixView class.
Definition: matpackI.h:1093
StokesVector::IsPolarized
bool IsPolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
Definition: propagationmatrix.h:1325
PropagationMatrix::IsEmpty
bool IsEmpty() const
Asks if the class is empty.
Definition: propagationmatrix.h:221
LazyScale::LazyScale
LazyScale(const base &t, const Numeric &x)
Construct a new Lazy Scale object.
Definition: propagationmatrix.h:54
PropagationMatrix::NumberOfAzimuthAngles
Index NumberOfAzimuthAngles() const
The number of azimuth angles of the propagation matrix.
Definition: propagationmatrix.h:210
PropagationMatrix::Data
const Tensor4 & Data() const
Get full const view to data.
Definition: propagationmatrix.h:940
joker
const Joker joker
PropagationMatrix::RemoveAtPosition
void RemoveAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
Definition: propagationmatrix.h:725
PropagationMatrix::K24
ConstVectorView K24(const Index iz=0, const Index ia=0) const
Vector view to K(1, 3) elements.
Definition: propagationmatrix.h:919
PropagationMatrix::maa
Index maa
Definition: propagationmatrix.h:973
PropagationMatrix::AddAbsorptionVectorAtPosition
void AddAbsorptionVectorAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)
Adds as a Stokes vector at position.
Definition: propagationmatrix.h:739
PropagationMatrix::Kjj
ConstVectorView Kjj(const Index iz=0, const Index ia=0) const
Vector view to diagonal elements.
Definition: propagationmatrix.h:869
ARTS::Group::Tensor4
Tensor4 Tensor4
Definition: autoarts.h:105
PropagationMatrix::MatrixInverseAtPosition
void MatrixInverseAtPosition(MatrixView ret, const Index iv=0, const Index iz=0, const Index ia=0) const
Return the matrix inverse at the position.
Definition: propagationmatrix.cc:1506
PropagationMatrix::FittingShape
bool FittingShape(ConstMatrixView x) const
Tests of the input matrix fits Propagation Matrix style.
Definition: propagationmatrix.cc:1640
PropagationMatrix::IsZero
bool IsZero(const Index iv=0, const Index iz=0, const Index ia=0) const
False if any non-zeroes in internal Matrix representation.
Definition: propagationmatrix.h:230
PropagationMatrix::K13
ConstVectorView K13(const Index iz=0, const Index ia=0) const
Vector view to K(0, 2) elements.
Definition: propagationmatrix.h:889
StokesVector::operator+=
StokesVector & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
Definition: propagationmatrix.h:1187
ARTS::Var::y
Vector y(Workspace &ws) noexcept
Definition: autoarts.h:7401
PropagationMatrix
Definition: propagationmatrix.h:87
PropagationMatrix::SetFaraday
void SetFaraday(const Numeric &rot, const Index iv=0, const Index iz=0, const Index ia=0)
Sets the Faraday rotation to the PropagationMatrix at required position.
Definition: propagationmatrix.h:313
PropagationMatrix::IsRotational
bool IsRotational(const Index iv=0, const Index iz=0, const Index ia=0) const
False if diagonal element is non-zero in internal Matrix representation.
Definition: propagationmatrix.h:247
data
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Definition: arts_api_classes.cc:232
ARTS::Var::stokes_dim
Index stokes_dim(Workspace &ws) noexcept
Definition: autoarts.h:6650
PropagationMatrix::mfreqs
Index mfreqs
Definition: propagationmatrix.h:972
PropagationMatrix::operator-=
PropagationMatrix & operator-=(ConstVectorView x)
Subtraction operator.
Definition: propagationmatrix.h:671
operator*
LazyScale< PropagationMatrix > operator*(const PropagationMatrix &pm, const Numeric &x)
Returns a lazy multiplier.
Definition: propagationmatrix.h:1369
PropagationMatrix::K13
VectorView K13(const Index iz=0, const Index ia=0)
Vector view to K(0, 2) elements.
Definition: propagationmatrix.h:819
PropagationMatrix::RemoveAtPosition
void RemoveAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
Definition: propagationmatrix.h:699
ArrayOfArrayOfArrayOfStokesVector
Array< ArrayOfArrayOfStokesVector > ArrayOfArrayOfArrayOfStokesVector
Definition: propagationmatrix.h:1356
Tensor4
The Tensor4 class.
Definition: matpackIV.h:421
PropagationMatrix::K12
ConstVectorView K12(const Index iz=0, const Index ia=0) const
Vector view to K(0, 1) elements.
Definition: propagationmatrix.h:879
StokesVector::operator=
StokesVector & operator=(const Numeric &x)
Set this to constant value.
Definition: propagationmatrix.h:1223
PropagationMatrix::RightMultiplyAtPosition
void RightMultiplyAtPosition(MatrixView out, ConstMatrixView in, const Index iv=0, const Index iz=0, const Index ia=0) const
Multiply the matrix input from the right of this at position.
Definition: propagationmatrix.cc:1770
matpackIV.h
PropagationMatrix::operator+=
PropagationMatrix & operator+=(ConstVectorView x)
Addition operator.
Definition: propagationmatrix.h:599
PropagationMatrix::AddAverageAtPosition
void AddAverageAtPosition(ConstMatrixView mat1, ConstMatrixView mat2, const Index iv=0, const Index iz=0, const Index ia=0)
Add the average of the two input at position.
Definition: propagationmatrix.cc:1610
PropagationMatrix::MultiplyAtPosition
void MultiplyAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Multiply operator at position.
Definition: propagationmatrix.h:541
operator<<
std::ostream & operator<<(std::ostream &os, const PropagationMatrix &pm)
output operator
Definition: propagationmatrix.cc:2036
ConstTensor4View
A constant view of a Tensor4.
Definition: matpackIV.h:133
PropagationMatrix::MultiplyAndAdd
void MultiplyAndAdd(const Numeric x, const PropagationMatrix &y)
Multiply input by scalar and add to this.
Definition: propagationmatrix.cc:1631
complex.h
A class implementing complex numbers for ARTS.
Tensor3View
The Tensor3View class.
Definition: matpackIII.h:239
PropagationMatrix::PropagationMatrix
PropagationMatrix(ConstTensor4View x)
Construct a new Propagation Matrix object.
Definition: propagationmatrix.h:142
PropagationMatrix::PropagationMatrix
PropagationMatrix(PropagationMatrix &&pm) noexcept
Construct a new Propagation Matrix object.
Definition: propagationmatrix.h:130
Array
This can be used to make arrays out of anything.
Definition: array.h:108
PropagationMatrix::MultiplyAtPosition
void MultiplyAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Multiply operator at position.
Definition: propagationmatrix.h:567
PropagationMatrix::K24
VectorView K24(const Index iz=0, const Index ia=0)
Vector view to K(1, 3) elements.
Definition: propagationmatrix.h:849
PropagationMatrix::operator()
Numeric operator()(const Index iv=0, const Index is1=0, const Index is2=0, const Index iz=0, const Index ia=0) const
access operator.
Definition: propagationmatrix.cc:1953
PropagationMatrix::K23
VectorView K23(const Index iz=0, const Index ia=0)
Vector view to K(1, 2) elements.
Definition: propagationmatrix.h:839
StokesVector::VectorAtPosition
ConstVectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0) const
Get a vectorview to the position.
Definition: propagationmatrix.h:1279
PropagationMatrix::operator+=
PropagationMatrix & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
Definition: propagationmatrix.h:589
compute_transmission_matrix_from_averaged_matrix_at_frequency
void compute_transmission_matrix_from_averaged_matrix_at_frequency(MatrixView T, const Numeric &r, const PropagationMatrix &averaged_propagation_matrix, const Index iv, const Index iz=0, const Index ia=0)
Compute the matrix exponent as the transmission matrix of this propagation matrix.
Definition: propagationmatrix.cc:272
PropagationMatrix::operator=
PropagationMatrix & operator=(const PropagationMatrix &other)
Copy operator.
Definition: propagationmatrix.h:365
PropagationMatrix::operator=
PropagationMatrix & operator=(const LazyScale< PropagationMatrix > &lpms)
Laze equal to opeartor.
Definition: propagationmatrix.h:354
PropagationMatrix::K34
ConstVectorView K34(const Index iz=0, const Index ia=0) const
Vector view to diagonal elements.
Definition: propagationmatrix.h:929
PropagationMatrix::NumberOfZenithAngles
Index NumberOfZenithAngles() const
The number of zenith angles of the propagation matrix.
Definition: propagationmatrix.h:207
StokesVector::StokesVector
StokesVector(const StokesVector &a, const StokesVector &b, const Numeric &scale=0.5)
Construct a new Stokes Vector as a scale between two others.
Definition: propagationmatrix.h:1139
PropagationMatrix::SetAtPosition
void SetAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
Definition: propagationmatrix.h:419
StokesVector::StokesVector
StokesVector(ConstVectorView x)
Construct a new Stokes Vector object.
Definition: propagationmatrix.h:1122
StokesVector::MultiplyAndAdd
void MultiplyAndAdd(const Numeric x, const PropagationMatrix &y)
Add a scaled version of the input.
Definition: propagationmatrix.h:1233
PropagationMatrix::K12
VectorView K12(const Index iz=0, const Index ia=0)
Vector view to K(0, 1) elements.
Definition: propagationmatrix.h:809
PropagationMatrix::operator*=
PropagationMatrix & operator*=(const PropagationMatrix &other)
Multiply operator.
Definition: propagationmatrix.h:507
StokesVector::StokesVector
StokesVector(ConstTensor4View x)
Construct a new Propagation Matrix object.
Definition: propagationmatrix.h:1107
PropagationMatrix::operator-=
PropagationMatrix & operator-=(const Numeric &x)
Subtraction operator.
Definition: propagationmatrix.h:687
PropagationMatrix::operator+=
PropagationMatrix & operator+=(const PropagationMatrix &other)
Addition operator.
Definition: propagationmatrix.h:579
PropagationMatrix::operator+=
PropagationMatrix & operator+=(const Numeric &x)
Addition operator.
Definition: propagationmatrix.h:611
PropagationMatrix::K34
VectorView K34(const Index iz=0, const Index ia=0)
Vector view to K(2, 3) elements.
Definition: propagationmatrix.h:859
LazyScale::bas
const base & bas
A const reference to a value.
Definition: propagationmatrix.h:57
compute_transmission_matrix
void compute_transmission_matrix(Tensor3View T, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const Index iz=0, const Index ia=0)
Compute the matrix exponent as the transmission matrix of this propagation matrix.
Definition: propagationmatrix.cc:33
VectorView
The VectorView class.
Definition: matpackI.h:610
ArrayOfPropagationMatrix
Array< PropagationMatrix > ArrayOfPropagationMatrix
Definition: propagationmatrix.h:978
PropagationMatrix::operator/=
PropagationMatrix & operator/=(const Numeric &x)
Divide operator.
Definition: propagationmatrix.h:457
PropagationMatrix::AddAtPosition
void AddAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Addition at position operator.
Definition: propagationmatrix.h:649
PropagationMatrix::PropagationMatrix
PropagationMatrix(const PropagationMatrix &pm)
Construct a new Propagation Matrix object.
Definition: propagationmatrix.h:118
PropagationMatrix::mdata
Tensor4 mdata
Definition: propagationmatrix.h:974
ArrayOfArrayOfStokesVector
Array< ArrayOfStokesVector > ArrayOfArrayOfStokesVector
Definition: propagationmatrix.h:1355
ConstTensor4View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:66
PropagationMatrix::NumberOfFrequencies
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
Definition: propagationmatrix.h:204
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ConstTensor4View::npages
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:60
PropagationMatrix::Data
Tensor4 & Data()
Get full view to data.
Definition: propagationmatrix.h:937
ConstTensor4View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:57
StokesVector::NumberOfNeededVectors
Index NumberOfNeededVectors() const
The number of required vectors to fill this StokesVector.
Definition: propagationmatrix.h:1170
ARTS::Var::npages
Index npages(Workspace &ws) noexcept
Definition: autoarts.h:4675
ArrayOfArrayOfPropagationMatrix
Array< ArrayOfPropagationMatrix > ArrayOfArrayOfPropagationMatrix
Definition: propagationmatrix.h:979
PropagationMatrix::AddFaraday
void AddFaraday(const Numeric &rot, const Index iv=0, const Index iz=0, const Index ia=0)
Adds the Faraday rotation to the PropagationMatrix at required position.
Definition: propagationmatrix.h:297
PropagationMatrix::LeftMultiplyAtPosition
void LeftMultiplyAtPosition(MatrixView out, ConstMatrixView in, const Index iv=0, const Index iz=0, const Index ia=0) const
Multiply the matrix input from the left of this at position.
Definition: propagationmatrix.cc:1707
PropagationMatrix::PropagationMatrix
PropagationMatrix(const Index nr_frequencies=0, const Index stokes_dim=1, const Index nr_za=1, const Index nr_aa=1, const Numeric v=0.0)
Initialize variable sizes.
Definition: propagationmatrix.h:100
PropagationMatrix::K14
VectorView K14(const Index iz=0, const Index ia=0)
Vector view to K(0, 3) elements.
Definition: propagationmatrix.h:829
PropagationMatrix::operator/=
PropagationMatrix & operator/=(ConstVectorView x)
Divide operator.
Definition: propagationmatrix.h:441
PropagationMatrix::mstokes_dim
Index mstokes_dim
Definition: propagationmatrix.h:972
ConstMatrixView
A constant view of a Matrix.
Definition: matpackI.h:982
PropagationMatrix::operator-=
PropagationMatrix & operator-=(const PropagationMatrix &other)
Subtraction operator.
Definition: propagationmatrix.h:661
ARTS::Var::nrows
Index nrows(Workspace &ws) noexcept
Definition: autoarts.h:4682
ConstTensor4View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:63
PropagationMatrix::operator*=
PropagationMatrix & operator*=(const Numeric &x)
Multiply operator.
Definition: propagationmatrix.h:529
PropagationMatrix::SetZero
void SetZero()
Sets all data to zero.
Definition: propagationmatrix.h:934
ArrayOfStokesVector
Array< StokesVector > ArrayOfStokesVector
Definition: propagationmatrix.h:1354
Range
The range class.
Definition: matpackI.h:160
LazyScale::scale
const Numeric & scale
A const reference to a Numeric.
Definition: propagationmatrix.h:60
StokesVector::operator=
StokesVector & operator=(const PropagationMatrix &x)
Set *this from a Propagation matrix.
Definition: propagationmatrix.h:1197
PropagationMatrix::StokesDimensions
Index StokesDimensions() const
The stokes dimension of the propagation matrix.
Definition: propagationmatrix.h:201
PropagationMatrix::DivideAtPosition
void DivideAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
Definition: propagationmatrix.h:469
StokesVector::StokesVector
StokesVector(const Index nr_frequencies=0, const Index stokes_dim=1, const Index nr_za=1, const Index nr_aa=1, const Numeric &v=0.0)
Initialize variable sizes.
Definition: propagationmatrix.h:1089
PropagationMatrix::mvectortype
bool mvectortype
Definition: propagationmatrix.h:975
PropagationMatrix::Kjj
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
Definition: propagationmatrix.h:799
Tensor4View
The Tensor4View class.
Definition: matpackIV.h:284
StokesVector::operator+=
StokesVector & operator+=(const PropagationMatrix &x)
Addition operator.
Definition: propagationmatrix.h:1177
StokesVector::IsUnpolarized
bool IsUnpolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
Definition: propagationmatrix.h:1347
PropagationMatrix::operator=
PropagationMatrix & operator=(PropagationMatrix &&pm) noexcept
Move operator.
Definition: propagationmatrix.h:337
PropagationMatrix::operator*=
PropagationMatrix & operator*=(ConstVectorView x)
Multiply operator.
Definition: propagationmatrix.h:517
StokesVector::AddAverageAtPosition
void AddAverageAtPosition(ConstVectorView vec1, ConstVectorView vec2, const Index iv=0, const Index iz=0, const Index ia=0)
Add the average of both inputs at position.
Definition: propagationmatrix.h:1300
PropagationMatrix::SetVectorType
void SetVectorType(bool vectortype)
Set the Vector Type object.
Definition: propagationmatrix.h:218
PropagationMatrix::GetTensor3
void GetTensor3(Tensor3View tensor3, const Index iz=0, const Index ia=0)
Get a Tensor3 object from this.
Definition: propagationmatrix.cc:1674
PropagationMatrix::K23
ConstVectorView K23(const Index iz=0, const Index ia=0) const
Vector view to K(1, 3) elements.
Definition: propagationmatrix.h:909
PropagationMatrix::DivideAtPosition
void DivideAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
Definition: propagationmatrix.h:495
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
PropagationMatrix::AddAtPosition
void AddAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Addition at position operator.
Definition: propagationmatrix.h:623
ARTS::Var::ncols
Index ncols(Workspace &ws) noexcept
Definition: autoarts.h:4546
PropagationMatrix::mza
Index mza
Definition: propagationmatrix.h:973
PropagationMatrix::PropagationMatrix
PropagationMatrix(ConstMatrixView x, const bool &assume_fit=false)
Initialize from single stokes_dim-by-stokes_dim matrix.
Definition: propagationmatrix.h:172
PropagationMatrix::operator=
PropagationMatrix & operator=(const Numeric &x)
Sets all data to constant.
Definition: propagationmatrix.h:380
StokesVector::SetAtPosition
void SetAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)
Definition: propagationmatrix.h:1285
ConstVectorView
A constant view of a Vector.
Definition: matpackI.h:476
PropagationMatrix::K14
ConstVectorView K14(const Index iz=0, const Index ia=0) const
Vector view to K(0, 3) elements.
Definition: propagationmatrix.h:899
compute_transmission_matrix_and_derivative
void compute_transmission_matrix_and_derivative(Tensor3View T, Tensor4View dT_upper_level, Tensor4View dT_lower_level, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const Array< PropagationMatrix > &dprop_mat_upper_level, const Array< PropagationMatrix > &dprop_mat_lower_level, const Numeric &dr_dTu=0.0, const Numeric &dr_dTl=0.0, const Index it=-1, const Index iz=0, const Index ia=0)
Definition: propagationmatrix.cc:478
ARTS::Var::nbooks
Index nbooks(Workspace &ws) noexcept
Definition: autoarts.h:4539
StokesVector::VectorAtPosition
VectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0)
Get a vectorview to the position.
Definition: propagationmatrix.h:1266
StokesVector::operator=
StokesVector & operator=(const LazyScale< PropagationMatrix > &lpms)
Set this lazily.
Definition: propagationmatrix.h:1212
PropagationMatrix::SetAtPosition
void SetAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
Definition: propagationmatrix.h:392