ARTS  2.3.1285(git:92a29ea9-dirty)
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),
106  mstokes_dim(stokes_dim),
107  mza(nr_za),
108  maa(nr_aa),
109  mvectortype(false) {
110  assert(mstokes_dim < 5 and mstokes_dim > 0);
111  mdata = Tensor4(maa, mza, mfreqs, NumberOfNeededVectors(), v);
112  }
113 
119  : mfreqs(pm.mfreqs),
120  mstokes_dim(pm.mstokes_dim),
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 
406  void SetAtPosition(ConstMatrixView x,
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 
483  void DivideAtPosition(ConstMatrixView x,
484  const Index iv = 0,
485  const Index iz = 0,
486  const Index ia = 0);
487 
495  void DivideAtPosition(const Numeric& x,
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 
555  void MultiplyAtPosition(ConstMatrixView x,
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 
637  void AddAtPosition(ConstMatrixView x,
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 
713  void RemoveAtPosition(ConstMatrixView x,
714  const Index iv = 0,
715  const Index iz = 0,
716  const Index ia = 0);
717 
725  void RemoveAtPosition(const Numeric& x,
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 
754  void AddAverageAtPosition(ConstMatrixView mat1,
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 
774  void MatrixInverseAtPosition(MatrixView ret,
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 
950  void LeftMultiplyAtPosition(MatrixView out,
951  ConstMatrixView in,
952  const Index iv = 0,
953  const Index iz = 0,
954  const Index ia = 0) const;
955 
956 
965  void RightMultiplyAtPosition(MatrixView out,
966  ConstMatrixView in,
967  const Index iv = 0,
968  const Index iz = 0,
969  const Index ia = 0) const;
970 
971  protected:
973  Index mza, maa;
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;
1096  mstokes_dim = stokes_dim;
1097  mza = nr_za;
1098  maa = nr_aa;
1099  assert(mstokes_dim < 5 and mstokes_dim > 0);
1100  mdata = Tensor4(maa, mza, mfreqs, mstokes_dim, v);
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) {
1142  mfreqs = a.NumberOfFrequencies();
1143  mstokes_dim = a.StokesDimensions();
1144  mza = a.NumberOfZenithAngles();
1145  maa = a.NumberOfAzimuthAngles();
1146  mdata.resize(maa, mza, mfreqs, mstokes_dim);
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 
1170  Index NumberOfNeededVectors() const { return mstokes_dim; }
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();
1202  mdata.resize(maa, mza, mfreqs, mstokes_dim);
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 
1233  void MultiplyAndAdd(const Numeric x, const PropagationMatrix& y) {
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
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
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.
ConstVectorView K23(const Index iz=0, const Index ia=0) const
Vector view to K(1, 3) elements.
Array< PropagationMatrix > ArrayOfPropagationMatrix
VectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0)
Get a vectorview to the position.
void MultiplyAndAdd(const Numeric x, const PropagationMatrix &y)
Add a scaled version of the input.
The VectorView class.
Definition: matpackI.h:610
PropagationMatrix & operator/=(const PropagationMatrix &other)
Divide operator.
A class implementing complex numbers for ARTS.
Index NumberOfAzimuthAngles() const
The number of azimuth angles of the propagation matrix.
The Tensor4View class.
Definition: matpackIV.h:284
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.
void RemoveAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
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.
Index NumberOfNeededVectors() const
The number of required vectors to fill this PropagationMatrix.
void SetAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
Index NumberOfNeededVectors() const
The number of required vectors to fill this StokesVector.
bool IsZero(const Index iv=0, const Index iz=0, const Index ia=0) const
False if any non-zeroes in internal Matrix representation.
The MatrixView class.
Definition: matpackI.h:1093
ConstVectorView K12(const Index iz=0, const Index ia=0) const
Vector view to K(0, 1) elements.
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.
Array< StokesVector > ArrayOfStokesVector
The Tensor4 class.
Definition: matpackIV.h:421
The range class.
Definition: matpackI.h:160
ConstVectorView Kjj(const Index iz=0, const Index ia=0) const
Vector view to diagonal elements.
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:60
PropagationMatrix(PropagationMatrix &&pm) noexcept
Construct a new Propagation Matrix object.
PropagationMatrix(ConstTensor4View x)
Construct a new Propagation Matrix object.
bool IsEmpty() const
Asks if the class is empty.
void MultiplyAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Multiply operator at position.
VectorView K24(const Index iz=0, const Index ia=0)
Vector view to K(1, 3) elements.
PropagationMatrix & operator-=(ConstVectorView x)
Subtraction operator.
std::ostream & operator<<(std::ostream &os, const PropagationMatrix &pm)
output operator
Class to help with hidden temporary variables for operations of type Numeric times Class...
ConstVectorView K13(const Index iz=0, const Index ia=0) const
Vector view to K(0, 2) elements.
void SetAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
Stokes vector is as Propagation matrix but only has 4 possible values.
PropagationMatrix & operator+=(ConstVectorView x)
Addition operator.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
ConstVectorView K24(const Index iz=0, const Index ia=0) const
Vector view to K(1, 3) elements.
void AddAbsorptionVectorAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)
Adds as a Stokes vector at position.
bool IsUnpolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:63
PropagationMatrix & operator+=(const PropagationMatrix &other)
Addition operator.
VectorView K23(const Index iz=0, const Index ia=0)
Vector view to K(1, 2) elements.
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:51
A constant view of a Tensor4.
Definition: matpackIV.h:133
VectorView K13(const Index iz=0, const Index ia=0)
Vector view to K(0, 2) elements.
PropagationMatrix & operator/=(const Numeric &x)
Divide operator.
StokesVector & operator=(const LazyScale< PropagationMatrix > &lpms)
Set this lazily.
VectorView K12(const Index iz=0, const Index ia=0)
Vector view to K(0, 1) elements.
void MultiplyAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Multiply operator at position.
Array< ArrayOfArrayOfStokesVector > ArrayOfArrayOfArrayOfStokesVector
VectorView K34(const Index iz=0, const Index ia=0)
Vector view to K(2, 3) elements.
LazyScale(const base &t, const Numeric &x)
Construct a new Lazy Scale object.
void RemoveAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
Index NumberOfZenithAngles() const
The number of zenith angles of the propagation matrix.
The Tensor3View class.
Definition: matpackIII.h:239
PropagationMatrix & operator*=(const PropagationMatrix &other)
Multiply operator.
StokesVector(ConstTensor4View x)
Construct a new Propagation Matrix object.
PropagationMatrix & operator+=(const Numeric &x)
Addition operator.
bool IsPolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
PropagationMatrix & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
PropagationMatrix & operator=(const PropagationMatrix &other)
Copy operator.
PropagationMatrix & operator=(const LazyScale< PropagationMatrix > &lpms)
Laze equal to opeartor.
ConstVectorView K34(const Index iz=0, const Index ia=0) const
Vector view to diagonal elements.
void AddAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Addition at position operator.
PropagationMatrix(const PropagationMatrix &pm)
Construct a new Propagation Matrix object.
PropagationMatrix & operator/=(ConstVectorView x)
Divide operator.
const Joker joker
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Index StokesDimensions() const
The stokes dimension of the propagation matrix.
Array< ArrayOfStokesVector > ArrayOfArrayOfStokesVector
LazyScale< PropagationMatrix > operator*(const PropagationMatrix &pm, const Numeric &x)
Returns a lazy multiplier.
Tensor4 & Data()
Get full view to data.
PropagationMatrix & operator-=(const Numeric &x)
Subtraction operator.
StokesVector & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
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.
PropagationMatrix & operator=(PropagationMatrix &&pm) noexcept
Move operator.
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.
Array< ArrayOfPropagationMatrix > ArrayOfArrayOfPropagationMatrix
VectorView K14(const Index iz=0, const Index ia=0)
Vector view to K(0, 3) elements.
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
This can be used to make arrays out of anything.
Definition: array.h:40
const base & bas
A const reference to a value.
void DivideAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
PropagationMatrix & operator-=(const PropagationMatrix &other)
Subtraction operator.
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
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.
void SetVectorType(bool vectortype)
Set the Vector Type object.
A constant view of a Vector.
Definition: matpackI.h:476
StokesVector & operator=(const PropagationMatrix &x)
Set *this from a Propagation matrix.
A constant view of a Matrix.
Definition: matpackI.h:982
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:57
ConstVectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0) const
Get a vectorview to the position.
void AddAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Addition at position operator.
PropagationMatrix & operator*=(const Numeric &x)
Multiply operator.
void SetZero()
Sets all data to zero.
StokesVector(const StokesVector &a, const StokesVector &b, const Numeric &scale=0.5)
Construct a new Stokes Vector as a scale between two others.
StokesVector & operator+=(const PropagationMatrix &x)
Addition operator.
PropagationMatrix(ConstMatrixView x, const bool &assume_fit=false)
Initialize from single stokes_dim-by-stokes_dim matrix.
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)
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:66
StokesVector & operator=(const Numeric &x)
Set this to constant value.
void DivideAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
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.
const Numeric & scale
A const reference to a Numeric.
PropagationMatrix & operator*=(ConstVectorView x)
Multiply operator.
StokesVector(ConstVectorView x)
Construct a new Stokes Vector object.
PropagationMatrix & operator=(const Numeric &x)
Sets all data to constant.
const Tensor4 & Data() const
Get full const view to data.
ConstVectorView K14(const Index iz=0, const Index ia=0) const
Vector view to K(0, 3) elements.
void SetAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)