Skip Menu |

This queue is for tickets about the Math-FFT CPAN distribution.

Report information
The Basics
Id: 22068
Status: resolved
Priority: 0/
Queue: Math-FFT

People
Owner: Nobody in particular
Requestors: thomas.poleschner [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.28
Fixed in: (no value)



Subject: signal size 65536
# Following code results in a spectrum with # negative values only on my machine: # # $ perl -v # This is perl, v5.8.5 built for i386-linux-thread-multi # # $ uname -a # Linux 2.6.9-34.0.1.ELsmp #1 SMP Wed May 17 17:05:24 EDT 2006 # (RedHat 4) # ------------------------------------------------------------ #!/usr/bin/perl -w use Math::FFT; my $PI = 3.1415926539; # my $N = 32768; <-- That works fine my $N = 2 * 32768; # <-- That produces negative spectrum values my $fs = 500; my @dat = (); for( my $k=0; $k<$N; $k++ ) { $dat[ $k ] = sin( 2*$PI*$k/$fs) + sin( 3*$PI*$k/$fs) + sin( 4*$PI*$k/$fs); } my $fft = new Math::FFT(\@dat); my $spectrum = $fft->spctrm; open SPECTRUM, ">tmp.dat"; for (my $k=0; $k<$N/2+1; $k++) { my $x = $k/$N*$fs; my $y = $spectrum->[$k]; print SPECTRUM $x." ".$y."\n"; } close SPECTRUM;
On Fri Oct 13 00:00:09 2006, tpolesch wrote: Show quoted text
> # Following code results in a spectrum with > # negative values only on my machine: > # > # $ perl -v > # This is perl, v5.8.5 built for i386-linux-thread-multi > # > # $ uname -a > # Linux 2.6.9-34.0.1.ELsmp #1 SMP Wed May 17 17:05:24 EDT 2006 > # (RedHat 4) > # ------------------------------------------------------------ > #!/usr/bin/perl -w > > use Math::FFT; > > my $PI = 3.1415926539; > # my $N = 32768; <-- That works fine > my $N = 2 * 32768; # <-- That produces negative spectrum values > my $fs = 500; > my @dat = (); > > for( my $k=0; $k<$N; $k++ ) > { > $dat[ $k ] = sin( 2*$PI*$k/$fs) > + sin( 3*$PI*$k/$fs) > + sin( 4*$PI*$k/$fs); > } > > my $fft = new Math::FFT(\@dat); > my $spectrum = $fft->spctrm; > > open SPECTRUM, ">tmp.dat"; > > for (my $k=0; $k<$N/2+1; $k++) > { > my $x = $k/$N*$fs; > my $y = $spectrum->[$k]; > > print SPECTRUM $x." ".$y."\n"; > } > > close SPECTRUM;
Hi, this was caused by 64K**2 being more than the value of "int". This is fixed in the repo in commit b750d71139f93eba1c6dcf98afc064520154e690 and will be on CPAN soon. Thanks for the report. Regards, -- Shlomi Fish