Use Perl arrays for float* arguments in CBLAS routines
commitb30835ee4ee4d3d4d835cb941b80a12688dfd432
authorVincent Danjean <Vincent.Danjean@ens-lyon.org>
Wed, 22 Apr 2009 14:48:54 +0000 (22 22:48 +0800)
committerJonathan "Duke" Leto <jonathan@leto.net>
Thu, 21 May 2009 09:08:42 +0000 (21 17:08 +0800)
tree1fa2d894ccfc90f1d8f7aff95b6873fccb37c9fd
parent9000c8f19dd75db0b1c192b50d1c1c736312d98b
Use Perl arrays for float* arguments in CBLAS routines

Note: we allocate some memory for the C array
AND for a structure to be able to push back the results
in the perl Array when the parameter is an IN/OUT parameter.

In order to archive this, the struture is placed before
$1 (because $1 is used directly in the C function call
so it must point to the C array)

Tests have been adapted to send arrays instead of single values.

NOTE2: I'm not sure this is the right Perl API. Indeed, if we
follow this path, each CBLAS routine will require some Perl->C
array conversions and back for the result. This can be very
inefficient if we want to make several calls to CBLAS routines
in a row.
  Perhaps, a good Perl interface would be something as:
my $opaque_C_array=CBLAS::Array->new( [ 2, 3, 5, 6.7] );
CBLAS::sdsdot(2.3, $opaque_C_array, 1, $opaque_C_array, 1);
CBLAS::sdsdot(2.3, $opaque_C_array, 1, $opaque_C_array, 1);
...
my $result=$opaque_C_array->get_perl_array();
for $val (@{$result}) { ... }

Ie: C array are encapsulated in opaque perl objects (with
constructors, accessors and destructors) and can be reused
with several CBLAS invocations ?

Signed-off-by: Jonathan "Duke" Leto <jonathan@leto.net>
swig/CBLAS.i
swig/gsl_typemaps.i
t/CBLAS.t