I'm trying to do something like this
#include <boost/numeric/ublas/vector.hpp>
using namespace boost::numeric::ublas;
class A{
protected:
vector< double > a_;
public:
A( vector< double > a ) :
a_( a ) {};
};
class B : public A{
public:
B() : A( vector< double >( { 1.25, 2.75, 3.34 } ) ){};
};
The result should be, that the vector a_
gets declared as a three-vector containing a_[0]=1.25, a_[1]=2.75, a_[2]=3.34
.
This code is not working because boost::numeric::ublas::vector
does not have a constructor which can handle vector<double>( { 1.25, 2.75, 3.34 } )
What should I use instead? Maybe the constructor
vector (size_type size, const double &data)
from the boost documentation helps?
You may change the default storage type of an ublas/vector from unbounded_array to std::vector to get initializer_list support or introduce a helper function to initialize the member: