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++) { 00054 v_[i]=vv.v_[i]; 00055 if (f0_ && vv.f0_) f_[i]=vv.f_[i]; 00056 } 00057 return *this; 00058 }; 00059 00060 // Set type id: 00061 void setType(const VisVector::VisType& type); 00062 00063 // Return type id 00064 inline VisType& type() { return vistype_; }; 00065 00066 // Reassign origin 00067 inline void sync(Complex& vis) { 00068 if (!owner_) {v0_=&vis; f0_=NULL; origin();} 00069 else {throw(AipsError("Illegal VisVector sync")); } 00070 }; 00071 00072 // Reassign origin 00073 inline void sync(Complex& vis, Bool& flag) { 00074 if (!owner_) {v0_=&vis; f0_=&flag; origin();} 00075 else {throw(AipsError("Illegal VisVector sync")); } 00076 }; 00077 00078 00079 // Go to origin 00080 inline void origin() {v_=v0_;f_=f0_;}; 00081 00082 // Increment to next vector 00083 // (use function pointers in ctor to handle owner_ case?) 00084 inline void operator++() { 00085 if (!owner_) {v_+=vistype_; if (f0_) f_+=vistype_;} 00086 else throw(AipsError("Illegal VisVector ++")); 00087 }; 00088 inline void operator++(int) { 00089 if (!owner_) {v_+=vistype_; if (f0_) f_+=vistype_;} 00090 else throw(AipsError("Illegal VisVector ++")); 00091 }; 00092 00093 // Advance step vectors forward 00094 inline void advance(const Int& step) { 00095 if (!owner_) {v_+=(step*vistype_); if (f0_) f_+=(step*vistype_);} 00096 else throw(AipsError("Illegal VisVector advance")); 00097 }; 00098 00099 // Re-order elements 00100 void polznMap(); 00101 void polznUnMap(); 00102 00103 inline void zero() { 00104 for (Int i=0;i<vistype_;i++) {v_[i]=Complex(0.0);if (f0_) f_[i]=True;} 00105 }; 00106 00107 // Print it out 00108 friend ostream& operator<<(ostream& os, const VisVector& vec); 00109 00110 // Give access to Mueller,Jones classes for application 00111 friend class Mueller; 00112 friend class MuellerDiag; 00113 friend class MuellerDiag2; 00114 friend class AddMuellerDiag; 00115 friend class AddMuellerDiag2; 00116 friend class MuellerScal; 00117 friend class Jones; 00118 friend class JonesGenLin; 00119 friend class JonesDiag; 00120 friend class JonesScal; 00121 00122 00123 00124 private: 00125 00126 // Default ctor private to avoid use 00127 VisVector() {}; 00128 00129 // VisVector length (4, 2, or 1) 00130 VisType vistype_; 00131 00132 // Does the VisVector own the storage, or are 00133 // we pointing to something external 00134 Bool owner_; 00135 00136 // Pointer to origin 00137 Complex *v0_; 00138 Bool *f0_; 00139 00140 // Moving pointer 00141 Complex *v_; 00142 Bool *f_; 00143 00144 00145 }; 00146 00147 // Globals: 00148 00149 // Return VisType according to length of data array corr axis 00150 VisVector::VisType visType(const Int& ncorr); 00151 00152 00153 } //# NAMESPACE CASA - END 00154 00155 #endif 00156 00157 00158