casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VisVector.h
Go to the documentation of this file.
00001 //# VisVector.h: Definition of VisVector
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_VISVECTOR_H
00029 #define SYNTHESIS_VISVECTOR_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/Complex.h>
00033 #include <casa/Arrays/Cube.h>
00034 #include <casa/iostream.h>
00035 #include <casa/Exceptions/Error.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 class VisVector {
00040   
00041 public:
00042   
00043   enum VisType{One=1, Two=2, Four=4};
00044   
00045   // Construct from length 
00046   VisVector(const VisType& len, const Bool& owner=False);
00047 
00048   // Dtor
00049   ~VisVector();
00050 
00051   // Assignment (data copy)
00052   inline VisVector& operator=(const VisVector& vv) {
00053     for (Int i=0;i<vistype_;i++) v_[i]=vv.v_[i];
00054     return *this;
00055   };
00056 
00057   // Set type id:
00058   void setType(const VisVector::VisType& type);
00059 
00060   // Return type id
00061   inline VisType& type() { return vistype_; };
00062   
00063   // Reassign origin
00064   inline void sync(Complex& vis) { 
00065     if (!owner_)  {v0_=&vis; origin();}
00066     else          {throw(AipsError("Illegal VisVector sync")); }
00067   };
00068   
00069   // Go to origin
00070   inline void origin() {v_=v0_;};
00071   
00072   // Increment to next vector
00073   //  (use function pointers in ctor to handle owner_ case?)
00074   inline void operator++() { 
00075     if (!owner_)  v_+=vistype_;
00076     else          throw(AipsError("Illegal VisVector ++")); 
00077   };
00078   inline void operator++(int) { 
00079     if (!owner_)  v_+=vistype_;
00080     else          throw(AipsError("Illegal VisVector ++")); 
00081   };
00082 
00083   // Advance step vectors forward
00084   inline void advance(const Int& step) { 
00085     if (!owner_)  v_+=(step*vistype_);
00086     else          throw(AipsError("Illegal VisVector advance")); 
00087   };
00088 
00089 
00090   // Re-order elements
00091   void polznMap();
00092   void polznUnMap();
00093 
00094   inline void zero() { for (Int i=0;i<vistype_;i++) v_[i]=Complex(0.0); };
00095 
00096   // Print it out
00097   friend ostream& operator<<(ostream& os, const VisVector& vec);
00098 
00099   // Give access to Mueller,Jones classes for application
00100   friend class Mueller;
00101   friend class MuellerDiag;
00102   friend class MuellerDiag2;
00103   friend class AddMuellerDiag;
00104   friend class AddMuellerDiag2;
00105   friend class MuellerScal;
00106   friend class Jones;
00107   friend class JonesGenLin;
00108   friend class JonesDiag;
00109   friend class JonesScal;
00110 
00111 
00112   
00113 private:
00114 
00115   // Default ctor private to avoid use
00116   VisVector() {};
00117 
00118   // VisVector length (4, 2, or 1)
00119   VisType vistype_;
00120   
00121   Bool owner_;
00122 
00123   // Pointer to origin
00124   Complex *v0_;
00125   
00126   // Moving pointer
00127   Complex *v_;
00128   
00129 };
00130 
00131 // Globals:
00132 
00133 // Return VisType according to length of data array corr axis
00134 VisVector::VisType visType(const Int& ncorr);
00135 
00136 
00137 } //# NAMESPACE CASA - END
00138 
00139 #endif
00140 
00141 
00142