![]() |
Blitz Support : |
From: Sean Dettrick (sean_at_[hidden])
Date: 2003-10-01 16:18:17
Dear Todd,
I've been reading the doco on your blitz++ library and am very impressed.
If you have the time, I'd like to ask some questions about it.
I'm thinking of using blitz++ in my code (a particle-in-cell plasma
physics simulation). I use two legacy applications: the fortran77
FISHPACK elliptic differential equation solver, and the MPI parallel
library. In both cases I need to pass a contiguous chunk of memory to
the legacy apps. Until now I have been implementing 2D and 3D arrays
using manually managed 1 dimensional STL vector<> objects, e.g.
#include <vector>
int Nx=10;
int Ny=20;
vector<float> V(Nx*Ny); // 2D represented by 1D vector<>
Now if I want to use blitz++ instead,
Array<float,2> A(Nx,Ny);
then I have three questions:
1. Is the underlying data always contiguous in memory (assuming stride=1)?
2. If so, is there a way of referencing the underlying 2D contiguous
data as I would with a pointer to the 1D STL vector<>?
e.g.
legacy_C_app( &V[0], Nx*Ny ); // pass the whole "2D" array
or
legacy_F77_app( &V[0], Nx*Ny ); // pass the whole "2D" array
(I find the above method especially convenient for calling F77 since I
can sidestep the different index-ordering of C and F77.)
3. If I take a slice of a 2D Array in either dimension using the
assignment operator, will the resulting 1D Arrays be contiguous in
memory? (I know this won't work with the copy constructor)
i.e., given
Array<int,1> Xslice( Nx ), Yslice( Ny );
Xslice = A( Range::all(), 3 );
Yslice = A( 3, Range::all() );
can I now pass Xslice and Yslice to legacy apps?
e.g.
legacy_C_app( &Xslice[0], Nx ); // pass a contiguous slice along the
X axis
legacy_C_app( &Yslice[0], Ny ); // pass a contiguous slice along the
Y axis
I will certainly understand if you don't have the time to address these
questions.
Thanks very much,
Sean Dettrick