![]() |
Blitz Support : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2005-02-16 18:59:43
Hi John,
You can't control the storage order with the resize() method, but there are
other simple ways of selecting Fortran array storage. One is to do it in
the constructor. So
class Foo {
private:
Array<float,3> a;
public:
Foo() : a(FortranArray<3>()) {}
};
The other way is to invoke the setStorage() method to change the default
array storage order post-construction. So this would look like
class Foo {
private:
Array<float,3> a;
public:
Foo() {a.setStorage(FortranArray<3>());}
};
By the way, FortranArray<> is a pre-defined class derived from
GeneralArrayStorage<> that has the Fortran-style array storage order you are
looking for. Using FortranArray<> also sets the base index for each array
dimension to 1 instead of the C-style base index of 0. If you don't want
this particular feature, use ColumnMajorArray<> instead. See the file
<blitz/array/storage.h> for full details.
Regards, Julian C.
Dr. Julian C. Cummings Office: PB-111
Caltech/CACR, MC 158-79 Phone: 626-395-2543
1200 E. California Blvd. Fax: 626-584-5917
Pasadena, CA 91125
> -----Original Message-----
> From: blitz-support-bounces_at_[hidden]
> [mailto:blitz-support-bounces_at_[hidden]] On Behalf Of John Bray
> Sent: Wednesday, February 16, 2005 1:00 PM
> To: Support list for Blitz++
> Subject: [Blitz-support] Controlling storage order with resize
>
>
> Thanks for all the advice on defining null arrays and then
> resizing them. That worked fine, and I've now replicated my
> MPP environment with bounds swapping routines across processors.
>
> I would like to have Fortran-like array ordering though, but
> it seems that resize cannot take an ordering argument, so
>
> GeneralArrayStorage<3> storage;
>
> storage.ordering() = firstDim, secondDim, thirdDim;
>
> a.resize(3,4,5,storage);
>
> doesn't work, and I can't define the storage order of the array in
>
> Array<float,3> a;
>
> The reason I want to do this is I have a weather forecasting
> domain, where x,y,z correspond to longitude,latitude,
> vertical level, and most of the calculations are in the
> lat-long plane, so I'd like the longitude values contiguous,
> not the vertical levels.
>
> John
>
> _______________________________________________
> Blitz-support mailing list
> Blitz-support_at_[hidden]
> http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support
>