31 #if defined (__clang__) && !defined (__INTEL_COMPILER)
32 #pragma clang system_header
45 coeff_(NULL), deg_(-1), len_(0)
52 coeff_(), deg_(0), len_(1)
61 coeff_(), deg_(d), len_(d+1)
70 coeff_(), deg_(d), len_(d+1)
78 coeff_(), deg_(d), len_(l)
86 coeff_(), deg_(x.deg_), len_(x.deg_+1)
104 if (len_ < x.
deg_+1) {
118 template <
typename T>
125 template <
typename T>
132 template <
typename T>
139 template <
typename T>
146 template <
typename T>
153 template <
typename T>
160 template <
typename T>
166 template <
typename T>
171 if (d+1 > length()) {
185 template <
typename T>
190 if (d+1 > length()) {
197 template <
typename T>
216 template <
typename T>
224 template <
typename T>
233 template <
typename T>
241 template <
typename T>
247 x.
th->deg_ = th->deg_;
248 x.
th->len_ = th->deg_+1;
250 for (
int i=0; i<=th->deg_; i++)
251 x.
th->coeff_[i] = -th->coeff_[i];
256 template <
typename T>
268 template <
typename T>
280 template <
typename T>
287 for (
int i=0; i<=th->deg_; i++)
293 template <
typename T>
300 for (
int i=0; i<=th->deg_; i++)
306 template <
typename T>
315 int dmin = xd < d ? xd : d;
318 bool need_resize = l > length();
322 for (
int i=0; i<=d; i++)
323 c[i] = fastAccessCoeff(i);
327 T* xc = x.
th->coeff_;
329 for (
int i=0; i<=dmin; i++)
332 for (
int i=d+1; i<=xd; i++)
346 template <
typename T>
355 int dmin = xd < d ? xd : d;
358 bool need_resize = l > length();
362 for (
int i=0; i<=d; i++)
363 c[i] = fastAccessCoeff(i);
367 T* xc = x.
th->coeff_;
369 for (
int i=0; i<=dmin; i++)
372 for (
int i=d+1; i<=xd; i++)
386 template <
typename T>
395 if ((xd != d) && (xd != 0) && (d != 0))
396 throw "Taylor Error: Attempt to assign with incompatible degrees";
400 T* xc = x.
th->coeff_;
402 if (d > 0 && xd > 0) {
406 for (
int i=0; i<=d; i++) {
408 for (
int k=0; k<=i; ++k)
416 for (
int i=0; i<=d; i++)
420 if (length() < xd+1) {
423 for (
int i=0; i<=xd; i++)
429 for (
int i=d; i>=0; i--)
437 template <
typename T>
446 if ((xd != d) && (xd != 0) && (d != 0))
447 throw "Taylor Error: Attempt to assign with incompatible degrees";
451 T* xc = x.
th->coeff_;
453 if (d > 0 && xd > 0) {
457 for(
int i=0; i<=d; i++) {
459 for (
int k=1; k<=i; ++k)
460 tmp -= xc[k]*cc[i-k];
467 for (
int i=0; i<=d; i++)
474 cc[0] = c[0] / xc[0];
475 for (
int i=1; i<=xd; i++) {
477 for (
int k=1; k<=i; ++k)
478 tmp -= xc[k]*cc[i-k];
487 template <
typename T>
498 template <
typename T>
508 int dc = da > db ? da : db;
511 if ((da != db) && (da != 0) && (db != 0))
512 throw "operator+(): Arguments have incompatible degrees!";
520 if (da > 0 && db > 0) {
521 for (
int i=0; i<=dc; i++)
522 cc[i] = ca[i] + cb[i];
525 cc[0] = ca[0] + cb[0];
526 for (
int i=1; i<=dc; i++)
530 cc[0] = ca[0] + cb[0];
531 for (
int i=1; i<=dc; i++)
538 template <
typename T>
552 for (
int i=1; i<=dc; i++)
558 template <
typename T>
572 for (
int i=1; i<=dc; i++)
578 template <
typename T>
588 int dc = da > db ? da : db;
591 if ((da != db) && (da != 0) && (db != 0))
592 throw "operator+(): Arguments have incompatible degrees!";
600 if (da > 0 && db > 0) {
601 for (
int i=0; i<=dc; i++)
602 cc[i] = ca[i] - cb[i];
605 cc[0] = ca[0] - cb[0];
606 for (
int i=1; i<=dc; i++)
610 cc[0] = ca[0] - cb[0];
611 for (
int i=1; i<=dc; i++)
618 template <
typename T>
632 for (
int i=1; i<=dc; i++)
638 template <
typename T>
652 for (
int i=1; i<=dc; i++)
658 template <
typename T>
668 int dc = da > db ? da : db;
671 if ((da != db) && (da != 0) && (db != 0))
672 throw "operator+(): Arguments have incompatible degrees!";
680 if (da > 0 && db > 0) {
682 for (
int i=0; i<=dc; i++) {
684 for (
int k=0; k<=i; k++)
685 tmp += ca[k]*cb[i-k];
690 for (
int i=0; i<=dc; i++)
694 for (
int i=0; i<=dc; i++)
701 template <
typename T>
714 for (
int i=0; i<=dc; i++)
720 template <
typename T>
733 for (
int i=0; i<=dc; i++)
739 template <
typename T>
749 int dc = da > db ? da : db;
752 if ((da != db) && (da != 0) && (db != 0))
753 throw "operator+(): Arguments have incompatible degrees!";
761 if (da > 0 && db > 0) {
763 for (
int i=0; i<=dc; i++) {
765 for (
int k=0; k<=i; k++)
766 tmp -= cb[k]*cc[i-k];
771 for (
int i=0; i<=dc; i++)
776 cc[0] = ca[0] / cb[0];
777 for (
int i=1; i<=dc; i++) {
779 for (
int k=0; k<=i; k++)
780 tmp -= cb[k]*cc[i-k];
788 template <
typename T>
803 for (
int i=1; i<=dc; i++) {
805 for (
int k=0; k<=i; k++)
806 tmp -= cb[k]*cc[i-k];
813 template <
typename T>
826 for (
int i=0; i<=dc; i++)
832 template <
typename T>
845 for (
int i=1; i<=dc; i++) {
847 for (
int k=1; k<=i; k++)
848 tmp += k*cc[i-k]*ca[k];
855 template <
typename T>
868 for (
int i=1; i<=dc; i++) {
870 for (
int k=1; k<=i-1; k++)
871 tmp -= k*ca[i-k]*cc[k];
872 cc[i] = tmp / (i*ca[0]);
878 template <
typename T>
886 template <
typename T>
899 for (
int i=1; i<=dc; i++) {
901 for (
int k=1; k<=i-1; k++)
902 tmp -= cc[k]*cc[i-k];
903 cc[i] = tmp / (2.0*cc[0]);
909 #ifdef HAVE_SACADO_CXX11
910 template <
typename T>
914 return pow(aa,
typename Taylor<T>::value_type(1.0/3.0));
918 template <
typename T>
928 template <
typename T>
937 template <
typename T>
946 template <
typename T>
967 for (
int i=1; i<=dc; i++) {
970 for (
int k=1; k<=i; k++) {
971 tmp1 += k*ca[k]*cc[i-k];
972 tmp2 -= k*ca[k]*cs[i-k];
979 template <
typename T>
992 template <
typename T>
1005 template <
typename T>
1019 template <
typename T>
1040 for (
int i=1; i<=dc; i++) {
1043 for (
int k=1; k<=i; k++) {
1044 tmp1 += k*ca[k]*cc[i-k];
1045 tmp2 += k*ca[k]*cs[i-k];
1052 template <
typename T>
1065 template <
typename T>
1078 template <
typename T>
1092 template <
typename T>
1109 for (
int i=1; i<=dc; i++) {
1111 for (
int k=1; k<=i; k++)
1112 tmp += k*ca[k]*cb[i-k];
1119 template <
typename T>
1128 template <
typename T>
1137 template <
typename T>
1146 template <
typename T>
1159 template <
typename T>
1171 template <
typename T>
1183 template <
typename T>
1192 template <
typename T>
1201 template <
typename T>
1210 template <
typename T>
1215 if (a.
coeff(0) >= 0)
1221 template <
typename T>
1226 if (a.
coeff(0) >= 0)
1232 template <
typename T>
1246 template <
typename T>
1253 if (a >= b.
coeff(0))
1259 template <
typename T>
1266 if (a.
coeff(0) >= b)
1272 template <
typename T>
1286 template <
typename T>
1293 if (a <= b.
coeff(0))
1299 template <
typename T>
1306 if (a.
coeff(0) <= b)
1312 template <
typename T>
1322 template <
typename T>
1328 return a == b.
coeff(0);
1331 template <
typename T>
1337 return a.
coeff(0) == b;
1340 template <
typename T>
1350 template <
typename T>
1356 return a != b.
coeff(0);
1359 template <
typename T>
1365 return a.
coeff(0) != b;
1368 template <
typename T>
1370 operator<=(const Base< Taylor<T> >& aa,
1378 template <
typename T>
1380 operator<=(const typename Taylor<T>::value_type&
a,
1387 template <
typename T>
1389 operator<=(const Base< Taylor<T> >& aa,
1393 return a.
coeff(0) <= b;
1396 template <
typename T>
1406 template <
typename T>
1412 return a >= b.
coeff(0);
1415 template <
typename T>
1421 return a.
coeff(0) >= b;
1424 template <
typename T>
1426 operator<(const Base< Taylor<T> >& aa,
1434 template <
typename T>
1436 operator<(const typename Taylor<T>::value_type&
a,
1443 template <
typename T>
1445 operator<(const Base< Taylor<T> >& aa,
1449 return a.
coeff(0) < b;
1452 template <
typename T>
1462 template <
typename T>
1468 return a > b.
coeff(0);
1471 template <
typename T>
1477 return a.
coeff(0) > b;
1480 template <
typename T>
1482 bool is_zero =
true;
1483 for (
int i=0; i<=x.
degree(); i++)
1484 is_zero = is_zero && (x.
coeff(i) == 0.0);
1488 template <
typename T>
1497 template <
typename T>
1506 template <
typename T>
1515 template <
typename T>
1524 template <
typename T>
1533 template <
typename T>
1542 template <
typename T>
1544 operator << (std::ostream& os, const Base< Taylor<T> >& aa)
1549 for (
int i=0; i<=a.
degree(); i++) {
1550 os << a.
coeff(i) <<
" ";
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)
static KOKKOS_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
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)
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.
static KOKKOS_INLINE_FUNCTION void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
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.
static KOKKOS_INLINE_FUNCTION T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
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 > fabs(const Base< Taylor< T > > &a)
static KOKKOS_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
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.
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)
Taylor()
Default constructor.
bool toBool(const Taylor< T > &x)