LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - Mueller.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 14 32 43.8 %
Date: 2023-11-06 10:06:49 Functions: 12 28 42.9 %

          Line data    Source code
       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 <casacore/casa/aips.h>
      32             : #include <casacore/casa/BasicSL/Complex.h>
      33             : #include <iostream>
      34             : #include <casacore/casa/Exceptions/Error.h>
      35             : #include <synthesis/MeasurementComponents/VisVector.h>
      36             : #include <synthesis/MeasurementComponents/Jones.h>
      37             : 
      38             : namespace casa { //# NAMESPACE CASA - BEGIN
      39             : 
      40             : class Mueller {
      41             :   
      42             : public:
      43             :   
      44             :   enum MuellerType{AddDiag2=6,AddDiag=5,General=4,Diagonal=3,Diag2=2,Scalar=1};
      45             :  
      46             :   // Construct 
      47             :   Mueller();
      48             :   
      49             :   // Dtor
      50          31 :   virtual ~Mueller() {};
      51             :   
      52             :   // Return type id
      53           0 :   inline virtual MuellerType type() const { return Mueller::General; };
      54           0 :   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        4796 :   inline void setScalarData(casacore::Bool scalardata) const { scalardata_=scalardata; };
      61             :   
      62             :   // Synchronize with leading element in external array
      63           0 :   inline void sync(casacore::Complex& mat) { m0_=&mat; origin(); };
      64       31561 :   inline void sync(casacore::Complex& mat, casacore::Bool& ok) { m0_=&mat; ok0_=&ok; origin(); };
      65             :   
      66             :   // Reset to origin
      67       31561 :   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       51985 :   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
     106             :   casacore::Complex *m0_;
     107             :   casacore::Bool *ok0_;
     108             : 
     109             :   // Moving pointer
     110             :   casacore::Complex *m_, *mi_;
     111             :   casacore::Bool *ok_, *oki_;
     112             : 
     113             :   // casacore::Complex unity, zero (for use in invert and similar methods)
     114             :   const casacore::Complex cOne_,cZero_;
     115             : 
     116             :   mutable casacore::Bool scalardata_;
     117             : 
     118             : private: 
     119             : 
     120             :   // Zero the whole Mueller
     121             :   virtual void zero();
     122             : 
     123             :   // VisVector temporary (only relevant for Mueller::General)
     124             :   VisVector vtmp_;
     125             : 
     126             : 
     127             :   
     128             : };
     129             : 
     130             : class MuellerDiag : public Mueller {
     131             : 
     132             : public:
     133             :   
     134             :   // Construct 
     135             :   MuellerDiag();
     136             :   
     137             :   // Dtor
     138          31 :   virtual ~MuellerDiag() {};
     139             :   
     140             :   // Return type id
     141           0 :   inline virtual MuellerType type() const { return Mueller::Diagonal; };
     142           0 :   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          31 :   virtual ~MuellerDiag2() {};
     184             :   
     185             :   // Return type id
     186           0 :   inline virtual MuellerType type() const { return Mueller::Diag2; };
     187      103970 :   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           0 :   virtual ~MuellerScal() {};
     230             : 
     231             :   // Return type id
     232           0 :   inline virtual MuellerType type() const { return Mueller::Scalar; }
     233           0 :   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"
     268             : class AddMuellerDiag2 : public MuellerDiag2 {
     269             :   
     270             : public:
     271             : 
     272             :   // Construct 
     273             :   AddMuellerDiag2();
     274             : 
     275             :   // Dtor
     276          62 :   virtual ~AddMuellerDiag2() {};
     277             :   
     278             :   // Return type id
     279        4765 :   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           0 :   virtual ~AddMuellerDiag() {};
     310             :   
     311             :   // Return type id
     312           0 :   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
     344        9064 : inline casacore::Int muellerNPar(const Mueller::MuellerType& mtype) {
     345        9064 :   switch (mtype) {
     346           0 :   case Mueller::General:
     347           0 :     return 16;
     348             :     break;
     349           0 :   case Mueller::Diagonal:
     350             :   case Mueller::AddDiag:
     351           0 :     return 4;
     352             :     break;
     353        9064 :   case Mueller::Diag2:
     354             :   case Mueller::AddDiag2:
     355        9064 :     return 2;
     356             :     break;
     357           0 :   case Mueller::Scalar:
     358           0 :     return 1;
     359             :     break;
     360             :   }
     361             :   // must return something (shouldn't reach here)
     362           0 :   return 0;
     363             : }
     364             :     
     365             : 
     366             : // Return Mueller type according to underlying Jones and VisVector types
     367             : Mueller::MuellerType muellerType(const Jones::JonesType& jtype, const VisVector::VisType& vtype);
     368             : 
     369             : } //# NAMESPACE CASA - END
     370             : 
     371             : #endif
     372             : 

Generated by: LCOV version 1.16