All pastes #2430971 Raw Edit

Stuff

public unlisted cpp v1 · immutable
#2430971 ·published 2013-08-12 11:45 UTC
rendered paste body
#include <adolc/adolc.h>#include <cmath>#include <map>#include <iostream>#include <typeinfo>using namespace std;template<class Real>class wrap{public:  Real x;  wrap(Real x):	x(x){}  Real mul(const wrap<Real> v) const{	return x * v.x;  }};template<class Real>ostream& operator<<(ostream& os, const wrap<Real>& v){  return ( os << "wrap( " << v.x << " )" );}bool test_d(const wrap<const double> a,const wrap<const double> b){  cout << "   test()" << endl;  cout << "    before: a,b: " << a << ", " << b << endl;  const double A = b.mul(a);  cout << "    after : a,b: " << a << ", " << b << endl;  cout << "    A==" << A << endl;  make_pair(A, -A);  return true;}bool test_ad(const wrap<const adouble> a,const wrap<const adouble> b){  cout << "   test()" << endl;  cout << "    before: a,b: " << a << ", " << b << endl;  const adouble A = b.mul(a);  cout << "    after : a,b: " << a << ", " << b << endl;  cout << "    A==" << A << endl;  make_pair(A, -A);  return true;}int main(){  {#define D double	cout << "checking for " << typeid (D).name() << endl;	wrap<const D>	  a_(2), b_(3);	test_d(a_,b_) && test_d(a_,b_);#undef D  }  {#define D adouble	cout << "checking for " << typeid (D).name() << endl;	wrap<const D>	  a_(2), b_(3);	test_ad(a_,b_) 	  && test_ad(a_,b_);#undef D  }  return 0;}