Mueller.h

Go to the documentation of this file.
00001 //# Mueller.h: Definition of Mueller
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_MUELLER_H
00029 #define SYNTHESIS_MUELLER_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/VisVector.h>
00036 #include <synthesis/MeasurementComponents/Jones.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 class Mueller {
00041   
00042 public:
00043   
00044   enum MuellerType{AddDiag2=6,AddDiag=5,General=4,Diagonal=3,Diag2=2,Scalar=1};
00045  
00046   // Construct 
00047   Mueller();
00048   
00049   // Dtor
00050   virtual ~Mueller() {};
00051   
00052   // Return type id
00053   inline virtual MuellerType type() const { return Mueller::General; };
00054   inline virtual uInt typesize() const { return 16; };
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) { m0_=&mat; origin(); };
00064   inline void sync(Complex& mat, Bool& ok) { m0_=&mat; ok0_=&ok; origin(); };
00065   
00066   // Reset to origin
00067   inline void origin() {m_=m0_;ok_=ok0_;};
00068   
00069   // Increment to next vector (according to len)
00070   inline void operator++()    { m_+=typesize(); if (ok_) ok_+=typesize();};
00071   inline void operator++(int) { m_+=typesize(); if (ok_) ok_+=typesize();};
00072 
00073   // Advance step matrices forward (according to len)
00074   inline void advance(const Int& step) { m_+=(step*typesize()); if (ok_) ok_+=(step*typesize());};
00075 
00076   // Formation from Jones matrix outer product: General version
00077   virtual void fromJones(const Jones& jones1, const Jones& jones2);
00078 
00079   // In-place invert
00080   virtual void invert();
00081 
00082   // Set matrix elements according to ok flag
00083   //  (so we don't have to check ok flags atomically in apply)
00084   virtual void setMatByOk();
00085 
00086   // In-place multiply onto a VisVector: General version
00087   virtual void apply(VisVector& v);
00088   virtual void apply(VisVector& v, Bool& vflag);
00089 
00090   // Apply only flags according to cal flags
00091   virtual void applyFlag(Bool& vflag);
00092   virtual void flag(VisVector& v);
00093 
00094   // Multiply onto a vis VisVector, preserving input (copy then in-place apply)
00095   virtual void apply(VisVector& out, const VisVector& in);
00096 
00097   // print it out
00098   friend ostream& operator<<(ostream& os, const Mueller& mat);
00099     
00100 protected:
00101   
00102   // Copy ctor protected 
00103   Mueller(const Mueller& mat);
00104 
00105   // Pointer to origin
00106   Complex *m0_;
00107   Bool *ok0_;
00108 
00109   // Moving pointer
00110   Complex *m_, *mi_;
00111   Bool *ok_, *oki_;
00112 
00113   // Complex unity, zero (for use in invert and similar methods)
00114   const Complex cOne_,cZero_;
00115 
00116   mutable Bool scalardata_;
00117 
00118 private: 
00119 
00120   // Zero the whole Mueller
00121   virtual void zero();
00122 
00123   // VisVector temporary (only relevant for Mueller::General)
00124   VisVector vtmp_;
00125 
00126 
00127   
00128 };
00129 
00130 class MuellerDiag : public Mueller {
00131 
00132 public:
00133   
00134   // Construct 
00135   MuellerDiag();
00136   
00137   // Dtor
00138   virtual ~MuellerDiag() {};
00139   
00140   // Return type id
00141   inline virtual MuellerType type() const { return Mueller::Diagonal; };
00142   inline virtual uInt typesize() const { return 4; };
00143 
00144   // Formation from Jones matrix outer product: optimized Diagonal version
00145   virtual void fromJones(const Jones& jones1, const Jones& jones2);
00146   
00147   // In-place invert
00148   virtual void invert();
00149 
00150   // Set matrix elements according to ok flag
00151   //  (so we don't have to check ok flags atomically in apply)
00152   virtual void setMatByOk();
00153 
00154   // In-place multiply onto a VisVector: optimized Diagonal version
00155   virtual void apply(VisVector& v);
00156   virtual void apply(VisVector& v, Bool& vflag);
00157   using Mueller::apply;
00158 
00159   // Apply only flags according to cal flags
00160   virtual void applyFlag(Bool& vflag);
00161   virtual void flag(VisVector& v);
00162 
00163 protected:
00164   
00165   // Default/Copy ctors are protected 
00166   MuellerDiag(const MuellerDiag& mat);
00167 
00168 private: 
00169 
00170   // Zero the whole Mueller
00171   virtual void zero();
00172   
00173 };
00174 
00175 class MuellerDiag2 : public MuellerDiag {
00176   
00177 public:
00178 
00179   // Construct 
00180   MuellerDiag2();
00181 
00182   // Dtor
00183   virtual ~MuellerDiag2() {};
00184   
00185   // Return type id
00186   inline virtual MuellerType type() const { return Mueller::Diag2; };
00187   inline virtual uInt typesize() const { return 2; };
00188 
00189   // Formation from Jones matrix outer product: optimized Diag2 version
00190   virtual void fromJones(const Jones& jones1, const Jones& jones2);
00191   
00192   // In-place invert
00193   virtual void invert();
00194 
00195   // Set matrix elements according to ok flag
00196   //  (so we don't have to check ok flags atomically in apply)
00197   virtual void setMatByOk();
00198 
00199   // In-place multiply onto a VisVector: optimized Diag2 version
00200   virtual void apply(VisVector& v);
00201   virtual void apply(VisVector& v, Bool& vflag);
00202   using MuellerDiag::apply;
00203 
00204   // Apply only flags according to cal flags
00205   virtual void applyFlag(Bool& vflag);
00206   virtual void flag(VisVector& v);
00207 
00208 protected:
00209   
00210   // Default/Copy ctors are protected 
00211   MuellerDiag2(const MuellerDiag2& mat);
00212   
00213 private: 
00214 
00215   // Zero the whole Mueller
00216   virtual void zero();
00217 
00218 };
00219 
00220 
00221 class MuellerScal : public MuellerDiag {
00222  
00223 public:
00224 
00225   // Construct 
00226   MuellerScal();
00227 
00228   // Dtor
00229   virtual ~MuellerScal() {};
00230 
00231   // Return type id
00232   inline virtual MuellerType type() const { return Mueller::Scalar; }
00233   inline virtual uInt typesize() const { return 1; };
00234 
00235   // Formation from Jones matrix outer product: optimized Scalar version
00236   virtual void fromJones(const Jones& jones1, const Jones& jones2);
00237 
00238   // In-place invert
00239   virtual void invert();
00240 
00241   // Set matrix elements according to ok flag
00242   //  (so we don't have to check ok flags atomically in apply)
00243   virtual void setMatByOk();
00244 
00245   // In-place multiply onto a VisVector: optimized Scalar version
00246   virtual void apply(VisVector& v);
00247   virtual void apply(VisVector& v, Bool& vflag);
00248   using MuellerDiag::apply;
00249 
00250   // Apply only flags according to cal flags
00251   virtual void applyFlag(Bool& vflag);
00252   virtual void flag(VisVector& v);
00253 
00254 protected:
00255   
00256   // Default/Copy ctors are protected 
00257   MuellerScal(const MuellerScal& mat);
00258 
00259 private: 
00260 
00261   // Zero the whole Mueller
00262   virtual void zero();
00263 
00264 };
00265 
00266 
00267 // Parallel-hands only "additive Mueller"
00268 class AddMuellerDiag2 : public MuellerDiag2 {
00269   
00270 public:
00271 
00272   // Construct 
00273   AddMuellerDiag2();
00274 
00275   // Dtor
00276   virtual ~AddMuellerDiag2() {};
00277   
00278   // Return type id
00279   inline virtual MuellerType type() const { return Mueller::AddDiag2; };
00280 
00281   // In-place invert (negate)
00282   virtual void invert();
00283 
00284   // Set matrix elements according to ok flag
00285   //  (so we don't have to check ok flags atomically in apply)
00286   virtual void setMatByOk();
00287 
00288   // In-place add onto a VisVector: optimized Diag2 version
00289   virtual void apply(VisVector& v);
00290   using MuellerDiag2::apply;
00291 
00292 protected:
00293   
00294   // Default/Copy ctors are protected 
00295   AddMuellerDiag2(const AddMuellerDiag2& mat);
00296   
00297 };
00298 
00299 
00300 // Full polarization "additive Mueller"
00301 class AddMuellerDiag : public MuellerDiag {
00302   
00303 public:
00304 
00305   // Construct 
00306   AddMuellerDiag();
00307 
00308   // Dtor
00309   virtual ~AddMuellerDiag() {};
00310   
00311   // Return type id
00312   inline virtual MuellerType type() const { return Mueller::AddDiag; };
00313 
00314   // In-place invert (negate)
00315   virtual void invert();
00316 
00317   // Set matrix elements according to ok flag
00318   //  (so we don't have to check ok flags atomically in apply)
00319   virtual void setMatByOk();
00320 
00321   // In-place add onto a VisVector:
00322   virtual void apply(VisVector& v);
00323   using MuellerDiag::apply;
00324 
00325 protected:
00326   
00327   // Default/Copy ctors are protected 
00328   AddMuellerDiag(const AddMuellerDiag& mat);
00329   
00330 };
00331 
00332 
00333 
00334 
00335 // Globals
00336 
00337 // Factory method
00338 Mueller* createMueller(const Mueller::MuellerType& mtype);
00339 
00340 // Return Mueller type according to Int
00341 //Mueller::MuellerType muellerType(const Int& n);
00342 
00343 // Return parameter count according to type
00344 inline Int muellerNPar(const Mueller::MuellerType& mtype) {
00345   switch (mtype) {
00346   case Mueller::General:
00347     return 16;
00348     break;
00349   case Mueller::Diagonal:
00350   case Mueller::AddDiag:
00351     return 4;
00352     break;
00353   case Mueller::Diag2:
00354   case Mueller::AddDiag2:
00355     return 2;
00356     break;
00357   case Mueller::Scalar:
00358     return 1;
00359     break;
00360   }
00361   // must return something (shouldn't reach here)
00362   return 0;
00363 }
00364     
00365 
00366 // Return Mueller type according to underlying Jones and VisVector types
00367 Mueller::MuellerType muellerType(const Jones::JonesType& jtype, const VisVector::VisType& vtype);
00368 
00369 } //# NAMESPACE CASA - END
00370 
00371 #endif
00372 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1