Skip to content

Instantly share code, notes, and snippets.

@leto
Created November 22, 2008 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leto/ce970fb0702d30768bb6 to your computer and use it in GitHub Desktop.
Save leto/ce970fb0702d30768bb6 to your computer and use it in GitHub Desktop.
From bc237fda172824e36a6de376e56e9865f6d857f4 Mon Sep 17 00:00:00 2001
From: Duke Leto <jonathan@leto.net>
Date: Tue, 18 Nov 2008 08:59:44 -0800
Subject: [PATCH] Valiant refactor that still doesn't fix the problem
---
swig/FFT.i | 14 ++++++++++++--
t/FFT.t | 23 ++++++++++++-----------
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/swig/FFT.i b/swig/FFT.i
index 0cd8bd5..3c5f7f2 100644
--- a/swig/FFT.i
+++ b/swig/FFT.i
@@ -1,6 +1,11 @@
%module "Math::GSL::FFT"
%include "typemaps.i"
%include "gsl_typemaps.i"
+%include "gsl/gsl_math.h"
+%include "gsl/gsl_sys.h"
+%include "gsl/gsl_pow_int.h"
+%include "gsl/gsl_nan.h"
+%include "gsl/gsl_machine.h"
%include "gsl/gsl_complex.h"
%include "gsl/gsl_fft.h"
%include "gsl/gsl_fft_complex.h"
@@ -8,6 +13,7 @@
%include "gsl/gsl_fft_real.h"
%include "../pod/FFT.pod"
+
%typemap(argout) (double data[], const size_t stride, const size_t n) {
int i=0;
AV* tempav = newAV();
@@ -36,10 +42,14 @@
}
%{
+ #include "gsl/gsl_complex.h"
+ #include "gsl/gsl_sys.h"
+ #include "gsl/gsl_pow_int.h"
+ #include "gsl/gsl_nan.h"
+ #include "gsl/gsl_machine.h"
+ #include "gsl/gsl_math.h"
#include "gsl/gsl_fft.h"
#include "gsl/gsl_fft_complex.h"
#include "gsl/gsl_fft_halfcomplex.h"
#include "gsl/gsl_fft_real.h"
- #include "gsl/gsl_complex.h"
%}
-
diff --git a/t/FFT.t b/t/FFT.t
index a2ce667..2bdb782 100644
--- a/t/FFT.t
+++ b/t/FFT.t
@@ -1,11 +1,11 @@
package Math::GSL::FFT::Test;
-use Math::GSL::Test qw/:all/;
use base q{Test::Class};
-use Test::More;
-use Math::GSL::FFT qw/:all/;
-use Math::GSL qw/:all/;
-use Data::Dumper;
+use Math::GSL::Test qw/:all/;
+use Math::GSL::FFT qw/:all/;
+use Math::GSL qw/:all/;
use Math::GSL::Errno qw/:all/;
+use Data::Dumper;
+use Test::More;
use strict;
BEGIN { gsl_set_error_handler_off() }
@@ -18,17 +18,18 @@ sub teardown : Test(teardown) {
}
sub FFT_REAL_RADIX2_TRANSFORM : Tests
{
- my $data = [ (0) x 5, (1) x 22, (0) x 5 ];
- my ($status, $pass ) = gsl_fft_real_radix2_transform ($data, 1, 32);
- ok_status($status);
- ok_similar( $pass, [
- 22, -8.44205264582682, -4.64465605976076, -0.643126602526688, 1.70710678118655, 1.8349201998544,
+ my $input = [ (0) x 5, (1) x 22, (0) x 5 ];
+ my $expected = [ 22, -8.44205264582682, -4.64465605976076, -0.643126602526688, 1.70710678118655, 1.8349201998544,
0.572726230154202, -0.676964287646119, -1, -0.455944707054924, 0.255700894591988, 0.524240654352147,
0.292893218813453, -0.059180002187481, -0.183771064985432, -0.0818926089645147, 0, -0.831469612302545,
-0.923879532511287, -0.195090322016128, 0.707106781186547, 0.98078528040323, 0.38268343236509,
-0.555570233019602, -1, -0.555570233019602, 0.38268343236509, 0.980785280403231, 0.707106781186547,
-0.195090322016128, -0.923879532511287, -0.831469612302545
- ]);
+ ];
+ my ($status, $output ) = gsl_fft_real_radix2_transform ($input, 1, 32);
+ ok_status($status);
+
+ ok_similar( $output, $expected );
}
sub FFT_COMPLEX_RADIX2_FORWARD : Tests
--
1.6.0.1+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment