casa  \$Rev:20696\$
casa::Polynomial< T > Class Template Reference

A one dimensional polynomial class. More...

`#include <Polynomial.h>`

Inheritance diagram for casa::Polynomial< T >: List of all members.

## Public Member Functions

Polynomial ()
Constructs a zero'th order polynomial, with a coeficcient of 0.0.
Polynomial (uInt order)
Makes a polynomial of the given order, with all coeficcients set to zero.
Polynomial (const Polynomial< T > &other)
Copy constructor/assignment (deep copy)
template<class W >
Polynomial (const Polynomial< W > &other)
Polynomial< T > & operator= (const Polynomial< T > &other)
virtual ~Polynomial ()
Destructor.
virtual T eval (typename Function1D< T >::FunctionArg x) const
Evaluate the polynomial at `x`.
Polynomial< T > derivative () const
Return the polynomial which is the derivative of this one.
virtual Function< T > * clone () const
Return a copy of this object from the heap.
virtual Function< typename
FunctionTraits< T >::DiffType > *
virtual Function< typename
FunctionTraits< T >::BaseType > *

## Detailed Description

### template<class T> class casa::Polynomial< T >

A one dimensional polynomial class.

Reviewed By:
tcornwel
Date Reviewed:
1996/02/22
Test programs:
tPolynomial

### Synopsis

A Polynomial<T> contains a set of coefficients; its fundamental operations is evaluating itself at some "x". The number of coefficients is the order of the polynomial plus one, so is the number of available parameters.

Tip: The present implementation merely stores the coefficients in a Block; In the unlikely case that we need to deal with polynomials with many zero coefficients, a more efficient representation would be possible;

### Example

```     Polynomial<Float> pf(3); // Third order polynomial - coeffs 0 by default
pf.setCoefficient(1, 1.0);
pf = 2.0;
pf.setCoefficient(3, 3.0);  // 3x^3 + 2x^2 + x
pf(2); // == 34
```

### Template Type Argument Requirements (T)

• T should have standard numerical operators. Current implementation only tested for real types (and their AutoDiffs).

### Thrown Exceptions

• Assertion in debug mode if attempt is made to address incorrect coefficients

### To Do

• Global functions to make various ``special'' polynomials of various orders will be useful eventually.

Definition at line 90 of file Polynomial.h.

## Constructor & Destructor Documentation

template<class T>
 casa::Polynomial< T >::Polynomial ( ) ` [inline]`

Constructs a zero'th order polynomial, with a coeficcient of 0.0.

Definition at line 96 of file Polynomial.h.

template<class T>
 casa::Polynomial< T >::Polynomial ( uInt order ) ` [inline, explicit]`

Makes a polynomial of the given order, with all coeficcients set to zero.

Definition at line 99 of file Polynomial.h.

template<class T>
 casa::Polynomial< T >::Polynomial ( const Polynomial< T > & other ) ` [inline]`

Copy constructor/assignment (deep copy)

Definition at line 102 of file Polynomial.h.

template<class T>
template<class W >
 casa::Polynomial< T >::Polynomial ( const Polynomial< W > & other ) ` [inline]`

Definition at line 104 of file Polynomial.h.

template<class T>
 virtual casa::Polynomial< T >::~Polynomial ( ) ` [inline, virtual]`

Destructor.

Definition at line 110 of file Polynomial.h.

## Member Function Documentation

template<class T>
 virtual Function* casa::Polynomial< T >::clone ( ) const` [inline, virtual]`

Return a copy of this object from the heap.

The caller is responsible for deleting the pointer.

Implements casa::Function< T, T >.

Definition at line 124 of file Polynomial.h.

template<class T>
 virtual Function::DiffType>* casa::Polynomial< T >::cloneAD ( ) const` [inline, virtual]`

Reimplemented from casa::Function< T, T >.

Definition at line 125 of file Polynomial.h.

template<class T>
 virtual Function::BaseType>* casa::Polynomial< T >::cloneNonAD ( ) const` [inline, virtual]`

Reimplemented from casa::Function< T, T >.

Definition at line 127 of file Polynomial.h.

template<class T>
 Polynomial casa::Polynomial< T >::derivative ( ) const

Return the polynomial which is the derivative of this one.

e.g., ` 2+4x+5x^2 --> 0+4+10x `.

template<class T>
 virtual T casa::Polynomial< T >::eval ( typename Function1D< T >::FunctionArg x ) const` [virtual]`

Evaluate the polynomial at `x`.

template<class T>
 Polynomial& casa::Polynomial< T >::operator= ( const Polynomial< T > & other ) ` [inline]`

Definition at line 105 of file Polynomial.h.

Referenced by casa::Polynomial< AutoDiff< Float > >::operator=().

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