Boost logo

Boost Users :

From: jhr.walter_at_[hidden]
Date: 2003-02-26 15:03:35


Hi Roland,

you wrote:

> |> 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 ;-)
>
> Do you mean for the sake of getting better error diagnostics when I
> supply a completely unrelated type to foo? As i.e. foo(3.15)? Or did
> I misunderstand you?

Yes. I meant that you can reuse the name foo() in vector and matrix contexts
then, i.e.

template<class E>
void foo(const vector_expression<E>& arg);
template<class E>
void foo(const matrix_expression<E>& arg);

[snip]

> | Are you talking about the implementation of foo() now?
>
> Yes it seems so. Using either declaration will result in a separate
> overloaded function. (Is this referred to as code bloating?) But all
> I need is access to operator[] (and similar), operator(n,m), size1/2
> () and the value_type basically.

OK, I think I understand now what you're aiming at: you want ublas to give
you the characteristics of (ordinary ;-) runtime polymorphism. But would you
be willing to pay the performance penalty for using an virtual operator()
then, for example?

> This is why I tried first to
> formulate my algorithm in terms of iterators. Somehow I am trying to
> discard the expression type info I think, since I am only interested
> in the common member functions, that let me see it as a container.
> Could I write a kind of vector and matrix proxy that is able to
> acomplish this? Would you recommend or not to take this route?

There certainly are many cases, where runtime polymorphism is a good
solution. But this doesn't hold for ublas' operator() AFAIK.

> BTW.: I am not sure exactly what comprises the user interface to the
> uBLAS. Is this what is in the documentation?

Generally yes.

> Then what is
> vector_reference for?

vector_reference<> is mainly needed to describe the signatures of operators
returning expression templates.

> Why is vector_constant_reference not available
> and what is its purpose?

We had a lot of discussions regarding the question, if
vector_reference<const E> ~= vector_const_reference<E>. This approximation
is good enough for all compilers except Borland.

For more details please see the message archive of

groups.yahoo.com/group/ublas-dev

> Could this class be of help in my case?

Yes, if you intend to extend the expression template machinery.

[snip]

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