casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarshallableChebyshev.h
Go to the documentation of this file.
1 //# MarshalableChebyshev.h: a Marshallable Chebyshev polynomial
2 //# Copyright (C) 2002
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$
28 
29 #ifndef SCIMATH_MARSHALLABLECHEBYSHEV_H
30 #define SCIMATH_MARSHALLABLECHEBYSHEV_H
31 
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 
40 // <summary> A Chebyshev function class that supports serialization
41 // </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="wbrouw" date="2001/11/12" tests="tChebyshev" demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class=Function>Function</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // This class is named after Chebyshev Type I polynomials. "Marshallable"
54 // means that the class can be serialized into a form that can be transmitted
55 // to another execution context.
56 // </etymology>
57 //
58 // <synopsis>
59 // This class is a specialization of the Chebyshev class that supports
60 // serialization. That is, it allows one to write the state of the Chebyshev
61 // polynomial object into a Record. This record can then be transmitted
62 // to another execution context where it
63 // can be "reconstituted" as a new object with identical state as this one.
64 // This documentation focusses on this serialization functionality (also known
65 // as "marshalling"); for details about the general features of the Chebyshev
66 // polynomial series, see the <linkto class="Chebyshev">Chebyshev</linkto>
67 // class.
68 // </synopsis>
69 //
70 // <example>
71 // </example>
72 //
73 // <motivation>
74 // Making Chebyshev Marshallable provides a convenient way of configuring
75 // the simulator tool from .
76 // </motivation>
77 //
78 // <thrown>
79 // <li> Assertion in debug mode if attempt is made to address incorrect
80 // coefficients
81 // </thrown>
82 //
83 
84 template<class T>
85 class MarshallableChebyshev : public Chebyshev<T>,
86  public FunctionMarshallable
87 {
88 private:
89  static const String modenames[];
90 
91 public:
92  static const String FUNCTYPE;
93  static const String FUNCFIELDS[];
94 
95  // definitions of the fields stored in a serialized Record. The
96  // actual string names are stored in FUNCFIELDS
97  enum FieldNames {
98  // the array of coefficients
100  // the default mode
102  // the default value to use when mode=CONSTANT
104  // the 2-element double array
106  // the number of supported fields
108  };
109 
110  //# Constructors
111  // create a zero-th order Chebyshev polynomial with the first coefficient
112  // equal to zero. The bounded domain is [T(-1), T(1)]. The
113  // OutOfDomainMode is CONSTANT, and the default value is T(0).
116 
117  // create an n-th order Chebyshev polynomial with the coefficients
118  // equal to zero. The bounded domain is [T(-1), T(1)]. The
119  // OutOfDomainMode is CONSTANT, and the default value is T(0).
120  explicit MarshallableChebyshev(const uInt n) :
122 
123  // create a zero-th order Chebyshev polynomical with the first coefficient
124  // equal to one.
125  // min is the minimum value of its Chebyshev interval, and
126  // max is the maximum value.
127  // mode sets the behavior of the function outside the Chebyshev interval
128  // (see setOutOfIntervalMode() and OutOfIntervalMode enumeration
129  // definition for details).
130  // defval is the value returned when the function is evaluated outside
131  // the Chebyshev interval and mode=CONSTANT.
132  MarshallableChebyshev(const T &min, const T &max,
133  const typename ChebyshevEnums::
134  OutOfIntervalMode mode=ChebyshevEnums::CONSTANT,
135  const T &defval=T(0)) :
136  Chebyshev<T>(min, max, mode, defval), FunctionMarshallable(FUNCTYPE)
137  {}
138 
139  // create a fully specified Chebyshev polynomial.
140  // coeffs holds the coefficients of the Chebyshev polynomial (see
141  // setCoefficients() for details).
142  // min is the minimum value of its canonical range, and
143  // max is the maximum value.
144  // mode sets the behavior of the function outside the Chebyshev interval
145  // (see setOutOfIntervalMode() and OutOfIntervalMode enumeration
146  // definition for details).
147  // defval is the value returned when the function is evaluated outside
148  // the canonical range and mode=CONSTANT.
150  const T &min, const T &max,
151  const typename ChebyshevEnums::
152  OutOfIntervalMode mode=ChebyshevEnums::CONSTANT,
153  const T &defval=T(0)) :
154  Chebyshev<T>(coeffs, min, max, mode, defval),
156  {}
157 
158  // create a fully specified Chebyshev polynomial from parameters
159  // stored in a Record.
160  explicit MarshallableChebyshev(const Record& gr)
162 
163  // create a deep copy of another Chebyshev polynomial
164  // <group>
168  Chebyshev<T>(other), FunctionMarshallable(other) {}
169  // </group>
170 
171  // make a (deep) copy of another Chebyshev polynomial
172  // <group>
174  const MarshallableChebyshev<T> &other)
175  {
177  Chebyshev<T>::operator=(other);
178  return *this;
179  }
181  const Chebyshev<T> &other)
182  {
183  Chebyshev<T>::operator=(other);
184  return *this;
185  }
186  // </group>
187 
188  // Destructor
190 
191  // store the state of this Function into a Record
192  virtual void store(Record& gr) const;
193 
194  // Create a copy of this object. The caller is responsible for
195  // deleting the pointer.
196  virtual Function<T> *clone() const {
197  return new MarshallableChebyshev<T>(*this);
198  }
199 };
200 
201 
202 } //# NAMESPACE CASACORE - END
203 
204 #ifndef CASACORE_NO_AUTO_TEMPLATES
205 #include <casacore/scimath/Functionals/MarshallableChebyshev.tcc>
206 #endif //# CASACORE_NO_AUTO_TEMPLATES
207 #endif
MarshallableChebyshev()
create a zero-th order Chebyshev polynomial with the first coefficient equal to zero.
A 1-D Specialization of the Array class.
MarshallableChebyshev< T > & operator=(const MarshallableChebyshev< T > &other)
make a (deep) copy of another Chebyshev polynomial
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
return a constant, default value.
virtual ~MarshallableChebyshev()
Destructor.
Define enums for Chebyshev classes.
A function class that defines a Chebyshev polynomial.
Definition: Chebyshev.h:234
MarshallableChebyshev(const MarshallableChebyshev< T > &other)
MarshallableChebyshev(const Vector< T > &coeffs, const T &min, const T &max, const typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0))
create a fully specified Chebyshev polynomial.
a class for serializing/reconstituting Function objects to/from Records
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
virtual FunctionMarshallable & operator=(const FunctionMarshallable &other)
virtual Function< T > * clone() const
Create a copy of this object.
Chebyshev< T > & operator=(const Chebyshev< T > &other)
make this instance a (deep) copy of another Chebyshev polynomial
Definition: Chebyshev.h:298
A hierarchical collection of named fields of various types.
Definition: Record.h:180
FieldNames
definitions of the fields stored in a serialized Record.
MarshallableChebyshev< T > & operator=(const Chebyshev< T > &other)
A Chebyshev function class that supports serialization.
MarshallableChebyshev(const T &min, const T &max, const typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0))
create a zero-th order Chebyshev polynomical with the first coefficient equal to one.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
the default value to use when mode=CONSTANT
MarshallableChebyshev(const uInt n)
create an n-th order Chebyshev polynomial with the coefficients equal to zero.
MarshallableChebyshev(const Chebyshev< T > &other)
create a deep copy of another Chebyshev polynomial
unsigned int uInt
Definition: aipstype.h:51
virtual void store(Record &gr) const
store the state of this Function into a Record
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42