LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - VisVector.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 30 69 43.5 %
Date: 2024-12-11 20:54:31 Functions: 4 7 57.1 %

          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     1659036 : VisVector::VisVector(const VisType& vistype, const Bool& owner) :
      42     1659036 :   vistype_(vistype),
      43     1659036 :   owner_(owner),
      44     1659036 :   v0_(NULL),
      45     1659036 :   f0_(NULL),
      46     1659036 :   v_(NULL),
      47     1659036 :   f_(NULL)
      48             : {
      49     1659036 :   if (owner_) {
      50     3218211 :     v0_ = new Complex[vistype];
      51      661135 :     f0_ = new Bool[vistype];
      52      661135 :     origin();
      53             :   }
      54     1659036 : }
      55             : 
      56     1659036 : VisVector::~VisVector() {
      57     1659036 :   if (owner_) {
      58      661135 :     if (v0_) delete[] v0_;
      59      661135 :     if (f0_) delete[] f0_;
      60             :   }
      61     1659036 : }
      62             : 
      63         341 : void VisVector::setType(const VisVector::VisType& type) {
      64             : 
      65         341 :   vistype_=type;
      66             : 
      67         341 :   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         341 :   origin();
      75             : 
      76         341 : }
      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      330108 : VisVector::VisType visType(const Int& ncorr) {
     106             : 
     107      330108 :   switch (ncorr) {
     108      307929 :   case 4:
     109      307929 :     return VisVector::Four;
     110             :     break;
     111       22100 :   case 2:
     112       22100 :     return VisVector::Two;
     113             :     break;
     114          79 :   case 1:
     115          79 :     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             : 

Generated by: LCOV version 1.16