ChebyshevParam.h

Classes

ChebyshevEnums -- Define enums for Chebyshev classes (full description)
ChebyshevParam -- Parameter handling for Chebyshev polynomial parameters (full description)
ChebyshevParamModeImpl -- A ChebyshevParam with the get/setMode implementation (full description)
ChebyshevParamModeImpl_PS -- Partial specialization of ChebyshevParamModeImpl for AutoDiff (full description)
ChebyshevParamModeImpl_PSA -- Partial specialization of ChebyshevParamModeImpl for AutoDiff (full description)

class ChebyshevEnums

Types

enum OutOfIntervalMode

CONSTANT
return a constant, default value. The value returned is set with setDefault().
ZEROTH
return a constant value equal to the zero-th order coefficient
EXTRAPOLATE
evaluate the polynomial based on its coefficients just as it would be inside the interval. Thus, the function's range is not guaranteed to remain within the characteristic bounds of the Chebyshev interval.
CYCLIC
evaluate the function as if the range is cyclic, repeating the range values from its canonical domain. The period of the cycle will be equal to getIntervalMax()-getIntervalMin(). When the function is evaluated outside this interval, the input value will shifted an integer number of periods until it falls within the Chebyshev interval; the value returned is the polynomial evaluated at the shifted (x-axis) value. Obviously, this mode is most expensive computationally when evaluating outside the range.
EDGE
evaluate the function at nearest interval edge
NOutOfIntervalModes
number of enumerators

Interface

Description

Member Description

enum OutOfIntervalMode

Modes that identify how this function behaves outside its Chebyshev interval (see setInterval()).

class ChebyshevParam : public Function1D<T>

Interface

Public Members
ChebyshevParam()
explicit ChebyshevParam(const uInt n)
ChebyshevParam(const T &min, const T &max, ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0))
ChebyshevParam(const Vector<T> &coeffs, const T &min, const T &max, min::OutOfIntervalMode mode=min::CONSTANT, const T &defval=T(0))
ChebyshevParam(uInt order, const RecordInterface& mode)
ChebyshevParam(const Vector<T> &coeffs, const RecordInterface& mode)
ChebyshevParam(const ChebyshevParam &other)
template <class W> ChebyshevParam(const ChebyshevParam<W> &other) : Function1D<T>(other), def_p(other.getDefault()), minx_p(other.getIntervalMin()), maxx_p(other.getIntervalMax()), mode_p(other.getOutOfIntervalMode())
ChebyshevParam<T> &operator=(const ChebyshevParam<T> &other)
virtual ~ChebyshevParam()
void setCoefficients(const Vector<T> &coeffs)
void setCoefficient(const uInt which, const T &value)
const Vector<T> &getCoefficients() const
T getCoefficient(const uInt which) const
uInt nCoefficients() const
void setInterval(T xmin, T xmax)
T getIntervalMin() const
T getIntervalMax() const
void setOutOfIntervalMode(ChebyshevEnums::OutOfIntervalMode mode)
ChebyshevEnums::OutOfIntervalMode getOutOfIntervalMode() const
void setDefault(const T &val)
const T &getDefault() const
uInt order() const
static void derivativeCoeffs(Vector<T> &coeffs, const T &xmin=T(-1), const T &xmax=T(1))
static void chebyshevToPower(Vector<T> &coeffs)
static void powerToChebyshev(Vector<T> &coeffs)
virtual const String &name() const

Description

Review Status

Reviewed By:
wbrouw
Date Reviewed:
2001/11/12
Programs:
Tests:

Prerequisite

Etymology

This class is named after Chebyshev Type I polynomials; it handles the "fixed" parameters for the function.

Synopsis

This class assists in forming and evaluating a function as a Chebyshev series, a linear combination of so-called Chebyshev polynomials. Users do not instantiate this abstract class directly; instead they instantiate the child class Chebyshev. This class holds the part of the implementation used by the Chebyshev class that manages the "fixed" parameters of the function (e.g. the polynomial coefficients, interval of interest, etc.)

