in reply to Perl & C
For example, if you knew you were passing in an array of 15 doubles and were getting back an array of 15 doubles (with the obvious extension if the sizes were not the same), you could do:
$inval = pack("d*",1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) $results = pack("d*",(0)x15) $summary_result = c_function($inval,$results,15) @real_results = unpack("d*",$results) use Inline C => <<'END_OF_C_CODE'; double c_function(char * the_data, char * results,int nelems) { double *real_data = (double *) the_data; double *real_results = (double *) results; double summary_result; /* do your fast calculation here, storing elements in *real_resul +ts */ return summary_result; } END_OF_C_CODE
|
|---|