casacore
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::Interpolate1D< Domain, Range > Class Template Reference

More...

#include <Interpolate1D.h>

Public Types

enum  Method {
  nearestNeighbour ,
  linear ,
  cubic ,
  spline
}
 The different interpolation methods are enumerated here. More...
 
- Public Types inherited from casacore::Function1D< Domain, Range >
typedef const Domain * FunctionArg
 
- Public Types inherited from casacore::Function< T, U >
typedef FunctionTraits< T >::ArgType ArgType
 
typedef const ArgTypeFunctionArg
 

Public Member Functions

 Interpolate1D ()
 The default constructor generates a useless object until the setData function has been called. More...
 
 Interpolate1D (const SampledFunctional< Domain > &x, const SampledFunctional< Range > &y, const Bool sorted=False, const Bool uniq=False)
 Construct an object with the specified data. More...
 
void setData (const SampledFunctional< Domain > &x, const SampledFunctional< Range > &y, const Bool sorted=False, const Bool uniq=False)
 Define a new data set for the class to operate on. More...
 
 Interpolate1D (const Interpolate1D< Domain, Range > &other)
 The standard copy constructor, assignment operator and destructor. More...
 
Interpolate1D< Domain, Range > & operator= (const Interpolate1D< Domain, Range > &other)
 
 ~Interpolate1D ()
 
virtual const Stringname () const
 Name of function. More...
 
virtual Range eval (typename Function1D< Domain, Range >::FunctionArg x) const
 Interpolation is done using the () operator (see example above). More...
 
uInt getMethod () const
 inquire/set the current interpolation method. More...
 
void setMethod (uInt method)
 
Vector< Domain > getX () const
 Access the data set that interpolation is done over. More...
 
Vector< Range > getY () const
 
virtual Function< Domain, Range > * clone () const
 A function to copy the Interpolate1D object. More...
 
- Public Member Functions inherited from casacore::Function1D< Domain, Range >
 Function1D ()
 Constructors. More...
 
 Function1D (const uInt n)
 
 Function1D (const Vector< Domain > &in)
 
 Function1D (const FunctionParam< Domain > &other)
 
 Function1D (const Function1D< W, X > &other)
 
virtual ~Function1D ()
 Destructor. More...
 
virtual uInt ndim () const
 Returns the number of dimensions of function. More...
 
- Public Member Functions inherited from casacore::Function< T, U >
 Function ()
 Constructors. More...
 
 Function (const uInt n)
 
 Function (const Vector< T > &in)
 
 Function (const FunctionParam< T > &other)
 
template<class W , class X >
 Function (const Function< W, X > &other)
 
virtual ~Function ()
 Destructor. More...
 
uInt nparameters () const
 Returns the number of parameters. More...
 
virtual U eval (FunctionArg x) const =0
 Evaluate the function object. More...
 
T & operator[] (const uInt n)
 Manipulate the nth parameter (0-based) with no index check. More...
 
const T & operator[] (const uInt n) const
 
virtual U operator() () const
 Evaluate this function object at xor at x, y. More...
 
virtual U operator() (const ArgType &x) const
 
virtual U operator() (const Vector< ArgType > &x) const
 
virtual U operator() (FunctionArg x) const
 
virtual U operator() (const ArgType &x, const ArgType &y) const
 
virtual U operator() (const ArgType &x, const ArgType &y, const ArgType &z) const
 