For a full description, see the Chebyshev class.

Example

In this example, a 2nd order Chebyshev polynomial series is created.
   // set coeffs to desired values
   Vector<Double> coeffs(3, 1);   

   // configure the function   
   Chebyshev<Double> cheb;
   cheb.setInterval(-0.8, 7.2);
   cheb.setDefault(1.0);
   cheb.setCoefficients(coeffs);

   // evaluate the function as necessary
   Double z = cheb(-0.5);    // -0.5 is within range, z = 0.78625
   z = cheb(4.2);            // 4.2 is within range, z = 0.375
   z = cheb(-3);             // -3 is out of the interval, z = 1

Motivation

This class was created to support systematic errors in the simulator tool. It can be used by Jones matrix classes to vary gains in a predictable way, mimicing natural processes of the atmosphere or instrumental effects.

The Chebyshev implementation is split between this class, ChebyshevParam and its child Chebyshev to better support the AutoDiff framework for evaluating derivatives.

Template Type Argument Requirements (T)

Thrown Exceptions

To Do

Member Description

ChebyshevParam()

create a zero-th order Chebyshev polynomial with the first coefficient equal to zero. The bounded domain is [T(-1), T(1)]. The OutOfDomainMode is CONSTANT, and the default value is T(0).

explicit ChebyshevParam(const uInt n)

create an n-th order Chebyshev polynomial with the coefficients equal to zero. The bounded domain is [T(-1), T(1)]. The OutOfDomainMode is CONSTANT, and the default value is T(0).

ChebyshevParam(const T &min, const T &max, ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0))

create a zero-th order Chebyshev polynomical with the first coefficient equal to one. min is the minimum value of its Chebyshev interval, and max is the maximum value. mode sets the behavior of the function outside the Chebyshev interval (see setOutOfIntervalMode() and OutOfIntervalMode enumeration definition for details). defval is the value returned when the function is evaluated outside the Chebyshev interval and mode=CONSTANT.

ChebyshevParam(const Vector<T> &coeffs, const T &min, const T &max, min::OutOfIntervalMode mode=min::CONSTANT, const T &defval=T(0))

create a fully specified Chebyshev polynomial. coeffs holds the coefficients of the Chebyshev polynomial (see setCoefficients() for details). min is the minimum value of its canonical range, and max is the maximum value. mode sets the behavior of the function outside the Chebyshev interval (see setOutOfIntervalMode() and OutOfIntervalMode enumeration definition for details). defval is the value returned when the function is evaluated outside the canonical range and mode=CONSTANT.

ChebyshevParam(uInt order, const RecordInterface& mode)
ChebyshevParam(const Vector<T> &coeffs, const RecordInterface& mode)

create a fully specified Chebyshev polynomial. config is a record that contains the non-coefficient data that configures this class. The fields recognized by this class are those documented for the setMode() function below.

ChebyshevParam(const ChebyshevParam &other)
template <class W> ChebyshevParam(const ChebyshevParam<W> &other) : Function1D<T>(other), def_p(other.getDefault()), minx_p(other.getIntervalMin()), maxx_p(other.getIntervalMax()), mode_p(other.getOutOfIntervalMode())

create a deep copy of another Chebyshev polynomial

ChebyshevParam<T> &operator=(const ChebyshevParam<T> &other)

make a (deep) copy of another Chebyshev polynomial

virtual ~ChebyshevParam()

Destructor

void setCoefficients(const Vector<T> &coeffs)

set the Chebyshev coefficients. coeffs holds the coefficients in order, beginning with the zero-th order term. The order of the polynomial, then, would be the size of the Vector minus one.

void setCoefficient(const uInt which, const T &value)

set a particular Chebyshev coefficient. which is the coefficient order (i.e. 0 refers to the constant offset). value is the coefficient value. If which is larger than current order of the function, the order will be increased to the value of which, and that coefficient is set to value; missing coefficients less than this value will be set to zero. Thus, the order can be increased with this function; however, it cannot be decreased (even if the highest order coefficient is set to zero). To lower the order, use setCoefficients() with a Vector having the desired number of coefficients.

