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) {
142 th(new TaylorData(d,
x))
149 th(new TaylorData(d))
169resize(
int d,
bool keep_coeffs)
171 if (d+1 > length()) {
190 if (d+1 > length()) {
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];
287 for (
int i=0;
i<=th->deg_;
i++)
300 for (
int i=0;
i<=th->deg_;
i++)
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++)
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++)
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--)
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];
508 int dc = da > db ? da : db;
511 if ((da != db) && (da != 0) && (db != 0))
512 throw "operator+(): Arguments have incompatible degrees!";
516 const T* ca =
a.coeff();
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++)
552 for (
int i=1;
i<=dc;
i++)
568 const T* ca =
a.coeff();
572 for (
int i=1;
i<=dc;
i++)
588 int dc = da > db ? da : db;
591 if ((da != db) && (da != 0) && (db != 0))
592 throw "operator+(): Arguments have incompatible degrees!";
596 const T* ca =
a.coeff();
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++)
632 for (
int i=1;
i<=dc;
i++)
648 const T* ca =
a.coeff();
652 for (
int i=1;
i<=dc;
i++)
668 int dc = da > db ? da : db;
671 if ((da != db) && (da != 0) && (db != 0))
672 throw "operator+(): Arguments have incompatible degrees!";
676 const T* ca =
a.coeff();
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++)
714 for (
int i=0;
i<=dc;
i++)
730 const T* ca =
a.coeff();
733 for (
int i=0;
i<=dc;
i++)
749 int dc = da > db ? da : db;
752 if ((da != db) && (da != 0) && (db != 0))
753 throw "operator+(): Arguments have incompatible degrees!";
757 const T* ca =
a.coeff();
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];
803 for (
int i=1;
i<=dc;
i++) {
805 for (
int k=0; k<=
i; k++)
806 tmp -= cb[k]*cc[
i-k];
823 const T* ca =
a.coeff();
826 for (
int i=0;
i<=dc;
i++)
840 const T* ca =
a.coeff();
844 cc[0] = std::exp(ca[0]);
845 for (
int i=1;
i<=dc;
i++) {
847 for (
int k=1; k<=
i; k++)
848 tmp += k*cc[
i-k]*ca[k];
863 const T* ca =
a.coeff();
867 cc[0] = std::log(ca[0]);
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]);
883 return log(
a) / std::log(10.0);
894 const T* ca =
a.coeff();
898 cc[0] = std::sqrt(ca[0]);
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
934 return exp(b*std::log(
a));
956 if (
c.degree() != dc)
959 const T* ca =
a.coeff();
965 cs[0] = std::sin(ca[0]);
966 cc[0] = std::cos(ca[0]);
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];
1005template <
typename T>
1010 int dc =
a.degree();
1019template <
typename T>
1026 int dc =
a.degree();
1029 if (
c.degree() != dc)
1030 c.resize(dc,
false);
1032 const T* ca =
a.coeff();
1038 cs[0] = std::sinh(ca[0]);
1039 cc[0] = std::cosh(ca[0]);
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];
1052template <
typename T>
1057 int dc =
a.degree();
1065template <
typename T>
1070 int dc =
a.degree();
1078template <
typename T>
1083 int dc =
a.degree();
1092template <
typename T>
1100 int dc =
a.degree();
1103 const T* ca =
a.coeff();
1109 for (
int i=1;
i<=dc;
i++) {
1111 for (
int k=1; k<=
i; k++)
1112 tmp += k*ca[k]*cb[
i-k];
1119template <
typename T>
1125 return quad(std::acos(
a.coeff(0)),
a, b);
1128template <
typename T>
1134 return quad(std::asin(
a.coeff(0)),
a, b);
1137template <
typename T>
1143 return quad(std::atan(
a.coeff(0)),
a, b);
1146template <
typename T>
1159template <
typename T>
1171template <
typename T>
1179 c.fastAccessCoeff(0) =
atan2(
a.coeff(0),b);
1183template <
typename T>
1192template <
typename T>
1201template <
typename T>
1210template <
typename T>
1215 if (
a.coeff(0) >= 0)
1221template <
typename T>
1226 if (
a.coeff(0) >= 0)
1232template <
typename T>
1240 if (
a.coeff(0) >= b.
coeff(0))
1246template <
typename T>
1259template <
typename T>
1266 if (
a.coeff(0) >= b)
1272template <
typename T>
1280 if (
a.coeff(0) <= b.
coeff(0))
1286template <
typename T>
1299template <
typename T>
1306 if (
a.coeff(0) <= b)
1312template <
typename T>
1319 return a.coeff(0) == b.
coeff(0);
1322template <
typename T>
1331template <
typename T>
1337 return a.coeff(0) == b;
1340template <
typename T>
1347 return a.coeff(0) != b.
coeff(0);
1350template <
typename T>
1359template <
typename T>
1365 return a.coeff(0) != b;
1368template <
typename T>
1375 return a.coeff(0) <= b.
coeff(0);
1378template <
typename T>
1387template <
typename T>
1393 return a.coeff(0) <= b;
1396template <
typename T>
1403 return a.coeff(0) >= b.
coeff(0);
1406template <
typename T>
1415template <
typename T>
1421 return a.coeff(0) >= b;
1424template <
typename T>
1431 return a.coeff(0) < b.
coeff(0);
1434template <
typename T>
1443template <
typename T>
1449 return a.coeff(0) < b;
1452template <
typename T>
1459 return a.coeff(0) > b.
coeff(0);
1462template <
typename T>
1471template <
typename T>
1477 return a.coeff(0) > b;
1480template <
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);
1488template <
typename T>
1497template <
typename T>
1506template <
typename T>
1515template <
typename T>
1524template <
typename T>
1533template <
typename T>
1542template <
typename T>
1549 for (
int i=0;
i<=
a.degree();
i++) {
1550 os <<
a.coeff(
i) <<
" ";
atan2(expr1.val(), expr2.val())
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
void makeOwnCopy()
Make handle have its own copy of rep.
Taylor< T > & operator-=(const T &x)
Subtraction-assignment operator with constant right-hand-side.
Taylor< T > & operator/=(const T &x)
Division-assignment operator with constant right-hand-side.
Sacado::Handle< TaylorData > th
void resizeCoeffs(int len)
Resize coefficient array to new size.
void reserve(int d)
Reserve space for a degree d polynomial.
Taylor< T > & operator=(const T &val)
Assignment operator with constant right-hand-side.
Taylor< T > & operator+=(const T &x)
Addition-assignment operator with constant right-hand-side.
int degree() const
Returns degree of polynomial.
Taylor< T > & operator*=(const T &x)
Multiplication-assignment operator with constant right-hand-side.
Taylor< T > operator+() const
Unary-plus operator.
T value_type
Typename of values.
Taylor< T > operator-() const
Unary-minus operator.
const T * coeff() const
Returns Taylor coefficient array.
void resize(int d, bool keep_coeffs)
Resize polynomial to degree d.
Taylor()
Default constructor.
Taylor< T > operator*(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > operator-(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
bool operator==(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > operator+(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
bool operator!=(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
bool operator>=(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Taylor< T > operator/(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
void sincos(const Base< Taylor< T > > &a, Taylor< T > &s, Taylor< T > &c)
bool operator&&(const Base< Taylor< T > > &xx1, const Base< Taylor< T > > &xx2)
void sinhcosh(const Base< Taylor< T > > &a, Taylor< T > &s, Taylor< T > &c)
bool operator||(const Base< Taylor< T > > &xx1, const Base< Taylor< T > > &xx2)
bool operator>(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
std::ostream & operator<<(std::ostream &os, const Expr< ExprT > &x)
bool operator<=(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
bool toBool(const Taylor< T > &x)
Taylor< T > quad(const typename Taylor< T >::value_type &c0, const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
bool operator<(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Base class for Sacado types to control overload resolution.
const derived_type & derived() const
T * coeff_
Taylor polynomial coefficients.
TaylorData & operator=(const TaylorData &x)
Assignment operator.
int len_
Length of allocated polynomial array.
TaylorData()
Default constructor.
static SACADO_INLINE_FUNCTION T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
static SACADO_INLINE_FUNCTION void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.