47 #ifdef PACKAGE_BUGREPORT
48 #undef PACKAGE_BUGREPORT
53 #ifdef PACKAGE_TARNAME
54 #undef PACKAGE_TARNAME
56 #ifdef PACKAGE_VERSION
57 #undef PACKAGE_VERSION
62 #include "adolc/adouble.h"
63 #include "adolc/interfaces.h"
75 y = x1*x2 +
sin(x1)/x2;
78 template <
typename TaylorType>
88 for (
int j=0; j<=degree; j++) {
95 for (
int j=0; j<nloop; j++) {
105 do_time_adolc(
int degree,
int nloop)
111 X[0] =
new double[degree+1];
112 X[1] =
new double[degree+1];
114 Y[0] =
new double[degree+1];
115 for (
int j=0; j<=degree; j++) {
116 X[0][j] = urand.number();
117 X[1][j] = urand.number();
131 for (
int j=0; j<nloop; j++) {
132 forward(0,1,2,degree,0,X,Y);
143 return timer.totalElapsedTime() / nloop;
147 do_time_adolc_retape(
int degree,
int nloop)
153 X[0] =
new double[degree+1];
154 X[1] =
new double[degree+1];
156 Y[0] =
new double[degree+1];
157 for (
int j=0; j<=degree; j++) {
158 X[0][j] = urand.number();
159 X[1][j] = urand.number();
166 for (
int j=0; j<nloop; j++) {
173 forward(0,1,2,degree,0,X,Y);
184 return timer.totalElapsedTime() / nloop;
188 int main(
int argc,
char* argv[]) {
198 clp.
setDocString(
"This program tests the speed of various forward mode AD implementations for a single multiplication operation");
200 clp.
setOption(
"degree", °ree,
"Polynomial degree");
202 clp.
setOption(
"nloop", &nloop,
"Number of loops");
206 parseReturn= clp.
parse(argc, argv);
210 std::cout.setf(std::ios::scientific);
211 std::cout.precision(p);
212 std::cout <<
"Times (sec) for degree = " << degree
213 <<
" nloop = " << nloop <<
": " << std::endl;
215 t = do_time< Sacado::Tay::Taylor<double> >(degree, nloop);
216 std::cout <<
"Taylor: " << std::setw(w) << t << std::endl;
218 t = do_time< Sacado::Tay::CacheTaylor<double> >(degree, nloop);
219 std::cout <<
"CacheTaylor: " << std::setw(w) << t << std::endl;
222 t = do_time_adolc(degree, nloop);
223 std::cout <<
"ADOL-C: " << std::setw(w) << t << std::endl;
224 t = do_time_adolc_retape(degree, nloop);
225 std::cout <<
"ADOL-C (retape): " << std::setw(w) << t << std::endl;
229 catch (std::exception& e) {
230 cout << e.what() << endl;
233 catch (
const char *s) {
238 cout <<
"Caught unknown exception!" << endl;
ScalarT number()
Get random number.
Sacado::Tay::Taylor< double > TaylorType
void start(bool reset=false)
T & fastAccessCoeff(int i)
Returns degree i term without bounds checking.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
double do_time(int nderiv, int nloop)
void setDocString(const char doc_string[])
double totalElapsedTime(bool readCurrentTime=false) const
const T func(int n, T *x)