Hi Liz,
So you're saying to do something like:
my $str = join(@arr, / /); # to create a string of each element separated
# by spaces
&cFunction(\$str); # then pass the string reference to the c function
__DATA__
__C__
void cFunction(SV* str) {
// Convert the string ref into a C array
}
That sounds like a great idea if you know a
more efficient way of creating an array from this string
reference than Neil showed with his for loop.
I'm very new to C, can you show me how to do this?
In order to interface with Matlab's Math and Graphics libraries, I
have to create a mxArray using the following prototype:
mxArray *mlfDoubleMatrix(int m, int n, const double *pr,
const double *pi);
Where:
int m = Number of rows.
int n = Number of columns.
const double *pr = Pointer to values to initialize the mxArray array
vector of real values.
const double *pi = Pointer to values to initialize the mxArray array
vector of imaginary values. Specify NULL if there
is no imaginary part.
This is the only matlab function that I have found which doesn't
take a pre-existing mxArray.
Thanks...Brady
-----Original Message-----
From: Elizabeth Mattijsen [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 2:23 PM
To: bbcannon; 'Neil Watkiss'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Instantiating arrays with Inline
At 01:56 PM 6/10/02 -0600, bbcannon wrote:
>I only have one gripe(sorry!). The arrays that I will be working with
>could potentially have thousands of entries. Having to iterate
>through each element of each array seems like an extremely large waste
>of time.
>I obviously don't understand what it takes to convert a perl
>reference to a C reference (if it can be done at all), but is
>it not possible? Or is that just a "Perfect World" scenario?
Couldn't you -pack- your array into a scalar and pass a reference to that?
Liz