Boost logo

Ublas :

Subject: Re: [ublas] A ublas::tie to vector expressions?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-07-15 08:02:57


Nasos Iliopoulos <nasos_i <at> hotmail.com> writes:
> That would be very useful indeed and not hard to generalize.

Oops, I sent in my test file and not the implementation. I decided to learn
a little boost preprocessor, so the attached file may be a complete
implementation of the vector expression tie for a compile time constant
size. My test file is also attached, but if you want to use it you will
have to change around the includes, etc.

The test file succeeds with MSVC10 and Intel 11.1 on Windows. I am sure it
could be made more efficient... The main issue I have is forcing default
constructible on the value-types, which you will see if you go through the
code. I suppose that helpers of different sizes could be generated instead
of my trick with the mpl::void_, but I really didn't want to debug that PP
iteration.

Alas, I would love to use variable argument templates, but it is one of the
C++0X features that just isn't widely available enough yet. I use auto,
decltype, and C++0X lambdas all the time in my 2 windows compilers, but the
variable argument templates will be > 1 year for MSVC and Intel.

How would the notation for tie'ing for matrices work? Would it be to
scalars of just vectors? I can visualize something like the following:
ublas::vector<double> v0(2);
ublas::vector<double> v1(2);
ublas::matrix<double> m(2,2);

ublas::tie_by_column(v0, v1) = m;
ublas::tie_by_row(v0, v1) = m;

My gut is that the notation should be more consistent with the new
assignment operators, etc. in ublas, but I am not sure I know how.