casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mueller.h
Go to the documentation of this file.
1 //# Mueller.h: Definition of Mueller
2 //# Copyright (C) 1996,1997,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be adressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 
28 #ifndef SYNTHESIS_MUELLER_H
29 #define SYNTHESIS_MUELLER_H
30 
31 #include <casa/aips.h>
32 #include <casa/BasicSL/Complex.h>
33 #include <casa/iostream.h>
34 #include <casa/Exceptions/Error.h>
37 
38 namespace casa { //# NAMESPACE CASA - BEGIN
39 
40 class Mueller {
41 
42 public:
43 
45 
46  // Construct
47  Mueller();
48 
49  // Dtor
50  virtual ~Mueller() {};
51 
52  // Return type id
53  inline virtual MuellerType type() const { return Mueller::General; };
54  inline virtual casacore::uInt typesize() const { return 16; };
55 
56  // Set scalardata_
57  // TBD: Handle this better; for now, we need to set this from
58  // an external call so we handle single-corr data properly
59  // when setting non-corr-dep flags
60  inline void setScalarData(casacore::Bool scalardata) const { scalardata_=scalardata; };
61 
62  // Synchronize with leading element in external array
63  inline void sync(casacore::Complex& mat) { m0_=&mat; origin(); };
64  inline void sync(casacore::Complex& mat, casacore::Bool& ok) { m0_=&mat; ok0_=&ok; origin(); };
65 
66  // Reset to origin
67  inline void origin() {m_=m0_;ok_=ok0_;};
68 
69  // Increment to next vector (according to len)
70  inline void operator++() { m_+=typesize(); if (ok_) ok_+=typesize();};
71  inline void operator++(int) { m_+=typesize(); if (ok_) ok_+=typesize();};
72 
73  // Advance step matrices forward (according to len)
74  inline void advance(const casacore::Int& step) { m_+=(step*typesize()); if (ok_) ok_+=(step*typesize());};
75 
76  // Formation from Jones matrix outer product: General version
77  virtual void fromJones(const Jones& jones1, const Jones& jones2);
78 
79  // In-place invert
80  virtual void invert();
81 
82  // Set matrix elements according to ok flag
83  // (so we don't have to check ok flags atomically in apply)
84  virtual void setMatByOk();
85 
86  // In-place multiply onto a VisVector: General version
87  virtual void apply(VisVector& v);
88  virtual void apply(VisVector& v, casacore::Bool& vflag);
89 
90  // Apply only flags according to cal flags
91  virtual void applyFlag(casacore::Bool& vflag);
92  virtual void flag(VisVector& v);
93 
94  // Multiply onto a vis VisVector, preserving input (copy then in-place apply)
95  virtual void apply(VisVector& out, const VisVector& in);
96 
97  // print it out
98  friend std::ostream& operator<<(std::ostream& os, const Mueller& mat);
99 
100 protected:
101 
102  // Copy ctor protected
103  Mueller(const Mueller& mat);
104 
105  // Pointer to origin
108 
109  // Moving pointer
112 
113  // casacore::Complex unity, zero (for use in invert and similar methods)
115 
117 
118 private:
119 
120  // Zero the whole Mueller
121  virtual void zero();
122 
123  // VisVector temporary (only relevant for Mueller::General)
125 
126 
127 
128 };
129 
130 class MuellerDiag : public Mueller {
131 
132 public:
133 
134  // Construct
135  MuellerDiag();
136 
137  // Dtor
138  virtual ~MuellerDiag() {};
139 
140  // Return type id
141  inline virtual MuellerType type() const { return Mueller::Diagonal; };
142  inline virtual casacore::uInt typesize() const { return 4; };
143 
144  // Formation from Jones matrix outer product: optimized Diagonal version
145  virtual void fromJones(const Jones& jones1, const Jones& jones2);
146 
147  // In-place invert
148  virtual void invert();
149 
150  // Set matrix elements according to ok flag
151  // (so we don't have to check ok flags atomically in apply)
152  virtual void setMatByOk();
153 
154  // In-place multiply onto a VisVector: optimized Diagonal version
155  virtual void apply(VisVector& v);
156  virtual void apply(VisVector& v, casacore::Bool& vflag);
157  using Mueller::apply;
158 
159  // Apply only flags according to cal flags
160  virtual void applyFlag(casacore::Bool& vflag);
161  virtual void flag(VisVector& v);
162 
163 protected:
164 
165  // Default/Copy ctors are protected
166  MuellerDiag(const MuellerDiag& mat);
167 
168 private:
169 
170  // Zero the whole Mueller
171  virtual void zero();
172 
173 };
174 
175 class MuellerDiag2 : public MuellerDiag {
176 
177 public:
178 
179  // Construct
180  MuellerDiag2();
181 
182  // Dtor
183  virtual ~MuellerDiag2() {};
184 
185  // Return type id
186  inline virtual MuellerType type() const { return Mueller::Diag2; };
187  inline virtual casacore::uInt typesize() const { return 2; };
188 
189  // Formation from Jones matrix outer product: optimized Diag2 version
190  virtual void fromJones(const Jones& jones1, const Jones& jones2);
191 
192  // In-place invert
193  virtual void invert();
194 
195  // Set matrix elements according to ok flag
196  // (so we don't have to check ok flags atomically in apply)
197  virtual void setMatByOk();
198 
199  // In-place multiply onto a VisVector: optimized Diag2 version
200  virtual void apply(VisVector& v);
201  virtual void apply(VisVector& v, casacore::Bool& vflag);
202  using MuellerDiag::apply;
203 
204  // Apply only flags according to cal flags
205  virtual void applyFlag(casacore::Bool& vflag);
206  virtual void flag(VisVector& v);
207 
208 protected:
209 
210  // Default/Copy ctors are protected
211  MuellerDiag2(const MuellerDiag2& mat);
212 
213 private:
214 
215  // Zero the whole Mueller
216  virtual void zero();
217 
218 };
219 
220 
221 class MuellerScal : public MuellerDiag {
222 
223 public:
224 
225  // Construct
226  MuellerScal();
227 
228  // Dtor
229  virtual ~MuellerScal() {};
230 
231  // Return type id
232  inline virtual MuellerType type() const { return Mueller::Scalar; }
233  inline virtual casacore::uInt typesize() const { return 1; };
234 
235  // Formation from Jones matrix outer product: optimized Scalar version
236  virtual void fromJones(const Jones& jones1, const Jones& jones2);
237 
238  // In-place invert
239  virtual void invert();
240 
241  // Set matrix elements according to ok flag
242  // (so we don't have to check ok flags atomically in apply)
243  virtual void setMatByOk();
244 
245  // In-place multiply onto a VisVector: optimized Scalar version
246  virtual void apply(VisVector& v);
247  virtual void apply(VisVector& v, casacore::Bool& vflag);
248  using MuellerDiag::apply;
249 
250  // Apply only flags according to cal flags
251  virtual void applyFlag(casacore::Bool& vflag);
252  virtual void flag(VisVector& v);
253 
254 protected:
255 
256  // Default/Copy ctors are protected
257  MuellerScal(const MuellerScal& mat);
258 
259 private:
260 
261  // Zero the whole Mueller
262  virtual void zero();
263 
264 };
265 
266 
267 // Parallel-hands only "additive Mueller"
269 
270 public:
271 
272  // Construct
273  AddMuellerDiag2();
274 
275  // Dtor
276  virtual ~AddMuellerDiag2() {};
277 
278  // Return type id
279  inline virtual MuellerType type() const { return Mueller::AddDiag2; };
280 
281  // In-place invert (negate)
282  virtual void invert();
283 
284  // Set matrix elements according to ok flag
285  // (so we don't have to check ok flags atomically in apply)
286  virtual void setMatByOk();
287 
288  // In-place add onto a VisVector: optimized Diag2 version
289  virtual void apply(VisVector& v);
290  using MuellerDiag2::apply;
291 
292 protected:
293 
294  // Default/Copy ctors are protected
295  AddMuellerDiag2(const AddMuellerDiag2& mat);
296 
297 };
298 
299 
300 // Full polarization "additive Mueller"
301 class AddMuellerDiag : public MuellerDiag {
302 
303 public:
304 
305  // Construct
306  AddMuellerDiag();
307 
308  // Dtor
309  virtual ~AddMuellerDiag() {};
310 
311  // Return type id
312  inline virtual MuellerType type() const { return Mueller::AddDiag; };
313 
314  // In-place invert (negate)
315  virtual void invert();
316 
317  // Set matrix elements according to ok flag
318  // (so we don't have to check ok flags atomically in apply)
319  virtual void setMatByOk();
320 
321  // In-place add onto a VisVector:
322  virtual void apply(VisVector& v);
323  using MuellerDiag::apply;
324 
325 protected:
326 
327  // Default/Copy ctors are protected
328  AddMuellerDiag(const AddMuellerDiag& mat);
329 
330 };
331 
332 
333 
334 
335 // Globals
336 
337 // Factory method
338 Mueller* createMueller(const Mueller::MuellerType& mtype);
339 
340 // Return Mueller type according to Int
341 //Mueller::MuellerType muellerType(const casacore::Int& n);
342 
343 // Return parameter count according to type
345  switch (mtype) {
346  case Mueller::General:
347  return 16;
348  break;
349  case Mueller::Diagonal:
350  case Mueller::AddDiag:
351  return 4;
352  break;
353  case Mueller::Diag2:
354  case Mueller::AddDiag2:
355  return 2;
356  break;
357  case Mueller::Scalar:
358  return 1;
359  break;
360  }
361  // must return something (shouldn't reach here)
362  return 0;
363 }
364 
365 
366 // Return Mueller type according to underlying Jones and VisVector types
368 
369 } //# NAMESPACE CASA - END
370 
371 #endif
372 
void sync(casacore::Complex &mat, casacore::Bool &ok)
Definition: Mueller.h:64
virtual void invert()
In-place invert.
virtual ~MuellerDiag()
Dtor.
Definition: Mueller.h:138
VisVector vtmp_
VisVector temporary (only relevant for Mueller::General)
Definition: Mueller.h:124
MuellerDiag2()
Construct.
int Int
Definition: aipstype.h:50
MuellerScal()
Construct.
void operator++()
Increment to next vector (according to len)
Definition: Mueller.h:70
virtual casacore::uInt typesize() const
Definition: Mueller.h:54
virtual void fromJones(const Jones &jones1, const Jones &jones2)
Formation from Jones matrix outer product: optimized Scalar version.
virtual casacore::uInt typesize() const
Definition: Mueller.h:233
void operator++(int)
Definition: Mueller.h:71
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
virtual ~Mueller()
Dtor.
Definition: Mueller.h:50
virtual void zero()
Zero the whole Mueller.
virtual ~MuellerScal()
Dtor.
Definition: Mueller.h:229
virtual void apply(VisVector &v)
In-place add onto a VisVector:
casacore::Bool * ok0_
Definition: Mueller.h:107
virtual void invert()
In-place invert.
casacore::Complex * mi_
Definition: Mueller.h:110
Parallel-hands only &quot;additive Mueller&quot;.
Definition: Mueller.h:268
virtual ~MuellerDiag2()
Dtor.
Definition: Mueller.h:183
AddMuellerDiag()
Construct.
virtual void fromJones(const Jones &jones1, const Jones &jones2)
Formation from Jones matrix outer product: optimized Diagonal version.
Full polarization &quot;additive Mueller&quot;.
Definition: Mueller.h:301
virtual void flag(VisVector &v)
virtual void apply(VisVector &v)
In-place multiply onto a VisVector: General version.
Mueller::MuellerType muellerType(const Jones::JonesType &jtype, const VisVector::VisType &vtype)
Return Mueller type according to underlying Jones and VisVector types.
casacore::Bool * ok_
Definition: Mueller.h:111
virtual casacore::uInt typesize() const
Definition: Mueller.h:187
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:141
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:232
MuellerDiag()
Construct.
void origin()
Reset to origin.
Definition: Mueller.h:67
virtual ~AddMuellerDiag2()
Dtor.
Definition: Mueller.h:276
casacore::Complex * m0_
Pointer to origin.
Definition: Mueller.h:106
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:186
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
virtual void zero()
Zero the whole Mueller.
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:312
virtual void invert()
In-place invert.
casacore::Complex * m_
Moving pointer.
Definition: Mueller.h:110
virtual void apply(VisVector &v)
In-place add onto a VisVector: optimized Diag2 version.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Mueller()
Construct.
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
Mueller * createMueller(const Mueller::MuellerType &mtype)
Globals.
virtual void applyFlag(casacore::Bool &vflag)
Apply only flags according to cal flags.
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
friend std::ostream & operator<<(std::ostream &os, const Mueller &mat)
print it out
virtual void invert()
In-place invert (negate)
casacore::Int muellerNPar(const Mueller::MuellerType &mtype)
Return Mueller type according to Int Mueller::MuellerType muellerType(const casacore::Int&amp; n); ...
Definition: Mueller.h:344
casacore::Bool scalardata_
Definition: Mueller.h:116
void sync(casacore::Complex &mat)
Synchronize with leading element in external array.
Definition: Mueller.h:63
void setScalarData(casacore::Bool scalardata) const
Set scalardata_ TBD: Handle this better; for now, we need to set this from an external call so we han...
Definition: Mueller.h:60
virtual void fromJones(const Jones &jones1, const Jones &jones2)
Formation from Jones matrix outer product: optimized Diag2 version.
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:279
virtual void zero()
Zero the whole Mueller.
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
AddMuellerDiag2()
Construct.
virtual void applyFlag(casacore::Bool &vflag)
Apply only flags according to cal flags.
virtual void applyFlag(casacore::Bool &vflag)
Apply only flags according to cal flags.
virtual void applyFlag(casacore::Bool &vflag)
Apply only flags according to cal flags.
virtual void flag(VisVector &v)
virtual void apply(VisVector &v)
In-place multiply onto a VisVector: optimized Diagonal version.
virtual MuellerType type() const
Return type id.
Definition: Mueller.h:53
const casacore::Complex cZero_
Definition: Mueller.h:114
virtual casacore::uInt typesize() const
Definition: Mueller.h:142
virtual void fromJones(const Jones &jones1, const Jones &jones2)
Formation from Jones matrix outer product: General version.
virtual void apply(VisVector &v)
In-place multiply onto a VisVector: optimized Diag2 version.
casacore::Bool * oki_
Definition: Mueller.h:111
virtual void invert()
In-place invert.
const casacore::Complex cOne_
casacore::Complex unity, zero (for use in invert and similar methods)
Definition: Mueller.h:114
virtual void flag(VisVector &v)
void advance(const casacore::Int &step)
Advance step matrices forward (according to len)
Definition: Mueller.h:74
virtual ~AddMuellerDiag()
Dtor.
Definition: Mueller.h:309
virtual void setMatByOk()
Set matrix elements according to ok flag (so we don&#39;t have to check ok flags atomically in apply) ...
virtual void invert()
In-place invert (negate)
virtual void flag(VisVector &v)
unsigned int uInt
Definition: aipstype.h:51
virtual void zero()
Zero the whole Mueller.
virtual void apply(VisVector &v)
In-place multiply onto a VisVector: optimized Scalar version.