10 #ifndef SACADO_TAY_TAYLOR_HPP
11 #define SACADO_TAY_TAYLOR_HPP
86 void resize(
int d,
bool keep_coeffs);
142 const T&
val()
const {
return th->coeff_[0];}
168 T tmp= i<=
th->deg_ ?
th->coeff_[
i]:
T(0.);
return tmp;}
267 template <
typename T>
278 for (
int i=1;
i<=
n; ++
i)
280 for (
int i=
n;
i<=d; ++
i) {
282 c = (c / (
i-
n+1)) * (
i+1);
288 template <
typename T> Taylor<T>
operator+(
const Base< Taylor<T> >&
a,
289 const Base< Taylor<T> >& b);
290 template <
typename T> Taylor<T>
operator+(
const typename Taylor<T>::value_type&
a,
291 const Base< Taylor<T> >& b);
292 template <
typename T> Taylor<T>
operator+(
const Base< Taylor<T> >&
a,
293 const typename Taylor<T>::value_type& b);
294 template <
typename T> Taylor<T>
operator-(
const Base< Taylor<T> >&
a,
295 const Base< Taylor<T> >& b);
296 template <
typename T> Taylor<T>
operator-(
const typename Taylor<T>::value_type&
a,
297 const Base< Taylor<T> >& b);
298 template <
typename T> Taylor<T>
operator-(
const Base< Taylor<T> >&
a,
299 const typename Taylor<T>::value_type& b);
300 template <
typename T> Taylor<T>
operator*(
const Base< Taylor<T> >&
a,
301 const Base< Taylor<T> >& b);
302 template <
typename T> Taylor<T>
operator*(
const typename Taylor<T>::value_type&
a,
303 const Base< Taylor<T> >& b);
304 template <
typename T> Taylor<T>
operator*(
const Base< Taylor<T> >&
a,
305 const typename Taylor<T>::value_type& b);
306 template <
typename T> Taylor<T>
operator/(
const Base< Taylor<T> >&
a,
307 const Base< Taylor<T> >& b);
308 template <
typename T> Taylor<T>
operator/(
const typename Taylor<T>::value_type&
a,
309 const Base< Taylor<T> >& b);
310 template <
typename T> Taylor<T>
operator/(
const Base< Taylor<T> >&
a,
311 const typename Taylor<T>::value_type& b);
312 template <
typename T> Taylor<T>
exp(
const Base< Taylor<T> >&
a);
313 template <
typename T> Taylor<T>
log(
const Base< Taylor<T> >&
a);
314 template <
typename T> Taylor<T>
log10(
const Base< Taylor<T> >&
a);
315 template <
typename T> Taylor<T>
sqrt(
const Base< Taylor<T> >&
a);
316 template <
typename T> Taylor<T>
cbrt(
const Base< Taylor<T> >&
a);
317 template <
typename T> Taylor<T>
pow(
const Base< Taylor<T> >&
a,
318 const Base< Taylor<T> >& b);
319 template <
typename T> Taylor<T>
pow(
const typename Taylor<T>::value_type&
a,
320 const Base< Taylor<T> >& b);
321 template <
typename T> Taylor<T>
pow(
const Base< Taylor<T> >&
a,
322 const typename Taylor<T>::value_type& b);
323 template <
typename T>
void sincos(
const Base< Taylor<T> >&
a,
324 Taylor<T>& s, Taylor<T>&
c);
325 template <
typename T> Taylor<T>
cos(
const Base< Taylor<T> >&
a);
326 template <
typename T> Taylor<T>
sin(
const Base< Taylor<T> >&
a);
327 template <
typename T> Taylor<T>
tan(
const Base< Taylor<T> >&
a);
328 template <
typename T>
void sinhcosh(
const Base< Taylor<T> >&
a,
329 Taylor<T>& s, Taylor<T>&
c);
330 template <
typename T> Taylor<T>
cosh(
const Base< Taylor<T> >&
a);
331 template <
typename T> Taylor<T>
sinh(
const Base< Taylor<T> >&
a);
332 template <
typename T> Taylor<T>
tanh(
const Base< Taylor<T> >&
a);
333 template <
typename T> Taylor<T>
quad(
const typename Taylor<T>::value_type& c0,
334 const Base< Taylor<T> >&
a,
335 const Base< Taylor<T> >& b);
336 template <
typename T> Taylor<T>
acos(
const Base< Taylor<T> >&
a);
337 template <
typename T> Taylor<T>
asin(
const Base< Taylor<T> >&
a);
338 template <
typename T> Taylor<T>
atan(
const Base< Taylor<T> >&
a);
339 template <
typename T> Taylor<T>
atan2(
const Base< Taylor<T> >&
a,
340 const Base< Taylor<T> >& b);
341 template <
typename T> Taylor<T>
atan2(
const typename Taylor<T>::value_type&
a,
342 const Base< Taylor<T> >& b);
343 template <
typename T> Taylor<T>
atan2(
const Base< Taylor<T> >&
a,
344 const typename Taylor<T>::value_type& b);
345 template <
typename T> Taylor<T>
acosh(
const Base< Taylor<T> >&
a);
346 template <
typename T> Taylor<T>
asinh(
const Base< Taylor<T> >&
a);
347 template <
typename T> Taylor<T>
atanh(
const Base< Taylor<T> >&
a);
348 template <
typename T> Taylor<T>
abs(
const Base< Taylor<T> >&
a);
349 template <
typename T> Taylor<T>
fabs(
const Base< Taylor<T> >&
a);
350 template <
typename T> Taylor<T>
max(
const Base< Taylor<T> >&
a,
351 const Base< Taylor<T> >& b);
352 template <
typename T> Taylor<T>
max(
const typename Taylor<T>::value_type&
a,
353 const Base< Taylor<T> >& b);
354 template <
typename T> Taylor<T>
max(
const Base< Taylor<T> >&
a,
355 const typename Taylor<T>::value_type& b);
356 template <
typename T> Taylor<T>
min(
const Base< Taylor<T> >&
a,
357 const Base< Taylor<T> >& b);
358 template <
typename T> Taylor<T>
min(
const typename Taylor<T>::value_type&
a,
359 const Base< Taylor<T> >& b);
360 template <
typename T> Taylor<T>
min(
const Base< Taylor<T> >&
a,
361 const typename Taylor<T>::value_type& b);
363 const Base< Taylor<T> >& b);
364 template <
typename T>
bool operator==(
const typename Taylor<T>::value_type&
a,
365 const Base< Taylor<T> >& b);
367 const typename Taylor<T>::value_type& b);
369 const Base< Taylor<T> >& b);
370 template <
typename T>
bool operator!=(
const typename Taylor<T>::value_type&
a,
371 const Base< Taylor<T> >& b);
373 const typename Taylor<T>::value_type& b);
374 template <
typename T>
bool operator<=(const Base< Taylor<T> >&
a,
376 template <
typename T>
bool operator<=(const typename Taylor<T>::value_type&
a,
378 template <
typename T>
bool operator<=(const Base< Taylor<T> >&
a,
379 const typename Taylor<T>::value_type& b);
381 const Base< Taylor<T> >& b);
382 template <
typename T>
bool operator>=(
const typename Taylor<T>::value_type&
a,
383 const Base< Taylor<T> >& b);
385 const typename Taylor<T>::value_type& b);
386 template <
typename T>
bool operator<(const Base< Taylor<T> >&
a,
388 template <
typename T>
bool operator<(const typename Taylor<T>::value_type&
a,
390 template <
typename T>
bool operator<(const Base< Taylor<T> >&
a,
391 const typename Taylor<T>::value_type& b);
393 const Base< Taylor<T> >& b);
394 template <
typename T>
bool operator>(
const typename Taylor<T>::value_type&
a,
395 const Base< Taylor<T> >& b);
397 const typename Taylor<T>::value_type& b);
398 template <
typename T> std::ostream&
operator << (std::ostream& os,
399 const Base< Taylor<T> >&
a);
408 #endif // SACADO_TAY_TAYLOR_HPP
Taylor< T > operator+(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
ASinExprType< T >::expr_type asin(const Expr< T > &expr)
void resizeCoeffs(int len)
Resize coefficient array to new size.
void resize(int d, bool keep_coeffs)
Resize polynomial to degree d.
void sinhcosh(const Base< Taylor< T > > &a, Taylor< T > &s, Taylor< T > &c)
T value_type
Typename of values.
int deg_
Degree of polynomial.
Taylor< T > log(const Base< Taylor< T > > &a)
bool hasFastAccess(int d) const
Returns true if polynomial has degree >= d.
Taylor< T > & operator-=(const T &x)
Subtraction-assignment operator with constant right-hand-side.
Taylor< T > asinh(const Base< Taylor< T > > &a)
TanhExprType< T >::expr_type tanh(const Expr< T > &expr)
PowExprType< Expr< T1 >, Expr< T2 > >::expr_type pow(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
TanExprType< T >::expr_type tan(const Expr< T > &expr)
T coeff(int i) const
Returns degree i term with bounds checking.
bool operator>(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > operator+() const
Unary-plus operator.
int len_
Length of allocated polynomial array.
TaylorData & operator=(const TaylorData &x)
Assignment operator.
Taylor< T > & operator*=(const T &x)
Multiplication-assignment operator with constant right-hand-side.
Taylor< T > operator/(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > & operator=(const T &val)
Assignment operator with constant right-hand-side.
ACosExprType< T >::expr_type acos(const Expr< T > &expr)
TaylorData()
Default constructor.
bool operator>=(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Turn Taylor into a meta-function class usable with mpl::apply.
Base class for Sacado types to control overload resolution.
Taylor< T > sin(const Base< Taylor< T > > &a)
void copyForWrite()
Prepare polynomial for writing.
const T & fastAccessCoeff(int i) const
Returns degree i term without bounds checking.
CacheTaylor< T > diff(const CacheTaylor< T > &x, int n=1)
Compute Taylor series of n-th derivative of x.
expr expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c *expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr2 expr1 expr2 expr1 expr1 expr1 c
Taylor< T > cos(const Base< Taylor< T > > &a)
T & fastAccessCoeff(int i)
Returns degree i term without bounds checking.
Taylor< T > operator-() const
Unary-minus operator.
Taylor< T > quad(const typename Taylor< T >::value_type &c0, const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Base template specification for testing equivalence.
bool isEqualTo(const Taylor &x) const
Returns whether two Taylor objects have the same values.
Taylor< T > operator*(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > sinh(const Base< Taylor< T > > &a)
Taylor< T > sqrt(const Base< Taylor< T > > &a)
int length() const
Return length of array.
Log10ExprType< T >::expr_type log10(const Expr< T > &expr)
Taylor< T > max(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > cbrt(const Base< Taylor< T > > &a)
Taylor< T > fabs(const Base< Taylor< T > > &a)
const T & val() const
Returns value.
const T * coeff() const
Returns Taylor coefficient array.
Sacado::Handle< TaylorData > th
ATanExprType< T >::expr_type atan(const Expr< T > &expr)
Taylor< T > abs(const Base< Taylor< T > > &a)
void reserve(int d)
Reserve space for a degree d polynomial.
std::ostream & operator<<(std::ostream &os, const Expr< ExprT > &x)
Taylor< T > atan2(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > exp(const Base< Taylor< T > > &a)
T * coeff_
Taylor polynomial coefficients.
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from value_type)
void sincos(const Base< Taylor< T > > &a, Taylor< T > &s, Taylor< T > &c)
Taylor< T > atanh(const Base< Taylor< T > > &a)
Taylor< T > cosh(const Base< Taylor< T > > &a)
bool operator==(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > min(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > operator-(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > & operator/=(const T &x)
Division-assignment operator with constant right-hand-side.
Taylor< T > acosh(const Base< Taylor< T > > &a)
Taylor< T > & operator+=(const T &x)
Addition-assignment operator with constant right-hand-side.
int degree() const
Returns degree of polynomial.
bool operator!=(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor()
Default constructor.
T * coeff()
Returns Taylor coefficient array.