Boost logo

Boost Users :

From: jhr.walter_at_[hidden]
Date: 2003-02-26 05:25:51


Hi Roland,

you wrote:

> I think I found out now, what I was missing. I am working with
> expressions now, and so I have to refer to the arguments as
>
> arg().size()

Correct.

> But this still leaves me with even more questions:
>
> Why would I prefer:
>
> template<class E>
> void foo(const vector_expression<E>& arg)
> {
> arg().size();
> }
>
> over
>
> template<class V>
> void foo(const V& arg)
> {
> arg.size();
> }
>
> ?

You could overload foo() for vector_expression<> and matrix_expression<>
then. Sorry for giving the second hint first ;-)

> When rethinking my problem it seems to me as if I would need to
> decide whether my algorithm should work on expressions or on
> containers.

Hm. In a certain way, yes.

> But where is my container? vector is a container and an
> expression. This confuses me somewhat.
> Ok, my original question was of how to
> foo(m.column(0)) or foo(m.row(1))
> and this automatically made an expression from my rows/cols.

Yes.

> So creating my subroutine in a way is implementing an algorithm. But
> as I feel this is different from what uBLAS does in functional.hpp,
> isn't it?

Yes, functional.hpp is pretty much an implementation detail.

> What I originally was looking for was a container concept similar to
> std::vector that extends to matrix.

Hm. Vector and matrix are different concepts IMO.

> I am aware that uBLAS is much
> more powerful, but leaves me with the question of how to write my own
> subroutines.

You've lost me. Above you've pointed out both ways to declare generic
functions foo(). Are you talking about the implementation of foo() now?

> Could you Joerg or anyone else give me some ideas of how
> to do this (conceptually simple) task or point me to some example
> code?

I believe, I've answered this one already:

http://groups.yahoo.com/group/Boost-Users/message/3028

(see the bottom of the posting). Anything wrong with that?

Best 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