Line data Source code
1 : //# VisVector.cc: Implementation 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 : #include <synthesis/MeasurementComponents/VisVector.h> 29 : 30 : #include <casacore/casa/aips.h> 31 : #include <casacore/casa/BasicSL/Complex.h> 32 : #include <casacore/casa/Arrays/Cube.h> 33 : #include <iostream> 34 : #include <casacore/casa/Exceptions/Error.h> 35 : #include <casacore/casa/namespace.h> 36 : 37 : 38 : using namespace casacore; 39 : namespace casa { //# NAMESPACE CASA - BEGIN 40 : 41 80 : VisVector::VisVector(const VisType& vistype, const Bool& owner) : 42 80 : vistype_(vistype), 43 80 : owner_(owner), 44 80 : v0_(NULL), 45 80 : f0_(NULL), 46 80 : v_(NULL), 47 80 : f_(NULL) 48 : { 49 80 : if (owner_) { 50 240 : v0_ = new Complex[vistype]; 51 48 : f0_ = new Bool[vistype]; 52 48 : origin(); 53 : } 54 80 : } 55 : 56 80 : VisVector::~VisVector() { 57 80 : if (owner_) { 58 48 : if (v0_) delete[] v0_; 59 48 : if (f0_) delete[] f0_; 60 : } 61 80 : } 62 : 63 32 : void VisVector::setType(const VisVector::VisType& type) { 64 : 65 32 : vistype_=type; 66 : 67 32 : if (owner_) { 68 0 : delete[] v0_; 69 0 : delete[] f0_; 70 0 : v0_ = new Complex[vistype_]; 71 0 : f0_ = new Bool[vistype_]; 72 : } 73 : 74 32 : origin(); 75 : 76 32 : } 77 : 78 0 : void VisVector::polznMap() { 79 0 : Complex vswap(v_[1]); 80 0 : v_[1]=v_[2]; 81 0 : v_[2]=v_[3]; 82 0 : v_[3]=vswap; 83 0 : if (f0_) { 84 0 : Bool fswap(f_[1]); 85 0 : f_[1]=f_[2]; 86 0 : f_[2]=f_[3]; 87 0 : f_[3]=fswap; 88 : } 89 0 : } 90 : 91 0 : void VisVector::polznUnMap() { 92 0 : Complex vswap(v_[3]); 93 0 : v_[3]=v_[2]; 94 0 : v_[2]=v_[1]; 95 0 : v_[1]=vswap; 96 0 : if (f0_) { 97 0 : Bool fswap(f_[3]); 98 0 : f_[3]=f_[2]; 99 0 : f_[2]=f_[1]; 100 0 : f_[1]=fswap; 101 : } 102 0 : } 103 : 104 : 105 32 : VisVector::VisType visType(const Int& ncorr) { 106 : 107 32 : switch (ncorr) { 108 0 : case 4: 109 0 : return VisVector::Four; 110 : break; 111 32 : case 2: 112 32 : return VisVector::Two; 113 : break; 114 0 : case 1: 115 0 : return VisVector::One; 116 : break; 117 0 : default: 118 0 : throw(AipsError("No such VisVector type")); 119 : } 120 : } 121 : 122 0 : ostream& operator<<(ostream& os, const VisVector& vec) { 123 : 124 : Complex *vi; 125 0 : vi=vec.v_; 126 0 : cout << "[" << *vi; 127 0 : ++vi; 128 0 : for (Int i=1;i<vec.vistype_;++i,++vi) cout << ", " << *vi; 129 0 : if (vec.f0_) { 130 0 : cout << " fl="; 131 : Bool *fi; 132 0 : fi=vec.f_; 133 0 : for (Int i=0;i<vec.vistype_;++i,++fi) cout << (*fi ? "T" : "F"); 134 : } 135 0 : cout << "]"; 136 0 : return os; 137 : } 138 : 139 : } //# NAMESPACE CASA - END 140 :