POD for Math::GSL::Test
[Math-GSL.git] / gsl_typemaps.i
blob79db1ed92e21584569f2f570ab896783fbd57830
1 %typemap(in) double const [] {
2 AV *tempav;
3 I32 len;
4 int i;
5 SV **tv;
6 if (!SvROK($input))
7 croak("Math::GSL : $$1_name is not a reference!");
8 if (SvTYPE(SvRV($input)) != SVt_PVAV)
9 croak("Math::GSL : $$1_name is not an array ref!");
11 tempav = (AV*)SvRV($input);
12 len = av_len(tempav);
13 $1 = (double *) malloc((len+1)*sizeof(double));
14 for (i = 0; i <= len; i++) {
15 tv = av_fetch(tempav, i, 0);
16 $1[i] = (double) SvNV(*tv);
20 %apply double const [] {
21 size_t *p ,double *data, double *dest, double *f_in, double *f_out,
22 double data[], const double * src, double x[], double a[], double b[] ,
23 const double * x, const double * y, const double * w , const double x_array[],
24 const double xrange[], const double yrange[], double * base,
25 const double * base, const double xrange[], const double yrange[] ,
26 const double * array , const double data2[], const double w[] ,
27 float const *A, float const *B, float const *C, float *C, double *v,
28 gsl_complex_packed_array data
31 %apply int *OUTPUT { size_t *imin, size_t *imax, size_t *neval };
32 %apply double * OUTPUT {
33 double * min_out, double * max_out,
34 double *abserr, double *result
37 static HV * Callbacks = (HV*)NULL;
38 /* this function returns the value
39 of evaluating the function pointer
40 stored in func with argument x
42 double callthis(double x , int func, void *params){
43 SV ** sv;
44 double y;
45 dSP;
47 //fprintf(stderr, "LOOKUP CALLBACK\n");
48 sv = hv_fetch(Callbacks, (char*)func, sizeof(func), FALSE );
49 if (sv == (SV**)NULL) {
50 fprintf(stderr, "Math::GSL(callthis): %d not in Callbacks!\n", func);
51 return;
54 PUSHMARK(SP);
55 XPUSHs(sv_2mortal(newSVnv((double)x)));
56 PUTBACK;
57 call_sv(*sv, G_SCALAR);
58 y = POPn;
59 return y;
62 %typemap(in) gsl_monte_function * {
63 croak("FOOBAR!");
64 gsl_monte_function MF;
65 int count;
66 SV ** callback;
67 double x;
68 if (!SvROK($input)) {
69 croak("Math::GSL : $$1_name is not a reference value!");
71 if (Callbacks == (HV*)NULL)
72 Callbacks = newHV();
73 fprintf(stderr,"STORE gsl_monte_function CALLBACK: %d\n", (int)$input);
74 hv_store( Callbacks, (char*)&$input, sizeof($input), newSVsv($input), 0 );
76 MF.params = &$input;
77 MF.function = &callthis;
78 $1 = &MF;
80 %typemap(in) gsl_function * {
81 gsl_function F;
82 int count;
83 SV ** callback;
84 double x;
86 if (!SvROK($input)) {
87 croak("Math::GSL : $$1_name is not a reference value!");
89 if (Callbacks == (HV*)NULL)
90 Callbacks = newHV();
91 //fprintf(stderr,"STORE CALLBACK: %d\n", (int)$input);
92 hv_store( Callbacks, (char*)&$input, sizeof($input), newSVsv($input), 0 );
94 F.params = &$input;
95 F.function = &callthis;
96 $1 = &F;
99 %typemap(in) gsl_function_fdf * {
100 fprintf(stderr, 'FDF_FUNC');