LCOV - code coverage report
Current view: top level - components/SpectralComponents - SpectralList2.tcc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 11 14 78.6 %
Date: 2024-11-06 17:42:47 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //# SpectralList2.cc: Member templates for SpectralList
       2             : //# Copyright (C) 2001,2002
       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: SpectralList2.tcc 19935 2007-02-27 05:07:40Z Malte.Marquarding $
      27             : 
      28             : //# Includes
      29             : #include <components/SpectralComponents/SpectralList.h>
      30             : 
      31             : #include <casacore/casa/Arrays/Vector.h>
      32             : #include <casacore/casa/Exceptions/Error.h>
      33             : #include <components/SpectralComponents/SpectralElement.h>
      34             : 
      35             : namespace casa { //# NAMESPACE CASA - BEGIN
      36             : 
      37             : //# Member templates
      38             : template <class MT>
      39             : void SpectralList::evaluate(casacore::Vector<MT> &y) const {
      40             :   for (casacore::uInt j=0; j<y.nelements(); j++) {
      41             :     if (list_p.nelements() > 0) y(j) = (*list_p[0])(j);
      42             :     else y(j) = 0;
      43             :   };
      44             :   for (casacore::uInt i=1; i<list_p.nelements(); i++) {
      45             :     for (casacore::uInt j=0; j<y.nelements(); j++) y(j) += (*list_p[i])(j);
      46             :   };
      47             : }
      48             : 
      49             : template <class MT>
      50      529069 : void SpectralList::evaluate(casacore::Vector<MT> &y, const casacore::Vector<MT> &x) const {
      51      529069 :   y.resize(x.nelements());
      52    21686846 :   for (casacore::uInt j=0; j<x.nelements(); j++) {
      53    21157777 :     if (list_p.nelements() > 0) y(j) = (*list_p[0])(x(j));
      54           0 :     else y(j) = 0;
      55             :   };
      56      529069 :   for (casacore::uInt i=1; i<list_p.nelements(); i++) {
      57           0 :     for (casacore::uInt j=0; j<x.nelements(); j++) y(j) += (*list_p[i])(x(j));
      58             :   };
      59      529069 : }
      60             : 
      61             : template <class MT>
      62             : void SpectralList::residual(casacore::Vector<MT> &y) const {
      63             :   for (casacore::uInt i=0; i<list_p.nelements(); i++) {
      64             :     for (casacore::uInt j=0; j<y.nelements(); j++) y(j) -= (*list_p[i])(j);
      65             :   };
      66             : }
      67             : 
      68             : template <class MT>
      69      529097 : void SpectralList::residual(casacore::Vector<MT> &y, const casacore::Vector<MT> &x) const {
      70      529097 :   if (x.nelements() != y.nelements()) {
      71           0 :     throw(casacore::AipsError("Unequal lengths in arguments SpectralList::residual"));
      72             :   };
      73     1058194 :   for (casacore::uInt i=0; i<list_p.nelements(); i++) {
      74    21687080 :     for (casacore::uInt j=0; j<x.nelements(); j++) y(j) -= (*list_p[i])(x(j));
      75             :   };
      76      529097 : }
      77             : 
      78             : } //# NAMESPACE CASA - END
      79             : 

Generated by: LCOV version 1.16