Click here to Skip to main content
15,884,841 members
Articles / Programming Languages / CUDA

odeint v2 - Solving ordinary differential equations in C++

Rate me:
Please Sign up or sign in to vote.
4.64/5 (18 votes)
19 Oct 2011CPOL19 min read 129K   2.8K   34  
odeint v2 - Solving ordinary differential equations in C++
#include <boost/numeric/odeint/util/is_resizeable.hpp>


template< class Stepper , class State >
bool adjust_size_by_resizeability( Stepper &stepper , const State &x , boost::true_type )
{
    return stepper.adjust_size( x );
}

template< class Stepper , class State>
bool adjust_size_by_resizeability( Stepper &stepper , const State &x , boost::false_type )
{
    return false;
}

struct always_resizer
{

    template< class Stepper , class State >
    bool adjust_size( Stepper& stepper, const State &x )
    {
        return adjust_size_by_resizeability( stepper , x , typename boost::numeric::odeint::is_resizeable< State >::type() );
        stepper.resize( x );
    }

};


struct initially_resizer
{
    bool m_initialized;

    initially_resizer(): m_initialized( false )
    { }

    template< class Stepper , class State >
    bool adjust_size( Stepper& stepper, const State &x )
    {
        if( !m_initialized )
        {
            m_initialized = true;
            return adjust_size_by_resizeability( stepper , x , typename boost::numeric::odeint::is_resizeable< State >::type() );
        }
        return false;
    }
};


struct never_resizer
{
    template< class Stepper , class State >
    void adjust_size( Stepper& stepper, const State &x )
    { }
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions