10#ifndef TEUCHOS_POLYNOMIAL_HPP
11#define TEUCHOS_POLYNOMIAL_HPP
13#include "Teuchos_PolynomialDecl.hpp"
16template <
typename CoeffT>
18 const CoeffT& cloneCoeff,
19 unsigned int reserve) :
28 for (
unsigned int i=0; i<
sz; i++)
32template <
typename CoeffT>
34 unsigned int reserve) :
45template <
typename CoeffT>
50template <
typename CoeffT>
57 if (
coeff[0] != Teuchos::null) {
58 for (
unsigned int i=
sz; i<
d+1; i++)
65template <
typename CoeffT>
72 "Polynomial<CoeffT>::getCoefficient(i): " <<
73 "Error, coefficient i = " << i <<
74 " is not in range, degree = " <<
d <<
"." );
79template <
typename CoeffT>
86 "Polynomial<CoeffT>::getCoefficient(i): " <<
87 "Error, coefficient i = " << i <<
88 " is not in range, degree = " <<
d <<
"." );
93template <
typename CoeffT>
100 "Polynomial<CoeffT>::setCoefficient(i,v): " <<
101 "Error, coefficient i = " << i <<
102 " is not in range, degree = " <<
d <<
"." );
105 "Polynomial<CoeffT>::setCoefficient(i,v): " <<
106 "Error, coefficient i = " << i <<
" is null!");
111template <
typename CoeffT>
120 "Polynomial<CoeffT>::setCoefficientPtr(i,v): " <<
121 "Error, coefficient i = " << i <<
122 " is not in range, degree = " <<
d <<
"." );
127template <
typename CoeffT>
131 CoeffT* x, CoeffT* xdot)
const
133 bool evaluate_xdot = (xdot != NULL);
136 for (
unsigned int i=0; i<=
d; i++)
139 "Polynomial<CoeffT>::evaluate(): " <<
140 "Error, coefficient i = " << i <<
" is null!");
158 for (
int k=
d-1; k>=0; --k) {
163 if (evaluate_xdot && k > 0)
Defines basic traits for the scalar field type.
T & get(ParameterList &l, const std::string &name)
A shorter name for getParameter().
static void assign(coeff_type *y, const scalar_type &alpha)
Assign a scalar to a coefficient.
static void update(coeff_type *y, const coeff_type &x, const scalar_type &beta)
y = x + beta*y
static void copy(const coeff_type &x, coeff_type *y)
Copy a coefficient.
static Teuchos::RCP< coeff_type > clone(const coeff_type &c)
Clone a coefficient.
void setCoefficient(unsigned int i, const CoeffT &v)
Set coefficient i to c.
Teuchos::RCP< CoeffT > getCoefficient(unsigned int i)
Return ref-count pointer to coefficient i.
Teuchos::PolynomialTraits< coeff_type >::scalar_type scalar_type
Typename of scalars.
unsigned int sz
Size of polynomial (may be > d).
void evaluate(typename Teuchos::Polynomial< CoeffT >::scalar_type &t, CoeffT *x, CoeffT *xdot=NULL) const
Evaluate polynomial and possibly its derivative at time t.
void setDegree(unsigned int deg)
Set degree of polynomial to deg.
std::vector< Teuchos::RCP< CoeffT > > coeff
Vector of polynomial coefficients.
unsigned int d
Degree of polynomial.
Polynomial(unsigned int deg, const CoeffT &cloneCoeff, unsigned int reserve=0)
Create a polynomial of degree deg.
void setCoefficientPtr(unsigned int i, const Teuchos::RCP< CoeffT > &c_ptr)
Set pointer for coefficient i to c_ptr. DANGEROUS!
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
static T zero()
Returns representation of zero for this scalar type.