Blitz logo

Blitz Support :

From: Julian Cummings (cummings_at_[hidden])
Date: 2003-12-11 15:46:02


Hello Andrius,

Andrius Kurtinaitis wrote:

>
>> blitz::Array<double,1> Aeven = A(even);
>> blitz::Array<double,1> Aodd = A(odd);
>>
>> Aeven = central12(Aeven);
>> Aodd = central12(Aodd);
>
>
> I did not know that you can directly use difference operators on the
> arrays (not only in stencil declarations). And in fact - i tried to
> compile this example and i failed. Or was this just a pseudocode?

I didn't actually test the code, just wrote it down. In any case, you
cannot in fact directly use a stencil operator on an Array. However,
the header file <blitz/array/stencil-et.h> includes declarations of many
of the standard stencil operators as functions that can be applied to an
Array. So if you #include <blitz/array/stencil-et.h>, the code will
compile. (Actually, there is one other minor problem. The difference
operators such as central12 are declared with the second argument for
the dimension along which to difference being optional. But the
analogous declaration for the central12 stencil function in stencil-et.h
does not have a default value for this second argument. So you would
have to say central12(Aeven,0), for instance. I think this is an
oversight, and I will fix this in the blitz repository in the near future.)

>
> Furthermore, I think that Aeven = central12(Aeven) is not the same as
> A(even) = 0.5 * (A(even+1) - A(even-1)), because Aeven already has
> only even points and so has no chance to access odd points which are
> in A(even+1) and A(even-1). Probably you even did not mean that :-)

Yep, you're right! I tried this out and it doesn't work as expected for
the reason you noted.
This is another one of those things that I think worked in Pooma (using
a "view engine" inside an Array to view a subarray while maintaining
access to the whole original Array) but doesn't work in blitz. Sorry
about that! But the first method I outlined should do what you asked
for originally.

Regards, Julian C.

-- 
Dr. Julian C. Cummings                       E-mail: cummings_at_[hidden]
California Institute of Technology           Phone:  626-395-2543
1200 E. California Blvd., Mail Code 158-79   Fax:    626-584-5917
Pasadena, CA 91125