Boolmask (const uInt n)
 Manipulate the mask associated with the nth parameter (e.g. More...
 
const Boolmask (const uInt n) const
 
const FunctionParam< T > & parameters () const
 Return the parameter interface. More...
 
FunctionParam< T > & parameters ()
 
const Vector< ArgType > & argp () const
 Get arg_p and parset_p. More...
 
Bool parsetp () const
 
void lockParam ()
 Compiler cannot always find the correct 'const' version of parameter access. More...
 
void unlockParam ()
 
virtual void setMode (const RecordInterface &mode)
 get/set the function mode. More...
 
virtual void getMode (RecordInterface &mode) const
 
virtual Bool hasMode () const
 return True if the implementing function supports a mode. More...
 
ostream & print (ostream &os) const
 Print the function (i.e. More...
 
virtual Function< typename FunctionTraits< T >::DiffType > * cloneAD () const
 
virtual Function< typename FunctionTraits< T >::BaseType > * cloneNonAD () const
 
- Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, T >
virtual ~Functional ()
 Destructor. More...
 
virtual T operator() (const FunctionTraits< T >::ArgType &x) const=0
 Map a Domain x into a Range y value. More...
 
- Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, T >
virtual ~Functional ()
 Destructor. More...
 
virtual T operator() (const Vector< FunctionTraits< T >::ArgType > &x) const=0
 Map a Domain x into a Range y value. More...
 

Private Member Functions

Range polynomialInterpolation (const Domain x, uInt n, uInt offset) const
 A private function for doing polynomial interpolation. More...
 

Private Attributes

uInt curMethod
 
uInt nElements
 
Block< Domain > xValues
 
Block< Range > yValues
 
Block< Range > y2Values
 

Additional Inherited Members

- Protected Attributes inherited from casacore::Function< T, U >
FunctionParam< T > param_p
 The parameters and masks. More...
 
Vector< ArgTypearg_p
 Aid for non-contiguous argument storage. More...
 
Bool parset_p
 Indicate parameter written. More...
 
Bool locked_p
 Indicate that parameters are expected to be locked from changing. More...
 

Detailed Description

template<class Domain, class Range>
class casacore::Interpolate1D< Domain, Range >

Interpolate in one dimension

Intended use:

Public interface

Review Status

Reviewed By:
wyoung
Date Reviewed:
1996/10/18
Test programs:
tInterpolate1D
Demo programs:
dInterpolate1D

Prerequisite

Etymology

The Interpolate1D class does interpolation in one dimension only.

Synopsis

This class will, given the abscissa and ordinates of a set of one dimensional data, interpolate on this data set giving the value at any specified ordinate. It will extrapolate if necessary, but this is will usually give a poor result. There is no requirement for the ordinates to be regularly spaced, or even sorted in any numerical order. However each abscissa should have a unique value.

Interpolation can be done using the following methods:

The restriction that each abcissus has a unique value can be lifted by setting the uniq=True option in the appropriate functions. This imposes the following additional restrictions on interpolation.

The abscissa must be a SampledFunctional that returns a scalar value that can be ordered. ie. an uInt, Int, Float or Double (not Complex). The ordinate can be any data type that has addition, and subtraction defined as well as multiplication by a scalar. So the ordinate can be complex numbers, where the interpolation is done separately on the real and imaginary components, or an array, where the interpolation is done separately on an element by element basis.

This class will curently make an internal copy of the data supplied to it, and sort the data if it is not told it is already sorted, by using the sorted=True flag.

Example

This code fragment sets the interpolation method to cubic before interpolating on the supplied (x,y) vectors.

Vector<Float> x(4); indgen(x);
Vector<Double> y(4); indgen(y); y = y*y*y;
ScalarSampledFunctional<Float> fx(x)
ScalarSampledFunctional<Double> fy(y);
Interpolate1D<Float, Double> gain(fx, fy);
for (Float xs = -1; xs < 5; xs += 0.1)
cout << "gain(" << xs << "):" << gain(xs) << endl;
@ cubic
Fits a third order polynomial to 4 pts
void indgen(TableVector< T > &tv, T start, T inc)
Definition: TabVecMath.h:400
float Float
Definition: aipstype.h:54

Motivation

This class is motivated by the need to interpolate over the gain solutions obtained from calibrator observations, in order to get the gain at arbitrary times.

Template Type Argument Requirements (Domain)

Template Type Argument Requirements (Range)

Thrown Exceptions

To Do

Definition at line 140 of file Interpolate1D.h.

Member Enumeration Documentation

◆ Method

template<class Domain , class Range >
enum casacore::Interpolate1D::Method

The different interpolation methods are enumerated here.

Enumerator
nearestNeighbour 

Crude but sometimes useful.

linear 

The most common method and the Default.

cubic 

Fits a third order polynomial to 4 pts

spline 

Natural Cubic Splines.

Definition at line 144 of file Interpolate1D.h.

Constructor & Destructor Documentation

◆ Interpolate1D() [1/3]

template<class Domain , class Range >
casacore::Interpolate1D< Domain, Range >::Interpolate1D ( )

The default constructor generates a useless object until the setData function has been called.

◆ Interpolate1D() [2/3]

template<class Domain , class Range >
casacore::Interpolate1D< Domain, Range >::Interpolate1D ( const SampledFunctional< Domain > &  x,
const SampledFunctional< Range > &  y,
const Bool  sorted = False,
const Bool  uniq = False 
)

Construct an object with the specified data.

◆ Interpolate1D() [3/3]

template<class Domain , class Range >
casacore::Interpolate1D< Domain, Range >::Interpolate1D ( const Interpolate1D< Domain, Range > &  other)

The standard copy constructor, assignment operator and destructor.

Internal data is copied in both cases (copy semantics)

◆ ~Interpolate1D()

template<class Domain , class Range >
casacore::Interpolate1D< Domain, Range >::~Interpolate1D ( )

Member Function Documentation

◆ clone()

template<class Domain , class Range >
virtual Function<Domain, Range>* casacore::Interpolate1D< Domain, Range >::clone ( ) const
virtual

A function to copy the Interpolate1D object.

Implements casacore::Function< T, U >.

◆ eval()

template<class Domain , class Range >
virtual Range casacore::Interpolate1D< Domain, Range >::eval ( typename Function1D< Domain, Range >::FunctionArg  x) const
virtual

Interpolation is done using the () operator (see example above).

Actual use is through the virtual eval() function.

◆ getMethod()

template<class Domain , class Range >
uInt casacore::Interpolate1D< Domain, Range >::getMethod ( ) const
inline

inquire/set the current interpolation method.

uInts are used as arguments instead of the Interpolate1D::Method enumerator due to compiler limitations. See the example above (or the demo code) for the recommended way to call these functions.

Definition at line 195 of file Interpolate1D.h.

References casacore::Interpolate1D< Domain, Range >::curMethod.

◆ getX()

template<class Domain , class Range >
Vector<Domain> casacore::Interpolate1D< Domain, Range >::getX ( ) const

Access the data set that interpolation is done over.

This will usually be sorted.

◆ getY()

template<class Domain , class Range >
Vector<Range> casacore::Interpolate1D< Domain, Range >::getY ( ) const

◆ name()

template<class Domain , class Range >
virtual const String& casacore::Interpolate1D< Domain, Range >::name ( ) const
inlinevirtual

Name of function.

Reimplemented from casacore::Function< T, U >.

Definition at line 182 of file Interpolate1D.h.

◆ operator=()

template<class Domain , class Range >
Interpolate1D<Domain, Range>& casacore::Interpolate1D< Domain, Range >::operator= ( const Interpolate1D< Domain, Range > &  other)

◆ polynomialInterpolation()

template<class Domain , class Range >
Range casacore::Interpolate1D< Domain, Range >::polynomialInterpolation ( const Domain  x,
uInt  n,
uInt  offset 
) const
private

A private function for doing polynomial interpolation.

◆ setData()

template<class Domain , class Range >
void casacore::Interpolate1D< Domain, Range >::setData ( const SampledFunctional< Domain > &  x,
const SampledFunctional< Range > &  y,
const Bool  sorted = False,
const Bool  uniq = False 
)

Define a new data set for the class to operate on.

Equivalent in many aspects to creating a new object.

◆ setMethod()

template<class Domain , class Range >
void casacore::Interpolate1D< Domain, Range >::setMethod ( uInt  method)

Member Data Documentation

◆ curMethod

template<class Domain , class Range >
uInt casacore::Interpolate1D< Domain, Range >::curMethod
private

◆ nElements

template<class Domain , class Range >
uInt casacore::Interpolate1D< Domain, Range >::nElements
private

Definition at line 216 of file Interpolate1D.h.

◆ xValues

template<class Domain , class Range >
Block<Domain> casacore::Interpolate1D< Domain, Range >::xValues
private

Definition at line 217 of file Interpolate1D.h.

◆ y2Values

template<class Domain , class Range >
Block<Range> casacore::Interpolate1D< Domain, Range >::y2Values
private

Definition at line 219 of file Interpolate1D.h.

◆ yValues

template<class Domain , class Range >
Block<Range> casacore::Interpolate1D< Domain, Range >::yValues
private

Definition at line 218 of file Interpolate1D.h.


The documentation for this class was generated from the following files: