11 #if defined (__clang__) && !defined (__INTEL_COMPILER)
12 #pragma clang system_header
25 coeff_(NULL), deg_(-1), len_(0)
32 coeff_(), deg_(0), len_(1)
41 coeff_(), deg_(d), len_(d+1)
50 coeff_(), deg_(d), len_(d+1)
58 coeff_(), deg_(d), len_(l)
66 coeff_(), deg_(x.deg_), len_(x.deg_+1)
84 if (len_ < x.
deg_+1) {
105 template <
typename T>
112 template <
typename T>
119 template <
typename T>
126 template <
typename T>
133 template <
typename T>
140 template <
typename T>
146 template <
typename T>
151 if (d+1 > length()) {
165 template <
typename T>
170 if (d+1 > length()) {
177 template <
typename T>
196 template <
typename T>
204 template <
typename T>
213 template <
typename T>
221 template <
typename T>
227 x.
th->deg_ = th->deg_;
228 x.
th->len_ = th->deg_+1;
230 for (
int i=0;
i<=th->deg_;
i++)
231 x.
th->coeff_[
i] = -th->coeff_[
i];
236 template <
typename T>
248 template <
typename T>
260 template <
typename T>
267 for (
int i=0;
i<=th->deg_;
i++)
273 template <
typename T>
280 for (
int i=0;
i<=th->deg_;
i++)
286 template <
typename T>
295 int dmin = xd < d ? xd : d;
298 bool need_resize = l > length();
302 for (
int i=0;
i<=d;
i++)
303 c[
i] = fastAccessCoeff(
i);
307 T* xc = x.
th->coeff_;
309 for (
int i=0;
i<=dmin;
i++)
312 for (
int i=d+1;
i<=xd;
i++)
326 template <
typename T>
335 int dmin = xd < d ? xd : d;
338 bool need_resize = l > length();
342 for (
int i=0;
i<=d;
i++)
343 c[
i] = fastAccessCoeff(
i);
347 T* xc = x.
th->coeff_;
349 for (
int i=0;
i<=dmin;
i++)
352 for (
int i=d+1;
i<=xd;
i++)
366 template <
typename T>
375 if ((xd != d) && (xd != 0) && (d != 0))
376 throw "Taylor Error: Attempt to assign with incompatible degrees";
380 T* xc = x.
th->coeff_;
382 if (d > 0 && xd > 0) {
386 for (
int i=0;
i<=d;
i++) {
388 for (
int k=0; k<=
i; ++k)
396 for (
int i=0;
i<=d;
i++)
400 if (length() < xd+1) {
403 for (
int i=0;
i<=xd;
i++)
409 for (
int i=d;
i>=0;
i--)
417 template <
typename T>
426 if ((xd != d) && (xd != 0) && (d != 0))
427 throw "Taylor Error: Attempt to assign with incompatible degrees";
431 T* xc = x.
th->coeff_;
433 if (d > 0 && xd > 0) {
437 for(
int i=0;
i<=d;
i++) {
439 for (
int k=1; k<=
i; ++k)
440 tmp -= xc[k]*cc[
i-k];
447 for (
int i=0;
i<=d;
i++)
454 cc[0] = c[0] / xc[0];
455 for (
int i=1;
i<=xd;
i++) {
457 for (
int k=1; k<=
i; ++k)
458 tmp -= xc[k]*cc[
i-k];
467 template <
typename T>
478 template <
typename T>
488 int dc = da > db ? da : db;
491 if ((da != db) && (da != 0) && (db != 0))
492 throw "operator+(): Arguments have incompatible degrees!";
500 if (da > 0 && db > 0) {
501 for (
int i=0;
i<=dc;
i++)
502 cc[
i] = ca[
i] + cb[
i];
505 cc[0] = ca[0] + cb[0];
506 for (
int i=1;
i<=dc;
i++)
510 cc[0] = ca[0] + cb[0];
511 for (
int i=1;
i<=dc;
i++)
518 template <
typename T>
532 for (
int i=1;
i<=dc;
i++)
538 template <
typename T>
552 for (
int i=1;
i<=dc;
i++)
558 template <
typename T>
568 int dc = da > db ? da : db;
571 if ((da != db) && (da != 0) && (db != 0))
572 throw "operator+(): Arguments have incompatible degrees!";
580 if (da > 0 && db > 0) {
581 for (
int i=0;
i<=dc;
i++)
582 cc[
i] = ca[
i] - cb[
i];
585 cc[0] = ca[0] - cb[0];
586 for (
int i=1;
i<=dc;
i++)
590 cc[0] = ca[0] - cb[0];
591 for (
int i=1;
i<=dc;
i++)
598 template <
typename T>
612 for (
int i=1;
i<=dc;
i++)
618 template <
typename T>
632 for (
int i=1;
i<=dc;
i++)
638 template <
typename T>
648 int dc = da > db ? da : db;
651 if ((da != db) && (da != 0) && (db != 0))
652 throw "operator+(): Arguments have incompatible degrees!";
660 if (da > 0 && db > 0) {
662 for (
int i=0;
i<=dc;
i++) {
664 for (
int k=0; k<=
i; k++)
665 tmp += ca[k]*cb[
i-k];
670 for (
int i=0;
i<=dc;
i++)
674 for (
int i=0;
i<=dc;
i++)
681 template <
typename T>
694 for (
int i=0;
i<=dc;
i++)
700 template <
typename T>
713 for (
int i=0;
i<=dc;
i++)
719 template <
typename T>
729 int dc = da > db ? da : db;
732 if ((da != db) && (da != 0) && (db != 0))
733 throw "operator+(): Arguments have incompatible degrees!";
741 if (da > 0 && db > 0) {
743 for (
int i=0;
i<=dc;
i++) {
745 for (
int k=0; k<=
i; k++)
746 tmp -= cb[k]*cc[
i-k];
751 for (
int i=0;
i<=dc;
i++)
756 cc[0] = ca[0] / cb[0];
757 for (
int i=1;
i<=dc;
i++) {
759 for (
int k=0; k<=
i; k++)
760 tmp -= cb[k]*cc[
i-k];
768 template <
typename T>
783 for (
int i=1;
i<=dc;
i++) {
785 for (
int k=0; k<=
i; k++)
786 tmp -= cb[k]*cc[
i-k];
793 template <
typename T>
806 for (
int i=0;
i<=dc;
i++)
812 template <
typename T>
825 for (
int i=1;
i<=dc;
i++) {
827 for (
int k=1; k<=
i; k++)
828 tmp += k*cc[
i-k]*ca[k];
835 template <
typename T>
848 for (
int i=1;
i<=dc;
i++) {
850 for (
int k=1; k<=
i-1; k++)
851 tmp -= k*ca[
i-k]*cc[k];
852 cc[
i] = tmp / (
i*ca[0]);
858 template <
typename T>
866 template <
typename T>
879 for (
int i=1;
i<=dc;
i++) {
881 for (
int k=1; k<=
i-1; k++)
882 tmp -= cc[k]*cc[
i-k];
883 cc[
i] = tmp / (2.0*cc[0]);
889 template <
typename T>
896 template <
typename T>
906 template <
typename T>
915 template <
typename T>
924 template <
typename T>
945 for (
int i=1;
i<=dc;
i++) {
948 for (
int k=1; k<=
i; k++) {
949 tmp1 += k*ca[k]*cc[
i-k];
950 tmp2 -= k*ca[k]*cs[
i-k];
957 template <
typename T>
970 template <
typename T>
983 template <
typename T>
997 template <
typename T>
1018 for (
int i=1;
i<=dc;
i++) {
1021 for (
int k=1; k<=
i; k++) {
1022 tmp1 += k*ca[k]*cc[
i-k];
1023 tmp2 += k*ca[k]*cs[
i-k];
1030 template <
typename T>
1043 template <
typename T>
1056 template <
typename T>
1070 template <
typename T>
1087 for (
int i=1;
i<=dc;
i++) {
1089 for (
int k=1; k<=
i; k++)
1090 tmp += k*ca[k]*cb[
i-k];
1097 template <
typename T>
1106 template <
typename T>
1115 template <
typename T>
1124 template <
typename T>
1137 template <
typename T>
1149 template <
typename T>
1161 template <
typename T>
1170 template <
typename T>
1179 template <
typename T>
1188 template <
typename T>
1193 if (a.
coeff(0) >= 0)
1199 template <
typename T>
1204 if (a.
coeff(0) >= 0)
1210 template <
typename T>
1224 template <
typename T>
1231 if (a >= b.
coeff(0))
1237 template <
typename T>
1244 if (a.
coeff(0) >= b)
1250 template <
typename T>
1264 template <
typename T>
1271 if (a <= b.
coeff(0))
1277 template <
typename T>
1284 if (a.
coeff(0) <= b)
1290 template <
typename T>
1300 template <
typename T>
1306 return a == b.
coeff(0);
1309 template <
typename T>
1315 return a.
coeff(0) == b;
1318 template <
typename T>
1328 template <
typename T>
1334 return a != b.
coeff(0);
1337 template <
typename T>
1343 return a.
coeff(0) != b;
1346 template <
typename T>
1348 operator<=(const Base< Taylor<T> >& aa,
1356 template <
typename T>
1358 operator<=(const typename Taylor<T>::value_type&
a,
1365 template <
typename T>
1367 operator<=(const Base< Taylor<T> >& aa,
1371 return a.
coeff(0) <= b;
1374 template <
typename T>
1384 template <
typename T>
1390 return a >= b.
coeff(0);
1393 template <
typename T>
1399 return a.
coeff(0) >= b;
1402 template <
typename T>
1404 operator<(const Base< Taylor<T> >& aa,
1412 template <
typename T>
1414 operator<(const typename Taylor<T>::value_type&
a,
1421 template <
typename T>
1423 operator<(const Base< Taylor<T> >& aa,
1427 return a.
coeff(0) < b;
1430 template <
typename T>
1440 template <
typename T>
1446 return a > b.
coeff(0);
1449 template <
typename T>
1455 return a.
coeff(0) > b;
1458 template <
typename T>
1460 bool is_zero =
true;
1462 is_zero = is_zero && (x.
coeff(
i) == 0.0);
1466 template <
typename T>
1475 template <
typename T>
1484 template <
typename T>
1493 template <
typename T>
1502 template <
typename T>
1511 template <
typename T>
1520 template <
typename T>
1522 operator << (std::ostream& os, const Base< Taylor<T> >& aa)
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.
void makeOwnCopy()
Make handle have its own copy of rep.
Taylor< T > log(const Base< Taylor< T > > &a)
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)
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
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.
bool operator||(const Base< Taylor< T > > &xx1, const Base< Taylor< T > > &xx2)
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)
Base class for Sacado types to control overload resolution.
Taylor< T > sin(const Base< Taylor< T > > &a)
bool operator&&(const Base< Taylor< T > > &xx1, const Base< Taylor< T > > &xx2)
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)
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)
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)
static SACADO_INLINE_FUNCTION void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
Taylor< T > fabs(const Base< Taylor< T > > &a)
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.
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.
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
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)
const derived_type & derived() const
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)
static SACADO_INLINE_FUNCTION T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
Taylor()
Default constructor.
bool toBool(const Taylor< T > &x)