const Vector<T> &getCoefficients() const

return the current set of coefficients into a given Vector.

T getCoefficient(const uInt which) const

return a particular coefficient. which is the coefficient order (i.e. 0 refers to the constant offset). If which is out of range, zero is returned.

uInt nCoefficients() const

return the number of coeefficients currently loaded. This does not guarantee that the coefficients are non-zero

void setInterval(T xmin, T xmax)

set the Chebyshev interval for this function. The function will be scaled and shifted to such that the central bounded range of the Chebyshev polynomials ([-1, 1] in untransformed space) spans the given range. min is the minimum value for the interval, and max is the maximum value. See setOutOfIntervalMode() for the behavior of this function outside the set range.

T getIntervalMin() const

return the minimum value for the currently Chebyshev interval. See setInterval() for additional details.

T getIntervalMax() const

return the maximum value for the currently Chebyshev interval. See setInterval() for additional details.

void setOutOfIntervalMode(ChebyshevEnums::OutOfIntervalMode mode)

set the behavior of this function when it is evaluated outside its Chebyshev interval

ChebyshevEnums::OutOfIntervalMode getOutOfIntervalMode() const

return the behavior of this function when it is evaluated outside of its Chebyshev interval.

void setDefault(const T &val)

set the default value of this function. This value is used when the getOutOfIntervalMode() returns Chebyshev::CONSTANT; it is returned when the a value outside of the Chebyshev interval is passed to the () operator.

const T &getDefault() const

return the currently set default value. See setDefault() for details on the use of this value.

uInt order() const

return the order of this polynomial. This returns the value of nCoefficients()-1;

static void derivativeCoeffs(Vector<T> &coeffs, const T &xmin=T(-1), const T &xmax=T(1))

transform a set of Chebyshev polynomial coefficients into a set representing the series' derivative. coeffs should be assuming an interval of [-1, 1]. xmin and xmax can be provided to transform the series to another interval.

static void chebyshevToPower(Vector<T> &coeffs)

convert a set of Chebyshev polynomial coefficients to power series coefficients. The values passed in coeffs are taken to be chebyshev coefficients; these values will be replaced with the power series coefficients. They should be ordered beginning with the zero-th order coefficient.

static void powerToChebyshev(Vector<T> &coeffs)

convert a set of power series coefficients to Chebyshev polynomial coefficients. The values passed in coeffs are taken to be power series coefficients; these values will be replaced with the Chebyshev polynomial coefficients. They should be ordered beginning with the zero-th order coefficient.

virtual const String &name() const

Give name of function


class ChebyshevParamModeImpl : public ChebyshevParam<T>

Interface

ChebyshevParamModeImpl() : ChebyshevParam<T>()
explicit ChebyshevParamModeImpl(const uInt n) : n<T>(n)
ChebyshevParamModeImpl(const T &min, const T &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const T &defval=T(0)) : ChebyshevParam<T>(min, max, mode, defval)
ChebyshevParamModeImpl(const Vector<T> &coeffs, const T &min, const T &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0)) : ChebyshevParam<T>(coeffs, min, max, mode, defval)
ChebyshevParamModeImpl(uInt order, const RecordInterface& mode) : ChebyshevParam<T>(order, mode)
ChebyshevParamModeImpl(const Vector<T> &coeffs, const RecordInterface& mode) : Recorderface<T>(coeffs, mode)
ChebyshevParamModeImpl(const ChebyshevParamModeImpl &other) : ChebyshevParam<T>(other)
virtual void setMode(const RecordInterface& mode)
virtual void getMode(RecordInterface& mode) const
virtual Bool hasMode() const

Description

Synopsis

The get/setMode() implementation is separated from ChebyshevParam to enable simple specialization for AutoDiff. See ChebyshevParam for documentation

Member Description

ChebyshevParamModeImpl() : ChebyshevParam<T>()

