4 use Math
::GSL
::Machine qw
/:all/;
5 use Math
::GSL
::Const qw
/:all/;
9 use Scalar
::Util qw
/looks_like_number/;
12 our @ISA = qw(Exporter DynaLoader);
14 our @EXPORT_OK = qw( is_similar $GSL_MODE_DEFAULT $GSL_PREC_DOUBLE $GSL_PREC_SINGLE $GSL_PREC_APPROX);
15 our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
17 our ($GSL_PREC_DOUBLE, $GSL_PREC_SINGLE, $GSL_PREC_APPROX ) = 0..2;
18 our $GSL_MODE_DEFAULT = $GSL_PREC_DOUBLE;
20 use constant MAX_DOUBLE => 1.7976931348623157e+308;
21 use constant MIN_DOUBLE => 2.2250738585072014e-308;
22 use constant MAX_FLOAT => 3.40282347e+38;
23 use constant MIN_FLOAT => 1.175494351e-38;
28 Math::GSL - Perl interface to the GNU Scientific Library (GSL) using SWIG
38 use Math::GSL::RNG qw/:all/;
43 Jonathan Leto, C<< <jonathan@leto.net> >> and Thierry Moisan C<< <thierry.moisan@gmail.com> >>
47 Please report any bugs or feature requests to the authors directly.
52 You can find documentation for this module with the perldoc command.
56 or online at L<http://leto.net/code/Math-GSL/>
60 =item * AnnoCPAN: Annotated CPAN documentation
62 L<http://annocpan.org/dist/Math::GSL>
66 L<http://cpanratings.perl.org/d/Math::GSL>
70 L<http://search.cpan.org/dist/Math::GSL>
75 =head1 ACKNOWLEDGEMENTS
78 =head1 COPYRIGHT & LICENSE
80 Copyright 2008 Jonathan Leto, Thierry Moisan all rights reserved.
82 This program is free software; you can redistribute it and/or modify it
83 under the same terms as Perl itself.
89 my ($self,$args) = @_;
90 my $class = ref $self || $self || 'Math::GSL';
98 BLAS Diff Machine Permute Statistics
99 Block Eigen Matrix Poly Sum
100 BSpline Errno PowInt Sys
101 CBLAS FFT Min IEEEUtils
102 CDF Fit Mode QRNG Types
103 Chebyshev Function Monte RNG Vector
104 Heapsort Multifit Randist
105 Combination Histogram Multimin Roots Wavelet
106 Complex Histogram2d Multiroots SF Wavelet2D
108 DFT Integration NTuple Sort
110 Deriv Linalg Permutation Spline
116 my ($self,$results,$class) = @_;
119 while (my($k,$v)=each %$results){
120 my $eps = 2048*$Math::GSL::Machine::GSL_DBL_EPSILON; # TOL3
122 defined $class ? ( $x = eval qq{${class}::$k} )
126 print "got $x for $k\n" if defined $ENV{DEBUG};
128 if (ref $v eq 'ARRAY'){
134 ok(0, qq{'$k' died} );
135 } elsif ($x =~ /nan|inf/i){
136 ok( $val eq $x, "'$val'?='$x'" );
138 my $res = abs($x-$val);
140 : ok( $res <= $eps, "$k ?= $x,\n+- $res, tol=$eps" );
146 my ($x,$y, $eps) = @_;
148 if (ref $x eq 'ARRAY' && ref $y eq 'ARRAY') {
150 warn "is_similar(): argument of different length!";
154 my $delta = abs($x->[$_] - $y->[$_]);
156 warn "\n\tElements start differing at index $_, delta = $delta\n";
157 warn qq{\t\t\$x->[$_] = } . $x->[$_] . "\n";
158 warn qq{\t\t\$y->[$_] = } . $y->[$_] . "\n";
165 abs($x-$y) <= $eps ? return 1 : return 0;
172 return 0 unless ( defined $x && looks_like_number($x) );
174 return 1 if ($x == 0);
185 return 0 unless ( defined $x && looks_like_number($x) );
187 return 1 if ($x == 0);
196 sub _has_quads { $Config{use64bitint} eq 'define' || ($Config{longsize} >= 8) }
197 sub _has_long_doubles { $Config{d_longdbl} eq 'define' }
198 sub _has_long_doubles_as_default { $Config{uselongdouble} eq 'define' }
199 sub _has_long_doubles_same_as_doubles { $Config{doublesize} == $Config{longdblsize} }
201 sub _assert_dies($;$)
203 my ($code,$msg) = @_;
204 my $status = eval { &$code };
205 print "status=||$status||\n\$\?=$?\n\$\!=$!\n" if 0;
206 $@ ? ok(1, $msg) : ok (0, join "\n", $@, $msg );