Create va_list versions of Integrator state load and unload member functions. Ref #401

This commit is contained in:
John M. Penn 2017-03-28 17:55:27 -05:00
parent 03f79dbbe0
commit a7039aea61
3 changed files with 94 additions and 140 deletions

View File

@ -14,7 +14,7 @@
#define INTEG_ALLOC(typespec, num) (typespec*)calloc((size_t)num,sizeof(typespec))
#define INTEG_FREE(p) free(p)
#endif
#include <cstdarg>
/*
#ifdef USE_ER7_UTILS_INTEGRATORS
#include "er7_utils/integration/core/include/integration_technique.hh"
@ -63,6 +63,9 @@ namespace Trick {
virtual int integrate_2nd_order_ode (
double const* accel, double* velocity, double* position);
#ifndef SWIGPYTHON
void state_in (double* arg1, va_list argp);
#endif
void state_in (double* arg1, ...)
#ifndef SWIGPYTHON
#ifdef __GNUC__
@ -72,6 +75,9 @@ namespace Trick {
#endif
#endif
;
#ifndef SWIGPYTHON
void deriv_in (double* arg1, va_list argp);
#endif
void deriv_in (double* arg1, ...)
#ifndef SWIGPYTHON
#ifdef __GNUC__
@ -81,6 +87,9 @@ namespace Trick {
#endif
#endif
;
#ifndef SWIGPYTHON
void state_out (double* arg1, va_list argp);
#endif
void state_out(double* arg1, ...)
#ifndef SWIGPYTHON
#ifdef __GNUC__
@ -91,6 +100,9 @@ namespace Trick {
#endif
;
#ifndef SWIGPYTHON
void deriv2_in (double* arg1, va_list argp);
#endif
void deriv2_in (double* arg1, ...)
#ifndef SWIGPYTHON
#ifdef __GNUC__

View File

@ -85,97 +85,84 @@ int Trick::Integrator::integrate_2nd_order_ode (
return rc;
}
/**
*/
void Trick::Integrator::state_in (double* arg1, ...) {
va_list ap;
int i;
double* narg;
va_start(ap, arg1);
i=0;
narg = arg1;
void Trick::Integrator::state_in (double* arg1, va_list argp) {
int i = 0;
double* next_arg = arg1;
if (verbosity) message_publish(MSG_DEBUG, "LOAD STATE: ");
while (narg != (double*)NULL) {
state[i] = *narg;
if (verbosity) message_publish(MSG_DEBUG," %g", *narg);
narg = va_arg(ap, double*);
while (next_arg != (double*) NULL) {
state[i] = *next_arg;
if (verbosity) message_publish(MSG_DEBUG," %g", *next_arg);
next_arg = va_arg(argp, double*);
i++;
};
}
if (verbosity) message_publish(MSG_DEBUG,"\n");
va_end(ap);
}
/**
*/
void Trick::Integrator::deriv_in ( double* arg1, ...) {
void Trick::Integrator::state_in (double* arg1, ...) {
va_list argp;
va_start(argp, arg1);
state_in(arg1, argp);
va_end(argp);
}
va_list ap;
int i;
double* narg;
va_start(ap, arg1);
i=0;
narg = arg1;
void Trick::Integrator::deriv_in ( double* arg1, va_list argp) {
int i = 0;
double* next_arg = arg1;
if (verbosity) message_publish(MSG_DEBUG, "LOAD DERIV: ");
while (narg != (double*)NULL) {
deriv[intermediate_step][i] = *narg;
if (verbosity) message_publish(MSG_DEBUG," %g",*narg);
narg = va_arg(ap, double*);
while (next_arg != (double*) NULL) {
deriv[intermediate_step][i] = *next_arg;
if (verbosity) message_publish(MSG_DEBUG," %g", *next_arg);
next_arg = va_arg(argp, double*);
i++;
};
va_end(ap);
}
if (verbosity) message_publish(MSG_DEBUG,"\n");
}
/**
*/
void Trick::Integrator::deriv2_in ( double* arg1, ...) {
void Trick::Integrator::deriv_in ( double* arg1, ...) {
va_list argp;
va_start(argp, arg1);
deriv_in(arg1, argp);
va_end(argp);
}
va_list ap;
int i;
double* narg;
va_start(ap, arg1);
i=0;
narg = arg1;
void Trick::Integrator::deriv2_in ( double* arg1, va_list argp) {
int i = 0;
double* next_arg = arg1;
if (verbosity) message_publish(MSG_DEBUG, "LOAD DERIV2: ");
while (narg != (double*)NULL) {
deriv2[intermediate_step][i] = *narg;
if (verbosity) message_publish(MSG_DEBUG," %g",*narg);
narg = va_arg(ap, double*);
while (next_arg != (double*) NULL) {
deriv2[intermediate_step][i] = *next_arg;
if (verbosity) message_publish(MSG_DEBUG," %g", *next_arg);
next_arg = va_arg(argp, double*);
i++;
};
}
if (verbosity) message_publish(MSG_DEBUG,"\n");
va_end(ap);
}
void Trick::Integrator::deriv2_in ( double* arg1, ...) {
va_list argp;
va_start(argp, arg1);
deriv2_in(arg1, argp);
va_end(argp);
}
/**
*/
void Trick::Integrator::state_out (double* arg1, ...) {
va_list ap;
int i;
double* narg;
va_start(ap, arg1);
i=0;
narg = arg1;
void Trick::Integrator::state_out (double* arg1, va_list argp) {
int i = 0;
double* next_arg = arg1;
if (verbosity) message_publish(MSG_DEBUG, "UNLOAD STATE: ");
while (narg != (double*)NULL) {
*narg = state_ws[intermediate_step][i];
if (verbosity) message_publish(MSG_DEBUG," %g",*narg);
narg = va_arg(ap, double*);
while (next_arg != (double*) NULL) {
*next_arg = state_ws[intermediate_step][i];
if (verbosity) message_publish(MSG_DEBUG," %g", *next_arg);
next_arg = va_arg(argp, double*);
i++;
};
}
if (verbosity) message_publish(MSG_DEBUG,"\n");
va_end(ap);
}
void Trick::Integrator::state_out (double* arg1, ...) {
va_list argp;
va_start(argp, arg1);
state_out(arg1, argp);
va_end(argp);
}
bool Trick::Integrator::get_first_step_deriv() {

View File

@ -30,23 +30,11 @@ extern "C" void set_integ_time(double time_value) {
}
extern "C" void load_state(double* arg1, ... ) {
va_list ap;
int i;
double* narg;
va_list argp;
if (trick_curr_integ != NULL) {
va_start(ap, arg1);
i=0;
narg = arg1;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"LOAD STATE:\n");
while (narg != (double*)NULL) {
trick_curr_integ->state[i] = *narg;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"%g\n",*narg);
narg = va_arg(ap, double*);
i++;
};
va_end(ap);
va_start(argp, arg1);
trick_curr_integ->state_in(arg1, argp);
va_end(argp);
} else {
message_publish(MSG_ERROR, "Integ load_state ERROR: trick_curr_integ is not set.\n") ;
}
@ -64,22 +52,11 @@ extern "C" void load_indexed_state(unsigned int index , double state) {
extern "C" void load_deriv( double* arg1, ...) {
va_list ap;
int i;
double* narg;
va_list argp;
if (trick_curr_integ != NULL) {
va_start(ap, arg1);
i=0;
narg = arg1;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"LOAD DERIV: \n");
while (narg != (double*)NULL) {
trick_curr_integ->deriv[trick_curr_integ->intermediate_step][i] = *narg;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"%g\n",*narg);
narg = va_arg(ap, double*);
i++;
};
va_end(ap);
va_start(argp, arg1);
trick_curr_integ->deriv_in(arg1, argp);
va_end(argp);
} else {
message_publish(MSG_ERROR, "Integ load_deriv ERROR: trick_curr_integ is not set.\n") ;
}
@ -97,24 +74,13 @@ extern "C" void load_indexed_deriv(unsigned int index , double deriv) {
extern "C" void load_deriv2( double* arg1, ...) {
va_list ap;
int i;
double* narg;
va_list argp;
if (trick_curr_integ != NULL) {
va_start(ap, arg1);
i=0;
narg = arg1;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"LOAD DERIV2:\n");
while (narg != (double*)NULL) {
trick_curr_integ->deriv2[trick_curr_integ->intermediate_step][i] = *narg;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"%g\n",*narg);
narg = va_arg(ap, double*);
i++;
};
va_end(ap);
va_start(argp, arg1);
trick_curr_integ->deriv2_in(arg1, argp);
va_end(argp);
} else {
message_publish(MSG_ERROR, "Integ load_deriv ERROR: trick_curr_integ is not set.\n") ;
message_publish(MSG_ERROR, "Integ load_deriv2 ERROR: trick_curr_integ is not set.\n") ;
}
}
@ -130,22 +96,11 @@ extern "C" void load_indexed_deriv2(unsigned int index , double deriv2) {
extern "C" void unload_state (double* arg1, ...) {
va_list ap;
int i;
double* narg;
va_list argp;
if (trick_curr_integ != NULL) {
va_start(ap, arg1);
i=0;
narg = arg1;
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"UNLOAD STATE:\n");
while (narg != (double*)NULL) {
*narg = trick_curr_integ->state_ws[trick_curr_integ->intermediate_step][i];
if (trick_curr_integ->verbosity) message_publish(MSG_DEBUG,"%g\n",*narg);
narg = va_arg(ap, double*);
i++;
};
va_end(ap);
va_start(argp, arg1);
trick_curr_integ->state_out(arg1, argp);
va_end(argp);
} else {
message_publish(MSG_ERROR, "Integ unload_state ERROR: trick_curr_integ is not set.\n") ;
}