requirements for arbitrary types in boost.odeint
boost, numeric, numerical-methods, operator-overloading
Solution
Sorry for a rather lengthy answer, but I had the feeling that some kind of clarification would be helpful:
In general, there are two ways of specializing types in odeint.
One way is specializing algebras which are thought to adapt how one iterates over a container or collection, like a `std::vector`, `std::array`, `ublas::matrix`, etc. In odeint some predefined algebra exists:
- `range_algebra` which works with all container fulfilling a range concept from boost.range
- `fusion_algebra` for compile-time sequences
- `vector_space_algebra` which directs the iteration to the operations.
- `thrust_algebra` for use with thrust - a STL-like framework for CUDA
The second possibility to adapt for special types are the operations which are thought to allow you to specify how to perform the basic operations on the elements of the container. Here, some predefined operations exist
- `default_operations` which work on most types like `double`, `float`, `std::complex<>`, ... `default_operations` only assume that the operators +,-,*,/ are defined as well as the basic functions like `abs`, `max`.
- `thrust_operation` for usage with thrust
If I understand your question correctly, you have one or more types for points with can live in different coordinate systems and therefore the operators on this type has to be adapted to work with odeint. In this case you can use the `range_algebra` in combination with the 'default_operations': Say your type is called `point_type` and it basically consists of doubles, the main floating point type. In order to work with the 'default_operations' you need
- `point_type operator+( point_type , double );`
- `point_type operator+( double , point_type );`
- `point_type operator+( point_type , point_type );`
- `point_type operator*( point_type , double );`
- `point_type operator*( double , point_type );`
- `point_type operator/( point_type , double );`
- `double abs( point_type );`
I think this is all which is needed. Then you should be able to use your point_type in containers like `vector`, `array`, etc. There is also an example in odeint, showing how to adapt special point types: solar system with point types. It is pretty easy if you use the Boost.Operators library.
Edit: Fixed some typos.
Problem
there are some examples of using arbitrary precision and matrices in boost.odeint (boost ordinary differential equation solver). I would like to use odeint atoms in different types of coordinates (Cartesian, polar or action-angle). which operations should I overload for atoms? +,-, min, max, pow? in which file can I look up which operations odeint uses? Update (1) from default algebra, it looks like it needs "+","*" and abs(), max()