Line data Source code
1 : //# VisVector.h: Definition of VisVector 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_VISVECTOR_H 29 : #define SYNTHESIS_VISVECTOR_H 30 : 31 : #include <casacore/casa/aips.h> 32 : #include <casacore/casa/BasicSL/Complex.h> 33 : #include <casacore/casa/Arrays/Cube.h> 34 : #include <iostream> 35 : #include <casacore/casa/Exceptions/Error.h> 36 : 37 : namespace casa { //# NAMESPACE CASA - BEGIN 38 : 39 : class VisVector { 40 : 41 : public: 42 : 43 : enum VisType{One=1, Two=2, Four=4}; 44 : 45 : // Construct from length 46 : VisVector(const VisType& len, const casacore::Bool& owner=false); 47 : 48 : // Dtor 49 : ~VisVector(); 50 : 51 : // Assignment (data copy) 52 0 : inline VisVector& operator=(const VisVector& vv) { 53 0 : for (casacore::Int i=0;i<vistype_;i++) { 54 0 : v_[i]=vv.v_[i]; 55 0 : if (f0_ && vv.f0_) f_[i]=vv.f_[i]; 56 : } 57 0 : return *this; 58 : }; 59 : 60 : // Set type id: 61 : void setType(const VisVector::VisType& type); 62 : 63 : // Return type id 64 0 : inline VisType& type() { return vistype_; }; 65 : 66 : // Reassign origin 67 0 : inline void sync(casacore::Complex& vis) { 68 0 : if (!owner_) {v0_=&vis; f0_=NULL; origin();} 69 0 : else {throw(casacore::AipsError("Illegal VisVector sync")); } 70 0 : }; 71 : 72 : // Reassign origin 73 0 : inline void sync(casacore::Complex& vis, casacore::Bool& flag) { 74 0 : if (!owner_) {v0_=&vis; f0_=&flag; origin();} 75 0 : else {throw(casacore::AipsError("Illegal VisVector sync")); } 76 0 : }; 77 : 78 : 79 : // Go to origin 80 0 : inline void origin() {v_=v0_;f_=f0_;}; 81 : 82 : // Increment to next vector 83 : // (use function pointers in ctor to handle owner_ case?) 84 : inline void operator++() { 85 : if (!owner_) {v_+=vistype_; if (f0_) f_+=vistype_;} 86 : else throw(casacore::AipsError("Illegal VisVector ++")); 87 : }; 88 0 : inline void operator++(int) { 89 0 : if (!owner_) {v_+=vistype_; if (f0_) f_+=vistype_;} 90 0 : else throw(casacore::AipsError("Illegal VisVector ++")); 91 0 : }; 92 : 93 : // Advance step vectors forward 94 0 : inline void advance(const casacore::Int& step) { 95 0 : if (!owner_) {v_+=(step*vistype_); if (f0_) f_+=(step*vistype_);} 96 0 : else throw(casacore::AipsError("Illegal VisVector advance")); 97 0 : }; 98 : 99 : // Re-order elements 100 : void polznMap(); 101 : void polznUnMap(); 102 : 103 0 : inline void zero() { 104 0 : for (casacore::Int i=0;i<vistype_;i++) {v_[i]=casacore::Complex(0.0);if (f0_) f_[i]=true;} 105 0 : }; 106 : 107 : // Print it out 108 : friend std::ostream& operator<<(std::ostream& os, const VisVector& vec); 109 : 110 : // Give access to Mueller,Jones classes for application 111 : friend class Mueller; 112 : friend class MuellerDiag; 113 : friend class MuellerDiag2; 114 : friend class AddMuellerDiag; 115 : friend class AddMuellerDiag2; 116 : friend class MuellerScal; 117 : friend class Jones; 118 : friend class JonesGenLin; 119 : friend class JonesDiag; 120 : friend class JonesScal; 121 : 122 : 123 : 124 : private: 125 : 126 : // Default ctor private to avoid use 127 : VisVector() {}; 128 : 129 : // VisVector length (4, 2, or 1) 130 : VisType vistype_; 131 : 132 : // Does the VisVector own the storage, or are 133 : // we pointing to something external 134 : casacore::Bool owner_; 135 : 136 : // Pointer to origin 137 : casacore::Complex *v0_; 138 : casacore::Bool *f0_; 139 : 140 : // Moving pointer 141 : casacore::Complex *v_; 142 : casacore::Bool *f_; 143 : 144 : 145 : }; 146 : 147 : // Globals: 148 : 149 : // Return VisType according to length of data array corr axis 150 : VisVector::VisType visType(const casacore::Int& ncorr); 151 : 152 : 153 : } //# NAMESPACE CASA - END 154 : 155 : #endif 156 : 157 : 158 :