[MATRIX-SIG] Python/Fortran interface
Kevin Rodgers
krodgers@tdyryan.com
Mon, 18 Aug 1997 08:36:13 -0700
At 07:39 AM 8/18/97 -0700, motteler@laura.llnl.gov wrote:
>FORTRAN arrays are stored in column-major order whereas
>(contiguous) NumPy arrays are stored in row-major order.
>Thus to communicate a NumPy array to FORTRAN, make it
>contiguous and take its transpose.
>
This may seem a minor nit, but "row-major" and "column-major" seem to imply
two-dimensional arrays only; it would be more correct to say, "Fortran
stores arrays contiguously with the leftmost index varying fastest and the
rightmost index varying slowest; C is just the opposite." This generalizes
to arrays of more than two dimensions, which is one of the real advantages
of NumPy over Matlab or Xmath (yes, I know that Matlab 5 has "true"
multidimensional arrays, and Xmath (of which I am a devoted user) has some
specialized arrays of more than two dimensions). So plllleeeeezzzzzeeeee
let's not restrict ourselves to two-d, linear algebra stuff here!
On the more general subject of extending/embedding/interfacing NumPy with
whatever, does anybody have a reasonably straightforward and concise
explanation of how NumPy arrays are stored (i.e., an annotated structure
definition)? I've looked through the source, plus a fairly substantial
library that has NumPy interfaces (PyOpenGL), and I've been able to piece
it together somewhat, but it still has a bit of the
fumbling-in-the-pea-soup feeling to it. Thanks in advance . . .
----------------------------------------------------------------------
Kevin Rodgers Teledyne Ryan Aeronautical krodgers@tdyryan.com
"This one goes up to eleven." -- Nigel Tufnel
----------------------------------------------------------------------
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________