On Fri, 3 Aug 2001, Evan Zane Macosko wrote:

> I've got a large two dimensional matrix of float values--about 6000 rows
> and 1000 columns (the size will vary, but will always be two
> dimensional)--and I need to pass it from Perl to C to do some hefty
> mathematical computations.  I can't seem to figure out how to pass it
> in--I tried passing in the reference to the array, and then assigning a C
> variable to that address, but Inline doesn't like that.  Any suggestions?
> Also, I want to output a matrix (1000x1000) if possible.

A Perl array isn't very much like a C array - it's not just a chunk of
memory.  To extract a C array from a Perl array you'll need to learn how
to use the av_* functions in the Perl API.  Check out "perldoc perlapi"
and look at the array functions available.  You'll also need to learn
about accessing references from C if you want to able to pass a
two-dimensional (array of arrays) structure from Perl to C.

Sounds hard, right?  It is but I can assure you it is possible.  Give it
a try and if you get stuck post us some code that we can comment on.

-sam


Reply via email to