source: branches/casa-release-4_3/external-alma/components/SpectralComponents/SpectralList.h@ 3063

Last change on this file since 3063 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: 5.5 KB
Line 
1//# SpectralList.h: A set of SpectralElements
2//# Copyright (C) 2001
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//#
27//# $Id: SpectralList.h 21229 2012-04-02 12:00:20Z gervandiepen $
28
29#ifndef COMPONENTS_SPECTRALLIST_H
30#define COMPONENTS_SPECTRALLIST_H
31
32//# Includes
33#include <casa/aips.h>
34#include <casa/Containers/Block.h>
35
36namespace casa { //# NAMESPACE CASA - BEGIN
37
38//# Forward Declarations
39class SpectralElement;
40class RecordInterface;
41class String;
42template <class T> class Vector;
43
44// <summary>
45// A set of SpectralElements
46// </summary>
47
48// <use visibility=export>
49
50// <reviewed reviewer="" date="yyyy/mm/dd" tests="tSpectralFit" demos="">
51// </reviewed>
52
53// <prerequisite>
54// <li> <linkto class=SpectralElement>SpectralElement</linkto> class
55// </prerequisite>
56//
57// <etymology>
58// From spectral line and element list
59// </etymology>
60//
61// <synopsis>
62// The SpectralList class is a container for a set of spectral elements.
63//
64// The list can be used in the
65// <linkto class=SpectralFit>SpectralFit</linkto> class and in the
66// <linkto class=SpectralEstimate>SpectralEstimate</linkto> class.
67//
68// </synopsis>
69//
70// <example>
71// </example>
72//
73// <motivation>
74// To have a container for fitting of spectral profiles to an observed spectrum
75// </motivation>
76//
77// <todo asof="2001/02/04">
78// <li> add more profile types
79// </todo>
80
81class SpectralList {
82 public:
83
84 //# Constructors
85 // Default constructor creates an empty list
86 SpectralList();
87 // Construct a list with a maximum length of n (0: unlimited length)
88 explicit SpectralList(uInt nmax);
89 // Construct with an initial element
90 explicit SpectralList(const SpectralElement &in);
91 // Copy constructor (deep copy)
92 SpectralList(const SpectralList &other);
93
94 //#Destructor
95 // Destructor
96 ~SpectralList();
97
98 //# Operators
99 // Assignment (copy semantics)
100 SpectralList &operator=(const SpectralList &other);
101 // Evaluate the value of the sum of the elements at x
102 Double operator()(const Double x) const;
103 // Get element n
104 // <thrown>
105 // <li> AipsError if illegal n
106 // </thrown>
107 // <group>
108 const SpectralElement* operator[](const uInt n) const;
109 SpectralElement* operator[](const uInt n);
110 // </group>
111
112 //# Member functions
113 // Get the number of elements in list
114 uInt nelements() const { return list_p.nelements(); };
115
116 // Get the profile values for all elements in list. The evaluation
117 // is for the length of the given <src>prof</src>, assuming x values of
118 // 0,1,... if no x given.
119 // <group>
120 template <class MT>
121 void evaluate(Vector<MT> &y) const;
122 template <class MT>
123 void evaluate(Vector<MT> &y, const Vector<MT> &x) const;
124 // </group>
125
126 // Calculate the residuals at the points x; by subtracting the model from y.
127 // x=0,1,2,.. if not given.
128 // <thrown>
129 // <li> AipsError if y and x have different lengths
130 // </thrown>
131 // <group>
132 template <class MT>
133 void residual(Vector<MT> &y) const;
134 template <class MT>
135 void residual(Vector<MT> &y, const Vector<MT> &x) const;
136 // </group>
137
138 // Add elements to list (False if list has max length and full)
139 // <group>
140 Bool add(const SpectralElement &in);
141 Bool add(const SpectralList &in);
142 // </group>
143 // Insert in sort order in the list
144 // <group>
145 void insert(const SpectralElement &in);
146 void insert(const SpectralList &in);
147 // </group>
148 // Set an element in the list. Return False if more than one place beyond
149 // end of list; or if beyond max size.
150 Bool set(const SpectralElement &in, const uInt which);
151
152 // Clear the list
153 void clear();
154
155 // Set a maximum size of the list
156 void set(const uInt nmax);
157
158 // Sort the list on the first parameter (i.e. peak value for Gaussian)
159 void sort();
160
161 // Convert to and from a Record (see details in SpectralElement)
162 // <group>
163 Bool fromRecord (String& errMsg, const RecordInterface& container);
164 Bool toRecord(RecordInterface& container) const;
165 //</group>
166
167 private:
168 //#Data
169 // Max length allowed of list
170 uInt nmax_p;
171 // List of elements
172 PtrBlock<SpectralElement *> list_p;
173
174 //# Member functions
175 // Compare two elements
176 Int compar(const SpectralElement &p1, const SpectralElement &p2) const;
177
178};
179
180//# Global functions
181// <summary> Global functions </summary>
182// <group name=Output>
183// Output declaration
184std::ostream &operator<<(std::ostream &os, const SpectralList &lst);
185// </group>
186
187
188} //# NAMESPACE CASA - END
189
190#ifndef CASACORE_NO_AUTO_TEMPLATES
191#include <components/SpectralComponents/SpectralList2.tcc>
192#endif //# CASACORE_NO_AUTO_TEMPLATES
193#endif
Note: See TracBrowser for help on using the repository browser.