LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - VisVector.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 27 66 40.9 %
Date: 2023-11-06 10:06:49 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: aips2-request@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     1653493 : VisVector::VisVector(const VisType& vistype, const Bool& owner) :
      42     1653493 :   vistype_(vistype),
      43     1653493 :   owner_(owner),
      44             :   v0_(NULL),
      45             :   f0_(NULL),
      46             :   v_(NULL),
      47     3306986 :   f_(NULL)
      48             : {
      49     1653493 :   if (owner_) {
      50     3207231 :     v0_ = new Complex[vistype];
      51      658939 :     f0_ = new Bool[vistype];
      52      658939 :     origin();
      53             :   }
      54     1653493 : }
      55             : 
      56     3306986 : VisVector::~VisVector() {
      57     1653493 :   if (owner_) {
      58      658939 :     if (v0_) delete[] v0_;
      59      658939 :     if (f0_) delete[] f0_;
      60             :   }
      61     1653493 : }
      62             : 
      63         339 : void VisVector::setType(const VisVector::VisType& type) {
      64             : 
      65         339 :   vistype_=type;
      66             : 
      67         339 :   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         339 :   origin();
      75             : 
      76         339 : }
      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      329014 : VisVector::VisType visType(const Int& ncorr) {
     106             : 
     107      329014 :   switch (ncorr) {
     108      306837 :   case 4:
     109      306837 :     return VisVector::Four;
     110             :     break;
     111       22098 :   case 2:
     112       22098 :     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