source: trunk/external-alma/components/SpectralComponents/LogTransformedPolynomialSpectralElement.cc@ 3102

Last change on this file since 3102 was 2980, checked in by Malte Marquarding, 10 years ago

Add a copy of casacore/components/SpectralComponents to external-alma directory to prepare for its removal from casacore-trunk. DOn;t activate in SConscript yet.

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