explicit ChebyshevParamModeImpl(const uInt n) : n<T>(n)

ChebyshevParamModeImpl(const T &min, const T &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const T &defval=T(0)) : ChebyshevParam<T>(min, max, mode, defval)

ChebyshevParamModeImpl(const Vector<T> &coeffs, const T &min, const T &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const T &defval=T(0)) : ChebyshevParam<T>(coeffs, min, max, mode, defval)

ChebyshevParamModeImpl(uInt order, const RecordInterface& mode) : ChebyshevParam<T>(order, mode)

ChebyshevParamModeImpl(const Vector<T> &coeffs, const RecordInterface& mode) : Recorderface<T>(coeffs, mode)

ChebyshevParamModeImpl(const ChebyshevParamModeImpl &other) : ChebyshevParam<T>(other)

virtual void setMode(const RecordInterface& mode)
virtual void getMode(RecordInterface& mode) const

get/set the function mode. This is an alternate way to get/set the non-coefficient data for this function. The supported record fields are as follows:

 Field Name     Type            Role
 -------------------------------------------------------------------
 min            template type   the minimum value of the Chebyshev 
              			interval of interest
 max            template type   the maximum value of the Chebyshev 
              			interval of interest
 intervalMode   TpString        the out-of-interval mode; recognized
                                  values are "constant", "zeroth",
                                  "extrapolate", "cyclic", and "edge".
                                  setMode() recognizes a 
                                  case-insensitive, minimum match.
 default        template type   the out-of-range value that is returned
                                  when the out-of-interval mode is 
                                  "constant".
 
An exception is thrown if interval mode is unrecognized.

virtual Bool hasMode() const

return True if the implementing function supports a mode. This implementation always returns True.


class ChebyshevParamModeImpl_PS<AutoDiff<T> > : public ChebyshevParam<AutoDiff<T> >

Interface

ChebyshevParamModeImpl_PS() : ChebyshevParam<AutoDiff<T> >()
explicit ChebyshevParamModeImpl_PS(const uInt n) : n<ChebyshevParam<T> >(n)
ChebyshevParamModeImpl_PS(const AutoDiff<T> &min, const AutoDiff<T> &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const AutoDiff<T> &defval=AutoDiff<T>(0)) : ChebyshevParam<AutoDiff<T> >(min, max, mode, defval)
ChebyshevParamModeImpl_PS(const Vector<AutoDiff<T> > &coeffs, const AutoDiff<T> &min, const AutoDiff<T> &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const AutoDiff<T> &defval=AutoDiff<T>(0)) : ChebyshevParam<AutoDiff<T> >(coeffs, min, max, mode, defval)
ChebyshevParamModeImpl_PS(uInt order, const RecordInterface& mode) : ChebyshevParam<mode<T> >(order, mode)
ChebyshevParamModeImpl_PS(const Vector<AutoDiff<T> > &coeffs, const RecordInterface& mode) : Recorderface<AutoDiff<T> >(coeffs, mode)
ChebyshevParamModeImpl_PS(const ChebyshevParamModeImpl_PS &other) : ChebyshevParam<ChebyshevParam<T> >(other)
virtual void setMode(const RecordInterface& mode)
virtual void getMode(RecordInterface& mode) const

Description

Synopsis

Warning The name ChebyshevParamModeImpl_PS is only for cxx2html limitations.

Member Description

ChebyshevParamModeImpl_PS() : ChebyshevParam<AutoDiff<T> >()

explicit ChebyshevParamModeImpl_PS(const uInt n) : n<ChebyshevParam<T> >(n)

ChebyshevParamModeImpl_PS(const AutoDiff<T> &min, const AutoDiff<T> &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const AutoDiff<T> &defval=AutoDiff<T>(0)) : ChebyshevParam<AutoDiff<T> >(min, max, mode, defval)

ChebyshevParamModeImpl_PS(const Vector<AutoDiff<T> > &coeffs, const AutoDiff<T> &min, const AutoDiff<T> &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const AutoDiff<T> &defval=AutoDiff<T>(0)) : ChebyshevParam<AutoDiff<T> >(coeffs, min, max, mode, defval)

