LCOV - code coverage report
Current view: top level - components/SpectralComponents - SpectralElement2.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 42 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 3 0.0 %

          Line data    Source code
       1             : //# SpectralElement.cc: Describes (a set of related) spectral lines
       2             : //# Copyright (C) 2001,2004
       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 addressed 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             : //# $Id: SpectralElement.cc 21024 2011-03-01 11:46:18Z gervandiepen $
      27             : 
      28             : #include <components/SpectralComponents/CompiledSpectralElement.h>
      29             : #include <components/SpectralComponents/GaussianSpectralElement.h>
      30             : #include <components/SpectralComponents/GaussianMultipletSpectralElement.h>
      31             : #include <components/SpectralComponents/LorentzianSpectralElement.h>
      32             : #include <components/SpectralComponents/PolynomialSpectralElement.h>
      33             : #include <components/SpectralComponents/PowerLogPolynomialSpectralElement.h>
      34             : #include <casacore/casa/Exceptions/Error.h>
      35             : #include <casacore/casa/BasicMath/Math.h>
      36             : 
      37             : #include <iostream>
      38             : 
      39             : using namespace casacore;
      40             : namespace casa { //# NAMESPACE CASA - BEGIN
      41             : 
      42           0 : ostream &operator<<(ostream &os, const SpectralElement &elem) {
      43           0 :         switch (elem.getType()) {
      44           0 :         case SpectralElement::GAUSSIAN:
      45           0 :                 os << *dynamic_cast<const GaussianSpectralElement*>(&elem);
      46           0 :                 break;
      47           0 :         case SpectralElement::POLYNOMIAL:
      48           0 :                 os << *dynamic_cast<const PolynomialSpectralElement*>(&elem);
      49           0 :                 break;
      50           0 :         case SpectralElement::COMPILED:
      51             :         case SpectralElement::POWERLOGPOLY:
      52             :         case SpectralElement::LOGTRANSPOLY:
      53           0 :                 os << *dynamic_cast<const CompiledSpectralElement*>(&elem);
      54           0 :         break;
      55           0 :         case SpectralElement::GMULTIPLET:
      56           0 :                 os << *dynamic_cast<const GaussianMultipletSpectralElement*>(&elem);
      57           0 :                 break;
      58           0 :         case SpectralElement::LORENTZIAN:
      59           0 :                 os << *dynamic_cast<const LorentzianSpectralElement*>(&elem);
      60           0 :                 break;
      61           0 :         default:
      62           0 :                 throw AipsError("SpectralElement2::<<((): Logic Error. Unhandled spectral element type");
      63             :         }
      64           0 :         return os;
      65             : }
      66             : 
      67           0 : bool near(const SpectralElement& s1, const SpectralElement& s2, const double tol) {
      68           0 :         if (s1.getType() != s2.getType()) {
      69           0 :                 return false;
      70             :         }
      71           0 :         for (uInt j=0; j<s1.get().size(); j++) {
      72           0 :                 if (! casacore::near(s1.get()[j], s2.get()[j], tol)) {
      73           0 :                         return false;
      74             :                 }
      75           0 :                 if (! casacore::near(s1.getError()[j], s2.getError()[j], tol)) {
      76           0 :                         return false;
      77             :                 }
      78           0 :                 if (s1.fixed()[j] != s2.fixed()[j]) {
      79           0 :                         return false;
      80             :                 }
      81             :         }
      82           0 :         return true;
      83             : }
      84             : 
      85           0 : bool nearAbs(const SpectralElement& s1, const SpectralElement& s2, const Double tol) {
      86           0 :         if (s1.getType() != s2.getType()) {
      87           0 :                 return false;
      88             :         }
      89           0 :         for (uInt j=0; j<s1.get().size(); j++) {
      90           0 :                 if (! casacore::nearAbs(s1.get()[j], s2.get()[j], tol)) {
      91           0 :                         return false;
      92             :                 }
      93           0 :                 if (! casacore::nearAbs(s1.getError()[j], s2.getError()[j], tol)) {
      94           0 :                         return false;
      95             :                 }
      96           0 :                 if (s1.fixed()[j] != s2.fixed()[j]) {
      97           0 :                         return false;
      98             :                 }
      99             :         }
     100           0 :         return true;
     101             : }
     102             : 
     103             : 
     104             : 
     105             : } //# NAMESPACE CASA - END
     106             : 
     107             : 

Generated by: LCOV version 1.16