$include_dir="/home/hyper-archives/ublas/include"; include("$include_dir/msg-header.inc") ?>
From: Michael Stevens (mail_at_[hidden])
Date: 2005-06-17 03:43:33
Guys,
On Thursday 16 June 2005 21:00, Gunter Winkler wrote:
> Am Donnerstag, 16. Juni 2005 13:10 schrieb Toon Knapen:
> > IMHO the way to have both is as I have described below: we know that
> > in uBLAS different containers are never aliased. Aliasing only occurs
> > when one is working with views.
> > So from the moment only containers 
> > are used in an expression, the expression engine can safely assume
> > there is no aliasing.
??? I'm still not sure we are on the same wavelength with regard to aliases. 
Hopefully the following is correct.
Aliases occur both with views AND when a container (or any of it's elements) 
appears on both the LHS and RHS of an expression.
The ONLY aliases that are a problem for expression evaluation are the LHS/RHS 
aliases. Because an element can change during the evaluation.
There is a special case when the RHS is only a container and not a general 
expression. In the case the LHS and RHS can still be aliases, BUT since we no 
both what the expression is (=, += etc) and the element ordering of the 
container we can choose an algorithm that is insensitive to any potential 
alias.
> Do you have an idea how to implement this? I would think of adding a new
> typedef to each container/proxy class:
>
>  struct data_container { };
>  struct data_proxy { };
>
>  typedef data_container data_category;
> or
>  typedef data_proxy     data_category;
>
> and add a new typedef to all matrix/vector expressions
>
>  typedef compute_data_category<
>    E1::data_category,
>    E2::data_category>::result_type  data_category;
>
> and use partial specialization to define compute_data_category<>. But
> this is a lot of work. Is there a better way?
I think this would be the way to propergate the container only property in an 
expression. It would still be very very hard to make use of. I suspect we 
could match a few simple expressions such as
        A = B+C
and choose a an LHS alias invariant algorithm when only containers are used.
Even for 
        A = prod (B,C)
it doesn't help. Here there is no useful LHS alias invariant algorithm which 
avoids temporaries.
I think Ian's suggestion of changing uBLAS default evaluation to be alias 
unsafe and checking on DEBUG builds is the way to go!
Michael
-- 
___________________________________
Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering
    http://bayesclasses.sf.net
___________________________________