Hi,
Consider the following expression:
x = v / norm_2( v ) (*)
where v is a VectorExpression and x a DensevectorCollection e.g.
In the current glas backend implementation, (*) corresponds to something
like:
for ( size_type i=0; i<size(x); ++i ) {
x( i ) = v( i ) / norm_2( v ) ;
}
This implies that norm_2(v) is reevaluated for each entry in x. The
reason is that norm_2 does not return a value, but an expression that is
only evaluated when it is used in a backend. It is pretty easy to change
the evaluation system so that the result of norm_2 is first stored into
a temporary variable. The loop would then look like:
value_type< norm_2_expression ... >::type temp( norm_2(v) ) ;
for ( size_type i=0; i<size(x); ++i ) {
x( i ) = v( i ) / temp ;
}
Personnally, I prefer the second option, since I see no advantage of the
first, but I may be wrong. Comments please.
Karl
[Karl.Meerbergen.vcf]
begin:vcard
fn:Karl Meerbergen
n:Meerbergen;Karl
org:K.U. Leuven;Department of Computer Science
adr:Room 02.014;;Celestijnenlaan 200A;Heverlee (Leuven);;B-3001;Belgium
email;internet:Karl.Meerbergen@...
tel;work:+32 16 32 79 59
tel;fax:+32 16 32 79 96
tel;cell:+32 474 26 66 59
note:http://www.kuleuven.be/cwis/email_disclaimer.htm
url:http://www.cs.kuleuven.be/~karlm
version:2.1
end:vcard
_______________________________________________
glas mailing list
glas@...
http://lists.boost.org/mailman/listinfo.cgi/glas