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"
64 #include "adolc/taping.h"
76 y = x1*x2 +
sin(x1)/x2;
79 template <
typename TaylorType>
89 for (
int j=0; j<=degree; j++) {
96 for (
int j=0; j<nloop; j++) {
106 do_time_adolc(
int degree,
int nloop)
112 X[0] =
new double[degree+1];
113 X[1] =
new double[degree+1];
115 Y[0] =
new double[degree+1];
116 for (
int j=0; j<=degree; j++) {
117 X[0][j] = urand.number();
118 X[1][j] = urand.number();
132 for (
int j=0; j<nloop; j++) {
133 forward(0,1,2,degree,0,X,Y);
144 return timer.totalElapsedTime() / nloop;
148 do_time_adolc_retape(
int degree,
int nloop)
154 X[0] =
new double[degree+1];
155 X[1] =
new double[degree+1];
157 Y[0] =
new double[degree+1];
158 for (
int j=0; j<=degree; j++) {
159 X[0][j] = urand.number();
160 X[1][j] = urand.number();
167 for (
int j=0; j<nloop; j++) {
174 forward(0,1,2,degree,0,X,Y);
185 return timer.totalElapsedTime() / nloop;
189 int main(
int argc,
char* argv[]) {
199 clp.
setDocString(
"This program tests the speed of various forward mode AD implementations for a single multiplication operation");
201 clp.
setOption(
"degree", °ree,
"Polynomial degree");
203 clp.
setOption(
"nloop", &nloop,
"Number of loops");
207 parseReturn= clp.
parse(argc, argv);
211 std::cout.setf(std::ios::scientific);
212 std::cout.precision(p);
213 std::cout <<
"Times (sec) for degree = " << degree
214 <<
" nloop = " << nloop <<
": " << std::endl;
216 t = do_time< Sacado::Tay::Taylor<double> >(degree, nloop);
217 std::cout <<
"Taylor: " << std::setw(w) << t << std::endl;
219 t = do_time< Sacado::Tay::CacheTaylor<double> >(degree, nloop);
220 std::cout <<
"CacheTaylor: " << std::setw(w) << t << std::endl;
223 t = do_time_adolc(degree, nloop);
224 std::cout <<
"ADOL-C: " << std::setw(w) << t << std::endl;
225 t = do_time_adolc_retape(degree, nloop);
226 std::cout <<
"ADOL-C (retape): " << std::setw(w) << t << std::endl;
230 catch (std::exception& e) {
231 cout << e.what() << endl;
234 catch (
const char *s) {
239 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)