Boost C++ Libraries: Ticket #4436: Introduce an unpack to arguments operation for vectors and matrices https://svn.boost.org/trac10/ticket/4436 <p> The new ublas assignment facility provides a convenient way to fill up matrices and vectors, but the opposite would also be useful. Quoting: </p> <pre class="wiki">The boost assignment is really nice, but what about the other direction (from vector to scalars)? This comes up quite often. ublas::vector&lt;double&gt; f() { ublas::vector&lt;double&gt; v(2); v(0) = 1.1; v(1) = 2.1; return v; } double x; double y; ublas::vector&lt;double&gt; v(2); v(0) = 1.1; v(1) = 2.1; ublas::tie(x, y) = v; ublas::tie(x, y) = f(); //With function ublas::matrix&lt;double&gt; mat(2,2); //.... ublas::tie(x, y) = row(mat, 0); ublas::vector&lt;int&gt; 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 </pre><p> and </p> <pre class="wiki">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 </pre><p> Some ideas of implementation tools and techniques include: </p> <ol><li>Boost tuple </li><li>Variadic templates </li><li>Custom exhaustive implementation (up to a certain number of return values) </li></ol> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4436 Trac 1.4.3 anonymous Thu, 15 Jul 2010 13:05:10 GMT attachment set https://svn.boost.org/trac10/ticket/4436 https://svn.boost.org/trac10/ticket/4436 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">tie.hpp</span> </li> </ul> Ticket anonymous Thu, 15 Jul 2010 13:05:44 GMT attachment set https://svn.boost.org/trac10/ticket/4436 https://svn.boost.org/trac10/ticket/4436 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_tie.cpp</span> </li> </ul> Ticket