freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freepooma-devel] A question about code for computation of Tensor de


From: ali rostai
Subject: Re: [Freepooma-devel] A question about code for computation of Tensor determinant
Date: Wed, 27 Jan 2010 22:32:16 +0330

Hi Richard,
Thanks for your useful notes.

1. As I know _expression_ templates support is needed
when we want to loop over elements of an array and don't
want to use a "for" construct explicitly, So If I stick to using
usual for construct, is it safe to use t.getIJ<0,0>() instead of
t(0,0)?

2. Even we keep the t(0,0), the operator() of the class is
an inline function and the optimizer of gcc probably is able to
make the result equivalent to t.getIJ<0,0>()?

3. It has been always a question for me that how can I find
the compiler has successfully Inlined a function that I have
marked it as inline?

Regards,
Ali


On Wed, Jan 27, 2010 at 1:08 AM, Richard Guenther <address@hidden> wrote:
ali rostai wrote:
> Hi,
>
> In file "Tiny/TensorOperators.h" the following code has
> been used for computation of Tensor determinant.
> -------------------------------------------------
> // Partial specializations for D={1,2,3}
> template<class T, class E>
> inline T
> det(const Tensor<3,T,E>& t)
> {
>   T result;
>   result =
>     t(0,0)*(t(1,1)*t(2,2) - t(1,2)*t(2,1)) +
>     t(0,1)*(t(1,2)*t(2,0) - t(1,0)*t(2,2)) +
>     t(0,2)*(t(1,0)*t(2,1) - t(1,1)*t(2,0));
>   return result;
> }
> ---------------------------------------------------
> as I know the t(0,0) is a runtime call,
> why  the member function template "getIJ()" has not been
> used? I mean a code like this
> t.getIJ<0,0>()

It is because TensorOperators.h (and other Tiny classes) do not fully
use _expression_ templates.  There is a patch on the patch-tracker
to fix this up for vectors (if I remember correctly) - the interaction
with the Array _expression_ templates is complicated though.

It's an area that needs to be reworked a lot.

Richard.

> Regards
> Ali Roustaei
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Freepooma-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/freepooma-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]