Jones.h

Go to the documentation of this file.
00001 //# Jones.h: Definition of Jones
00002 //# Copyright (C) 1996,1997,2000,2001,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be adressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 
00028 #ifndef SYNTHESIS_JONES_H
00029 #define SYNTHESIS_JONES_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/Complex.h>
00033 #include <casa/iostream.h>
00034 #include <casa/Exceptions/Error.h>
00035 //#include <synthesis/MeasurementComponents/Mueller.h>
00036 #include <synthesis/MeasurementComponents/VisVector.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 class Jones {
00041   
00042 public:
00043   
00044   enum JonesType{General=4,GenLinear=3,Diagonal=2,Scalar=1};
00045 
00046   // Construct 
00047   Jones();
00048   
00049   // Dtor
00050   virtual ~Jones() {};
00051   
00052   // Return type id
00053   inline virtual JonesType type() const { return Jones::General; };
00054   inline virtual Int typesize() const { return 4; };
00055 
00056   // Set scalardata_ 
00057   //  TBD: Handle this better; for now, we need to set this from
00058   //       an external call so we handle single-corr data properly
00059   //       when setting non-corr-dep flags
00060   inline void setScalarData(Bool scalardata) const { scalardata_=scalardata; };
00061   
00062   // Synchronize with leading element in external array
00063   inline void sync(Complex& mat) { j0_=&mat; origin(); };
00064   inline void sync(Complex& mat, Bool& ok) { j0_=&mat; ok0_=&ok; origin(); };
00065   
00066   // Reset to origin
00067   inline void origin() {j_=j0_; ok_=ok0_;};
00068   
00069   // Increment to next matrix (according to type)
00070   inline void operator++()    { j_+=typesize(); if (ok_) ok_+=typesize();};
00071   inline void operator++(int) { j_+=typesize(); if (ok_) ok_+=typesize();};
00072 
00073   // Advance step matrices forward (according to typesize)
00074   inline void advance(const Int& step) { j_+=(step*typesize()); if (ok_) ok_+=(step*typesize());};
00075 
00076   // In-place invert
00077   virtual void invert();
00078 
00079   // Set matrix elements according to ok flag
00080   //   (so we don't have to check ok flags atomically in apply)
00081   virtual void setMatByOk();
00082 
00083   // In-place multipication with another Jones
00084   virtual void operator*=(const Jones& other);
00085 
00086   // Apply rightward to a VisVector
00087   virtual void applyRight(VisVector& v) const;
00088   virtual void applyRight(VisVector& v, Bool& vflag) const;
00089 
00090   // Apply leftward (transposed) to a VisVector 
00091   virtual void applyLeft(VisVector& v) const;
00092   virtual void applyLeft(VisVector& v, Bool& vflag) const;
00093 
00094   // Set flags according to solution flags
00095   virtual void applyFlag(Bool& vflag) const;
00096   virtual void flagRight(VisVector& v) const;
00097   virtual void flagLeft(VisVector& v) const;
00098 
00099   // print it out
00100   friend ostream& operator<<(ostream& os, const Jones& mat);
00101 
00102   // Give access to Mueller formation method
00103   friend class Mueller;
00104   friend class MuellerDiag;
00105   friend class MuellerDiag2;
00106   friend class MuellerScal;
00107     
00108   friend class JonesDiag;
00109   friend class JonesScal;
00110 
00111 protected:
00112   
00113   // Copy ctor protected 
00114   Jones(const Jones& mat);
00115 
00116   // Pointer to origin
00117   Complex *j0_;
00118   Bool *ok0_;
00119   
00120   // Moving pointer
00121   Complex *j_, *ji_;
00122   Bool *ok_, *oki_;
00123 
00124   // Complex unity, zero
00125   const Complex cOne_,cZero_;
00126 
00127   // Is data scalar?
00128   mutable Bool scalardata_;
00129 
00130 private:
00131 
00132   // Zero the Jones matrix
00133   virtual void zero();
00134 
00135   // Temporary VisVector
00136   VisVector vtmp_;
00137   
00138 };
00139 
00140 
00141 class JonesGenLin : public Jones {
00142   
00143 public:
00144   
00145   // Construct 
00146   JonesGenLin();
00147   
00148   // Dtor
00149   virtual ~JonesGenLin() {};
00150   
00151   // Return type id
00152   inline virtual JonesType type() const { return Jones::GenLinear; };
00153   inline virtual Int typesize() const { return 2; };
00154 
00155   // In-place invert
00156   virtual void invert();
00157 
00158   // Set matrix elements according to ok flag
00159   //   (so we don't have to check ok flags atomically in apply)
00160   virtual void setMatByOk();
00161 
00162   // In-place multipication with another Jones
00163   virtual void operator*=(const Jones& other);
00164 
00165   // Apply rightward to a VisVector
00166   virtual void applyRight(VisVector& v) const;
00167   virtual void applyRight(VisVector& v, Bool& vflag) const;
00168 
00169   // Apply leftward (transposed) to a VisVector
00170   virtual void applyLeft(VisVector& v) const;
00171   virtual void applyLeft(VisVector& v, Bool& vflag) const;
00172 
00173   // Set flags according to solution flags
00174   virtual void applyFlag(Bool& vflag) const;
00175   virtual void flagRight(VisVector& v) const;
00176   virtual void flagLeft(VisVector& v) const;
00177 
00178   // Give access to Mueller formation methods
00179   friend class MuellerDiag;
00180   friend class MuellerDiag2;
00181     
00182 protected:
00183   
00184   // Copy ctor protected 
00185   JonesGenLin(const JonesGenLin& mat);
00186 
00187 private:
00188 
00189   // Zero the Jones matrix
00190   virtual void zero();
00191 
00192 };
00193 
00194 
00195 class JonesDiag : public Jones {
00196   
00197 public:
00198   
00199   // Construct 
00200   JonesDiag();
00201   
00202   // Dtor
00203   virtual ~JonesDiag() {};
00204   
00205   // Return type id
00206   inline virtual JonesType type() const { return Jones::Diagonal; };
00207   inline virtual Int typesize() const { return 2; };
00208 
00209   // In-place invert
00210   virtual void invert();
00211 
00212   // Set matrix elements according to ok flag
00213   //   (so we don't have to check ok flags atomically in apply)
00214   virtual void setMatByOk();
00215 
00216   // In-place multipication with another Jones
00217   virtual void operator*=(const Jones& other);
00218 
00219   // Apply rightward to a VisVector
00220   virtual void applyRight(VisVector& v) const;
00221   virtual void applyRight(VisVector& v, Bool& vflag) const;
00222 
00223   // Apply leftward (transposed) to a VisVector
00224   virtual void applyLeft(VisVector& v) const;
00225   virtual void applyLeft(VisVector& v, Bool& vflag) const;
00226 
00227   // Set flags according to solution flags
00228   virtual void applyFlag(Bool& vflag) const;
00229   virtual void flagRight(VisVector& v) const;
00230   virtual void flagLeft(VisVector& v) const;
00231 
00232   // Give access to Mueller formation methods
00233   friend class MuellerDiag;
00234   friend class MuellerDiag2;
00235     
00236 protected:
00237   
00238   // Copy ctor protected 
00239   JonesDiag(const JonesDiag& mat);
00240 
00241 private:
00242 
00243   // Zero the Jones matrix
00244   virtual void zero();
00245 
00246 };
00247 
00248 
00249 class JonesScal : public JonesDiag {
00250   
00251 public:
00252   
00253   // Construct 
00254   JonesScal();
00255   
00256   // Dtor
00257   virtual ~JonesScal() {};
00258   
00259   // Return type id
00260   inline virtual JonesType type() const { return Jones::Scalar; };
00261   inline virtual Int typesize() const { return 1; };
00262 
00263   // In-place invert
00264   virtual void invert();
00265 
00266   // Set matrix elements according to ok flag
00267   //   (so we don't have to check ok flags atomically in apply)
00268   virtual void setMatByOk();
00269 
00270   // In-place multipication with another Jones
00271   virtual void operator*=(const Jones& other);
00272 
00273   // Apply rightward to a VisVector
00274   virtual void applyRight(VisVector& v) const;
00275   virtual void applyRight(VisVector& v, Bool& vflag) const;
00276 
00277   // Apply leftward (transposed) to a VisVector
00278   virtual void applyLeft(VisVector& v) const;
00279   virtual void applyLeft(VisVector& v, Bool& vflag) const;
00280 
00281   // Set flags according to solution flags
00282   virtual void applyFlag(Bool& vflag) const;
00283   virtual void flagRight(VisVector& v) const;
00284   virtual void flagLeft(VisVector& v) const { flagRight(v); };  // flagging commutes
00285 
00286   // Give access to Mueller formation methods
00287   friend class MuellerScal;
00288     
00289 protected:
00290   
00291   // Copy ctor protected 
00292   JonesScal(const JonesScal& mat);
00293 
00294 private:
00295 
00296   // Zero the Jones matrix
00297   virtual void zero();
00298 
00299 };
00300 
00301 
00302 // Global methods:
00303 
00304 // Factory method for creation of Jones
00305 Jones* createJones(const Jones::JonesType& jtype);
00306 
00307 // Apply a pair of Jones to a VisVector:
00308 void apply(const Jones& j1, VisVector& v, const Jones& j2);
00309 void apply(const Jones& j1, VisVector& v, const Jones& j2, Bool& vflag);
00310 
00311 // Return enum from integer
00312 Jones::JonesType jonesType(const Int& n);
00313 
00314 // Return parameter count from 
00315 inline Int jonesNPar(const Jones::JonesType& jtype) {
00316   switch (jtype) {
00317   case Jones::General:
00318     return 4;
00319     break;
00320   case Jones::GenLinear:
00321   case Jones::Diagonal:
00322     return 2;
00323     break;
00324   case Jones::Scalar:
00325     return 1;
00326     break;
00327   }
00328   // must return something
00329   return 0;
00330 }
00331 
00332 
00333 } //# NAMESPACE CASA - END
00334 
00335 #endif
00336 
00337 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1