I am expanding the example of studying parameters from boost odeint used with traction, and I don’t know how to pass the vector of values to the observer constructor, so that these values can be accessed (read-only) from within the observer functor.
The following code is for observer only.
struct minimum_perturbation_observer {
struct minPerturbFunctor
{
template< class T >
__host__ __device__
void operator()( T t ) const
{
}
};
minimum_perturbation_observer( size_t N, state_type unchangingVector, int len) :
m_N( N ),
m_output( N ),
m_unchangingVector( len )
{
thrust::fill( m_output.begin() , m_output.end() , 0.0 );
thrust::copy( unchangingVector.begin(), unchangingVector.end(),
m_unchangingVector.begin());
}
template< class State >
void operator()(State x , value_type t )
{
thrust::for_each(
thrust::make_zip_iterator( thrust::make_tuple(
boost::begin( x ) + 0*m_N,
boost::begin( x ) + 1*m_N,
boost::begin( m_output )
)
),
thrust::make_zip_iterator( thrust::make_tuple(
boost::begin( x ) + 1*m_N,
boost::begin( x ) + 2*m_N,
boost::begin( m_output ) + m_N
)
) ,
minPerturbFunctor() );
}
size_t m_N;
state_type m_output;
state_type m_unchangingVector;
};
I experimented with creating m_unchangingVector staticor const, but this is not true because it needs to be installed after creating the observer instance.
, , - unchangingVector thrust::make_zip_iterator( thrust::make_tuple(..., , , ( ). , , , (T t) , unchangingVector , .
, , , , , /.
, , error: a nonstatic member reference must be relative to a specific object. , m_unchangingVector .
, , , .
.
struct minPerturbFunctor
{
minPerturbFunctor( state_type unchangingVector, int len ) :
f_unchangingVector( len )
{
thrust::copy( f_unchangingVector.begin(),
f_unchangingVector.end(),
unchangingVector.begin());
f_len = len;
};
template< class T >
__host__ __device__
void operator()( T t ) const
{
}
};
: ( "thrust:: detail:: vector_base > :: operator []" ) > ( "minimum_perturbation_observer:: minPerturbFunctor:: operator() > " )
/usr/local/cuda/bin/..//include/thrust/detail/function.h(104): : ( "thrust:: device_vector > :: device_vector" ) ( "thrust:: detail:: device_function:: device_function" )
?