Boost logo

Boost Users :

From: jhr.walter_at_[hidden]
Date: 2003-02-26 15:31:05


Hi Roland,

you wrote:

> This is an addendum to my previous post...
>
> I looked into the bayesclasses as you were suggesting and as far as I
> see the use of the uBLAS does something I was presuming before. There
> is a local Vec and Matrix class which are defined as following:
>
>=============================================================
> class Vec: public ublas::vector<double>
> {
> ...
> template <class E>
> Vec(const ublas::vector_expression<E>& e) : ublas::vector<double>
> (e)
> {} // vector_expression conversion constructor
> ...
> template <class E>
> Vec& operator=(const ublas::vector_expression<E>& r)
> { // Expression assignment, may be dependant on r
> ublas::vector<double>::operator=(r);
> return *this;
> }
> ...
> }
>=============================================================
>
> This essentially removes the expression information in the
> assignment. Am I right?

Hm. ublas' operator=() or assign() always are the point of evaluation, i.e.
they never copy expression trees.

> Now when defining
> void foo(Vec& arg) {}
> there is no passing of the expression tree to the function, since it
> is converted to vector<double> when passed as an argument.
> I presume this will create a temporary, won't it?

Yep. This is Michael's design decision.

> So I end up wondering whether it is a good idea to use
> boost::multi_arry as a container and boost:numeric::matrix for
> expression evaluation?

You want to use boost::multi_array to get COW?

> Will it be easy to interface back and forth?
> Or is this a completely odd idea?

During the past nobody proposed to change the default storage containers of
ublas to support COW. On the contrary there were some voices emphasizing
that using COW it is sometimes (too) unclear, whether a = b is a shallow
copy or a deep copy. If you want to change this behaviour, you'll probably
have to discuss the topic on lists.boost.org or on
groups.yahoo.com/group/ublas-dev.

Regards,

Joerg


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net