Adding support for the PowInt subsystem, as well making the verbosity of the test...
[Math-GSL.git] / trunk / lib / Math / GSL.pm
blob0a520ea69f65276401d67ea4d48f080ee6b1b9c7
1 package Math::GSL;
3 use warnings;
4 use Config;
5 use Data::Dumper;
6 use Test::More;
7 use strict;
9 our $VERSION = 0.01;
11 =head1 NAME
13 Math::GSL - OO Perl interface to the GNU Scientific Library (GSL)
15 =head1 VERSION
17 Version 0.01
19 =cut
21 =head1 SYNOPSIS
24 use Math::GSL::Sf qw/ ... /;
25 ...
27 =head1 EXPORT
29 Nothing is exported by default. This is alpha software, the API could change at any second.
32 =head1 AUTHOR
34 Jonathan Leto, C<< <jonathan at leto.net> >>
36 =head1 BUGS
38 Please report any bugs or feature requests to C<bug-math-gsl at rt.cpan.org>, or through
39 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math::GSL>. I will be notified, and then you'll
40 automatically be notified of progress on your bug as I make changes.
43 =head1 SUPPORT
45 You can find documentation for this module with the perldoc command.
47 perldoc Math::GSL
49 or online at L<http://leto.net/code/Math-GSL/>
52 You can also look for information at:
54 =over 4
56 =item * RT: CPAN's request tracker
58 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Math::GSL>
60 =item * AnnoCPAN: Annotated CPAN documentation
62 L<http://annocpan.org/dist/Math::GSL>
64 =item * CPAN Ratings
66 L<http://cpanratings.perl.org/d/Math::GSL>
68 =item * Search CPAN
70 L<http://search.cpan.org/dist/Math::GSL>
72 =back
75 =head1 ACKNOWLEDGEMENTS
78 =head1 COPYRIGHT & LICENSE
80 Copyright 2008 Jonathan Leto, 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.
85 =cut
87 sub new
89 my ($self,$args) = @_;
90 my $class = ref $self || $self || 'Math::GSL';
91 my $this = { };
92 bless $this, $class;
95 sub subsystems
97 return qw/ CDF Errno Fit Machine PowInt Randist SF Types /;
100 sub verify_results
102 my ($self,$results,$eps) = @_;
103 $eps ||= 1e-8;
104 while (my($k,$v)=each %$results){
105 my $x = eval $k;
106 print "got $x for $k\n" if defined $ENV{DEBUG};
107 if($x =~ /nan/i){
108 ok( $v eq $x, "'$v'?='$x'" );
109 } else {
110 my $res = abs($x-$v);
111 $@ ? ok(0)
112 : ok( $res < $eps, "$k ?= $x, +- $res" );
117 use constant MIN_DOUBLE => 2.2250738585072014e-308;
118 use constant MAX_DOUBLE => 1.7976931348623157E+308;
119 use constant MAX_FLOAT => 3.40282347E+38;
120 use constant MIN_FLOAT => 1.175494351e-38;
122 sub _has_quads { $Config{use64bitint} eq 'define' || ($Config{longsize} >= 8) }
123 sub _has_long_doubles { $Config{d_longdbl} eq 'define' }
124 sub _has_long_doubles_as_default { $Config{uselongdouble} eq 'define' }
125 sub _has_long_doubles_same_as_doubles { $Config{doublesize} == $Config{longdblsize} }
127 sub _assert_dies($;$)
129 my ($code,$msg) = @_;
130 my $status = eval { &$code };
131 print "status=||$status||\n\$\?=$?\n\$\!=$!\n" if 0;
132 $@ ? ok(1, $msg) : ok (0, join "\n", $@, $msg );