Boost logo

Ublas :

Subject: Re: [ublas] A ublas::tie to vector expressions?
From: David Bellot (david.bellot_at_[hidden])
Date: 2010-07-15 02:31:25


of course variadic templates would be a better solution even if we will
restrict the number of users.
There are plenty of boost libraries that can help us doing that too, so it
should not be too complex.

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

On Wed, Jul 14, 2010 at 23:12, Nasos Iliopoulos <nasos_i_at_[hidden]> wrote:

> That would be very useful indeed and not hard to generalize.
>
> I can see two approaches:
> 1. Exhaustive definition of functions with a varying number of arguments
> (like 16 (or more) implementations for vector and 16 for matrix), like the
> one you have in your implementation.
> 2. Variadic templates (that would be cool, but available only to c++0x
> compatible compilers) if somebody wants some hints let me know).
>
> Do you thing this should have any features other than the ones you have in
> your example?
>
> Best
> Nasos
>
>
>
> ------------------------------
> From: jesseperla_at_[hidden]
> Date: Wed, 14 Jul 2010 10:52:36 -0400
> To: ublas_at_[hidden]
> Subject: [ublas] A ublas::tie to vector expressions?
>
>
> 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
>
>
> ------------------------------
> Hotmail has tools for the New Busy. Search, chat and e-mail from your
> inbox. Learn more.<http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: david.bellot_at_[hidden]
>

-- 
David Bellot, PhD
david.bellot_at_[hidden]
http://david.bellot.free.fr