![]() |
Blitz Support : |
From: Peter Kümmel (syntheticpp_at_[hidden])
Date: 2005-06-17 05:12:54
Julian Cummings wrote:
> There should be only one loop, and in fact, it should be slightly better
> than what you wrote above because you do not need to store the temporary
> result of c1.f(A(i,j)) back into A(i,j) first.
Great!!
> This can be hard to verify
> unless you have a compiler that preserves intermediate C code (e.g., KCC) or
> prints out the templates it instantiates (e.g., SGI CC).
Supports gcc this too?
> By the way, you do
> not need the index placeholders i and j on the right-hand side of your
> expression unless there is an offset or restricted range with respect to the
> original Array domain. So you can just say
>
> A = c2.f(c1.f(A));
Thanks, using blitz more intensively in the last days I've also
realized it.
But I've also realized that I need calculations on the indices,
e.g. A = A exp(sqrt(i*i+j*j)). But I can't find a way to move
the calculations from the call to the function, A = f(A,i,j)),
seems that this is impossible.
Is the usage of the indices the best way to implement such
calculations? I've written some benchmark code to compare with
C-code and C is in all cases the fasted one.
>>forall()
>>[
>> A=A+B,
>> B=A*A
>>]
>>
>
>
> Yes. You can loop through the Array using either nested loops over the
> indices or using a single loop with an Array iterator.
Do you mean with "nested loops" the C way?
It is also possible with Array iterators?
I thought this is not possible within blitz, I've nothing found about it.
Could you please give me a hint or a short example.
Regards,
Peter
P.S.
I've no problems compiling blitz (cvs version) with mingw32.