Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/vdanjean/math--gsl into dan…
Browse files Browse the repository at this point in the history
…jean

Conflicts:
	Build.PL
	swig/gsl_typemaps.i
  • Loading branch information
leto committed May 8, 2009
2 parents dc0610c + 1870269 commit 9000c8f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion swig/SF.i
Expand Up @@ -33,7 +33,7 @@
#include "gsl/gsl_sf_lambert.h"
#include "gsl/gsl_sf_legendre.h"
#include "gsl/gsl_sf_log.h"
#ifdef GSL_VERSION && GSL_VERSION == "1.11"
#if defined(GSL_VERSION_minor) && GSL_VERSION_MINOR == 11
#include "gsl/gsl_sf_mathieu.h"
#endif
#include "gsl/gsl_sf_pow_int.h"
Expand Down
61 changes: 40 additions & 21 deletions swig/gsl_typemaps.i
Expand Up @@ -4,14 +4,16 @@
%include "gsl/gsl_inline.h"
#endif

typedef int size_t;

%{
#include "gsl/gsl_nan.h"
#include "gsl/gsl_math.h"
#include "gsl/gsl_monte.h"
%}

/*****************************
* handle 'double const []' as an input array of doubles
* We allocate the C array at the begining and free it at the end
*/
%typemap(in) double const [] {
AV *tempav;
I32 len;
Expand All @@ -35,6 +37,21 @@ typedef int size_t;
if ($1) free($1);
}

%apply double const [] {
double *data, double *dest, double *f_in, double *f_out,
double data[], const double * src, double x[], double a[], double b[],
const double * x, const double * y, const double * w , const double x_array[],
const double xrange[], const double yrange[], double * base,
const double * base, const double xrange[], const double yrange[] ,
const double * array , const double data2[], const double w[] ,
double *v,
gsl_complex_packed_array data
};

/*****************************
* handle 'float const []' as an input array of floats
* We allocate the C array at the begining and free it at the end
*/
%typemap(in) float const [] {
AV *tempav;
I32 len;
Expand All @@ -58,6 +75,14 @@ typedef int size_t;
if ($1) free($1);
}

%apply float const [] {
float const *A, float const *B, float const *C, float *C
};

/*****************************
* handle 'size_t const []' as an input array of size_t
* We allocate the C array at the begining and free it at the end
*/
%typemap(in) size_t const [] {
AV *tempav;
I32 len;
Expand All @@ -81,32 +106,26 @@ typedef int size_t;
if ($1) free($1);
}

%apply double const [] {
double *data, double *dest, double *f_in, double *f_out,
double data[], const double * src, double x[], double a[], double b[],
const double * x, const double * y, const double * w , const double x_array[],
const double xrange[], const double yrange[], double * base,
const double * base, const double xrange[], const double yrange[] ,
const double * array , const double data2[], const double w[] ,
double *v,
gsl_complex_packed_array data
};

%apply float const [] {
float const *A, float const *B, float const *C, float *C
};

%apply size_t const [] {
size_t *p
}

/*****************************
* handle some parameters as input or output
*/
%apply int *OUTPUT { size_t *imin, size_t *imax, size_t *neval };
%apply double * OUTPUT {
double * min_out, double * max_out,
double *abserr, double *result
};
%{

/*****************************
* Callback managment
*/
%{
/* structure to hold required information while the gsl function call
for each callback
*/
struct gsl_function_perl {
gsl_function C_gsl_function;
SV * function;
Expand All @@ -120,9 +139,8 @@ typedef int size_t;
};


/* this function returns the value
of evaluating the function pointer
stored in func with argument x
/* These functions (C callbacks) calls the perl callbacks.
Info for perl callback can be found using the 'void*params' parameter
*/
double call_gsl_function(double x , void *params){
struct gsl_function_perl *F=(struct gsl_function_perl*)params;
Expand Down Expand Up @@ -310,6 +328,7 @@ typedef int size_t;
SvREFCNT_dec(p->params);
};

/* TODO: same thing should be done for these kinds of callbacks */
%typemap(in) gsl_function_fdf * {
fprintf(stderr, 'FDF_FUNC');
return GSL_NAN;
Expand Down

0 comments on commit 9000c8f

Please sign in to comment.