Boost logo

Ublas :

Subject: [ublas] [Boost-ublas] How to use stateful functors in ublas expression
From: dariomt_at_[hidden]
Date: 2011-09-15 05:27:03


Hi all,

In my post "How to use function calls in ublas expression" [1] I was
redirected to [2] which was very useful.

Now I can write code like this withput creating unnecessary temporaries

ublas::vector<double> x, y, z, w;
x = y + ublas::apply_to_all( z, functor::log<double>() ) + w;

But after looking into ublas code I found out that the template machinery
ends up calling the static function apply() of the functor, making it
impossible to use stateful functors in the expressions.

My question is: does anyone know the rationale for this decision? I would
expect that allowing stateful functors and calling their operator() member
function (like in STL) would make ublas much more extendable.

Thanks!

[1]
http://boost.2283326.n4.nabble.com/Boost-ublas-How-to-use-function-calls-in-ublas-expression-tt2711515.html#a2711519

[2]
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Examples_-_How_To_Extend_UBLAS