]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/examples/gmpxx/lorenz_gmpxx.cpp
4 * This example demonstrates how odeint can be used with arbitrary precision types.
6 * Copyright 2011-2012 Karsten Ahnert
7 * Copyright 2011-2012 Mario Mulansky
9 * Distributed under the Boost Software License, Version 1.0.
10 * (See accompanying file LICENSE_1_0.txt or
11 * copy at http://www.boost.org/LICENSE_1_0.txt)
17 #include <boost/array.hpp>
21 #include <boost/numeric/odeint.hpp>
24 using namespace boost::numeric::odeint
;
27 typedef mpf_class value_type
;
28 typedef boost::array
< value_type
, 3 > state_type
;
32 void operator()( const state_type
&x
, state_type
&dxdt
, value_type t
) const
34 const value_type
sigma( 10.0 );
35 const value_type
R( 28.0 );
36 const value_type
b( value_type( 8.0 ) / value_type( 3.0 ) );
38 dxdt
[0] = sigma
* ( x
[1] - x
[0] );
39 dxdt
[1] = R
* x
[0] - x
[1] - x
[0] * x
[2];
40 dxdt
[2] = -b
* x
[2] + x
[0] * x
[1];
48 struct streaming_observer
52 streaming_observer( std::ostream
&out
) : m_out( out
) { }
54 template< class State
, class Time
>
55 void operator()( const State
&x
, Time t
) const
58 for( size_t i
=0 ; i
<x
.size() ; ++i
) m_out
<< "\t" << x
[i
] ;
68 int main( int argc
, char **argv
)
71 const int precision
= 1024;
72 mpf_set_default_prec( precision
);
74 state_type x
= {{ value_type( 10.0 ) , value_type( 10.0 ) , value_type( 10.0 ) }};
76 cout
.precision( 1000 );
77 integrate_const( runge_kutta4
< state_type
, value_type
>() ,
78 lorenz() , x
, value_type( 0.0 ) , value_type( 10.0 ) , value_type( value_type( 1.0 ) / value_type( 10.0 ) ) ,
79 streaming_observer( cout
) );