21 gettimeofday(&t->
tic, 0);
29 gettimeofday(&t->
toc, 0);
31 if ((t->
toc.tv_usec - t->
tic.tv_usec) < 0)
33 temp.tv_sec = t->
toc.tv_sec - t->
tic.tv_sec - 1;
34 temp.tv_usec = 1000000 + t->
toc.tv_usec - t->
tic.tv_usec;
38 temp.tv_sec = t->
toc.tv_sec - t->
tic.tv_sec;
39 temp.tv_usec = t->
toc.tv_usec - t->
tic.tv_usec;
64 printf(
"input: \n[" );
66 if( i < (ACADO_NX-1) ) printf(
"%.3g, ", x[i] );
67 else printf(
"%.3g]", x[i] );
71 if( i < (ACADO_NE-1) ) printf(
"%.3g, ", x[ACADO_NX+i] );
72 else printf(
"%.3g]", x[ACADO_NX+i] );
76 for( j = 0; j < ACADO_NX+
ACADO_NU; j++ ) {
77 if( j < (ACADO_NX+ACADO_NU-1) ) printf(
"%.3g, ", x[ACADO_NX+ACADO_NE+i*(ACADO_NX+ACADO_NU)+j] );
78 else printf(
"%.3g;", x[ACADO_NX+ACADO_NE+i*(ACADO_NX+ACADO_NU)+j] );
80 if( i < (ACADO_NX-1) ) printf(
"\n" );
85 if( i < (ACADO_NU-1) ) printf(
"%.3g, ", x[ACADO_NX+ACADO_NE+ACADO_NX*(ACADO_NX+ACADO_NU)+i] );
86 else printf(
"%.3g]\n\n", x[ACADO_NX+ACADO_NE+ACADO_NX*(ACADO_NX+ACADO_NU)+i] );
93 double acado_aux[ 800 ];
102 #include "ADsymbolic_output.c" 105 printf(
"------------------------------------------------------------\nRunning test..\n\n" );
116 double t_tmp1, t_tmp2;
123 for( i = 0; i <
TIMING; i++ ) {
128 printf(
"symmetricDerivative: \n" );
131 for( k = 0; k <= j; k++ ) {
132 printf(
"%.3g, ", f1[i] );
140 for( i = 0; i <
TIMING; i++ ) {
141 alternativeSymmetric(x, f2);
145 printf(
"\nalternativeSymmetric: \n" );
148 for( k = 0; k <= j; k++ ) {
149 printf(
"%.3g, ", f2[i] );
156 printf(
"\n------------------------------\nDifference: \n" );
160 for( k = 0; k <= j; k++ ) {
161 diff[i] = fabs( f1[i] - f2[i] );
162 if( diff[i] > error ) error = diff[i];
163 printf(
"%.3g, ", diff[i] );
169 printf(
"Error: %.3g\n------------------------------\n", error );
171 printf(
"Timing symmetricDerivative : %.3g μs\n", 1e6*t_tmp1 );
172 printf(
"Timing alternativeSymmetric: %.3g μs\n\n", 1e6*t_tmp2 );
174 printf(
"done!\n------------------------------------------------------------\n" );
Expression symmetricDerivative(const Expression &arg1, const Expression &arg2, const Expression &forward_seed, const Expression &backward_seed, Expression *forward_result, Expression *backward_result)
ACADOworkspace acadoWorkspace
void initializeX(double *x)
struct ACADOworkspace_ ACADOworkspace