M
mlt
I am trying to do the following statement using std::vector and
ublas::vector:
boost_vector vec1(3);
vec1(0) = 1;
vec1(1) = 2;
vec1(2) = 3;
P[0][0] = P[0][0] + vec1;
But making the read from P[0][0] before assigning to P[0][0] gives an error.
This is how the code is called:
typedef boost::numeric::ublas::vector<double> boost_vector;
std::vector< std::vector<boost_vector > > P;
testUblas(P);
// where:
void testUblas(std::vector< std::vector<boost_vector > > & P )
{
int rows = 3;
P.resize(rows);
for (int j=0; j<rows; j++)
{
P[j].resize(3);
}
boost_vector vec1(3);
vec1(0) = 1;
vec1(1) = 2;
vec1(2) = 3;
P[0][0] = P[0][0] + vec1; // Error
}
I have tried: P[j].clear() in the initializer loop but it does not help. How
do I make a correct initialzation of P after passing it to testUblas?
ublas::vector:
boost_vector vec1(3);
vec1(0) = 1;
vec1(1) = 2;
vec1(2) = 3;
P[0][0] = P[0][0] + vec1;
But making the read from P[0][0] before assigning to P[0][0] gives an error.
This is how the code is called:
typedef boost::numeric::ublas::vector<double> boost_vector;
std::vector< std::vector<boost_vector > > P;
testUblas(P);
// where:
void testUblas(std::vector< std::vector<boost_vector > > & P )
{
int rows = 3;
P.resize(rows);
for (int j=0; j<rows; j++)
{
P[j].resize(3);
}
boost_vector vec1(3);
vec1(0) = 1;
vec1(1) = 2;
vec1(2) = 3;
P[0][0] = P[0][0] + vec1; // Error
}
I have tried: P[j].clear() in the initializer loop but it does not help. How
do I make a correct initialzation of P after passing it to testUblas?