source: trunk/external-alma/components/SpectralComponents/test/tPowerLogPolynomialSpectralElement.cc@ 3146

Last change on this file since 3146 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: 2.3 KB
Line 
1//# tProfileFit1D.cc: test the ProfileFit1D class
2//# Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2004
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This program is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU General Public License as published by the Free
7//# Software Foundation; either version 2 of the License, or (at your option)
8//# any later version.
9//#
10//# This program 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 General Public License for
13//# more details.
14//#
15//# You should have received a copy of the GNU General Public License along
16//# with this program; if not, write to the Free Software Foundation, Inc.,
17//# 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
27#include <casa/aips.h>
28#include <casa/Arrays/ArrayMath.h>
29#include <casa/Containers/Record.h>
30#include <casa/Utilities/PtrHolder.h>
31#include <components/SpectralComponents/PowerLogPolynomialSpectralElement.h>
32#include <components/SpectralComponents/SpectralElementFactory.h>
33
34#include <casa/Utilities/Assert.h>
35#include <casa/Arrays/ArrayIO.h>
36
37#include <casa/Arrays/Vector.h>
38
39#include <casa/iostream.h>
40
41#include <casa/namespace.h>
42
43
44int main() {
45 {
46 try {
47 cout << "Test constructor" << endl;
48 Vector<Double> p(3);
49 p[0] = 5.5;
50 p[1] = 2.2;
51 p[2] = 3.3;
52 PowerLogPolynomialSpectralElement plp(p);
53 AlwaysAssert(near(plp(2), 123.36739264171082), AipsError);
54
55 cout << plp << endl;
56 AlwaysAssert(allTrue(plp.get() == p), AipsError);
57 cout << "Test to/from record" << endl;
58 Record rec;
59 plp.toRecord(rec);
60 PtrHolder<SpectralElement> el(SpectralElementFactory::fromRecord(rec));
61 plp = *dynamic_cast<PowerLogPolynomialSpectralElement *>(el.ptr());
62 AlwaysAssert(allTrue(plp.get() == p), AipsError);
63 }
64 catch (const AipsError& x) {
65 cout << x.getMesg() << endl;
66 return 1;
67 }
68 }
69
70 cout << "ok" << endl;
71 return 0;
72
73
74}
Note: See TracBrowser for help on using the repository browser.