Boost logo

Ublas :

Subject: [ublas] A ublas::tie to vector expressions?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-07-14 10:52:36


The boost assignment is really nice, but what about the other direction
(from vector to scalars)? This comes up quite often.

ublas::vector<double> f()
{
ublas::vector<double> v(2);
 v(0) = 1.1;
v(1) = 2.1;
return v;
}

double x;
double y;

 ublas::vector<double> v(2);
v(0) = 1.1;
v(1) = 2.1;

ublas::tie(x, y) = v;
ublas::tie(x, y) = f(); //With function

ublas::matrix<double> mat(2,2); //....
ublas::tie(x, y) = row(mat, 0);

ublas::vector<int> v2(2);
v2(0) = 1;
 v2(1) = 2;

        int z;
        ublas::tie(x, z); //With different types

For vector expressions, this seems to be easy enough to do. See the
attached basic implementation for 2 parameters. With a little boost
preprocessor, this could be fairly general. What do people think? Are
there any boost PP who could generalize this?

-Jesse