Click here to Skip to main content
15,895,557 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 130.1K   2.8K   34  
odeint v2 - Solving ordinary differential equations in C++
/*
 * range_algebra.hpp
 *
 *  Created on: Feb 12, 2011
 *      Author: karsten
 */

#ifndef RANGE_ALGEBRA_HPP_
#define RANGE_ALGEBRA_HPP_

#include <iostream>
#include <algorithm>

#include <boost/range.hpp>
#include <boost/functional/forward_adapter.hpp>

struct algebra1
{
	struct for_each1_impl
	{
		template< class S1 , class Op >
		void operator()( S1 &s1 , Op op ) const
		{
			std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op	);
			tmp2 = 0.11;
		}
		typedef void result_type;
	};

	struct for_each2_impl
	{
		template< class S1 , class Op >
		void operator()( S1 &s1 , Op op ) const
		{
			std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op	);
			std::cout << tmp2 << std::endl;
		}
		typedef void result_type;
	};


	typedef boost::forward_adapter< for_each1_impl , 2 > for_each1;

	double tmp2;

};


// alternativ

struct algebra2
{
	template< class S1 , class Op >
	void for_each1( S1 &s1 , Op op )
	{
		tmp = 123.0;
		std::for_each( boost::begin( s1 ) , boost::end( s1 ) , op	);
	};

	double tmp;
};



#endif /* RANGE_ALGEBRA_HPP_ */

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