[Boost-bugs] [Boost C++ Libraries] #4436: Introduce an unpack to arguments operation for vectors and matrices

Subject: [Boost-bugs] [Boost C++ Libraries] #4436: Introduce an unpack to arguments operation for vectors and matrices
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-15 12:17:14


#4436: Introduce an unpack to arguments operation for vectors and matrices
-------------------------------------+--------------------------------------
 Reporter: nasos_i@… | Owner: guwi17
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: uBLAS
  Version: Boost Development Trunk | Severity: Not Applicable
 Keywords: |
-------------------------------------+--------------------------------------
 The new ublas assignment facility provides a convenient way to fill up
 matrices and vectors, but the opposite would also be useful.
 Quoting:
 {{{
 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

 }}}

 and
 {{{
 What's about ublas::tie(V1,V2,V3) = M;
 That could be useful for applications where Vn are not directly managed by
 ublas. I mean that you make matrix computations which vectors are then
 sent
 to some sort of external outputs. That would be written in one line (like
 controlling and engine or whatever you can imagine, you know).
 that's splitting up a matrix in vectors .... ?

 Cheers,
 David
 }}}

 Some ideas of implementation tools and techniques include:
 1. Boost tuple
 2. Variadic templates
 3. Custom exhaustive implementation (up to a certain number of return
 values)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4436>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC