Blitz logo

Blitz Support :

From: Peter Kümmel (syntheticpp_at_[hidden])
Date: 2005-06-09 09:16:13


Hello,

I've got a question to the code "generated" by blitz:
Does following code

struct C1{
double f(double x)const {return x*x;}
BZ_DECLARE_MEMBER_FUNCTION(C1,f)
};
struct C2{
double f(double x)const {return sqrt(x);}
BZ_DECLARE_MEMBER_FUNCTION(C2,f)
};
...
int N=314;
Array<double, 2> A(N,N);

firstIndex i;
secondIndex j;
C1 c2;
C2 c2;
A = c2.f( c1.f( A(i,j) ) );

also result in only ONE loop?, e.g.:

for(i...
     for(j...
         A[i][j]= c1.f( (A[i][j]) );
         A[i][j]= c2.f( (A[i][j]) );

As I understand it this is the case, or I'm wrong?

Is there a difference in the generated code if I use
the "inline" specifier?

And is there a other syntax?
Something like

A = A(i,j) -> c1.f -> c2.f;
(A goes first through c1.f then through c2.f)
or
A = c2.f -> c1.f -> A(i,j);
(First c1.f is applied on A then c2.f)

Would it be hard to implement such a overloading?

And a other question: Is there a way to do looping
manually (similar to FTensor), e.g:

Array<int,1> A(N);
Array<int,1> B(N);

forall()
[
     A=A+B,
     B=A*A
]

Maybe such a syntax is possible or exits
already in the (other?) library.

Best regards,
Peter