Go to the documentation of this file.
34 #ifndef propagationmatrix_h
35 #define propagationmatrix_h
102 const Index nr_za = 1,
103 const Index nr_aa = 1,
110 assert(mstokes_dim < 5 and mstokes_dim > 0);
131 :
mfreqs(std::move(pm.mfreqs)),
133 mza(std::move(pm.mza)),
134 maa(std::move(pm.maa)),
135 mdata(std::move(pm.mdata)),
162 throw std::runtime_error(
163 "Tensor4 not representative of PropagationMatrix");
174 assert(mstokes_dim < 5 and mstokes_dim > 0);
177 if (not assume_fit) {
179 throw std::runtime_error(
"Matrix not fit as propagation matrix");
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);
192 mdata(0, 0, 0, 2) =
x(0, 2);
194 mdata(0, 0, 0, 1) =
x(0, 1);
196 mdata(0, 0, 0, 0) =
x(0, 0);
232 const Index ia = 0)
const {
236 if (n not_eq 0)
return false;
249 const Index ia = 0)
const {
250 if (
mdata(ia, iz, iv, 0) == 0.0)
273 throw std::runtime_error(
274 "Cannot understand the input in PropagationMatrix");
286 const Index ia = 0)
const;
300 const Index ia = 0) {
316 const Index ia = 0) {
330 const Index ia = 0)
const;
339 mfreqs = std::move(pm.mfreqs);
341 mza = std::move(pm.mza);
342 maa = std::move(pm.maa);
343 mdata = std::move(pm.mdata);
395 const Index ia = 0) {
422 const Index ia = 0) {
472 const Index ia = 0) {
498 const Index ia = 0) {
544 const Index ia = 0) {
570 const Index ia = 0) {
626 const Index ia = 0) {
652 const Index ia = 0) {
702 const Index ia = 0) {
728 const Index ia = 0) {
742 const Index ia = 0) {
777 const Index ia = 0)
const;
954 const Index ia = 0)
const;
969 const Index ia = 0)
const;
1002 const Index ia = 0);
1024 const Index ia = 0);
1060 const Index it = -1,
1062 const Index ia = 0);
1091 const Index nr_za = 1,
1092 const Index nr_aa = 1,
1099 assert(mstokes_dim < 5 and mstokes_dim > 0);
1115 throw std::runtime_error(
"Tensor4 is bad for StokesVector");
1127 assert(mstokes_dim < 5 and mstokes_dim > 0);
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));
1235 assert(
mfreqs ==
y.NumberOfFrequencies());
1236 assert(
mza ==
y.NumberOfZenithAngles());
1237 assert(
maa ==
y.NumberOfAzimuthAngles());
1268 const Index ia = 0) {
1281 const Index ia = 0)
const {
1288 const Index ia = 0) {
1304 const Index ia = 0) {
1307 mdata(ia, iz, iv, 3) += (vec1[3] + vec2[3]) * 0.5;
1309 mdata(ia, iz, iv, 2) += (vec1[2] + vec2[2]) * 0.5;
1311 mdata(ia, iz, iv, 1) += (vec1[1] + vec2[1]) * 0.5;
1313 mdata(ia, iz, iv, 0) += (vec1[0] + vec2[0]) * 0.5;
1327 const Index ia = 0)
const {
1330 if (
K14(iz, ia)[iv] not_eq 0.0)
return true;
1332 if (
K13(iz, ia)[iv] not_eq 0.0)
return true;
1334 if (
K12(iz, ia)[iv] not_eq 0.0)
return true;
1349 const Index ia = 0)
const {
1385 #endif //propagationmatrix_h
Class to help with hidden temporary variables for operations of type Numeric times Class.
void MatrixAtPosition(MatrixView ret, const Index iv=0, const Index iz=0, const Index ia=0) const
Sets the dense matrix.
PropagationMatrix & operator/=(const PropagationMatrix &other)
Divide operator.
void resize(Index b, Index p, Index r, Index c)
Resize function.
Stokes vector is as Propagation matrix but only has 4 possible values.
Index NumberOfNeededVectors() const
The number of required vectors to fill this PropagationMatrix.
bool IsPolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
bool IsEmpty() const
Asks if the class is empty.
LazyScale(const base &t, const Numeric &x)
Construct a new Lazy Scale object.
Index NumberOfAzimuthAngles() const
The number of azimuth angles of the propagation matrix.
const Tensor4 & Data() const
Get full const view to data.
void RemoveAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
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.
ConstVectorView Kjj(const Index iz=0, const Index ia=0) const
Vector view to diagonal elements.
void MatrixInverseAtPosition(MatrixView ret, const Index iv=0, const Index iz=0, const Index ia=0) const
Return the matrix inverse at the position.
bool FittingShape(ConstMatrixView x) const
Tests of the input matrix fits Propagation Matrix style.
bool IsZero(const Index iv=0, const Index iz=0, const Index ia=0) const
False if any non-zeroes in internal Matrix representation.
ConstVectorView K13(const Index iz=0, const Index ia=0) const
Vector view to K(0, 2) elements.
StokesVector & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
Vector y(Workspace &ws) noexcept
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.
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.
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Index stokes_dim(Workspace &ws) noexcept
PropagationMatrix & operator-=(ConstVectorView x)
Subtraction operator.
LazyScale< PropagationMatrix > operator*(const PropagationMatrix &pm, const Numeric &x)
Returns a lazy multiplier.
VectorView K13(const Index iz=0, const Index ia=0)
Vector view to K(0, 2) elements.
void RemoveAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Subtraction at position.
Array< ArrayOfArrayOfStokesVector > ArrayOfArrayOfArrayOfStokesVector
ConstVectorView K12(const Index iz=0, const Index ia=0) const
Vector view to K(0, 1) elements.
StokesVector & operator=(const Numeric &x)
Set this to constant value.
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.
PropagationMatrix & operator+=(ConstVectorView x)
Addition operator.
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.
void MultiplyAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Multiply operator at position.
std::ostream & operator<<(std::ostream &os, const PropagationMatrix &pm)
output operator
A constant view of a Tensor4.
void MultiplyAndAdd(const Numeric x, const PropagationMatrix &y)
Multiply input by scalar and add to this.
A class implementing complex numbers for ARTS.
PropagationMatrix(ConstTensor4View x)
Construct a new Propagation Matrix object.
PropagationMatrix(PropagationMatrix &&pm) noexcept
Construct a new Propagation Matrix object.
This can be used to make arrays out of anything.
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.
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.
VectorView K23(const Index iz=0, const Index ia=0)
Vector view to K(1, 2) elements.
ConstVectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0) const
Get a vectorview to the position.
PropagationMatrix & operator+=(const LazyScale< PropagationMatrix > &lpms)
Addition operator.
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.
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.
Index NumberOfZenithAngles() const
The number of zenith angles of the propagation matrix.
StokesVector(const StokesVector &a, const StokesVector &b, const Numeric &scale=0.5)
Construct a new Stokes Vector as a scale between two others.
void SetAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.
StokesVector(ConstVectorView x)
Construct a new Stokes Vector object.
void MultiplyAndAdd(const Numeric x, const PropagationMatrix &y)
Add a scaled version of the input.
VectorView K12(const Index iz=0, const Index ia=0)
Vector view to K(0, 1) elements.
PropagationMatrix & operator*=(const PropagationMatrix &other)
Multiply operator.
StokesVector(ConstTensor4View x)
Construct a new Propagation Matrix object.
PropagationMatrix & operator-=(const Numeric &x)
Subtraction operator.
PropagationMatrix & operator+=(const PropagationMatrix &other)
Addition operator.
PropagationMatrix & operator+=(const Numeric &x)
Addition operator.
VectorView K34(const Index iz=0, const Index ia=0)
Vector view to K(2, 3) elements.
const base & bas
A const reference to a value.
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.
Array< PropagationMatrix > ArrayOfPropagationMatrix
PropagationMatrix & operator/=(const Numeric &x)
Divide operator.
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.
Array< ArrayOfStokesVector > ArrayOfArrayOfStokesVector
Index ncols() const
Returns the number of columns.
Index NumberOfFrequencies() const
The number of frequencies of the propagation matrix.
NUMERIC Numeric
The type to use for all floating point numbers.
Index npages() const
Returns the number of pages.
Tensor4 & Data()
Get full view to data.
Index nbooks() const
Returns the number of books.
Index NumberOfNeededVectors() const
The number of required vectors to fill this StokesVector.
Index npages(Workspace &ws) noexcept
Array< ArrayOfPropagationMatrix > ArrayOfArrayOfPropagationMatrix
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 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.
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.
VectorView K14(const Index iz=0, const Index ia=0)
Vector view to K(0, 3) elements.
PropagationMatrix & operator/=(ConstVectorView x)
Divide operator.
A constant view of a Matrix.
PropagationMatrix & operator-=(const PropagationMatrix &other)
Subtraction operator.
Index nrows(Workspace &ws) noexcept
Index nrows() const
Returns the number of rows.
PropagationMatrix & operator*=(const Numeric &x)
Multiply operator.
void SetZero()
Sets all data to zero.
Array< StokesVector > ArrayOfStokesVector
const Numeric & scale
A const reference to a Numeric.
StokesVector & operator=(const PropagationMatrix &x)
Set *this from a Propagation matrix.
Index StokesDimensions() const
The stokes dimension of the propagation matrix.
void DivideAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
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.
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
StokesVector & operator+=(const PropagationMatrix &x)
Addition operator.
bool IsUnpolarized(const Index iv=0, const Index iz=0, const Index ia=0) const
Checks if vector is polarized.
PropagationMatrix & operator=(PropagationMatrix &&pm) noexcept
Move operator.
PropagationMatrix & operator*=(ConstVectorView x)
Multiply operator.
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.
void SetVectorType(bool vectortype)
Set the Vector Type object.
void GetTensor3(Tensor3View tensor3, const Index iz=0, const Index ia=0)
Get a Tensor3 object from this.
ConstVectorView K23(const Index iz=0, const Index ia=0) const
Vector view to K(1, 3) elements.
void DivideAtPosition(const Numeric &x, const Index iv=0, const Index iz=0, const Index ia=0)
Divide at position.
Vector x(Workspace &ws) noexcept
INDEX Index
The type to use for all integer numbers and indices.
void AddAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Addition at position operator.
Index ncols(Workspace &ws) noexcept
PropagationMatrix(ConstMatrixView x, const bool &assume_fit=false)
Initialize from single stokes_dim-by-stokes_dim matrix.
PropagationMatrix & operator=(const Numeric &x)
Sets all data to constant.
void SetAtPosition(ConstVectorView x, const Index iv=0, const Index iz=0, const Index ia=0)
A constant view of a Vector.
ConstVectorView K14(const Index iz=0, const Index ia=0) const
Vector view to K(0, 3) elements.
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 nbooks(Workspace &ws) noexcept
VectorView VectorAtPosition(const Index iv=0, const Index iz=0, const Index ia=0)
Get a vectorview to the position.
StokesVector & operator=(const LazyScale< PropagationMatrix > &lpms)
Set this lazily.
void SetAtPosition(const PropagationMatrix &x, const Index iv=0, const Index iz=0, const Index ia=0)
Set the At Position object.