LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - Jones.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 28 0.0 %
Date: 2024-10-10 15:00:01 Functions: 0 24 0.0 %

          Line data    Source code
       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: casa-feedback@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 <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/Mueller.h>
      36             : #include <synthesis/MeasurementComponents/VisVector.h>
      37             : 
      38             : namespace casa { //# NAMESPACE CASA - BEGIN
      39             : 
      40             : class Jones {
      41             :   
      42             : public:
      43             :   
      44             :   enum JonesType{General=4,GenLinear=3,Diagonal=2,Scalar=1};
      45             : 
      46             :   // Construct 
      47             :   Jones();
      48             :   
      49             :   // Dtor
      50           0 :   virtual ~Jones() {};
      51             :   
      52             :   // Return type id
      53           0 :   inline virtual JonesType type() const { return Jones::General; };
      54           0 :   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           0 :   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) { j0_=&mat; origin(); };
      64           0 :   inline void sync(casacore::Complex& mat, casacore::Bool& ok) { j0_=&mat; ok0_=&ok; origin(); };
      65             :   
      66             :   // Reset to origin
      67           0 :   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           0 :   inline void operator++(int) { j_+=typesize(); if (ok_) ok_+=typesize();};
      72             : 
      73             :   // Advance step matrices forward (according to typesize)
      74           0 :   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
     117             :   casacore::Complex *j0_;
     118             :   casacore::Bool *ok0_;
     119             :   
     120             :   // Moving pointer
     121             :   casacore::Complex *j_, *ji_;
     122             :   casacore::Bool *ok_, *oki_;
     123             : 
     124             :   // casacore::Complex unity, zero
     125             :   const casacore::Complex cOne_,cZero_;
     126             : 
     127             :   // Is data scalar?
     128             :   mutable casacore::Bool scalardata_;
     129             : 
     130             : private:
     131             : 
     132             :   // Zero the Jones matrix
     133             :   virtual void zero();
     134             : 
     135             :   // Temporary VisVector
     136             :   VisVector vtmp_;
     137             :   
     138             : };
     139             : 
     140             : 
     141             : class JonesGenLin : public Jones {
     142             :   
     143             : public:
     144             :   
     145             :   // Construct 
     146             :   JonesGenLin();
     147             :   
     148             :   // Dtor
     149           0 :   virtual ~JonesGenLin() {};
     150             :   
     151             :   // Return type id
     152           0 :   inline virtual JonesType type() const { return Jones::GenLinear; };
     153           0 :   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           0 :   virtual ~JonesDiag() {};
     204             :   
     205             :   // Return type id
     206           0 :   inline virtual JonesType type() const { return Jones::Diagonal; };
     207           0 :   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           0 :   virtual ~JonesScal() {};
     258             :   
     259             :   // Return type id
     260           0 :   inline virtual JonesType type() const { return Jones::Scalar; };
     261           0 :   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           0 :   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
     312             : Jones::JonesType jonesType(const casacore::Int& n);
     313             : 
     314             : // Return parameter count from 
     315           0 : inline casacore::Int jonesNPar(const Jones::JonesType& jtype) {
     316           0 :   switch (jtype) {
     317           0 :   case Jones::General:
     318           0 :     return 4;
     319             :     break;
     320           0 :   case Jones::GenLinear:
     321             :   case Jones::Diagonal:
     322           0 :     return 2;
     323             :     break;
     324           0 :   case Jones::Scalar:
     325           0 :     return 1;
     326             :     break;
     327             :   }
     328             :   // must return something
     329           0 :   return 0;
     330             : }
     331             : 
     332             : 
     333             : } //# NAMESPACE CASA - END
     334             : 
     335             : #endif
     336             : 
     337             : 

Generated by: LCOV version 1.16