MC++
mcfadbad.hpp
1 // Copyright (C) 2009-2013 Benoit Chachuat, Imperial College London.
2 // All Rights Reserved.
3 
4 #ifndef MC__MCFADBAD_HPP
5 #define MC__MCFADBAD_HPP
6 
7 #include "interval.hpp"
8 #include "mccormick.hpp"
9 #include "tmodel.hpp"
10 #include "cmodel.hpp"
11 #include "specbnd.hpp"
12 
13 #include "fadbad.h"
14 
15 namespace fadbad
16 {
18  template <> struct Op<mc::Interval>{
19  typedef double Base;
20  typedef mc::Interval I;
21  static Base myInteger( const int i ) { return Base(i); }
22  static Base myZero() { return myInteger(0); }
23  static Base myOne() { return myInteger(1);}
24  static Base myTwo() { return myInteger(2); }
25  static double myPI() { return mc::PI; }
26  static I myPos( const I& x ) { return x; }
27  static I myNeg( const I& x ) { return -x; }
28  template <typename U> static I& myCadd( I& x, const U& y ) { return x+=y; }
29  template <typename U> static I& myCsub( I& x, const U& y ) { return x-=y; }
30  template <typename U> static I& myCmul( I& x, const U& y ) { return x*=y; }
31  template <typename U> static I& myCdiv( I& x, const U& y ) { return x/=y; }
32  static I myInv( const I& x ) { return mc::inv( x ); }
33  static I mySqr( const I& x ) { return mc::pow( x, 2 ); }
34  template <typename X, typename Y> static I myPow( const X& x, const Y& y ) { return mc::pow( x, y ); }
35  static I mySqrt( const I& x ) { return mc::sqrt( x ); }
36  static I myLog( const I& x ) { return mc::log( x ); }
37  static I myExp( const I& x ) { return mc::exp( x ); }
38  static I mySin( const I& x ) { return mc::sin( x ); }
39  static I myCos( const I& x ) { return mc::cos( x ); }
40  static I myTan( const I& x ) { return mc::tan( x ); }
41  static I myAsin( const I& x ) { return mc::asin( x ); }
42  static I myAcos( const I& x ) { return mc::acos( x ); }
43  static I myAtan( const I& x ) { return mc::atan( x ); }
44  static bool myEq( const I& x, const I& y ) { return x==y; }
45  static bool myNe( const I& x, const I& y ) { return x!=y; }
46  static bool myLt( const I& x, const I& y ) { return x<y; }
47  static bool myLe( const I& x, const I& y ) { return x<=y; }
48  static bool myGt( const I& x, const I& y ) { return x>y; }
49  static bool myGe( const I& x, const I& y ) { return x>=y; }
50  };
51 
53  template <> template<typename T> struct Op< mc::McCormick<T> >{
54  typedef mc::McCormick<T> MC;
55  typedef double Base;
56  static Base myInteger( const int i ) { return Base(i); }
57  static Base myZero() { return myInteger(0); }
58  static Base myOne() { return myInteger(1);}
59  static Base myTwo() { return myInteger(2); }
60  static double myPI() { return mc::PI; }
61  static MC myPos( const MC& x ) { return x; }
62  static MC myNeg( const MC& x ) { return -x; }
63  template <typename U> static MC& myCadd( MC& x, const U& y ) { return x+=y; }
64  template <typename U> static MC& myCsub( MC& x, const U& y ) { return x-=y; }
65  template <typename U> static MC& myCmul( MC& x, const U& y ) { return x*=y; }
66  template <typename U> static MC& myCdiv( MC& x, const U& y ) { return x/=y; }
67  static MC myInv( const MC& x ) { return mc::inv( x ); }
68  static MC mySqr( const MC& x ) { return mc::pow( x, 2 ); }
69  template <typename X, typename Y> static MC myPow( const X& x, const Y& y ) { return mc::pow( x, y ); }
70  static MC mySqrt( const MC& x ) { return mc::sqrt( x ); }
71  static MC myLog( const MC& x ) { return mc::log( x ); }
72  static MC myExp( const MC& x ) { return mc::exp( x ); }
73  static MC mySin( const MC& x ) { return mc::sin( x ); }
74  static MC myCos( const MC& x ) { return mc::cos( x ); }
75  static MC myTan( const MC& x ) { return mc::tan( x ); }
76  static MC myAsin( const MC& x ) { return mc::asin( x ); }
77  static MC myAcos( const MC& x ) { return mc::acos( x ); }
78  static MC myAtan( const MC& x ) { return mc::atan( x ); }
79  static bool myEq( const MC& x, const MC& y ) { return x==y; }
80  static bool myNe( const MC& x, const MC& y ) { return x!=y; }
81  static bool myLt( const MC& x, const MC& y ) { return x<y; }
82  static bool myLe( const MC& x, const MC& y ) { return x<=y; }
83  static bool myGt( const MC& x, const MC& y ) { return x>y; }
84  static bool myGe( const MC& x, const MC& y ) { return x>=y; }
85  };
86 
88  template <> template<typename T> struct Op< mc::TVar<T> >{
89  typedef mc::TVar<T> TM;
90  typedef double Base;
91  static Base myInteger( const int i ) { return Base(i); }
92  static Base myZero() { return myInteger(0); }
93  static Base myOne() { return myInteger(1);}
94  static Base myTwo() { return myInteger(2); }
95  static double myPI() { return mc::PI; }
96  static TM myPos( const TM& x ) { return x; }
97  static TM myNeg( const TM& x ) { return -x; }
98  template <typename U> static TM& myCadd( TM& x, const U& y ) { return x+=y; }
99  template <typename U> static TM& myCsub( TM& x, const U& y ) { return x-=y; }
100  template <typename U> static TM& myCmul( TM& x, const U& y ) { return x*=y; }
101  template <typename U> static TM& myCdiv( TM& x, const U& y ) { return x/=y; }
102  static TM myInv( const TM& x ) { return mc::inv( x ); }
103  static TM mySqr( const TM& x ) { return mc::pow( x, 2 ); }
104  template <typename X, typename Y> static TM myPow( const X& x, const Y& y ) { return mc::pow( x, y ); }
105  static TM mySqrt( const TM& x ) { return mc::sqrt( x ); }
106  static TM myLog( const TM& x ) { return mc::log( x ); }
107  static TM myExp( const TM& x ) { return mc::exp( x ); }
108  static TM mySin( const TM& x ) { return mc::sin( x ); }
109  static TM myCos( const TM& x ) { return mc::cos( x ); }
110  static TM myTan( const TM& x ) { return mc::tan( x ); }
111  static TM myAsin( const TM& x ) { return mc::asin( x ); }
112  static TM myAcos( const TM& x ) { return mc::acos( x ); }
113  static TM myAtan( const TM& x ) { return mc::atan( x ); }
114  static bool myEq( const TM& x, const TM& y ) { return mc::Op<T>::eq(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
115  static bool myNe( const TM& x, const TM& y ) { return mc::Op<T>::ne(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
116  static bool myLt( const TM& x, const TM& y ) { return mc::Op<T>::lt(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
117  static bool myLe( const TM& x, const TM& y ) { return mc::Op<T>::le(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
118  static bool myGt( const TM& x, const TM& y ) { return mc::Op<T>::gt(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
119  static bool myGe( const TM& x, const TM& y ) { return mc::Op<T>::ge(const_cast<TM*>(&x)->bound(),const_cast<TM*>(&y)->bound()); }
120  };
121 
123  template <> template<typename T> struct Op< mc::CVar<T> >{
124  typedef mc::CVar<T> CM;
125  typedef double Base;
126  static Base myInteger( const int i ) { return Base(i); }
127  static Base myZero() { return myInteger(0); }
128  static Base myOne() { return myInteger(1);}
129  static Base myTwo() { return myInteger(2); }
130  static double myPI() { return mc::PI; }
131  static CM myPos( const CM& x ) { return x; }
132  static CM myNeg( const CM& x ) { return -x; }
133  template <typename U> static CM& myCadd( CM& x, const U& y ) { return x+=y; }
134  template <typename U> static CM& myCsub( CM& x, const U& y ) { return x-=y; }
135  template <typename U> static CM& myCmul( CM& x, const U& y ) { return x*=y; }
136  template <typename U> static CM& myCdiv( CM& x, const U& y ) { return x/=y; }
137  static CM myInv( const CM& x ) { return mc::inv( x ); }
138  static CM mySqr( const CM& x ) { return mc::pow( x, 2 ); }
139  template <typename X, typename Y> static CM myPow( const X& x, const Y& y ) { return mc::pow( x, y ); }
140  static CM mySqrt( const CM& x ) { return mc::sqrt( x ); }
141  static CM myLog( const CM& x ) { return mc::log( x ); }
142  static CM myExp( const CM& x ) { return mc::exp( x ); }
143  static CM mySin( const CM& x ) { return mc::sin( x ); }
144  static CM myCos( const CM& x ) { return mc::cos( x ); }
145  static CM myTan( const CM& x ) { return mc::tan( x ); }
146  static CM myAsin( const CM& x ) { return mc::asin( x ); }
147  static CM myAcos( const CM& x ) { return mc::acos( x ); }
148  static CM myAtan( const CM& x ) { return mc::atan( x ); }
149  static bool myEq( const CM& x, const CM& y ) { return mc::Op<T>::eq(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
150  static bool myNe( const CM& x, const CM& y ) { return mc::Op<T>::ne(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
151  static bool myLt( const CM& x, const CM& y ) { return mc::Op<T>::lt(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
152  static bool myLe( const CM& x, const CM& y ) { return mc::Op<T>::le(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
153  static bool myGt( const CM& x, const CM& y ) { return mc::Op<T>::gt(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
154  static bool myGe( const CM& x, const CM& y ) { return mc::Op<T>::ge(const_cast<CM*>(&x)->bound(),const_cast<CM*>(&y)->bound()); }
155  };
156 
158  template <> template<typename T> struct Op< mc::Specbnd<T> >{
159  typedef mc::Specbnd<T> SB;
160  typedef double Base;
161  static Base myInteger( const int i ) { return Base(i); }
162  static Base myZero() { return myInteger(0); }
163  static Base myOne() { return myInteger(1);}
164  static Base myTwo() { return myInteger(2); }
165  static double myPI() { return mc::PI; }
166  static SB myPos( const SB& x ) { return x; }
167  static SB myNeg( const SB& x ) { return -x; }
168  template <typename U> static SB& myCadd( SB& x, const U& y ) { return x+=y; }
169  template <typename U> static SB& myCsub( SB& x, const U& y ) { return x-=y; }
170  template <typename U> static SB& myCmul( SB& x, const U& y ) { return x*=y; }
171  template <typename U> static SB& myCdiv( SB& x, const U& y ) { return x/=y; }
172  static SB myInv( const SB& x ) { return mc::inv( x ); }
173  static SB mySqr( const SB& x ) { return mc::sqr( x ); }
174  template <typename X, typename Y> static SB myPow( const X& x, const Y& y ) { return mc::pow( x, y ); }
175  static SB mySqrt( const SB& x ) { return mc::sqrt( x ); }
176  static SB myLog( const SB& x ) { return mc::log( x ); }
177  static SB myExp( const SB& x ) { return mc::exp( x ); }
178  static SB mySin( const SB& x ) { return mc::sin( x ); }
179  static SB myCos( const SB& x ) { return mc::cos( x ); }
180  static SB myTan( const SB& x ) { return mc::tan( x ); }
181  static SB myAsin( const SB& x ) { return mc::asin( x ); }
182  static SB myAcos( const SB& x ) { return mc::acos( x ); }
183  static SB myAtan( const SB& x ) { return mc::atan( x ); }
184  static bool myEq( const SB& x, const SB& y ) { return mc::Op<T>::eq(x.SI(),y.SI()); }
185  static bool myNe( const SB& x, const SB& y ) { return mc::Op<T>::ne(x.SI(),y.SI()); }
186  static bool myLt( const SB& x, const SB& y ) { return mc::Op<T>::lt(x.SI(),y.SI()); }
187  static bool myLe( const SB& x, const SB& y ) { return mc::Op<T>::le(x.SI(),y.SI()); }
188  static bool myGt( const SB& x, const SB& y ) { return mc::Op<T>::gt(x.SI(),y.SI()); }
189  static bool myGe( const SB& x, const SB& y ) { return mc::Op<T>::ge(x.SI(),y.SI()); }
190  };
191 } // end namespace fadbad
192 
193 #include "fadiff.h"
194 
195 namespace fadbad
196 {
197 template <typename T, unsigned int N>
198 INLINE2 FTypeName<T,N> pow2(const FTypeName<T,N>& a, const int b)
199 {
200  FTypeName<T,N> c(Op<T>::myPow(a.val(),b));
201  if (!a.depend()) return c;
202  T tmp(b*Op<T>::myPow(a.val(),b-1));
203  c.setDepend(a);
204  for(unsigned int i=0;i<N;++i) c[i]=tmp*a[i];
205  return c;
206 }
207 template <typename T >
208 INLINE2 FTypeName<T,0> pow2(const FTypeName<T,0>& a, const int b)
209 {
210  FTypeName<T,0> c(Op<T>::myPow(a.val(),b));
211  if (!a.depend()) return c;
212  T tmp(b*Op<T>::myPow(a.val(),b-1));
213  c.setDepend(a);
214  for(unsigned int i=0;i<c.size();++i) c[i]=tmp*a[i];
215  return c;
216 }
217 } // end namespace fadbad
218 
219 #include "tadiff.h"
220 
221 namespace fadbad
222 {
223 template <typename U, int N>
224 struct TTypeNamePOW3 : public UnTTypeNameHV<U,N>
225 {
226  int m_b;
227  TTypeNamePOW3(const U& val, TTypeNameHV<U,N>* pOp, const int b):UnTTypeNameHV<U,N>(val,pOp),m_b(b){}
228  TTypeNamePOW3(TTypeNameHV<U,N>* pOp, const int b):UnTTypeNameHV<U,N>(pOp),m_b(b){}
229  unsigned int eval(const unsigned int k)
230  {
231  unsigned int l=this->opEval(k);
232  if( m_b==0 ){
233  if (0==this->length()) { this->val(0)=Op<U>::myOne(); this->length()=1; }
234  for(unsigned int i=this->length();i<l;++i) { this->val(i)=Op<U>::myZero(); }
235  }
236  else if( m_b==1 ){
237  for(unsigned int i=this->length();i<l;++i) { this->val(i)=this->opVal(i); }
238  }
239  else if( m_b==2 ){
240  if (0==this->length()) { this->val(0)=Op<U>::mySqr(this->opVal(0)); this->length()=1; }
241  for(unsigned int i=this->length();i<l;++i)
242  {
243  this->val(i)=Op<U>::myZero();
244  unsigned int m=(i+1)/2;
245  for(unsigned int j=0;j<m;++j) Op<U>::myCadd(this->val(i), this->opVal(i-j)*this->opVal(j));
246  Op<U>::myCmul(this->val(i), Op<U>::myTwo());
247  if (0==i%2) Op<U>::myCadd(this->val(i), Op<U>::mySqr(this->opVal(m)));
248  }
249  }
250  else if( m_b==3 ){
251  if (0==this->length()) { this->val(0)=Op<U>::myPow(this->opVal(0),m_b); this->length()=1; }
252  if (1<l && 1==this->length() ) { this->val(1)=Op<U>::myPow(this->opVal(0),m_b-1)
253  *this->opVal(1)*Op<U>::myInteger(m_b); this->length()=2; }
254  if (2<l && 2==this->length() ) { this->val(2)=Op<U>::myPow(this->opVal(0),m_b-2)
255  *( this->opVal(0)*this->opVal(2) + Op<U>::myInteger(m_b-1)*Op<U>::mySqr(this->opVal(1)) )
256  *Op<U>::myInteger(m_b); this->length()=3; }
257  for(unsigned int i=this->length();i<l;++i)
258  {
259  this->val(i)=Op<U>::myZero();
260  unsigned int m=(i+1)/2;
261  for(unsigned int j=0;j<m;++j) Op<U>::myCadd(this->val(i), this->opVal(i-j)*this->opVal(j));
262  Op<U>::myCmul(this->val(i), Op<U>::myTwo());
263  if (0==i%2) Op<U>::myCadd(this->val(i), Op<U>::mySqr(this->opVal(m)));
264  }
265  for(unsigned int i=l-1; i>=this->length();--i)
266  {
267  Op<U>::myCmul(this->val(i), this->opVal(0));
268  for(unsigned int j=1;j<=i;++j) Op<U>::myCadd(this->val(i), this->val(i-j)*this->opVal(j));
269  }
270  }
271  else{
272  if (0==this->length()) { this->val(0)=Op<U>::myPow(this->opVal(0),m_b); this->length()=1; }
273  for(unsigned int i=this->length();i<l;++i)
274  {
275  this->val(i)=Op<U>::myZero();
276  for(unsigned int j=0;j<i;++j)
277  Op<U>::myCadd(this->val(i), ( m_b - (m_b+Op<U>::myOne()) * Op<U>::myInteger(j) /
278  Op<U>::myInteger(i) )*this->opVal(i-j)*this->val(j));
279  }
280  }
281  return this->length()=l;
282  }
283 private:
284  void operator=(const TTypeNamePOW3<U,N>&){} // not allowed
285 };
286 template <typename U, int N>
287 TTypeName<U,N> pow(const TTypeName<U,N>& val, const int b)
288 {
289  TTypeNameHV<U,N>* pHV=val.length()>0 ?
290  new TTypeNamePOW3<U,N>(Op<U>::myPow(val.val(),b), val.getTTypeNameHV(), b):
291  new TTypeNamePOW3<U,N>(val.getTTypeNameHV(), b);
292  return TTypeName<U,N>(pHV);
293 }
294 
295 } // end namespace fadbad
296 
297 #include "badiff.h"
298 
299 
300 #include "mcop.hpp"
301 
302 namespace mc
303 {
304 
306 template <> template<typename U> struct Op< fadbad::F<U> >
307 {
308  typedef fadbad::F<U> TU;
309  static TU point( const double c ) { throw std::runtime_error("mc::Op<T<U>>::point -- operation not permitted"); }
310  static TU zeroone() { throw std::runtime_error("mc::Op<T<U>>::zeroone -- operation not permitted"); }
311  static void I(TU& x, const TU&y) { x = y; }
312  static double l(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::l -- operation not permitted"); }
313  static double u(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::u -- operation not permitted"); }
314  static double abs (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::abs -- operation not permitted"); }
315  static double mid (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::mid -- operation not permitted"); }
316  static double diam(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::diam -- operation not permitted"); }
317  static TU inv (const TU& x) { return 1./x; }
318  static TU sqr (const TU& x) { return fadbad::sqr(x); }
319  static TU sqrt(const TU& x) { return fadbad::sqrt(x); }
320  static TU log (const TU& x) { return fadbad::log(x); }
321  static TU xlog(const TU& x) { return x*fadbad::log(x); }
322  static TU fabs(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fabs -- operation not permitted"); }
323  static TU exp (const TU& x) { return fadbad::exp(x); }
324  static TU sin (const TU& x) { return fadbad::sin(x); }
325  static TU cos (const TU& x) { return fadbad::cos(x); }
326  static TU tan (const TU& x) { return fadbad::tan(x); }
327  static TU asin(const TU& x) { return fadbad::asin(x); }
328  static TU acos(const TU& x) { return fadbad::acos(x); }
329  static TU atan(const TU& x) { return fadbad::atan(x); }
330  static TU erf (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erf -- operation not permitted"); }
331  static TU erfc(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erfc -- operation not permitted"); }
332  static TU fstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fstep -- operation not permitted"); }
333  static TU bstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::bstep -- operation not permitted"); }
334  static TU hull(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::hull -- operation not permitted"); }
335  static TU min (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::min -- operation not permitted"); }
336  static TU max (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::max -- operation not permitted"); }
337  static TU arh (const TU& x, const double k) { return fadbad::exp(-k/x); }
338  template <typename X, typename Y> static TU pow(const X& x, const Y& y) { return fadbad::pow(x,y); }
339  static TU monomial (const unsigned int n, const U* x, const int* k) { throw std::runtime_error("mc::Op<T<U>>::monomial -- operation not permitted"); }
340  static bool inter(TU& xIy, const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::inter -- operation not permitted"); }
341  static bool eq(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::eq -- operation not permitted"); }
342  static bool ne(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ne -- operation not permitted"); }
343  static bool lt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::lt -- operation not permitted"); }
344  static bool le(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::le -- operation not permitted"); }
345  static bool gt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::gt -- operation not permitted"); }
346  static bool ge(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ge -- operation not permitted"); }
347 };
348 
350 template <> template<typename U> struct Op< fadbad::B<U> >
351 {
352  typedef fadbad::B<U> TU;
353  static TU point( const double c ) { throw std::runtime_error("mc::Op<T<U>>::point -- operation not permitted"); }
354  static TU zeroone() { throw std::runtime_error("mc::Op<T<U>>::zeroone -- operation not permitted"); }
355  static void I(TU& x, const TU&y) { x = y; }
356  static double l(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::l -- operation not permitted"); }
357  static double u(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::u -- operation not permitted"); }
358  static double abs (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::abs -- operation not permitted"); }
359  static double mid (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::mid -- operation not permitted"); }
360  static double diam(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::diam -- operation not permitted"); }
361  static TU inv (const TU& x) { return 1./x; }
362  static TU sqr (const TU& x) { return fadbad::sqr(x); }
363  static TU sqrt(const TU& x) { return fadbad::sqrt(x); }
364  static TU log (const TU& x) { return fadbad::log(x); }
365  static TU xlog(const TU& x) { return x*fadbad::log(x); }
366  static TU fabs(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fabs -- operation not permitted"); }
367  static TU exp (const TU& x) { return fadbad::exp(x); }
368  static TU sin (const TU& x) { return fadbad::sin(x); }
369  static TU cos (const TU& x) { return fadbad::cos(x); }
370  static TU tan (const TU& x) { return fadbad::tan(x); }
371  static TU asin(const TU& x) { return fadbad::asin(x); }
372  static TU acos(const TU& x) { return fadbad::acos(x); }
373  static TU atan(const TU& x) { return fadbad::atan(x); }
374  static TU erf (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erf -- operation not permitted"); }
375  static TU erfc(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erfc -- operation not permitted"); }
376  static TU fstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fstep -- operation not permitted"); }
377  static TU bstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::bstep -- operation not permitted"); }
378  static TU hull(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::hull -- operation not permitted"); }
379  static TU min (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::min -- operation not permitted"); }
380  static TU max (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::max -- operation not permitted"); }
381  static TU arh (const TU& x, const double k) { return fadbad::exp(-k/x); }
382  template <typename X, typename Y> static TU pow(const X& x, const Y& y) { return fadbad::pow(x,y); }
383  static TU monomial (const unsigned int n, const U* x, const int* k) { throw std::runtime_error("mc::Op<T<U>>::monomial -- operation not permitted"); }
384  static bool inter(TU& xIy, const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::inter -- operation not permitted"); }
385  static bool eq(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::eq -- operation not permitted"); }
386  static bool ne(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ne -- operation not permitted"); }
387  static bool lt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::lt -- operation not permitted"); }
388  static bool le(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::le -- operation not permitted"); }
389  static bool gt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::gt -- operation not permitted"); }
390  static bool ge(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ge -- operation not permitted"); }
391 };
392 
394 template <> template<typename U> struct Op< fadbad::T<U> >
395 {
396  typedef fadbad::T<U> TU;
397  static TU point( const double c ) { throw std::runtime_error("mc::Op<T<U>>::point -- operation not permitted"); }
398  static TU zeroone() { throw std::runtime_error("mc::Op<T<U>>::zeroone -- operation not permitted"); }
399  static void I(TU& x, const TU&y) { x = y; }
400  static double l(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::l -- operation not permitted"); }
401  static double u(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::u -- operation not permitted"); }
402  static double abs (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::abs -- operation not permitted"); }
403  static double mid (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::mid -- operation not permitted"); }
404  static double diam(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::diam -- operation not permitted"); }
405  static TU inv (const TU& x) { return 1./x; }
406  static TU sqr (const TU& x) { return fadbad::sqr(x); }
407  static TU sqrt(const TU& x) { return fadbad::sqrt(x); }
408  static TU log (const TU& x) { return fadbad::log(x); }
409  static TU xlog(const TU& x) { return x*fadbad::log(x); }
410  static TU fabs(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fabs -- operation not permitted"); }
411  static TU exp (const TU& x) { return fadbad::exp(x); }
412  static TU sin (const TU& x) { return fadbad::sin(x); }
413  static TU cos (const TU& x) { return fadbad::cos(x); }
414  static TU tan (const TU& x) { return fadbad::tan(x); }
415  static TU asin(const TU& x) { return fadbad::asin(x); }
416  static TU acos(const TU& x) { return fadbad::acos(x); }
417  static TU atan(const TU& x) { return fadbad::atan(x); }
418  static TU erf (const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erf -- operation not permitted"); }
419  static TU erfc(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::erfc -- operation not permitted"); }
420  static TU fstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::fstep -- operation not permitted"); }
421  static TU bstep(const TU& x) { throw std::runtime_error("mc::Op<T<U>>::bstep -- operation not permitted"); }
422  static TU hull(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::hull -- operation not permitted"); }
423  static TU min (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::min -- operation not permitted"); }
424  static TU max (const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::max -- operation not permitted"); }
425  static TU arh (const TU& x, const double k) { return fadbad::exp(-k/x); }
426  template <typename X, typename Y> static TU pow(const X& x, const Y& y) { return fadbad::pow(x,y); }
427  static TU monomial (const unsigned int n, const U* x, const int* k) { throw std::runtime_error("mc::Op<T<U>>::monomial -- operation not permitted"); }
428  static bool inter(TU& xIy, const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::inter -- operation not permitted"); }
429  static bool eq(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::eq -- operation not permitted"); }
430  static bool ne(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ne -- operation not permitted"); }
431  static bool lt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::lt -- operation not permitted"); }
432  static bool le(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::le -- operation not permitted"); }
433  static bool gt(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::gt -- operation not permitted"); }
434  static bool ge(const TU& x, const TU& y) { throw std::runtime_error("mc::Op<T<U>>::ge -- operation not permitted"); }
435 };
436 
437 } // namespace mc
438 
439 #endif
C++ class for Taylor model computation of factorable function - Taylor model propagation.
Definition: tmodel.hpp:395
C++ class for McCormick relaxation arithmetic for factorable function.
Definition: mccormick.hpp:362
C++ class for Chebyshev model computation of factorable function - Chebyshev model propagation...
Definition: cmodel.hpp:207
C++ template class computing spectral bounds for the Hessian matrix of a factorable function on a box...
Definition: specbnd.hpp:317
C++ class for (non-verified) interval bounding of factorable function.
Definition: interval.hpp:129
const T & SI() const
Return spectral bounds for Hessian matrix.
Definition: specbnd.hpp:534
C++ structure to allow usage of various template parameters in the types mc::McCormick, mc::TModel, mc::TVar, and mc::SpecBnd of MC++ _ Specialization of this structure is required for the template parameters can be found in the header files defining the types mc::McCormick, mc::TModel, mc::TVar, and mc::SpecBnd.
Definition: mcop.hpp:13