> . to be a valid matrix or at least work like one.  One solution may be that the svd_impl is itself a matrix expression which calls apply1 if accessed.
That will do probably, an altenrative is to define a cast  operator member function (i.e. to either matrix or matrix expression). This needs some caution though. (I keep a small reservation for the following code)
class svd_impl {
...
...
operator ublas::matrix<T> () {
  ublas::matrix<T> S;
  ...
  return S; //RVO will probably kick in here
}

};

Best
Nasos


From: jesseperla@gmail.com
Date: Mon, 26 Jul 2010 14:15:14 -0400
To: ublas@lists.boost.org
Subject: Re: [ublas] todo list

Nasos Iliopoulos <nasos_i <at> hotmail.com> writes:
>take a look at Jesse's implementation for "tie" in trac:
Hopefully people don't take my implementation for vector tie's too seriously.  It 'works' but I am not sure it is elegant or efficient.
One other question was whether the term 'tie' is a good one.  I like the consistency with boost::fusion and std::tuple tie functions as a generic term for connecting to multiple return types, but I can understand other views that this is a kind of splitting functione.  My main use case is in splitting a vector of unrelated coefficients used in an optimizer, so the idea of  'tie' ing multiple return types into scalars rather than just 'splitting' up a vector makes more sense to me.

>this can be generalized to achieve "referenced return" or sort of. Imagine for example:
>overall, you will be able to do things like:
>S = svd(A);
>tie(Q,W) = svd(A);
>tie(U, S, V) = svd(A);

I didn't think of that ingenious way to overload based on return types and still keep ublas::tie generic.

One thing to consider though is how it might interact with 'auto'.  The problem becomes that decltype(svd(A)) == svd_impl<decltype(A)> whereas people might expect: 
auto S = svd(A);
or
std::cout << svd(A);
... to be a valid matrix or at least work like one.  One solution may be that the svd_impl is itself a matrix expression which calls apply1 if accessed...


Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. See how.