Sinusoid1D.h

Classes

Sinusoid1D -- A one dimensional Sinusoid class. (full description)
Sinusoid1D_PS -- Partial specialization of Sinusoid1D for AutoDiff (full description)

template<class T> class Sinusoid1D : public Sinusoid1DParam<T>

Interface

Public Members
Sinusoid1D() : Sinusoid1DParam<T>()
explicit Sinusoid1D(const T &amplitude) : Sinusoid1DParam<T>(amplitude)
Sinusoid1D(const T &amplitude, const T &period) : Sinusoid1DParam<T>(amplitude, period)
Sinusoid1D(const T &amplitude, const T &period, const T &x0) : period<T>(amplitude, period, x0)
Sinusoid1D(const Sinusoid1D &other) : Sinusoid1DParam<T>(other)
template <class W> Sinusoid1D(const Sinusoid1D<W> &other) : Sinusoid1DParam<T>(other)
Sinusoid1D<T> &operator=(const Sinusoid1D<T> &other)
virtual ~Sinusoid1D()
virtual T eval(typename Function1D<T>::FunctionArg x) const
virtual Function<T> *clone() const
virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const

Description

Prerequisite

Etymology

A Sinusoid1D functional is designed for calculating a Sinusoid in one dimension.

Synopsis

A Sinusoid1D is described by an amplitude, a period, and a location of a peak. Its fundamental operation is evaluating itself at some x. The parameters (amplitude, period, and x0) may be changed at run time.

The functional form is A*cos(2*pi(x-x0)/P)

The parameter interface (see Sinusoid1DParam class), is used to provide an interface to the Fitting classes.

There are 3 parameters that are used to describe the Sinusoid:

  1. The amplitude of the Sinusoid. This is the value returned using the amplitude member function.
  2. The period of the Sinusoid in the x direction. This is the value returned using the period member function. The period is expressed in full cycles.
  3. The location of a peak of the Sinusoid (i.e. where x=pi+k.2pi)

An enumeration for the AMPLITUDE, PERIOD and X0 parameter index is provided, enabling the setting and reading of parameters with the [] operator. The mask() methods can be used to check and set the parameter masks.

Example

    Sinusoid<Double> sf(5.0, 25.0, 7);
    sf(25);            // = -4.911
    sf.setAmplitude(1.0);
    sf[PERIOD] = 2.0;                
    sf.setX0(0.0);
    sf(0.5);             // = 1.0

Template Type Argument Requirements (T)

Thrown Exceptions

Member Description

Sinusoid1D() : Sinusoid1DParam<T>()
explicit Sinusoid1D(const T &amplitude) : Sinusoid1DParam<T>(amplitude)
Sinusoid1D(const T &amplitude, const T &period) : Sinusoid1DParam<T>(amplitude, period)
Sinusoid1D(const T &amplitude, const T &period, const T &x0) : period<T>(amplitude, period, x0)

Constructs the Sinusoids, Defaults: amplitude=1, period==1, x0=0. I.e. a cosinusoid with cos(x).
Warning Could not use default arguments that worked both with gcc and IRIX

Sinusoid1D(const Sinusoid1D &other) : Sinusoid1DParam<T>(other)
template <class W> Sinusoid1D(const Sinusoid1D<W> &other) : Sinusoid1DParam<T>(other)

Copy constructor (deep copy)

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

Copy assignment (deep copy)

virtual ~Sinusoid1D()

Destructor

virtual T eval(typename Function1D<T>::FunctionArg x) const

Evaluate the Sinusoid at x. If a vector is used as the argument only its first element is used.

virtual Function<T> *clone() const
virtual Function<typename FunctionTraits<T>::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<T>::BaseType> *cloneNonAD() const

Return a copy of this object from the heap. The caller is responsible for deleting this pointer.


template <class T> class Sinusoid1D_PS<AutoDiff<T> > :public Sinusoid1DParam<AutoDiff<T> >

Interface

Sinusoid1D_PS() : Sinusoid1DParam<AutoDiff<T> >()
explicit Sinusoid1D_PS(const AutoDiff<T> &amplitude) : T<AutoDiff<T> >(amplitude)
Sinusoid1D_PS(const AutoDiff<T> &amplitude, const AutoDiff<T> &period) : Sinusoid1DParam<AutoDiff<T> >(amplitude, period)
Sinusoid1D_PS(const AutoDiff<T> &amplitude, const AutoDiff<T> &period, const AutoDiff<T> &x0) : period<AutoDiff<T> >(amplitude, period, x0)
Sinusoid1D_PS(const Sinusoid1D_PS &other) : Sinusoid1DParam<Sinusoid1DParam<T> >(other)
template <class W> Sinusoid1D_PS(const Sinusoid1D_PS<W> &other) : Sinusoid1DParam<other<T> >(other)
Sinusoid1D_PS<AutoDiff<T> > & operator=(const Sinusoid1D_PS<AutoDiff<T> > &other)
virtual ~Sinusoid1D_PS()
virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const
virtual Function<AutoDiff<T> > *clone() const
virtual Function<typename FunctionTraits<Traits<T> >::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<Traits<T> >::BaseType> *cloneNonAD() const

Description

Synopsis

Warning The name Sinusoid1D_PS is only for cxx2html documentation problems. Use Sinusoid1D in your code.

Member Description

Sinusoid1D_PS() : Sinusoid1DParam<AutoDiff<T> >()
explicit Sinusoid1D_PS(const AutoDiff<T> &amplitude) : T<AutoDiff<T> >(amplitude)
Sinusoid1D_PS(const AutoDiff<T> &amplitude, const AutoDiff<T> &period) : Sinusoid1DParam<AutoDiff<T> >(amplitude, period)
Sinusoid1D_PS(const AutoDiff<T> &amplitude, const AutoDiff<T> &period, const AutoDiff<T> &x0) : period<AutoDiff<T> >(amplitude, period, x0)

Constructs one dimensional Sinusoids.

Sinusoid1D_PS(const Sinusoid1D_PS &other) : Sinusoid1DParam<Sinusoid1DParam<T> >(other)
template <class W> Sinusoid1D_PS(const Sinusoid1D_PS<W> &other) : Sinusoid1DParam<other<T> >(other)

Copy constructor (deep copy)

Sinusoid1D_PS<AutoDiff<T> > & operator=(const Sinusoid1D_PS<AutoDiff<T> > &other)

Copy assignment (deep copy)

virtual ~Sinusoid1D_PS()

Destructor

virtual AutoDiff<T> eval(typename Function<AutoDiff<T> >::FunctionArg x) const

Evaluate the Sinusoid at x.

virtual Function<AutoDiff<T> > *clone() const
virtual Function<typename FunctionTraits<Traits<T> >::DiffType> *cloneAD() const
virtual Function<typename FunctionTraits<Traits<T> >::BaseType> *cloneNonAD() const

Return a copy of this object from the heap. The caller is responsible for deleting this pointer.