| 1 |
#include "EXTERN.h" |
| 2 |
#include "perl.h" |
| 3 |
#include "pdl.h" |
| 4 |
#include "pdlcore.h" |
| 5 |
|
| 6 |
#define PDL PDL_LinearAlgebra_Trans |
| 7 |
extern Core *PDL; |
| 8 |
|
| 9 |
typedef PDL_Long integer; |
| 10 |
|
| 11 |
|
| 12 |
int xerbla_(char *sub, int *info) { return 0; } |
| 13 |
int xerbla_64_(char *sub, int *info) { return 0; } |
| 14 |
|
| 15 |
void dfunc_wrapper(void *p, integer n, SV* dfunc) |
| 16 |
{ |
| 17 |
dSP ; |
| 18 |
PDL_Indx odims[] = {0}; |
| 19 |
PDL_Indx nat_dims[] = {n}; |
| 20 |
PDL_Indx *dims = nat_dims; |
| 21 |
PDL_Indx ndims = 1; |
| 22 |
int type_add = PDL_CF - PDL_F; |
| 23 |
pdl *pdl = PDL->pdlnew(); |
| 24 |
PDL->setdims(pdl, dims, ndims); |
| 25 |
pdl->datatype = PDL_D + type_add; |
| 26 |
pdl->data = p; |
| 27 |
pdl->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED; |
| 28 |
HV *bless_stash = gv_stashpv("PDL", 0); |
| 29 |
ENTER ; SAVETMPS ; PUSHMARK(sp) ; |
| 30 |
SV *pdl1 = sv_newmortal(); |
| 31 |
PDL->SetSV_PDL(pdl1, pdl); |
| 32 |
pdl1 = sv_bless(pdl1, bless_stash); |
| 33 |
XPUSHs(pdl1); |
| 34 |
PUTBACK ; |
| 35 |
int count = perl_call_sv(dfunc, G_SCALAR); |
| 36 |
SPAGAIN; |
| 37 |
PDL->setdims(pdl, odims, 1); |
| 38 |
pdl->state &= ~(PDL_ALLOCATED |PDL_DONTTOUCHDATA); |
| 39 |
pdl->data=NULL; |
| 40 |
if (count !=1) |
| 41 |
croak("Error calling perl function\n"); |
| 42 |
PUTBACK ; FREETMPS ; LEAVE ; |
| 43 |
} |