casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Jones.h
Go to the documentation of this file.
1 //# Jones.h: Definition of Jones
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_JONES_H
29 #define SYNTHESIS_JONES_H
30 
31 #include <casa/aips.h>
32 #include <casa/BasicSL/Complex.h>
33 #include <casa/iostream.h>
34 #include <casa/Exceptions/Error.h>
35 //#include <synthesis/MeasurementComponents/Mueller.h>
37 
38 namespace casa { //# NAMESPACE CASA - BEGIN
39 
40 class Jones {
41 
42 public:
43 
45 
46  // Construct
47  Jones();
48 
49  // Dtor
50  virtual ~Jones() {};
51 
52  // Return type id
53  inline virtual JonesType type() const { return Jones::General; };
54  inline virtual casacore::Int typesize() const { return 4; };
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) { j0_=&mat; origin(); };
64  inline void sync(casacore::Complex& mat, casacore::Bool& ok) { j0_=&mat; ok0_=&ok; origin(); };
65 
66  // Reset to origin
67  inline void origin() {j_=j0_; ok_=ok0_;};
68 
69  // Increment to next matrix (according to type)
70  inline void operator++() { j_+=typesize(); if (ok_) ok_+=typesize();};
71  inline void operator++(int) { j_+=typesize(); if (ok_) ok_+=typesize();};
72 
73  // Advance step matrices forward (according to typesize)
74  inline void advance(const casacore::Int& step) { j_+=(step*typesize()); if (ok_) ok_+=(step*typesize());};
75 
76  // In-place invert
77  virtual void invert();
78 
79  // Set matrix elements according to ok flag
80  // (so we don't have to check ok flags atomically in apply)
81  virtual void setMatByOk();
82 
83  // In-place multipication with another Jones
84  virtual void operator*=(const Jones& other);
85 
86  // Apply rightward to a VisVector
87  virtual void applyRight(VisVector& v) const;
88  virtual void applyRight(VisVector& v, casacore::Bool& vflag) const;
89 
90  // Apply leftward (transposed) to a VisVector
91  virtual void applyLeft(VisVector& v) const;
92  virtual void applyLeft(VisVector& v, casacore::Bool& vflag) const;
93 
94  // Set flags according to solution flags
95  virtual void applyFlag(casacore::Bool& vflag) const;
96  virtual void flagRight(VisVector& v) const;
97  virtual void flagLeft(VisVector& v) const;
98 
99  // print it out
100  friend std::ostream& operator<<(std::ostream& os, const Jones& mat);
101 
102  // Give access to Mueller formation method
103  friend class Mueller;
104  friend class MuellerDiag;
105  friend class MuellerDiag2;
106  friend class MuellerScal;
107 
108  friend class JonesDiag;
109  friend class JonesScal;
110 
111 protected:
112 
113  // Copy ctor protected
114  Jones(const Jones& mat);
115 
116  // Pointer to origin
119 
120  // Moving pointer
123 
124  // casacore::Complex unity, zero
126 
127  // Is data scalar?
129 
130 private:
131 
132  // Zero the Jones matrix
133  virtual void zero();
134 
135  // Temporary VisVector
137 
138 };
139 
140 
141 class JonesGenLin : public Jones {
142 
143 public:
144 
145  // Construct
146  JonesGenLin();
147 
148  // Dtor
149  virtual ~JonesGenLin() {};
150 
151  // Return type id
152  inline virtual JonesType type() const { return Jones::GenLinear; };
153  inline virtual casacore::Int typesize() const { return 2; };
154 
155  // In-place invert
156  virtual void invert();
157 
158  // Set matrix elements according to ok flag
159  // (so we don't have to check ok flags atomically in apply)
160  virtual void setMatByOk();
161 
162  // In-place multipication with another Jones
163  virtual void operator*=(const Jones& other);
164 
165  // Apply rightward to a VisVector
166  virtual void applyRight(VisVector& v) const;
167  virtual void applyRight(VisVector& v, casacore::Bool& vflag) const;
168 
169  // Apply leftward (transposed) to a VisVector
170  virtual void applyLeft(VisVector& v) const;
171  virtual void applyLeft(VisVector& v, casacore::Bool& vflag) const;
172 
173  // Set flags according to solution flags
174  virtual void applyFlag(casacore::Bool& vflag) const;
175  virtual void flagRight(VisVector& v) const;
176  virtual void flagLeft(VisVector& v) const;
177 
178  // Give access to Mueller formation methods
179  friend class MuellerDiag;
180  friend class MuellerDiag2;
181 
182 protected:
183 
184  // Copy ctor protected
185  JonesGenLin(const JonesGenLin& mat);
186 
187 private:
188 
189  // Zero the Jones matrix
190  virtual void zero();
191 
192 };
193 
194 
195 class JonesDiag : public Jones {
196 
197 public:
198 
199  // Construct
200  JonesDiag();
201 
202  // Dtor
203  virtual ~JonesDiag() {};
204 
205  // Return type id
206  inline virtual JonesType type() const { return Jones::Diagonal; };
207  inline virtual casacore::Int typesize() const { return 2; };
208 
209  // In-place invert
210  virtual void invert();
211 
212  // Set matrix elements according to ok flag
213  // (so we don't have to check ok flags atomically in apply)
214  virtual void setMatByOk();
215 
216  // In-place multipication with another Jones
217  virtual void operator*=(const Jones& other);
218 
219  // Apply rightward to a VisVector
220  virtual void applyRight(VisVector& v) const;
221  virtual void applyRight(VisVector& v, casacore::Bool& vflag) const;
222 
223  // Apply leftward (transposed) to a VisVector
224  virtual void applyLeft(VisVector& v) const;
225  virtual void applyLeft(VisVector& v, casacore::Bool& vflag) const;
226 
227  // Set flags according to solution flags
228  virtual void applyFlag(casacore::Bool& vflag) const;
229  virtual void flagRight(VisVector& v) const;
230  virtual void flagLeft(VisVector& v) const;
231 
232  // Give access to Mueller formation methods
233  friend class MuellerDiag;
234  friend class MuellerDiag2;
235 
236 protected:
237 
238  // Copy ctor protected
239  JonesDiag(const JonesDiag& mat);
240 
241 private:
242 
243  // Zero the Jones matrix
244  virtual void zero();
245 
246 };
247 
248 
249 class JonesScal : public JonesDiag {
250 
251 public:
252 
253  // Construct
254  JonesScal();
255 
256  // Dtor
257  virtual ~JonesScal() {};
258 
259  // Return type id
260  inline virtual JonesType type() const { return Jones::Scalar; };
261  inline virtual casacore::Int typesize() const { return 1; };
262 
263  // In-place invert
264  virtual void invert();
265 
266  // Set matrix elements according to ok flag
267  // (so we don't have to check ok flags atomically in apply)
268  virtual void setMatByOk();
269 
270  // In-place multipication with another Jones
271  virtual void operator*=(const Jones& other);
272 
273  // Apply rightward to a VisVector
274  virtual void applyRight(VisVector& v) const;
275  virtual void applyRight(VisVector& v, casacore::Bool& vflag) const;
276 
277  // Apply leftward (transposed) to a VisVector
278  virtual void applyLeft(VisVector& v) const;
279  virtual void applyLeft(VisVector& v, casacore::Bool& vflag) const;
280 
281  // Set flags according to solution flags
282  virtual void applyFlag(casacore::Bool& vflag) const;
283  virtual void flagRight(VisVector& v) const;
284  virtual void flagLeft(VisVector& v) const { flagRight(v); }; // flagging commutes
285 
286  // Give access to Mueller formation methods
287  friend class MuellerScal;
288 
289 protected:
290 
291  // Copy ctor protected
292  JonesScal(const JonesScal& mat);
293 
294 private:
295 
296  // Zero the Jones matrix
297  virtual void zero();
298 
299 };
300 
301 
302 // Global methods:
303 
304 // Factory method for creation of Jones
305 Jones* createJones(const Jones::JonesType& jtype);
306 
307 // Apply a pair of Jones to a VisVector:
308 void apply(const Jones& j1, VisVector& v, const Jones& j2);
309 void apply(const Jones& j1, VisVector& v, const Jones& j2, casacore::Bool& vflag);
310 
311 // Return enum from integer
313 
314 // Return parameter count from
316  switch (jtype) {
317  case Jones::General:
318  return 4;
319  break;
320  case Jones::GenLinear:
321  case Jones::Diagonal:
322  return 2;
323  break;
324  case Jones::Scalar:
325  return 1;
326  break;
327  }
328  // must return something
329  return 0;
330 }
331 
332 
333 } //# NAMESPACE CASA - END
334 
335 #endif
336 
337 
const casacore::Complex cOne_
casacore::Complex unity, zero
Definition: Jones.h:125
casacore::Bool scalardata_
Is data scalar?
Definition: Jones.h:128
virtual void applyFlag(casacore::Bool &vflag) const
Set flags according to solution flags.
int Int
Definition: aipstype.h:50
Jones()
Construct.
casacore::Bool * ok_
Definition: Jones.h:122
void origin()
Reset to origin.
Definition: Jones.h:67
virtual JonesType type() const
Return type id.
Definition: Jones.h:152
void operator++(int)
Definition: Jones.h:71
virtual void flagRight(VisVector &v) const
void sync(casacore::Complex &mat)
Synchronize with leading element in external array.
Definition: Jones.h:63
void sync(casacore::Complex &mat, casacore::Bool &ok)
Definition: Jones.h:64
virtual void flagLeft(VisVector &v) const
Definition: Jones.h:284
virtual void applyRight(VisVector &v) const
Apply rightward to a VisVector.
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.
VisVector vtmp_
Temporary VisVector.
Definition: Jones.h:136
void apply(const Jones &j1, VisVector &v, const Jones &j2)
Apply a pair of Jones to a VisVector:
friend std::ostream & operator<<(std::ostream &os, const Jones &mat)
print it out
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: Jones.h:60
virtual void operator*=(const Jones &other)
In-place multipication with another Jones.
virtual void zero()
Zero the Jones matrix.
virtual void applyLeft(VisVector &v) const
Apply leftward (transposed) to a VisVector.
JonesGenLin()
Construct.
virtual void zero()
Zero the Jones matrix.
JonesScal()
Construct.
virtual ~Jones()
Dtor.
Definition: Jones.h:50
virtual casacore::Int typesize() const
Definition: Jones.h:153
casacore::Bool * ok0_
Definition: Jones.h:118
virtual void applyFlag(casacore::Bool &vflag) const
Set flags according to solution flags.
virtual void applyLeft(VisVector &v) const
Apply leftward (transposed) to a VisVector.
virtual void operator*=(const Jones &other)
In-place multipication with another Jones.
casacore::Int jonesNPar(const Jones::JonesType &jtype)
Return parameter count from.
Definition: Jones.h:315
virtual void invert()
In-place invert.
casacore::Complex * j0_
Pointer to origin.
Definition: Jones.h:117
Jones::JonesType jonesType(const casacore::Int &n)
Return enum from integer.
virtual void flagRight(VisVector &v) const
virtual ~JonesDiag()
Dtor.
Definition: Jones.h:203
virtual void zero()
Zero the Jones matrix.
virtual void zero()
Zero the Jones matrix.
void operator++()
Increment to next matrix (according to type)
Definition: Jones.h:70
virtual void operator*=(const Jones &other)
In-place multipication with another Jones.
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 applyRight(VisVector &v) const
Apply rightward to a VisVector.
virtual void flagLeft(VisVector &v) const
virtual void flagLeft(VisVector &v) const
casacore::Complex * j_
Moving pointer.
Definition: Jones.h:121
virtual void applyFlag(casacore::Bool &vflag) const
Set flags according to solution flags.
virtual casacore::Int typesize() const
Definition: Jones.h:54
virtual void applyFlag(casacore::Bool &vflag) const
Set flags according to solution flags.
casacore::Bool * oki_
Definition: Jones.h:122
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void applyRight(VisVector &v) const
Apply rightward to a VisVector.
casacore::Complex * ji_
Definition: Jones.h:121
virtual void flagRight(VisVector &v) const
virtual ~JonesScal()
Dtor.
Definition: Jones.h:257
JonesDiag()
Construct.
virtual void operator*=(const Jones &other)
In-place multipication with another Jones.
virtual JonesType type() const
Return type id.
Definition: Jones.h:206
Jones * createJones(const Jones::JonesType &jtype)
Global methods:
virtual casacore::Int typesize() const
Definition: Jones.h:261
virtual casacore::Int typesize() const
Definition: Jones.h:207
const casacore::Complex cZero_
Definition: Jones.h:125
virtual void applyLeft(VisVector &v) const
Apply leftward (transposed) to a VisVector.
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.
virtual JonesType type() const
Return type id.
Definition: Jones.h:53
void advance(const casacore::Int &step)
Advance step matrices forward (according to typesize)
Definition: Jones.h:74
virtual void applyRight(VisVector &v) const
Apply rightward to a VisVector.
virtual void flagRight(VisVector &v) const
virtual void flagLeft(VisVector &v) const
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.
virtual void applyLeft(VisVector &v) const
Apply leftward (transposed) to a VisVector.
virtual JonesType type() const
Return type id.
Definition: Jones.h:260
virtual ~JonesGenLin()
Dtor.
Definition: Jones.h:149