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: 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 : //# $Id: SpectralElement.cc 21024 2011-03-01 11:46:18Z gervandiepen $ 27 : 28 : #include <components/SpectralComponents/LogTransformedPolynomialSpectralElement.h> 29 : #include <casacore/casa/Exceptions/Error.h> 30 : #include <iostream> 31 : 32 : #define _ORIGIN String("LogTransformedPolynomialSpectralElement::") + __FUNCTION__ + ":" + String::toString(__LINE__) + ": " 33 : 34 : 35 : using namespace casacore; 36 : namespace casa { //# NAMESPACE CASA - BEGIN 37 : 38 : 39 0 : LogTransformedPolynomialSpectralElement::LogTransformedPolynomialSpectralElement( 40 : uInt order 41 0 : ) : PolynomialSpectralElement(order) { 42 0 : ThrowIf( 43 : order == 0, 44 : "order must be greater than zero." 45 : ); 46 0 : _setType(SpectralElement::LOGTRANSPOLY); 47 0 : } 48 : 49 0 : LogTransformedPolynomialSpectralElement::LogTransformedPolynomialSpectralElement( 50 : const Vector<Double>& param 51 0 : ) : PolynomialSpectralElement(param) { 52 0 : set(param); 53 0 : _setType(SpectralElement::LOGTRANSPOLY); 54 0 : } 55 : 56 0 : LogTransformedPolynomialSpectralElement::LogTransformedPolynomialSpectralElement( 57 : const LogTransformedPolynomialSpectralElement &other 58 0 : ) : PolynomialSpectralElement(other) {} 59 : 60 0 : LogTransformedPolynomialSpectralElement::~LogTransformedPolynomialSpectralElement() {} 61 : 62 0 : LogTransformedPolynomialSpectralElement& LogTransformedPolynomialSpectralElement::operator=( 63 : const LogTransformedPolynomialSpectralElement& other 64 : ) { 65 0 : if (this != &other) { 66 0 : PolynomialSpectralElement::operator=(other); 67 : } 68 0 : return *this; 69 : } 70 : 71 0 : SpectralElement* LogTransformedPolynomialSpectralElement::clone() const { 72 0 : return new LogTransformedPolynomialSpectralElement(*this); 73 : } 74 : 75 0 : ostream &operator<<( 76 : ostream &os, const LogTransformedPolynomialSpectralElement &elem 77 : ) { 78 0 : os << SpectralElement::fromType((elem.getType())) << " element: " << endl; 79 0 : uInt degree = elem.getDegree(); 80 0 : os << " Degree: " << degree << endl; 81 0 : os << " Function: ln(y) = ln(c0) "; 82 0 : ostringstream ss; 83 0 : Vector<Double> c = elem.get(); 84 0 : ss << "c0: " << exp(c[0]) << endl; 85 0 : for (uInt i=1; i<=degree; i++) { 86 0 : os << " + c" << i << "*ln(x)"; 87 0 : if (i > 1) { 88 0 : os << "**" << i; 89 : } 90 0 : ss << "c" << i << ": " << c[i] << endl; 91 : } 92 0 : os << endl; 93 0 : os << ss.str(); 94 0 : return os; 95 : } 96 : } 97 :