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/LogTransformedPolynomialSpectralElement.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 | int main() { |
---|
44 | { |
---|
45 | try { |
---|
46 | cout << "Test constructor" << endl; |
---|
47 | Vector<Double> p(3); |
---|
48 | p[0] = log(5.5); |
---|
49 | p[1] = 2.2; |
---|
50 | p[2] = 3.3; |
---|
51 | LogTransformedPolynomialSpectralElement ltp(p); |
---|
52 | cout << "at 2 " << ltp(log(2)) << endl; |
---|
53 | AlwaysAssert(near(ltp(log(2)), 4.8151668354003698), AipsError); |
---|
54 | |
---|
55 | cout << ltp << endl; |
---|
56 | AlwaysAssert(allTrue(ltp.get() == p), AipsError); |
---|
57 | cout << "Test to/from record" << endl; |
---|
58 | Record rec; |
---|
59 | ltp.toRecord(rec); |
---|
60 | PtrHolder<SpectralElement> el(SpectralElementFactory::fromRecord(rec)); |
---|
61 | LogTransformedPolynomialSpectralElement ltp2 = *dynamic_cast<LogTransformedPolynomialSpectralElement *>(el.ptr()); |
---|
62 | AlwaysAssert(ltp == ltp2, 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 | } |
---|