Hi Eric:
Eric Wilhelm wrote:
> # from Joe Landman
> # on Monday 21 August 2006 10:36 am:
>
>> $x = solve_for (@f,@k);
>
> Firstly, that is going to pass a flat list:
>
> 4.0, 3.0, 2.0 0.1, 0.2, 0.0, 0.0, 0.2, 0.3, 1.0, 1.0, 1.0
>
> (Aside: unless you set a prototype of two array refs, but don't do
> that.)
Was planning on fixing that later on, did it now to make life easier.
>
> But there is another problem: the error you are seeing is because
> Inline doesn't grok this function signature.
>
>> double *solve_for(double* f, double* k) {
>
> What you probably want is to pass [EMAIL PROTECTED], and [EMAIL PROTECTED]
> But, that means you'll
> need to change the signature to get a pair of SV*'s and you'll then
> need to unpack them.
Yup. Just did that.
>
> You also cannot return a pointer.
>
> Here's a basic example of using array references. There's more in the
> Inline::C-Cookbook.
>
> #!/usr/bin/perl
> use Inline C;
>
> @inputArray = ( "134.3", "2.224", "3.343");
> array_pass([EMAIL PROTECTED]);
>
> __END__
> __C__
>
> int array_pass (SV* array_ref) {
> AV *av_ptr;
> int n;
>
> if ( !SvROK(array_ref) || SvTYPE(SvRV(array_ref)) != SVt_PVAV )
> croak("Argument must be array reference");
>
> av_ptr = (AV*) SvRV(array_ref);
> printf("Number of elements: %d\n", 1+av_len(av_ptr));
> }
>
>
> --Eric
The major issue appears to be that I need to return an int, or an SV*.
It is working now with both of these. Reasonably sanely at that.
I would like to return an array reference though. Will need to look a
little deeper.
Thanks!
Joe
--
Joseph Landman, Ph.D
Founder and CEO
Scalable Informatics LLC,
email: [EMAIL PROTECTED]
web : http://www.scalableinformatics.com
phone: +1 734 786 8423
fax : +1 734 786 8452 or +1 866 888 3112
cell : +1 734 612 4615