Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Tay_CacheTaylorOps.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 // @HEADER
29 
30 #ifndef SACADO_TAY_CACHETAYLOROPS_HPP
31 #define SACADO_TAY_CACHETAYLOROPS_HPP
32 
34 
35 #include <cmath>
36 #include <valarray>
37 #include <algorithm> // for std::min and std::max
38 #include <ostream> // for std::ostream
39 
40 namespace Sacado {
41 
42  namespace Tay {
43 
44  // ---------------------- Unary Addition operator ------------------------
45 
46  template <typename ExprT>
47  class UnaryPlusOp {
48  public:
49 
50  typedef typename ExprT::value_type value_type;
51  typedef typename ExprT::scalar_type scalar_type;
52  typedef typename ExprT::base_expr_type base_expr_type;
53 
54  UnaryPlusOp(const ExprT& expr) {}
55 
56  void allocateCache(int d) const {}
57 
58  value_type computeCoeff(int i, const ExprT& expr) const {
59  return expr.coeff(i);
60  }
61 
63  const ExprT& expr) const {
64  return expr.fastAccessCoeff(i);
65  }
66 
67  }; // class UnaryPlusOp
68 
69  // ---------------------- Unary Subtraction operator ---------------------
70 
71  template <typename ExprT>
72  class UnaryMinusOp {
73  public:
74 
75  typedef typename ExprT::value_type value_type;
76  typedef typename ExprT::scalar_type scalar_type;
77  typedef typename ExprT::base_expr_type base_expr_type;
78 
79  UnaryMinusOp(const ExprT& expr) {}
80 
81  void allocateCache(int d) const {}
82 
83  value_type computeCoeff(int i, const ExprT& expr) const {
84  return -expr.coeff(i);
85  }
86 
88  const ExprT& expr) const {
89  return -expr.fastAccessCoeff(i);
90  }
91 
92  }; // class UnaryPlusOp
93 
94  // -------------------------- exp() function -----------------------------
95 
96  template <typename ExprT>
97  class ExpOp {
98  public:
99 
100  typedef typename ExprT::value_type value_type;
101  typedef typename ExprT::scalar_type scalar_type;
102  typedef typename ExprT::base_expr_type base_expr_type;
103 
104  ExpOp(const ExprT& expr) :
105  c(),
106  dc(-1) {}
107 
108  void allocateCache(int d) const {
109  c.resize(d+1,value_type(0));
110  }
111 
112  value_type computeCoeff(int i, const ExprT& expr) const {
113  if (static_cast<int>(i) > dc) {
114  if (dc < 0) {
115  c[0] = std::exp(expr.fastAccessCoeff(0));
116  dc = 0;
117  }
118  for (int k=dc+1; k<=i; k++) {
119  for (int j=1; j<=k; j++)
120  c[k] += value_type(j)*c[k-j]*expr.coeff(j);
121  c[k] /= value_type(k);
122  }
123  dc = i;
124  }
125  return c[i];
126  }
127 
129  const ExprT& expr) const
130  {
131  if (static_cast<int>(i) > dc) {
132  if (dc < 0) {
133  c[0] = std::exp(expr.fastAccessCoeff(0));
134  dc = 0;
135  }
136  for (int k=dc+1; k<=i; k++) {
137  for (int j=1; j<=k; j++)
138  c[k] += value_type(j)*c[k-j]*expr.fastAccessCoeff(j);
139  c[k] /= value_type(k);
140  }
141  dc = i;
142  }
143  return c[i];
144  }
145 
146  protected:
147 
148  mutable std::valarray<value_type> c;
149  mutable int dc;
150 
151  }; // class ExpOp
152 
153  // -------------------------- log() function -----------------------------
154 
155  template <typename ExprT>
156  class LogOp {
157  public:
158 
159  typedef typename ExprT::value_type value_type;
160  typedef typename ExprT::scalar_type scalar_type;
161  typedef typename ExprT::base_expr_type base_expr_type;
162 
163  LogOp(const ExprT& expr) :
164  c(),
165  dc(-1)
166  {}
167 
168  void allocateCache(int d) const {
169  c.resize(d+1,value_type(0));
170  }
171 
172  value_type computeCoeff(int i, const ExprT& expr) const {
173  if (static_cast<int>(i) > dc) {
174  if (dc < 0) {
175  c[0] = std::log(expr.fastAccessCoeff(0));
176  dc = 0;
177  }
178  for (int k=dc+1; k<=i; k++) {
179  c[k] = value_type(k)*expr.coeff(k);
180  for (int j=1; j<=k-1; j++)
181  c[k] -= value_type(j)*expr.coeff(k-j)*c[j];
182  c[k] /= (value_type(k)*expr.fastAccessCoeff(0));
183  }
184  dc = i;
185  }
186  return c[i];
187  }
188 
190  const ExprT& expr) const
191  {
192  if (static_cast<int>(i) > dc) {
193  if (dc < 0) {
194  c[0] = std::log(expr.fastAccessCoeff(0));
195  dc = 0;
196  }
197  for (int k=dc+1; k<=i; k++) {
198  c[k] = value_type(k)*expr.fastAccessCoeff(k);
199  for (int j=1; j<=k-1; j++)
200  c[k] -= value_type(j)*expr.fastAccessCoeff(k-j)*c[j];
201  c[k] /= (value_type(k)*expr.fastAccessCoeff(0));
202  }
203  dc = i;
204  }
205  return c[i];
206  }
207 
208  protected:
209 
210  mutable std::valarray<value_type> c;
211  mutable int dc;
212 
213  }; // class LogOp
214 
215  // -------------------------- sqrt() function -----------------------------
216 
217  template <typename ExprT>
218  class SqrtOp {
219  public:
220 
221  typedef typename ExprT::value_type value_type;
222  typedef typename ExprT::scalar_type scalar_type;
223  typedef typename ExprT::base_expr_type base_expr_type;
224 
225  SqrtOp(const ExprT& expr) :
226  c(),
227  dc(-1) {}
228 
229  void allocateCache(int d) const {
230  c.resize(d+1,value_type(0));
231  }
232 
233  value_type computeCoeff(int i, const ExprT& expr) const {
234  if (static_cast<int>(i) > dc) {
235  if (dc < 0) {
236  c[0] = std::sqrt(expr.fastAccessCoeff(0));
237  dc = 0;
238  }
239  value_type tmp = value_type(2)*c[0];
240  for (int k=dc+1; k<=i; k++) {
241  c[k] = expr.coeff(k);
242  for (int j=1; j<=k-1; j++)
243  c[k] -= c[j]*c[k-j];
244  c[k] /= tmp;
245  }
246  dc = i;
247  }
248  return c[i];
249  }
250 
252  const ExprT& expr) const
253  {
254  if (static_cast<int>(i) > dc) {
255  if (dc < 0) {
256  c[0] = std::sqrt(expr.fastAccessCoeff(0));
257  dc = 0;
258  }
259  value_type tmp = value_type(2)*c[0];
260  for (int k=dc+1; k<=i; k++) {
261  c[k] = expr.fastAccessCoeff(k);
262  for (int j=1; j<=k-1; j++)
263  c[k] -= c[j]*c[k-j];
264  c[k] /= tmp;
265  }
266  dc = i;
267  }
268  return c[i];
269  }
270 
271  protected:
272 
273  mutable std::valarray<value_type> c;
274  mutable int dc;
275 
276  }; // class SqrtOp
277 
278  // -------------------------- cos() function -----------------------------
279 
280  template <typename ExprT>
281  class CosOp {
282  public:
283 
284  typedef typename ExprT::value_type value_type;
285  typedef typename ExprT::scalar_type scalar_type;
286  typedef typename ExprT::base_expr_type base_expr_type;
287 
288  CosOp(const ExprT& expr) :
289  c(),
290  s(),
291  dc(-1) {}
292 
293  void allocateCache(int d) const {
294  c.resize(d+1,value_type(0));
295  s.resize(d+1,value_type(0));
296  }
297 
298  value_type computeCoeff(int i, const ExprT& expr) const {
299  if (static_cast<int>(i) > dc) {
300  if (dc < 0) {
301  c[0] = std::cos(expr.fastAccessCoeff(0));
302  s[0] = std::sin(expr.fastAccessCoeff(0));
303  dc = 0;
304  }
305  for (int k=dc+1; k<=i; k++) {
306  for (int j=1; j<=k; j++) {
307  c[k] -= value_type(j)*expr.coeff(j)*s[k-j];
308  s[k] += value_type(j)*expr.coeff(j)*c[k-j];
309  }
310  c[k] /= value_type(k);
311  s[k] /= value_type(k);
312  }
313  dc = i;
314  }
315  return c[i];
316  }
317 
319  const ExprT& expr) const
320  {
321  if (static_cast<int>(i) > dc) {
322  if (dc < 0) {
323  c[0] = std::cos(expr.fastAccessCoeff(0));
324  s[0] = std::sin(expr.fastAccessCoeff(0));
325  dc = 0;
326  }
327  for (int k=dc+1; k<=i; k++) {
328  for (int j=1; j<=k; j++) {
329  c[k] -= value_type(j)*expr.fastAccessCoeff(j)*s[k-j];
330  s[k] += value_type(j)*expr.fastAccessCoeff(j)*c[k-j];
331  }
332  c[k] /= value_type(k);
333  s[k] /= value_type(k);
334  }
335  dc = i;
336  }
337  return c[i];
338  }
339 
340  protected:
341 
342  mutable std::valarray<value_type> c;
343  mutable std::valarray<value_type> s;
344  mutable int dc;
345 
346  }; // class CosOp
347 
348  // -------------------------- sin() function -----------------------------
349 
350  template <typename ExprT>
351  class SinOp {
352  public:
353 
354  typedef typename ExprT::value_type value_type;
355  typedef typename ExprT::scalar_type scalar_type;
356  typedef typename ExprT::base_expr_type base_expr_type;
357 
358  SinOp(const ExprT& expr) :
359  c(),
360  s(),
361  dc(-1) {}
362 
363  void allocateCache(int d) const {
364  c.resize(d+1,value_type(0));
365  s.resize(d+1,value_type(0));
366  }
367 
368  value_type computeCoeff(int i, const ExprT& expr) const {
369  if (static_cast<int>(i) > dc) {
370  if (dc < 0) {
371  c[0] = std::cos(expr.fastAccessCoeff(0));
372  s[0] = std::sin(expr.fastAccessCoeff(0));
373  dc = 0;
374  }
375  for (int k=dc+1; k<=i; k++) {
376  for (int j=1; j<=k; j++) {
377  c[k] -= value_type(j)*expr.coeff(j)*s[k-j];
378  s[k] += value_type(j)*expr.coeff(j)*c[k-j];
379  }
380  c[k] /= value_type(k);
381  s[k] /= value_type(k);
382  }
383  dc = i;
384  }
385  return s[i];
386  }
387 
389  const ExprT& expr) const
390  {
391  if (static_cast<int>(i) > dc) {
392  if (dc < 0) {
393  c[0] = std::cos(expr.fastAccessCoeff(0));
394  s[0] = std::sin(expr.fastAccessCoeff(0));
395  dc = 0;
396  }
397  for (int k=dc+1; k<=i; k++) {
398  for (int j=1; j<=k; j++) {
399  c[k] -= value_type(j)*expr.fastAccessCoeff(j)*s[k-j];
400  s[k] += value_type(j)*expr.fastAccessCoeff(j)*c[k-j];
401  }
402  c[k] /= value_type(k);
403  s[k] /= value_type(k);
404  }
405  dc = i;
406  }
407  return s[i];
408  }
409 
410  protected:
411 
412  mutable std::valarray<value_type> c;
413  mutable std::valarray<value_type> s;
414  mutable int dc;
415 
416  }; // class SinOp
417 
418  // -------------------------- cosh() function -----------------------------
419 
420  template <typename ExprT>
421  class CoshOp {
422  public:
423 
424  typedef typename ExprT::value_type value_type;
425  typedef typename ExprT::scalar_type scalar_type;
426  typedef typename ExprT::base_expr_type base_expr_type;
427 
428  CoshOp(const ExprT& expr) :
429  c(),
430  s(),
431  dc(-1) {}
432 
433  void allocateCache(int d) const {
434  c.resize(d+1,value_type(0));
435  s.resize(d+1,value_type(0));
436  }
437 
438  value_type computeCoeff(int i, const ExprT& expr) const {
439  if (static_cast<int>(i) > dc) {
440  if (dc < 0) {
441  c[0] = std::cosh(expr.fastAccessCoeff(0));
442  s[0] = std::sinh(expr.fastAccessCoeff(0));
443  dc = 0;
444  }
445  for (int k=dc+1; k<=i; k++) {
446  for (int j=1; j<=k; j++) {
447  c[k] += value_type(j)*expr.coeff(j)*s[k-j];
448  s[k] += value_type(j)*expr.coeff(j)*c[k-j];
449  }
450  c[k] /= value_type(k);
451  s[k] /= value_type(k);
452  }
453  dc = i;
454  }
455  return c[i];
456  }
457 
459  const ExprT& expr) const
460  {
461  if (static_cast<int>(i) > dc) {
462  if (dc < 0) {
463  c[0] = std::cosh(expr.fastAccessCoeff(0));
464  s[0] = std::sinh(expr.fastAccessCoeff(0));
465  dc = 0;
466  }
467  for (int k=dc+1; k<=i; k++) {
468  for (int j=1; j<=k; j++) {
469  c[k] += value_type(j)*expr.fastAccessCoeff(j)*s[k-j];
470  s[k] += value_type(j)*expr.fastAccessCoeff(j)*c[k-j];
471  }
472  c[k] /= value_type(k);
473  s[k] /= value_type(k);
474  }
475  dc = i;
476  }
477  return c[i];
478  }
479 
480  protected:
481 
482  mutable std::valarray<value_type> c;
483  mutable std::valarray<value_type> s;
484  mutable int dc;
485 
486  }; // class CoshOp
487 
488  // -------------------------- sinh() function -----------------------------
489 
490  template <typename ExprT>
491  class SinhOp {
492  public:
493 
494  typedef typename ExprT::value_type value_type;
495  typedef typename ExprT::scalar_type scalar_type;
496  typedef typename ExprT::base_expr_type base_expr_type;
497 
498  SinhOp(const ExprT& expr) :
499  c(),
500  s(),
501  dc(-1) {}
502 
503  void allocateCache(int d) const {
504  c.resize(d+1,value_type(0));
505  s.resize(d+1,value_type(0));
506  }
507 
508  value_type computeCoeff(int i, const ExprT& expr) const {
509  if (static_cast<int>(i) > dc) {
510  if (dc < 0) {
511  c[0] = std::cosh(expr.fastAccessCoeff(0));
512  s[0] = std::sinh(expr.fastAccessCoeff(0));
513  dc = 0;
514  }
515  for (int k=dc+1; k<=i; k++) {
516  for (int j=1; j<=k; j++) {
517  c[k] += value_type(j)*expr.coeff(j)*s[k-j];
518  s[k] += value_type(j)*expr.coeff(j)*c[k-j];
519  }
520  c[k] /= value_type(k);
521  s[k] /= value_type(k);
522  }
523  dc = i;
524  }
525  return s[i];
526  }
527 
529  const ExprT& expr) const
530  {
531  if (static_cast<int>(i) > dc) {
532  if (dc < 0) {
533  c[0] = std::cosh(expr.fastAccessCoeff(0));
534  s[0] = std::sinh(expr.fastAccessCoeff(0));
535  dc = 0;
536  }
537  for (int k=dc+1; k<=i; k++) {
538  for (int j=1; j<=k; j++) {
539  c[k] += value_type(j)*expr.fastAccessCoeff(j)*s[k-j];
540  s[k] += value_type(j)*expr.fastAccessCoeff(j)*c[k-j];
541  }
542  c[k] /= value_type(k);
543  s[k] /= value_type(k);
544  }
545  dc = i;
546  }
547  return s[i];
548  }
549 
550  protected:
551 
552  mutable std::valarray<value_type> c;
553  mutable std::valarray<value_type> s;
554  mutable int dc;
555 
556  }; // class SinhOp
557 
558  // -------------------------- fabs() function -----------------------------
559 
560  template <typename ExprT>
561  class FAbsOp {
562  public:
563 
564  typedef typename ExprT::value_type value_type;
565  typedef typename ExprT::scalar_type scalar_type;
566  typedef typename ExprT::base_expr_type base_expr_type;
567 
568  FAbsOp(const ExprT& expr) {}
569 
570  void allocateCache(int d) const {}
571 
572  value_type computeCoeff(int i, const ExprT& expr) const {
573  if (expr.fastAccessCoeff(0) > 0)
574  return expr.coeff(i);
575  else
576  return -expr.coeff(i);
577  }
578 
580  const ExprT& expr) const
581  {
582  if (expr.fastAccessCoeff(0) > 0)
583  return expr.fastAccessCoeff(i);
584  else
585  return -expr.fastAccessCoeff(i);
586  }
587 
588  }; // class FAbsOp
589 
590  } // namespace Tay
591 
592 } // namespace Sacado
593 
594 #define TAYLOR_UNARYOP_MACRO(OPNAME,OP) \
595 namespace Sacado { \
596  namespace Tay { \
597  template <typename T> \
598  inline Expr< UnaryExpr< Expr<T>, OP > > \
599  OPNAME (const Expr<T>& expr) \
600  { \
601  typedef UnaryExpr< Expr<T>, OP > expr_t; \
602  \
603  return Expr<expr_t>(expr_t(expr)); \
604  } \
605  } \
606 } \
607  \
608 namespace std { \
609  using Sacado::Tay::OPNAME; \
610 }
611 
612 TAYLOR_UNARYOP_MACRO(operator+, UnaryPlusOp)
623 
624 #undef TAYLOR_UNARYOP_MACRO
625 
626 namespace Sacado {
627 
628  namespace Tay {
629 
630  // ---------------------- Addition operator -----------------------------
631 
632  template <typename ExprT1, typename ExprT2>
633  class AdditionOp {
634  public:
635 
636  typedef typename ExprT1::value_type value_type_1;
637  typedef typename ExprT2::value_type value_type_2;
638  typedef typename Sacado::Promote<value_type_1,
640 
641  typedef typename ExprT1::scalar_type scalar_type_1;
642  typedef typename ExprT2::scalar_type scalar_type_2;
643  typedef typename Sacado::Promote<scalar_type_1,
645 
646  typedef typename ExprT1::base_expr_type base_expr_type_1;
647  typedef typename ExprT2::base_expr_type base_expr_type_2;
648  typedef typename Sacado::Promote<base_expr_type_1,
650 
651  AdditionOp(const ExprT1& expr1, const ExprT2 expr2) {}
652 
653  void allocateCache(int d) const {}
654 
655  value_type
656  computeCoeff(int i, const ExprT1& expr1,
657  const ExprT2& expr2) const {
658  return expr1.coeff(i) + expr2.coeff(i);
659  }
660 
661  value_type
662  computeFastAccessCoeff(int i, const ExprT1& expr1,
663  const ExprT2& expr2) const {
664  return expr1.fastAccessCoeff(i) + expr2.fastAccessCoeff(i);
665  }
666 
667  }; // class AdditionOp
668 
669  template <typename ExprT1>
670  class AdditionOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
671  public:
672 
673  typedef typename ExprT1::value_type value_type;
674  typedef typename ExprT1::scalar_type scalar_type;
675  typedef typename ExprT1::base_expr_type base_expr_type;
677 
678  AdditionOp(const ExprT1& expr1, const ExprT2 expr2) {}
679 
680  void allocateCache(int d) const {}
681 
682  value_type
683  computeCoeff(int i, const ExprT1& expr1,
684  const ExprT2& expr2) const {
685  if (i == 0)
686  return expr1.coeff(i) + expr2.coeff(i);
687  else
688  return expr1.coeff(i);
689  }
690 
691  value_type
692  computeFastAccessCoeff(int i, const ExprT1& expr1,
693  const ExprT2& expr2) const {
694  if (i == 0)
695  return expr1.fastAccessCoeff(i) + expr2.fastAccessCoeff(i);
696  else
697  return expr1.fastAccessCoeff(i);
698  }
699 
700  }; // class AdditionOp
701 
702  template <typename ExprT2>
703  class AdditionOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
704  public:
705 
706  typedef typename ExprT2::value_type value_type;
707  typedef typename ExprT2::scalar_type scalar_type;
708  typedef typename ExprT2::base_expr_type base_expr_type;
710 
711  AdditionOp(const ExprT1& expr1, const ExprT2 expr2) {}
712 
713  void allocateCache(int d) const {}
714 
715  value_type
716  computeCoeff(int i, const ExprT1& expr1,
717  const ExprT2& expr2) const {
718  if (i == 0)
719  return expr1.coeff(i) + expr2.coeff(i);
720  else
721  return expr2.coeff(i);
722  }
723 
724  value_type
725  computeFastAccessCoeff(int i, const ExprT1& expr1,
726  const ExprT2& expr2) const {
727  if (i == 0)
728  return expr1.fastAccessCoeff(i) + expr2.fastAccessCoeff(i);
729  else
730  return expr2.fastAccessCoeff(i);
731  }
732 
733  }; // class AdditionOp
734 
735  // ---------------------- Subtraction operator ---------------------------
736 
737  template <typename ExprT1, typename ExprT2>
739  public:
740 
741  typedef typename ExprT1::value_type value_type_1;
742  typedef typename ExprT2::value_type value_type_2;
743  typedef typename Sacado::Promote<value_type_1,
745 
746  typedef typename ExprT1::scalar_type scalar_type_1;
747  typedef typename ExprT2::scalar_type scalar_type_2;
748  typedef typename Sacado::Promote<scalar_type_1,
750 
751  typedef typename ExprT1::base_expr_type base_expr_type_1;
752  typedef typename ExprT2::base_expr_type base_expr_type_2;
753  typedef typename Sacado::Promote<base_expr_type_1,
755 
756  SubtractionOp(const ExprT1& expr1, const ExprT2 expr2) {}
757 
758  void allocateCache(int d) const {}
759 
760  value_type
761  computeCoeff(int i, const ExprT1& expr1,
762  const ExprT2& expr2) const {
763  return expr1.coeff(i) - expr2.coeff(i);
764  }
765 
766  value_type
767  computeFastAccessCoeff(int i, const ExprT1& expr1,
768  const ExprT2& expr2) const {
769  return expr1.fastAccessCoeff(i) - expr2.fastAccessCoeff(i);
770  }
771 
772  }; // class SubtractionOp
773 
774  template <typename ExprT1>
775  class SubtractionOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
776  public:
777 
778  typedef typename ExprT1::value_type value_type;
779  typedef typename ExprT1::scalar_type scalar_type;
780  typedef typename ExprT1::base_expr_type base_expr_type;
782 
783  SubtractionOp(const ExprT1& expr1, const ExprT2 expr2) {}
784 
785  void allocateCache(int d) const {}
786 
787  value_type
788  computeCoeff(int i, const ExprT1& expr1,
789  const ExprT2& expr2) const {
790  if (i == 0)
791  return expr1.coeff(i) - expr2.coeff(i);
792  else
793  return expr1.coeff(i);
794  }
795 
796  value_type
797  computeFastAccessCoeff(int i, const ExprT1& expr1,
798  const ExprT2& expr2) const {
799  if (i == 0)
800  return expr1.fastAccessCoeff(i) - expr2.fastAccessCoeff(i);
801  else
802  return expr1.fastAccessCoeff(i);
803  }
804 
805  }; // class SubtractionOp
806 
807  template <typename ExprT2>
808  class SubtractionOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
809  public:
810 
811  typedef typename ExprT2::value_type value_type;
812  typedef typename ExprT2::scalar_type scalar_type;
813  typedef typename ExprT2::base_expr_type base_expr_type;
815 
816  SubtractionOp(const ExprT1& expr1, const ExprT2 expr2) {}
817 
818  void allocateCache(int d) const {}
819 
820  value_type
821  computeCoeff(int i, const ExprT1& expr1,
822  const ExprT2& expr2) const {
823  if (i == 0)
824  return expr1.coeff(i) - expr2.coeff(i);
825  else
826  return -expr2.coeff(i);
827  }
828 
829  value_type
830  computeFastAccessCoeff(int i, const ExprT1& expr1,
831  const ExprT2& expr2) const {
832  if (i == 0)
833  return expr1.fastAccessCoeff(i) - expr2.fastAccessCoeff(i);
834  else
835  return -expr2.fastAccessCoeff(i);
836  }
837 
838  }; // class SubtractionOp
839 
840  // ---------------------- Multiplication operator -------------------------
841 
842  template <typename ExprT1, typename ExprT2>
844  public:
845 
846  typedef typename ExprT1::value_type value_type_1;
847  typedef typename ExprT2::value_type value_type_2;
848  typedef typename Sacado::Promote<value_type_1,
850 
851  typedef typename ExprT1::scalar_type scalar_type_1;
852  typedef typename ExprT2::scalar_type scalar_type_2;
853  typedef typename Sacado::Promote<scalar_type_1,
855 
856  typedef typename ExprT1::base_expr_type base_expr_type_1;
857  typedef typename ExprT2::base_expr_type base_expr_type_2;
858  typedef typename Sacado::Promote<base_expr_type_1,
860 
861  MultiplicationOp(const ExprT1& expr1, const ExprT2 expr2) :
862  c(),
863  dc(-1) {}
864 
865  void allocateCache(int d) const {
866  c.resize(d+1,value_type(0));
867  }
868 
869  value_type
870  computeCoeff(int i, const ExprT1& expr1,
871  const ExprT2& expr2) const {
872  if (static_cast<int>(i) > dc) {
873  for (int k=dc+1; k<=i; k++) {
874  for (int j=0; j<=k; j++)
875  c[k] += expr1.coeff(j)*expr2.coeff(k-j);
876  }
877  dc = i;
878  }
879  return c[i];
880  }
881 
882  value_type
883  computeFastAccessCoeff(int i, const ExprT1& expr1,
884  const ExprT2& expr2) const {
885  if (static_cast<int>(i) > dc) {
886  for (int k=dc+1; k<=i; k++) {
887  for (int j=0; j<=k; j++)
888  c[k] += expr1.fastAccessCoeff(j)*expr2.fastAccessCoeff(k-j);
889  }
890  dc = i;
891  }
892  return c[i];
893  }
894 
895  protected:
896 
897  mutable std::valarray<value_type> c;
898  mutable int dc;
899 
900  }; // class MultiplicationOp
901 
902  template <typename ExprT1>
903  class MultiplicationOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
904  public:
905 
906  typedef typename ExprT1::value_type value_type;
907  typedef typename ExprT1::scalar_type scalar_type;
908  typedef typename ExprT1::base_expr_type base_expr_type;
910 
911  MultiplicationOp(const ExprT1& expr1, const ExprT2 expr2) {}
912 
913  void allocateCache(int d) const {}
914 
915  value_type
916  computeCoeff(int i, const ExprT1& expr1,
917  const ExprT2& expr2) const {
918  return expr1.coeff(i)*expr2.value();
919  }
920 
921  value_type
922  computeFastAccessCoeff(int i, const ExprT1& expr1,
923  const ExprT2& expr2) const {
924  return expr1.fastAccessCoeff(i)*expr2.value();
925  }
926 
927  }; // class MultiplicationOp
928 
929  template <typename ExprT2>
930  class MultiplicationOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
931  public:
932 
933  typedef typename ExprT2::value_type value_type;
934  typedef typename ExprT2::scalar_type scalar_type;
935  typedef typename ExprT2::base_expr_type base_expr_type;
937 
938  MultiplicationOp(const ExprT1& expr1, const ExprT2 expr2) {}
939 
940  void allocateCache(int d) const {}
941 
942  value_type
943  computeCoeff(int i, const ExprT1& expr1,
944  const ExprT2& expr2) const {
945  return expr1.value()*expr2.coeff(i);
946  }
947 
948  value_type
949  computeFastAccessCoeff(int i, const ExprT1& expr1,
950  const ExprT2& expr2) const {
951  return expr1.value()*expr2.fastAccessCoeff(i);
952  }
953 
954  }; // class MultiplicationOp
955 
956  // ---------------------- Division operator -------------------------
957 
958  template <typename ExprT1, typename ExprT2>
959  class DivisionOp {
960  public:
961 
962  typedef typename ExprT1::value_type value_type_1;
963  typedef typename ExprT2::value_type value_type_2;
964  typedef typename Sacado::Promote<value_type_1,
966 
967  typedef typename ExprT1::scalar_type scalar_type_1;
968  typedef typename ExprT2::scalar_type scalar_type_2;
969  typedef typename Sacado::Promote<scalar_type_1,
971 
972  typedef typename ExprT1::base_expr_type base_expr_type_1;
973  typedef typename ExprT2::base_expr_type base_expr_type_2;
974  typedef typename Sacado::Promote<base_expr_type_1,
976 
977  DivisionOp(const ExprT1& expr1, const ExprT2 expr2) :
978  c(),
979  dc(-1) {}
980 
981  void allocateCache(int d) const {
982  c.resize(d+1,value_type(0));
983  }
984 
985  value_type
986  computeCoeff(int i, const ExprT1& expr1,
987  const ExprT2& expr2) const {
988  if (static_cast<int>(i) > dc) {
989  for (int k=dc+1; k<=i; k++) {
990  c[k] = expr1.coeff(k);
991  for (int j=1; j<=k; j++)
992  c[k] -= expr2.coeff(j)*c[k-j];
993  c[k] /= expr2.fastAccessCoeff(0);
994  }
995  dc = i;
996  }
997  return c[i];
998  }
999 
1000  value_type
1001  computeFastAccessCoeff(int i, const ExprT1& expr1,
1002  const ExprT2& expr2) const {
1003  if (static_cast<int>(i) > dc) {
1004  for (int k=dc+1; k<=i; k++) {
1005  c[k] = expr1.coeff(k);
1006  for (int j=1; j<=k; j++)
1007  c[k] -= expr2.fastAccessCoeff(j)*c[k-j];
1008  c[k] /= expr2.fastAccessCoeff(0);
1009  }
1010  dc = i;
1011  }
1012  return c[i];
1013  }
1014 
1015  protected:
1016 
1017  mutable std::valarray<value_type> c;
1018  mutable int dc;
1019 
1020  }; // class DivisionOp
1021 
1022  template <typename ExprT1>
1023  class DivisionOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
1024  public:
1025 
1026  typedef typename ExprT1::value_type value_type;
1027  typedef typename ExprT1::scalar_type scalar_type;
1028  typedef typename ExprT1::base_expr_type base_expr_type;
1030 
1031  DivisionOp(const ExprT1& expr1, const ExprT2 expr2) {}
1032 
1033  void allocateCache(int d) const {}
1034 
1035  value_type
1036  computeCoeff(int i, const ExprT1& expr1,
1037  const ExprT2& expr2) const {
1038  return expr1.coeff(i)/expr2.value();
1039  }
1040 
1041  value_type
1042  computeFastAccessCoeff(int i, const ExprT1& expr1,
1043  const ExprT2& expr2) const {
1044  return expr1.fastAccessCoeff(i)/expr2.value();
1045  }
1046 
1047  }; // class DivisionOp
1048 
1049  template <typename ExprT2>
1050  class DivisionOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
1051  public:
1052 
1053  typedef typename ExprT2::value_type value_type;
1054  typedef typename ExprT2::scalar_type scalar_type;
1055  typedef typename ExprT2::base_expr_type base_expr_type;
1057 
1058  DivisionOp(const ExprT1& expr1, const ExprT2 expr2) :
1059  c(),
1060  dc(-1) {}
1061 
1062  void allocateCache(int d) const {
1063  c.resize(d+1,value_type(0));
1064  }
1065 
1066  value_type
1067  computeCoeff(int i, const ExprT1& expr1,
1068  const ExprT2& expr2) const {
1069  if (static_cast<int>(i) > dc) {
1070  if (dc < 0) {
1071  c[0] = expr1.fastAccessCoeff(0) / expr2.fastAccessCoeff(0);
1072  dc = 0;
1073  }
1074  for (int k=dc+1; k<=i; k++) {
1075  for (int j=1; j<=k; j++)
1076  c[k] -= expr2.coeff(j)*c[k-j];
1077  c[k] /= expr2.fastAccessCoeff(0);
1078  }
1079  dc = i;
1080  }
1081  return c[i];
1082  }
1083 
1084  value_type
1085  computeFastAccessCoeff(int i, const ExprT1& expr1,
1086  const ExprT2& expr2) const {
1087  if (static_cast<int>(i) > dc) {
1088  if (dc < 0) {
1089  c[0] = expr1.fastAccessCoeff(0) / expr2.fastAccessCoeff(0);
1090  dc = 0;
1091  }
1092  for (int k=dc+1; k<=i; k++) {
1093  c[k] = expr1.coeff(k);
1094  for (int j=1; j<=k; j++)
1095  c[k] -= expr2.fastAccessCoeff(j)*c[k-j];
1096  c[k] /= expr2.fastAccessCoeff(0);
1097  }
1098  dc = i;
1099  }
1100  return c[i];
1101  }
1102 
1103  protected:
1104 
1105  mutable std::valarray<value_type> c;
1106  mutable int dc;
1107 
1108  }; // class DivisionOp
1109 
1110  // ---------------------- Max operator -----------------------------
1111 
1112  template <typename ExprT1, typename ExprT2>
1113  class MaxOp {
1114  public:
1115 
1116  typedef typename ExprT1::value_type value_type_1;
1117  typedef typename ExprT2::value_type value_type_2;
1118  typedef typename Sacado::Promote<value_type_1,
1120 
1121  typedef typename ExprT1::scalar_type scalar_type_1;
1122  typedef typename ExprT2::scalar_type scalar_type_2;
1123  typedef typename Sacado::Promote<scalar_type_1,
1125 
1126  typedef typename ExprT1::base_expr_type base_expr_type_1;
1127  typedef typename ExprT2::base_expr_type base_expr_type_2;
1128  typedef typename Sacado::Promote<base_expr_type_1,
1130 
1131  MaxOp(const ExprT1& expr1, const ExprT2 expr2) {}
1132 
1133  void allocateCache(int d) const {}
1134 
1135  value_type
1136  computeCoeff(int i, const ExprT1& expr1,
1137  const ExprT2& expr2) const {
1138  if (i == 0)
1139  return std::max(expr1.coeff(0), expr2.coeff(0));
1140  else
1141  return expr1.coeff(0) >= expr2.coeff(0) ? expr1.coeff(i) :
1142  expr2.coeff(i);
1143  }
1144 
1145  value_type
1146  computeFastAccessCoeff(int i, const ExprT1& expr1,
1147  const ExprT2& expr2) const {
1148  if (i == 0)
1149  return std::max(expr1.fastAccessCoeff(0), expr2.fastAccessCoeff(0));
1150  else
1151  return expr1.fastAccessCoeff(0) >= expr2.fastAccessCoeff(0) ?
1152  expr1.fastAccessoeff(i) : expr2.fastAccessCoeff(i);
1153  }
1154 
1155  }; // class MaxOp
1156 
1157  template <typename ExprT1>
1158  class MaxOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
1159  public:
1160 
1161  typedef typename ExprT1::value_type value_type;
1162  typedef typename ExprT1::scalar_type scalar_type;
1163  typedef typename ExprT1::base_expr_type base_expr_type;
1165 
1166  MaxOp(const ExprT1& expr1, const ExprT2 expr2) {}
1167 
1168  void allocateCache(int d) const {}
1169 
1170  value_type
1171  computeCoeff(int i, const ExprT1& expr1,
1172  const ExprT2& expr2) const {
1173  if (i == 0)
1174  return std::max(expr1.coeff(0), expr2.value());
1175  else
1176  return expr1.coeff(0) >= expr2.value() ? expr1.coeff(i) :
1177  value_type(0);
1178  }
1179 
1180  value_type
1181  computeFastAccessCoeff(int i, const ExprT1& expr1,
1182  const ExprT2& expr2) const {
1183  if (i == 0)
1184  return std::max(expr1.fastAccessCoeff(0), expr2.value());
1185  else
1186  return expr1.fastAccessCoeff(0) >= expr2.value() ?
1187  expr1.fastAccessCoeff(i) : value_type(0);
1188  }
1189 
1190  }; // class MaxOp
1191 
1192  template <typename ExprT2>
1193  class MaxOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
1194  public:
1195 
1196  typedef typename ExprT2::value_type value_type;
1197  typedef typename ExprT2::scalar_type scalar_type;
1198  typedef typename ExprT2::base_expr_type base_expr_type;
1200 
1201  MaxOp(const ExprT1& expr1, const ExprT2 expr2) {}
1202 
1203  void allocateCache(int d) const {}
1204 
1205  value_type
1206  computeCoeff(int i, const ExprT1& expr1,
1207  const ExprT2& expr2) const {
1208  if (i == 0)
1209  return std::max(expr1.value(), expr2.coeff(0));
1210  else
1211  return expr1.value() >= expr2.coeff(0) ? value_type(0) :
1212  expr2.coeff(i);
1213  }
1214 
1215  value_type
1216  computeFastAccessCoeff(int i, const ExprT1& expr1,
1217  const ExprT2& expr2) const {
1218  if (i == 0)
1219  return std::max(expr1.value(), expr2.fastAccessCoeff(0));
1220  else
1221  return expr1.value() >= expr2.fastAccessCoeff(0) ? value_type(0) :
1222  expr2.fastAccessCoeff(i);
1223  }
1224 
1225  }; // class MaxOp
1226 
1227  // ---------------------- Min operator -----------------------------
1228 
1229  template <typename ExprT1, typename ExprT2>
1230  class MinOp {
1231  public:
1232 
1233  typedef typename ExprT1::value_type value_type_1;
1234  typedef typename ExprT2::value_type value_type_2;
1235  typedef typename Sacado::Promote<value_type_1,
1237  typedef typename ExprT1::scalar_type scalar_type_1;
1238  typedef typename ExprT2::scalar_type scalar_type_2;
1239  typedef typename Sacado::Promote<scalar_type_1,
1241 
1242  typedef typename ExprT1::base_expr_type base_expr_type_1;
1243  typedef typename ExprT2::base_expr_type base_expr_type_2;
1244  typedef typename Sacado::Promote<base_expr_type_1,
1246 
1247  MinOp(const ExprT1& expr1, const ExprT2 expr2) {}
1248 
1249  void allocateCache(int d) const {}
1250 
1251  value_type
1252  computeCoeff(int i, const ExprT1& expr1,
1253  const ExprT2& expr2) const {
1254  if (i == 0)
1255  return min(expr1.coeff(0), expr2.coeff(0));
1256  else
1257  return expr1.coeff(0) <= expr2.coeff(0) ? expr1.coeff(i) :
1258  expr2.coeff(i);
1259  }
1260 
1261  value_type
1262  computeFastAccessCoeff(int i, const ExprT1& expr1,
1263  const ExprT2& expr2) const {
1264  if (i == 0)
1265  return min(expr1.fastAccessCoeff(0), expr2.fastAccessCoeff(0));
1266  else
1267  return expr1.fastAccessCoeff(0) <= expr2.fastAccessCoeff(0) ?
1268  expr1.fastAccessCoeff(i) : expr2.fastAccessCoeff(i);
1269  }
1270 
1271  }; // class MinOp
1272 
1273  template <typename ExprT1>
1274  class MinOp<ExprT1, ConstExpr<typename ExprT1::value_type> > {
1275  public:
1276 
1277  typedef typename ExprT1::value_type value_type;
1278  typedef typename ExprT1::scalar_type scalar_type;
1279  typedef typename ExprT1::base_expr_type base_expr_type;
1281 
1282  MinOp(const ExprT1& expr1, const ExprT2 expr2) {}
1283 
1284  void allocateCache(int d) const {}
1285 
1286  value_type
1287  computeCoeff(int i, const ExprT1& expr1,
1288  const ExprT2& expr2) const {
1289  if (i == 0)
1290  return std::min(expr1.coeff(0), expr2.value());
1291  else
1292  return expr1.coeff(0) <= expr2.value() ? expr1.coeff(i) :
1293  value_type(0);
1294  }
1295 
1296  value_type
1297  computeFastAccessCoeff(int i, const ExprT1& expr1,
1298  const ExprT2& expr2) const {
1299  if (i == 0)
1300  return std::min(expr1.fastAccessCoeff(0), expr2.value());
1301  else
1302  return expr1.fastAccessCoeff(0) <= expr2.value() ?
1303  expr1.fastAccessCoeff(i) : value_type(0);
1304  }
1305 
1306  }; // class MinOp
1307 
1308  template <typename ExprT2>
1309  class MinOp<ConstExpr<typename ExprT2::value_type>, ExprT2 > {
1310  public:
1311 
1312  typedef typename ExprT2::value_type value_type;
1313  typedef typename ExprT2::scalar_type scalar_type;
1314  typedef typename ExprT2::base_expr_type base_expr_type;
1316 
1317  MinOp(const ExprT1& expr1, const ExprT2 expr2) {}
1318 
1319  void allocateCache(int d) const {}
1320 
1321  value_type
1322  computeCoeff(int i, const ExprT1& expr1,
1323  const ExprT2& expr2) const {
1324  if (i == 0)
1325  return std::min(expr1.value(), expr2.coeff(0));
1326  else
1327  return expr1.value() <= expr2.coeff(0) ? value_type(0) :
1328  expr2.coeff(i);
1329  }
1330 
1331  value_type
1332  computeFastAccessCoeff(int i, const ExprT1& expr1,
1333  const ExprT2& expr2) const {
1334  if (i == 0)
1335  return std::min(expr1.value(), expr2.fastAccessCoeff(0));
1336  else
1337  return expr1.value() <= expr2.fastAccessCoeff(0) ? value_type(0) :
1338  expr2.fastAccessCoeff(i);
1339  }
1340 
1341  }; // class MinOp
1342 
1343  // ------------------------ quadrature function ---------------------------
1344 
1345  template <typename ExprT1, typename ExprT2>
1346  class ASinQuadOp {
1347  public:
1348 
1349  typedef typename ExprT1::value_type value_type_1;
1350  typedef typename ExprT2::value_type value_type_2;
1351  typedef typename Sacado::Promote<value_type_1,
1353 
1354  typedef typename ExprT1::scalar_type scalar_type_1;
1355  typedef typename ExprT2::scalar_type scalar_type_2;
1356  typedef typename Sacado::Promote<scalar_type_1,
1358 
1359  typedef typename ExprT1::base_expr_type base_expr_type_1;
1360  typedef typename ExprT2::base_expr_type base_expr_type_2;
1361  typedef typename Sacado::Promote<base_expr_type_1,
1363 
1364  ASinQuadOp(const ExprT1& expr1, const ExprT2& expr2) :
1365  c(),
1366  dc(-1)
1367  {}
1368 
1369  void allocateCache(int d) const {
1370  c.resize(d+1,value_type(0));
1371  }
1372 
1373  value_type computeCoeff(int i, const ExprT1& expr1,
1374  const ExprT2& expr2) const {
1375  if (static_cast<int>(i) > dc) {
1376  if (dc < 0) {
1377  c[0] = std::asin(expr1.fastAccessCoeff(0));
1378  dc = 0;
1379  }
1380  for (int k=dc+1; k<=i; k++) {
1381  for (int j=1; j<=k; j++)
1382  c[k] += value_type(j)*expr2.coeff(k-j)*expr1.coeff(j);
1383  c[k] /= value_type(k);
1384  }
1385  dc = i;
1386  }
1387  return c[i];
1388  }
1389 
1391  const ExprT1& expr1,
1392  const ExprT2& expr2) const
1393  {
1394  if (static_cast<int>(i) > dc) {
1395  if (dc < 0) {
1396  c[0] = std::asin(expr1.fastAccessCoeff(0));
1397  dc = 0;
1398  }
1399  for (int k=dc+1; k<=i; k++) {
1400  for (int j=1; j<=k; j++)
1401  c[k] += value_type(j)*expr2.fastAccessCoeff(k-j)*
1402  expr1.fastAccessCoeff(j);
1403  c[k] /= value_type(k);
1404  }
1405  dc = i;
1406  }
1407  return c[i];
1408  }
1409 
1410  protected:
1411 
1412  mutable std::valarray<value_type> c;
1413  mutable int dc;
1414 
1415  }; // class ASinQuadOp
1416 
1417  template <typename ExprT1, typename ExprT2>
1418  class ACosQuadOp {
1419  public:
1420 
1421  typedef typename ExprT1::value_type value_type_1;
1422  typedef typename ExprT2::value_type value_type_2;
1423  typedef typename Sacado::Promote<value_type_1,
1425 
1426  typedef typename ExprT1::scalar_type scalar_type_1;
1427  typedef typename ExprT2::scalar_type scalar_type_2;
1428  typedef typename Sacado::Promote<scalar_type_1,
1430 
1431  typedef typename ExprT1::base_expr_type base_expr_type_1;
1432  typedef typename ExprT2::base_expr_type base_expr_type_2;
1433  typedef typename Sacado::Promote<base_expr_type_1,
1435 
1436  ACosQuadOp(const ExprT1& expr1, const ExprT2& expr2) :
1437  c(),
1438  dc(-1)
1439  {}
1440 
1441  void allocateCache(int d) const {
1442  c.resize(d+1,value_type(0));
1443  }
1444 
1445  value_type computeCoeff(int i, const ExprT1& expr1,
1446  const ExprT2& expr2) const {
1447  if (static_cast<int>(i) > dc) {
1448  if (dc < 0) {
1449  c[0] = std::acos(expr1.fastAccessCoeff(0));
1450  dc = 0;
1451  }
1452  for (int k=dc+1; k<=i; k++) {
1453  for (int j=1; j<=k; j++)
1454  c[k] += value_type(j)*expr2.coeff(k-j)*expr1.coeff(j);
1455  c[k] /= value_type(k);
1456  }
1457  dc = i;
1458  }
1459  return c[i];
1460  }
1461 
1463  const ExprT1& expr1,
1464  const ExprT2& expr2) const
1465  {
1466  if (static_cast<int>(i) > dc) {
1467  if (dc < 0) {
1468  c[0] = std::acos(expr1.fastAccessCoeff(0));
1469  dc = 0;
1470  }
1471  for (int k=dc+1; k<=i; k++) {
1472  for (int j=1; j<=k; j++)
1473  c[k] += value_type(j)*expr2.fastAccessCoeff(k-j)*
1474  expr1.fastAccessCoeff(j);
1475  c[k] /= value_type(k);
1476  }
1477  dc = i;
1478  }
1479  return c[i];
1480  }
1481 
1482  protected:
1483 
1484  mutable std::valarray<value_type> c;
1485  mutable int dc;
1486 
1487  }; // class ACosQuadOp
1488 
1489  template <typename ExprT1, typename ExprT2>
1490  class ATanQuadOp {
1491  public:
1492 
1493  typedef typename ExprT1::value_type value_type_1;
1494  typedef typename ExprT2::value_type value_type_2;
1495  typedef typename Sacado::Promote<value_type_1,
1497 
1498  typedef typename ExprT1::scalar_type scalar_type_1;
1499  typedef typename ExprT2::scalar_type scalar_type_2;
1500  typedef typename Sacado::Promote<scalar_type_1,
1502 
1503  typedef typename ExprT1::base_expr_type base_expr_type_1;
1504  typedef typename ExprT2::base_expr_type base_expr_type_2;
1505  typedef typename Sacado::Promote<base_expr_type_1,
1507 
1508  ATanQuadOp(const ExprT1& expr1, const ExprT2& expr2) :
1509  c(),
1510  dc(-1)
1511  {}
1512 
1513  void allocateCache(int d) const {
1514  c.resize(d+1,value_type(0));
1515  }
1516 
1517  value_type computeCoeff(int i, const ExprT1& expr1,
1518  const ExprT2& expr2) const {
1519  if (static_cast<int>(i) > dc) {
1520  if (dc < 0) {
1521  c[0] = std::atan(expr1.fastAccessCoeff(0));
1522  dc = 0;
1523  }
1524  for (int k=dc+1; k<=i; k++) {
1525  for (int j=1; j<=k; j++)
1526  c[k] += value_type(j)*expr2.coeff(k-j)*expr1.coeff(j);
1527  c[k] /= value_type(k);
1528  }
1529  dc = i;
1530  }
1531  return c[i];
1532  }
1533 
1535  const ExprT1& expr1,
1536  const ExprT2& expr2) const
1537  {
1538  if (static_cast<int>(i) > dc) {
1539  if (dc < 0) {
1540  c[0] = std::atan(expr1.fastAccessCoeff(0));
1541  dc = 0;
1542  }
1543  for (int k=dc+1; k<=i; k++) {
1544  for (int j=1; j<=k; j++)
1545  c[k] += value_type(j)*expr2.fastAccessCoeff(k-j)*
1546  expr1.fastAccessCoeff(j);
1547  c[k] /= value_type(k);
1548  }
1549  dc = i;
1550  }
1551  return c[i];
1552  }
1553 
1554  protected:
1555 
1556  mutable std::valarray<value_type> c;
1557  mutable int dc;
1558 
1559  }; // class ATanQuadOp
1560 
1561  } // namespace Tay
1562 
1563 } // namespace Sacado
1564 
1565 #define TAYLOR_BINARYOP_MACRO(OPNAME,OP) \
1566 namespace Sacado { \
1567  namespace Tay { \
1568  template <typename T1, typename T2> \
1569  inline Expr< BinaryExpr< Expr<T1>, Expr<T2>, OP > > \
1570  OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
1571  { \
1572  typedef BinaryExpr< Expr<T1>, Expr<T2>, OP > expr_t; \
1573  \
1574  return Expr<expr_t>(expr_t(expr1, expr2)); \
1575  } \
1576  \
1577  template <typename T> \
1578  inline Expr< BinaryExpr< ConstExpr<typename Expr<T>::value_type>, \
1579  Expr<T>, OP > > \
1580  OPNAME (const typename Expr<T>::value_type& c, \
1581  const Expr<T>& expr) \
1582  { \
1583  typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
1584  typedef BinaryExpr< ConstT, Expr<T>, OP > expr_t; \
1585  \
1586  return Expr<expr_t>(expr_t(ConstT(c), expr)); \
1587  } \
1588  \
1589  template <typename T> \
1590  inline Expr< BinaryExpr< Expr<T>, \
1591  ConstExpr<typename Expr<T>::value_type>, \
1592  OP > > \
1593  OPNAME (const Expr<T>& expr, \
1594  const typename Expr<T>::value_type& c) \
1595  { \
1596  typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
1597  typedef BinaryExpr< Expr<T>, ConstT, OP > expr_t; \
1598  \
1599  return Expr<expr_t>(expr_t(expr, ConstT(c))); \
1600  } \
1601  } \
1602 }
1603 
1608 
1609 #undef TAYLOR_BINARYOP_MACRO
1610 
1611  // The general definition of max/min works for Taylor variables too, except
1612  // we need to add a case when the argument types are different. This
1613  // can't conflict with the general definition, so we need to use
1614  // Substitution Failure Is Not An Error
1615 #include "Sacado_mpl_disable_if.hpp"
1616 #include "Sacado_mpl_is_same.hpp"
1617 
1618 #define TAYLOR_SFINAE_BINARYOP_MACRO(OPNAME,OP) \
1619 namespace Sacado { \
1620  namespace Tay { \
1621  template <typename T1, typename T2> \
1622  inline \
1623  typename \
1624  mpl::disable_if< mpl::is_same<T1,T2>, \
1625  Expr<BinaryExpr<Expr<T1>, Expr<T2>, OP> > >::type \
1626  OPNAME (const Expr<T1>& expr1, const Expr<T2>& expr2) \
1627  { \
1628  typedef BinaryExpr< Expr<T1>, Expr<T2>, OP > expr_t; \
1629  \
1630  return Expr<expr_t>(expr_t(expr1, expr2)); \
1631  } \
1632  \
1633  template <typename T> \
1634  inline Expr< BinaryExpr< ConstExpr<typename Expr<T>::value_type>, \
1635  Expr<T>, OP > > \
1636  OPNAME (const typename Expr<T>::value_type& c, \
1637  const Expr<T>& expr) \
1638  { \
1639  typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
1640  typedef BinaryExpr< ConstT, Expr<T>, OP > expr_t; \
1641  \
1642  return Expr<expr_t>(expr_t(ConstT(c), expr)); \
1643  } \
1644  \
1645  template <typename T> \
1646  inline Expr< BinaryExpr< Expr<T>, \
1647  ConstExpr<typename Expr<T>::value_type>, \
1648  OP > > \
1649  OPNAME (const Expr<T>& expr, \
1650  const typename Expr<T>::value_type& c) \
1651  { \
1652  typedef ConstExpr<typename Expr<T>::value_type> ConstT; \
1653  typedef BinaryExpr< Expr<T>, ConstT, OP > expr_t; \
1654  \
1655  return Expr<expr_t>(expr_t(expr, ConstT(c))); \
1656  } \
1657  } \
1658 }
1659 
1662 
1663 #undef TAYLOR_SFINAE_BINARYOP_MACRO
1664 
1665 namespace std {
1666  using Sacado::Tay::min;
1667  using Sacado::Tay::max;
1668 }
1669 
1670 namespace Sacado {
1671 
1672  namespace Tay {
1673 
1674  template <typename T1, typename T2>
1675  inline Expr< BinaryExpr< Expr<T1>, Expr<T2>, ASinQuadOp > >
1676  asin_quad (const Expr<T1>& expr1, const Expr<T2>& expr2)
1677  {
1678  typedef BinaryExpr< Expr<T1>, Expr<T2>, ASinQuadOp > expr_t;
1679 
1680  return Expr<expr_t>(expr_t(expr1, expr2));
1681  }
1682 
1683  template <typename T1, typename T2>
1684  inline Expr< BinaryExpr< Expr<T1>, Expr<T2>, ACosQuadOp > >
1685  acos_quad (const Expr<T1>& expr1, const Expr<T2>& expr2)
1686  {
1687  typedef BinaryExpr< Expr<T1>, Expr<T2>, ACosQuadOp > expr_t;
1688 
1689  return Expr<expr_t>(expr_t(expr1, expr2));
1690  }
1691 
1692  template <typename T1, typename T2>
1693  inline Expr< BinaryExpr< Expr<T1>, Expr<T2>, ATanQuadOp > >
1694  atan_quad (const Expr<T1>& expr1, const Expr<T2>& expr2)
1695  {
1696  typedef BinaryExpr< Expr<T1>, Expr<T2>, ATanQuadOp > expr_t;
1697 
1698  return Expr<expr_t>(expr_t(expr1, expr2));
1699  }
1700 
1701  template <typename ExprT1, typename ExprT2>
1702  struct PowExprType {
1706 
1708  };
1709 
1710  template <typename ExprT2>
1711  struct PowExprType< typename ExprT2::value_type, ExprT2 > {
1712  typedef typename ExprT2::value_type T1;
1715 
1717  };
1718 
1719  template <typename ExprT1>
1720  struct PowExprType<ExprT1,typename ExprT1::value_type> {
1721  typedef typename ExprT1::value_type T2;
1725 
1727  };
1728 
1729  template <typename T1, typename T2>
1730  inline typename PowExprType< Expr<T1>, Expr<T2> >::expr_type
1731  pow (const Expr<T1>& expr1, const Expr<T2>& expr2)
1732  {
1733  // pow(x,y) = exp(y*log(x))
1734  return exp(expr2*log(expr1));
1735  }
1736 
1737  template <typename T>
1738  inline typename PowExprType< typename Expr<T>::value_type, Expr<T> >::expr_type
1739  pow (const typename Expr<T>::value_type& c, const Expr<T>& expr)
1740  {
1741  // pow(x,y) = exp(y*log(x))
1742  return exp(expr*std::log(c));
1743  }
1744 
1745  template <typename T>
1746  inline typename PowExprType< Expr<T>, typename Expr<T>::value_type >::expr_type
1747  pow (const Expr<T>& expr, const typename Expr<T>::value_type& c)
1748  {
1749  // pow(x,y) = exp(y*log(x))
1750  return exp(c*log(expr));
1751  }
1752 
1753  template <typename T>
1754  struct Log10ExprType {
1759  };
1760 
1761  template <typename T>
1762  inline typename Log10ExprType<T>::expr_type
1763  log10 (const Expr<T>& expr)
1764  {
1765  // log10(x) = log(x)/log(10)
1766  return log(expr)/std::log(typename Expr<T>::value_type(10));
1767  }
1768 
1769  template <typename T>
1770  struct TanExprType {
1775  };
1776 
1777  template <typename T>
1778  inline typename TanExprType<T>::expr_type
1779  tan (const Expr<T>& expr)
1780  {
1781  // tan(x) = sin(x)/cos(x)
1782  return sin(expr)/cos(expr);
1783  }
1784 
1785  template <typename T>
1786  struct ASinExprType {
1794  };
1795 
1796  template <typename T>
1797  inline typename ASinExprType<T>::expr_type
1798  asin (const Expr<T>& expr)
1799  {
1800  typedef typename Expr<T>::value_type value_type;
1801 
1802  // asin(x) = integral of 1/sqrt(1-x*x)
1803  return asin_quad(expr, value_type(1)/sqrt(value_type(1)-expr*expr));
1804  }
1805 
1806  template <typename T>
1807  struct ACosExprType {
1815  };
1816 
1817  template <typename T>
1818  inline typename ACosExprType<T>::expr_type
1819  acos (const Expr<T>& expr)
1820  {
1821  typedef typename Expr<T>::value_type value_type;
1822 
1823  // acos(x) = integral of -1/sqrt(1-x*x)
1824  return acos_quad(expr, value_type(-1)/sqrt(value_type(1)-expr*expr));
1825  }
1826 
1827  template <typename T>
1828  struct ATanExprType {
1835  };
1836 
1837  template <typename T>
1838  inline typename ATanExprType<T>::expr_type
1839  atan (const Expr<T>& expr)
1840  {
1841  typedef typename Expr<T>::value_type value_type;
1842 
1843  // atan(x) = integral of 1/(1+x*x)
1844  return atan_quad(expr, value_type(1)/(value_type(1)+expr*expr));
1845  }
1846 
1847  template <typename T>
1848  struct TanhExprType {
1853  };
1854 
1855  template <typename T>
1856  inline typename TanhExprType<T>::expr_type
1857  tanh (const Expr<T>& expr)
1858  {
1859  // tanh(x) = sinh(x)/cosh(x)
1860  return sinh(expr)/cosh(expr);
1861  }
1862 
1863  } // namespace Tay
1864 
1865 } // namespace Sacado
1866 
1867 namespace std {
1868  using Sacado::Tay::pow;
1869  using Sacado::Tay::log10;
1870  using Sacado::Tay::tan;
1871  using Sacado::Tay::asin;
1872  using Sacado::Tay::acos;
1873  using Sacado::Tay::atan;
1874  using Sacado::Tay::tanh;
1875 }
1876 
1877 //-------------------------- Relational Operators -----------------------
1878 
1879 #define TAYLOR_RELOP_MACRO(OP) \
1880 namespace Sacado { \
1881  namespace Tay { \
1882  template <typename ExprT1, typename ExprT2> \
1883  inline bool \
1884  operator OP (const Expr<ExprT1>& expr1, \
1885  const Expr<ExprT2>& expr2) \
1886  { \
1887  return expr1.fastAccessCoeff(0) OP expr2.fastAccessCoeff(0); \
1888  } \
1889  \
1890  template <typename ExprT2> \
1891  inline bool \
1892  operator OP (const typename Expr<ExprT2>::value_type& a, \
1893  const Expr<ExprT2>& expr2) \
1894  { \
1895  return a OP expr2.fastAccessCoeff(0); \
1896  } \
1897  \
1898  template <typename ExprT1> \
1899  inline bool \
1900  operator OP (const Expr<ExprT1>& expr1, \
1901  const typename Expr<ExprT1>::value_type& b) \
1902  { \
1903  return expr1.fastAccessCoeff(0) OP b; \
1904  } \
1905  } \
1906 }
1907 
1914 TAYLOR_RELOP_MACRO(<<=)
1915 TAYLOR_RELOP_MACRO(>>=)
1918 
1919 #undef TAYLOR_RELOP_MACRO
1920 
1921 namespace Sacado {
1922 
1923  namespace Tay {
1924 
1925  template <typename ExprT>
1926  inline bool operator ! (const Expr<ExprT>& expr)
1927  {
1928  return ! expr.fastAccessCoeff(0);
1929  }
1930 
1931  } // namespace Tay
1932 
1933 } // namespace Sacado
1934 
1935 //-------------------------- Boolean Operators -----------------------
1936 namespace Sacado {
1937 
1938  namespace Tay {
1939 
1940  template <typename ExprT>
1941  bool toBool2(const Expr<ExprT>& x) {
1942  bool is_zero = true;
1943  for (int i=0; i<=x.degree(); i++)
1944  is_zero = is_zero && (x.coeff(i) == 0.0);
1945  return !is_zero;
1946  }
1947 
1948  } // namespace Tay
1949 
1950 } // namespace Sacado
1951 
1952 #define TAY_BOOL_MACRO(OP) \
1953 namespace Sacado { \
1954  namespace Tay { \
1955  template <typename ExprT1, typename ExprT2> \
1956  inline bool \
1957  operator OP (const Expr<ExprT1>& expr1, \
1958  const Expr<ExprT2>& expr2) \
1959  { \
1960  return toBool2(expr1) OP toBool2(expr2); \
1961  } \
1962  \
1963  template <typename ExprT2> \
1964  inline bool \
1965  operator OP (const typename Expr<ExprT2>::value_type& a, \
1966  const Expr<ExprT2>& expr2) \
1967  { \
1968  return a OP toBool2(expr2); \
1969  } \
1970  \
1971  template <typename ExprT1> \
1972  inline bool \
1973  operator OP (const Expr<ExprT1>& expr1, \
1974  const typename Expr<ExprT1>::value_type& b) \
1975  { \
1976  return toBool2(expr1) OP b; \
1977  } \
1978  } \
1979 }
1980 
1981 TAY_BOOL_MACRO(&&)
1982 TAY_BOOL_MACRO(||)
1983 
1984 #undef TAY_BOOL_MACRO
1985 
1986 //-------------------------- I/O Operators -----------------------
1987 
1988 namespace Sacado {
1989 
1990  namespace Tay {
1991 
1992  template <typename ExprT>
1993  std::ostream& operator << (std::ostream& os, const Expr<ExprT>& x) {
1994  os.setf(std::ios::fixed, std::ios::floatfield);
1995  os.width(12);
1996  os << "[";
1997 
1998  for (int i=0; i<=x.degree(); i++) {
1999  os.width(12);
2000  os << x.coeff(i);
2001  }
2002 
2003  os << "]";
2004  return os;
2005  }
2006 
2008  template <typename T>
2009  CacheTaylor<T> diff(const CacheTaylor<T>& x, int n = 1) {
2010  const int d = x.degree();
2011  if (n <= 0)
2012  return x;
2013  else if (n > d) {
2014  Taylor<T> y(0);
2015  return y;
2016  }
2017  CacheTaylor<T> y(d-n);
2018  int c = 1;
2019  for (int i=1; i<=n; ++i)
2020  c *= i;
2021  for (int i=n; i<=d; ++i) {
2022  y.fastAccessCoeff(i-n) = x.fastAccessCoeff(i) * T(c);
2023  c = (c / (i-n+1)) * (i+1);
2024  }
2025  return y;
2026  }
2027 
2028  } // namespace Tay
2029 
2030 } // namespace Sacado
2031 
2032 
2033 #endif // SACADO_TAY_CACHETAYLOROPS_HPP
MaxOp(const ExprT1 &expr1, const ExprT2 expr2)
UnaryExpr< Expr< T2 >, SqrtOp > T3
UnaryExpr< Expr< T >, CosOp > T2
BinaryExpr< ConstT, Expr< T3 >, DivisionOp > T4
ExprT::base_expr_type base_expr_type
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
Expr< BinaryExpr< Expr< T1 >, Expr< T2 >, ATanQuadOp > > atan_quad(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
AdditionOp(const ExprT1 &expr1, const ExprT2 expr2)
expr expr SinOp
#define TAYLOR_UNARYOP_MACRO(OPNAME, OP)
ConstExpr< typename Expr< T >::value_type > ConstT
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MaxOp
ASinExprType< T >::expr_type asin(const Expr< T > &expr)
BinaryExpr< Expr< T1 >, ConstT, DivisionOp > T2
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
asin(expr.val())
cosh(expr.val())
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
bool operator!(const Expr< ExprT > &expr)
Constant expression template.
MultiplicationOp(const ExprT1 &expr1, const ExprT2 expr2)
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
ExprT1::base_expr_type base_expr_type_1
abs(expr.val())
Taylor< T > log(const Base< Taylor< T > > &a)
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< Expr< T >, Expr< T4 >, ACosQuadOp > T5
ExprT2::base_expr_type base_expr_type_2
Sacado::Promote< value_type_1, value_type_2 >::type value_type
Forward-mode AD class using dynamic memory allocation.
unsigned int degree() const
Return degree of polynomial.
value_type computeCoeff(int i, const ExprT &expr) const
BinaryExpr< ConstT, Expr< T3 >, DivisionOp > T4
ATanQuadOp(const ExprT1 &expr1, const ExprT2 &expr2)
expr2 expr1 expr2 expr2 c *expr2 c *expr1 c *expr2 c *expr1 MinOp
ExprT1::base_expr_type base_expr_type_1
Expr< BinaryExpr< Expr< T1 >, Expr< T2 >, ACosQuadOp > > acos_quad(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
value_type computeCoeff(int i, const ExprT &expr) const
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
int degree() const
Returns degree of polynomial.
ExprT::value_type value_type
Typename of values.
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
std::valarray< value_type > s
TanhExprType< T >::expr_type tanh(const Expr< T > &expr)
ExprT1::base_expr_type base_expr_type_1
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)
Binary expression template.
expr expr CoshOp
UnaryExpr< Expr< T4 >, ExpOp > T5
ACosQuadOp(const ExprT1 &expr1, const ExprT2 &expr2)
bool toBool2(const Expr< ExprT > &x)
ExprT1::base_expr_type base_expr_type_1
ConstExpr< typename Expr< T >::value_type > ConstT
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< ExprT2, Expr< T3 >, MultiplicationOp > T4
value_type fastAccessCoeff(unsigned int i) const
Return degree i term of expression.
Unary expression template.
ConstExpr< typename Expr< T >::value_type > ConstT
DivisionOp(const ExprT1 &expr1, const ExprT2 expr2)
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
void allocateCache(int d) const
std::valarray< value_type > c
std::valarray< value_type > c
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
void allocateCache(int d) const
BinaryExpr< ConstT, Expr< T2 >, DivisionOp > T3
std::valarray< value_type > c
expr expr SqrtOp
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
ConstExpr< typename Expr< T >::value_type > ConstT
std::valarray< value_type > s
atan(expr.val())
value_type computeCoeff(int i, const ExprT &expr) const
std::valarray< value_type > c
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
ExprT2::base_expr_type base_expr_type_2
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Sacado::Promote< value_type_1, value_type_2 >::type value_type
value_type coeff(unsigned int i) const
Return degree i term of expression.
Sacado::Promote< value_type_1, value_type_2 >::type value_type
UnaryExpr< Expr< T2 >, SqrtOp > T3
expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 MultiplicationOp
T & fastAccessCoeff(int i)
Returns degree i term without bounds checking.
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
ACosExprType< T >::expr_type acos(const Expr< T > &expr)
#define TAYLOR_RELOP_MACRO(OP)
std::valarray< value_type > c
void allocateCache(int d) const
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor< T > sin(const Base< Taylor< T > > &a)
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
ExprT::base_expr_type base_expr_type
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< Expr< T1 >, Expr< T2 >, DivisionOp > T3
Sacado::Promote< value_type_1, value_type_2 >::type value_type
ExprT2::base_expr_type base_expr_type_2
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
#define T
Definition: Sacado_rad.hpp:573
ExprT2::base_expr_type base_expr_type_2
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
expr expr CosOp
BinaryExpr< Expr< T >, Expr< T3 >, ATanQuadOp > T4
Sacado::Promote< value_type_1, value_type_2 >::type value_type
value_type computeCoeff(int i, const ExprT &expr) const
CacheTaylor< T > diff(const CacheTaylor< T > &x, int n=1)
Compute Taylor series of n-th derivative of x.
ExprT::base_expr_type base_expr_type
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
UnaryExpr< Expr< T >, LogOp > T1
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor< T > cos(const Base< Taylor< T > > &a)
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeCoeff(int i, const ExprT &expr) const
ExprT::base_expr_type base_expr_type
UnaryExpr< Expr< T >, CoshOp > T2
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
std::valarray< value_type > s
ExprT1::base_expr_type base_expr_type_1
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< Expr< T1 >, Expr< T2 >, DivisionOp > T3
SimpleFad< ValueT > min(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
void allocateCache(int d) const
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
ExprT::base_expr_type base_expr_type
UnaryExpr< Expr< T >, SinOp > T1
#define TAYLOR_BINARYOP_MACRO(OPNAME, OP)
Taylor< T > sinh(const Base< Taylor< T > > &a)
std::valarray< value_type > c
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor< T > sqrt(const Base< Taylor< T > > &a)
ExprT1::scalar_type scalar_type_1
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
sqrt(expr.val())
value_type computeCoeff(int i, const ExprT &expr) const
Log10ExprType< T >::expr_type log10(const Expr< T > &expr)
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor< T > max(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
sinh(expr.val())
BinaryExpr< Expr< T >, Expr< T4 >, ASinQuadOp > T5
expr1 expr1 expr2 expr1 expr1 c expr2 expr1 expr2 expr1 expr2 expr1 expr1 expr1 expr1 expr1 expr1 c *expr2 expr1 c *expr2 expr1 c *expr2 expr1 DivisionOp
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
std::valarray< value_type > c
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type coeff(unsigned int i) const
Return degree i term of expression.
ExprT2::base_expr_type base_expr_type_2
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
std::valarray< value_type > c
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< ConstT, Expr< T1 >, SubtractionOp > T2
BinaryExpr< Expr< T >, Expr< T >, MultiplicationOp > T1
ExprT1::base_expr_type base_expr_type_1
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
value_type fastAccessCoeff(unsigned int i) const
Return degree i term of expression.
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
ExprT::base_expr_type base_expr_type
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
BinaryExpr< ConstT, Expr< T1 >, SubtractionOp > T2
ATanExprType< T >::expr_type atan(const Expr< T > &expr)
value_type computeCoeff(int i, const ExprT &expr) const
Sacado::Promote< value_type_1, value_type_2 >::type value_type
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
UnaryExpr< Expr< T >, SinhOp > T1
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
#define TAY_BOOL_MACRO(OP)
sin(expr.val())
Sacado::Promote< value_type_1, value_type_2 >::type value_type
ExprT2::scalar_type scalar_type_2
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
Taylor< T > exp(const Base< Taylor< T > > &a)
BinaryExpr< Expr< T >, Expr< T >, MultiplicationOp > T1
ExprT2::base_expr_type base_expr_type_2
std::valarray< value_type > c
SubtractionOp(const ExprT1 &expr1, const ExprT2 expr2)
value_type computeCoeff(int i, const ExprT &expr) const
std::valarray< value_type > c
log(expr.val())
#define TAYLOR_SFINAE_BINARYOP_MACRO(OPNAME, OP)
ASinQuadOp(const ExprT1 &expr1, const ExprT2 &expr2)
value_type computeCoeff(int i, const ExprT &expr) const
expr expr SinhOp
Sacado::Promote< value_type_1, value_type_2 >::type value_type
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor polynomial class.
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
MinOp(const ExprT1 &expr1, const ExprT2 expr2)
Taylor< T > cosh(const Base< Taylor< T > > &a)
std::valarray< value_type > c
BinaryExpr< Expr< T >, Expr< T >, MultiplicationOp > T1
ExprT::base_expr_type base_expr_type
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
acos(expr.val())
SimpleFad< ValueT > max(const SimpleFad< ValueT > &a, const SimpleFad< ValueT > &b)
ExprT::base_expr_type base_expr_type
ExprT2::scalar_type scalar_type_2
Sacado::Promote< value_type_1, value_type_2 >::type value_type
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
std::valarray< value_type > s
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Taylor< T > min(const Base< Taylor< T > > &a, const Base< Taylor< T > > &b)
Wrapper for a generic expression template.
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
exp(expr.val())
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
ExprT::base_expr_type base_expr_type
ExprT2::base_expr_type base_expr_type_2
expr expr expr ExpOp
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
fabs(expr.val())
ExprT1::base_expr_type base_expr_type_1
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
value_type computeFastAccessCoeff(int i, const ExprT &expr) const
value_type computeCoeff(int i, const ExprT &expr) const
Expr< BinaryExpr< Expr< T1 >, Expr< T2 >, ASinQuadOp > > asin_quad(const Expr< T1 > &expr1, const Expr< T2 > &expr2)
Sacado::Promote< base_expr_type_1, base_expr_type_2 >::type base_expr_type
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
int n
Sacado::Promote< scalar_type_1, scalar_type_2 >::type scalar_type
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
BinaryExpr< ExprT2, ConstExpr< T1 >, MultiplicationOp > T4
ExprT1::scalar_type scalar_type_1
value_type computeCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const
Base template specification for Promote.
cos(expr.val())
BinaryExpr< ConstExpr< T2 >, Expr< T3 >, MultiplicationOp > T4
BinaryExpr< ConstT, Expr< T1 >, AdditionOp > T2
value_type computeFastAccessCoeff(int i, const ExprT1 &expr1, const ExprT2 &expr2) const