Permalink
Browse files

Build.pl now defines MATH_GSLX_ODEIV2_USE_PDL when PDL is detected. c…

…ontainer.c now has dupe code in place so that either way, it passes tests
  • Loading branch information...
1 parent a86298d commit 06157ab3f68720fe20c4e4f3fd378ca42a79a0ed @jberger committed Sep 7, 2011
Showing with 22 additions and 1 deletion.
  1. +3 −1 Build.PL
  2. +19 −0 src/container.c
View
@@ -25,6 +25,8 @@ if ($gsl_version < $min_gsl_version) {
my $gsl_libs = qx! gsl-config --libs !;
my $have_pdl = Module::Build->check_installed_status('PDL')->{ok};
+my $extra_compiler_flags .=
+ '-Iinc' . ( $have_pdl ? ' -DMATH_GSLX_ODEIV2_USE_PDL' : '' );
my $build = Module::Build->new(
module_name => 'Math::GSLx::ODEIV2',
@@ -44,7 +46,7 @@ my $build = Module::Build->new(
},
xs_files => {'ODEIV2.xs' => 'lib/Math/GSLx/ODEIV2.xs'},
c_source => 'src',
- extra_compiler_flags => '-Iinc',
+ extra_compiler_flags => $extra_compiler_flags,
extra_linker_flags => $gsl_libs,
#meta_merge => {
# resources => {
View
@@ -10,6 +10,24 @@
#ifdef MATH_GSLX_ODEIV2_USE_PDL
+SV * make_container (int num, int steps) {
+ return newRV_noinc((SV*)newAV());
+}
+
+int store_data (SV* holder, int num, const double t, const double y[]) {
+ int i;
+ AV* data = newAV();
+
+ av_push(data, newSVnv(t));
+ for (i = 0; i < num; i++) {
+ av_push(data, newSVnv(y[i]));
+ }
+
+ av_push((AV *)SvRV(holder), newRV_noinc((SV *)data));
+
+ return 0;
+}
+
#else /* MATH_GSLX_ODEIV2_USE_PDL */
SV * make_container (int num, int steps) {
@@ -32,3 +50,4 @@ int store_data (SV* holder, int num, const double t, const double y[]) {
#endif /* MATH_GSLX_ODEIV2_USE_PDL */
/* -------------------------------------------- */
+

0 comments on commit 06157ab

Please sign in to comment.