Tudat/Mathematics/NumericalIntegrators/UnitTests/unitTestNumericalIntegrator.cpp
//! Test the amount of steps that NumericalIntegrator::integrateTo takes.
/*!
 * Test the amount of steps that NumericalIntegrator::integrateTo takes.
 * \param intervalStart The start of the integration interval.
 * \param intervalEnd The end of the integration interval.
 * \param initialState The initial state.
 * \param stepSize The step size to take.
 * \return True if actual number of steps is equal to actual number of steps; false otherwise.
 */
Test the amount of steps that NumericalIntegrator::integrateTo takes.
Test the amount of steps that NumericalIntegrator::integrateTo takes.
\param intervalStart The start of the integration interval.
\param intervalEnd The end of the integration interval.
\param initialState The initial state.
\param stepSize The step size to take.
\return True if actual number of steps is equal to actual number of steps; false otherwise.
Test the amount of steps that NumericalIntegrator :: integrateTo takes . Test the amount of steps that NumericalIntegrator :: integrateTo takes . \ param intervalStart The start of the integration interval . \ param intervalEnd The end of the integration interval . \ param initialState The initial state . \ param stepSize The step size to take . \ return True if actual number of steps is equal to actual number of steps ; false otherwise .
bool testIntegrateToFunction( const double intervalStart, const double intervalEnd,
                              const Eigen::VectorXd& initialState,
                              const double stepSize )
{
    DummyNumericalIntegrator integrator( intervalStart, initialState );
    Eigen::VectorXd integratedState = integrator.integrateTo( intervalEnd, stepSize );
    int expectedNumberOfSteps = static_cast< int >(
                std::ceil( ( intervalEnd - intervalStart ) / stepSize ) );
    if ( integratedState != initialState )
    {
        std::cerr << "DummyNumericalIntegrator was not a dummy integrator!" << std::endl;
        return false;
    }
    if ( integrator.numberOfSteps != expectedNumberOfSteps )
    {
        return false;
    }
    return true;
}
bool testIntegrateToFunction ( const double intervalStart , const double intervalEnd , const Eigen :: VectorXd & initialState , const double stepSize ) { DummyNumericalIntegrator integrator ( intervalStart , initialState ) ; Eigen :: VectorXd integratedState = integrator . integrateTo ( intervalEnd , stepSize ) ; int expectedNumberOfSteps = static_cast < int > ( std :: ceil ( ( intervalEnd - intervalStart ) / stepSize ) ) ; if ( integratedState != initialState ) { std :: cerr << " " << std :: endl ; return false ; } if ( integrator . numberOfSteps != expectedNumberOfSteps ) { return false ; } return true ; }
Test the amount of steps that NumericalIntegrator::integrateTo takes.
Test the amount of steps that NumericalIntegrator :: integrateTo takes .
// Calculate expected number of steps. // Check if the integrated state is equal to the initial state. // This is an exact comparison, because no arithmetics are performed on the state. // Check if the actual number of steps is equal to the expected number of steps.