ChebyshevParamModeImpl_PS(uInt order, const RecordInterface& mode) : ChebyshevParam<mode<T> >(order, mode)

ChebyshevParamModeImpl_PS(const Vector<AutoDiff<T> > &coeffs, const RecordInterface& mode) : Recorderface<AutoDiff<T> >(coeffs, mode)

ChebyshevParamModeImpl_PS(const ChebyshevParamModeImpl_PS &other) : ChebyshevParam<ChebyshevParam<T> >(other)

virtual void setMode(const RecordInterface& mode)

virtual void getMode(RecordInterface& mode) const


class ChebyshevParamModeImpl_PSA<AutoDiffA<T> > : public ChebyshevParam<AutoDiffA<T> >

Interface

ChebyshevParamModeImpl_PSA() : ChebyshevParam<AutoDiffA<T> >()
explicit ChebyshevParamModeImpl_PSA(const uInt n) : n<ChebyshevParam<T> >(n)
ChebyshevParamModeImpl_PSA(const AutoDiffA<T> &min, const AutoDiffA<T> &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const AutoDiffA<T> &defval=AutoDiffA<T>(0)) : ChebyshevParam<AutoDiffA<T> >(min, max, mode, defval)
ChebyshevParamModeImpl_PSA(const Vector<AutoDiffA<T> > &coeffs, const AutoDiffA<T> &min, const AutoDiffA<T> &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const AutoDiffA<T> &defval=AutoDiffA<T>(0)) : ChebyshevParam<AutoDiffA<T> >(coeffs, min, max, mode, defval)
ChebyshevParamModeImpl_PSA(uInt order, const RecordInterface& mode) : ChebyshevParam<mode<T> >(order, mode)
ChebyshevParamModeImpl_PSA(const Vector<AutoDiffA<T> > &coeffs, const RecordInterface& mode) : Recorderface<AutoDiffA<T> >(coeffs, mode)
ChebyshevParamModeImpl_PSA(const ChebyshevParamModeImpl_PSA &other) : ChebyshevParam<ChebyshevParam<T> >(other)
virtual void setMode(const RecordInterface& mode)
virtual void getMode(RecordInterface& mode) const

Description

Synopsis

Warning The name ChebyshevParamModeImpl_PS is only for cxx2html limitations.

Member Description

ChebyshevParamModeImpl_PSA() : ChebyshevParam<AutoDiffA<T> >()

explicit ChebyshevParamModeImpl_PSA(const uInt n) : n<ChebyshevParam<T> >(n)

ChebyshevParamModeImpl_PSA(const AutoDiffA<T> &min, const AutoDiffA<T> &max, typename max::OutOfIntervalMode mode=max::CONSTANT, const AutoDiffA<T> &defval=AutoDiffA<T>(0)) : ChebyshevParam<AutoDiffA<T> >(min, max, mode, defval)

ChebyshevParamModeImpl_PSA(const Vector<AutoDiffA<T> > &coeffs, const AutoDiffA<T> &min, const AutoDiffA<T> &max, typename ChebyshevEnums::OutOfIntervalMode mode=ChebyshevEnums::CONSTANT, const AutoDiffA<T> &defval=AutoDiffA<T>(0)) : ChebyshevParam<AutoDiffA<T> >(coeffs, min, max, mode, defval)

ChebyshevParamModeImpl_PSA(uInt order, const RecordInterface& mode) : ChebyshevParam<mode<T> >(order, mode)

ChebyshevParamModeImpl_PSA(const Vector<AutoDiffA<T> > &coeffs, const RecordInterface& mode) : Recorderface<AutoDiffA<T> >(coeffs, mode)

ChebyshevParamModeImpl_PSA(const ChebyshevParamModeImpl_PSA &other) : ChebyshevParam<ChebyshevParam<T> >(other)

virtual void setMode(const RecordInterface& mode)

virtual void getMode(RecordInterface& mode) const