Bump minor revision again, prepping for CPAN test release
[Math-GSL.git] / lib / Math / GSL.pm
blob134532156bb6bacb08d1bb54394080dcef14db8b
1 package Math::GSL;
2 use base 'Exporter';
3 use base 'DynaLoader';
4 use strict;
5 use Config;
6 use warnings;
7 use Test::More;
8 use Math::GSL::Test qw/:all/;
9 use Math::GSL::Const qw/:all/;
10 use Math::GSL::Errno qw/:all/;
11 use Math::GSL::Vector qw/:file/;
12 use Math::GSL::Machine qw/:all/;
13 our @EXPORT = qw();
14 our @EXPORT_OK = qw(
15 gsl_fopen gsl_fclose
16 $GSL_MODE_DEFAULT $GSL_PREC_DOUBLE
17 $GSL_PREC_SINGLE $GSL_PREC_APPROX
21 our %EXPORT_TAGS = ( all => \@EXPORT_OK, );
23 our ($GSL_PREC_DOUBLE, $GSL_PREC_SINGLE, $GSL_PREC_APPROX ) = 0 .. 2;
24 our $GSL_MODE_DEFAULT = $GSL_PREC_DOUBLE;
25 our $VERSION = '0.21_03';
27 =head1 NAME
29 Math::GSL - Perl interface to the GNU Scientific Library (GSL)
31 =head1 VERSION
33 Version 0.21_03
35 =head1 SYNOPSIS
37 use Math::GSL::Matrix;
38 my $matrix = Math::GSL::Matrix->new(5,5); # 5x5 zero matrix
39 # note that columns and rows are zero-based
40 $matrix->set_col(0, [1..5]) # set *first* column to 1,2,3,4,5
41 ->set_row(2, [5..9]); # set *third* column to 5,6,7,8,9
42 my @matrix = $matrix->as_list; # matrix as Perl list
43 my $gsl_matrix = $matrix->raw; # underlying GSL object
45 use Math::GSL::RNG;
46 my $rng = Math::GSL::RNG->new;
47 my @random_numbers = $rng->get(1000);
49 use Math::GSL::Deriv qw/:all/;
50 my $function = sub { my $x=shift; sin($x**2) };
51 my ($status,$val,$err) = gsl_deriv_central($function, 5, 0.01 );
53 Each GSL subsystem has it's own module. For example, the random number generator
54 subsystem is Math::GSL::RNG. Many subsystems have a more Perlish and
55 object-oriented frontend which can be used, as the above example shows. The raw
56 GSL object is useful for using the low-level GSL functions, which in the case of
57 the Matrix subsytem, would be of the form gsl_matrix_* . Each module has further
58 documentation about the low-level C functions as well as using the more
59 intuitive (but slightly slower) object-oriented interface.
61 =head1 SUBSYSTEMS
63 Math::GSL::BLAS - Linear Algebra Functions
64 Math::GSL::BSpline - BSplines
65 Math::GSL::CBLAS - Linear Algebra Functions
66 Math::GSL::CDF - Cumulative Distribution Functions
67 Math::GSL::Chebyshev - Chebyshev Polynomials
68 Math::GSL::Combination - Combinatoric Functions
69 Math::GSL::Complex - Complex Numbers
70 Math::GSL::Const - Various Constants
71 Math::GSL::DHT - Discrete Hilbert Transform
72 Math::GSL::Deriv - Numerical Derivative
73 Math::GSL::Eigen - Eigenvalues and Eigenvectors
74 Math::GSL::Errno - Error Handling
75 Math::GSL::FFT - Fast Fourier Transform
76 Math::GSL::Fit - Curve Fitting
77 Math::GSL::Heapsort - Sorting Heaps
78 Math::GSL::Histogram - Histograms
79 Math::GSL::Histogram2D - 2D Histograms
80 Math::GSL::Integration - Numerical Integration
81 Math::GSL::Interp - Interpolation
82 Math::GSL::Linalg - Linear Algebra
83 Math::GSL::Machine - Machine Specific Information
84 Math::GSL::Matrix - NxM Matrices
85 Math::GSL::Min - Minimization
86 Math::GSL::Monte - Monte Carlo Integrations
87 Math::GSL::Multifit - Multivariable Fitting
88 Math::GSL::Multimin - Multivariable Minimization
89 Math::GSL::Multiroots - Muiltvariable Root Finding
90 Math::GSL::NTuple - N Tuples
91 Math::GSL::ODEIV - Ordinary Differential Equation Solvers (Initial Value Problems)
92 Math::GSL::Permutation - Permutations
93 Math::GSL::Poly - Polynmials
94 Math::GSL::PowInt - Integer Power Functions
95 Math::GSL::QRNG - Quasi-Random Number Generators
96 Math::GSL::RNG - Random Number Generators
97 Math::GSL::Randist - Random Number Distributions
98 Math::GSL::Roots - Root Finding Algorithms
99 Math::GSL::SF - Special Functions
100 Math::GSL::Siman - Simulated Annealing
101 Math::GSL::Sort - Sorting
102 Math::GSL::Spline - Splines
103 Math::GSL::Statistics - Statistics Functions
104 Math::GSL::Sum - Summation
105 Math::GSL::Sys - Sytem utility functions
106 Math::GSL::Vector - N-dimensional Vectors
107 Math::GSL::Wavelet - Basic Wavelets
108 Math::GSL::Wavelet2D - 2D Wavelets
111 =head1 AUTHORS
113 Jonathan Leto, C<< <jonathan@leto.net> >> and Thierry Moisan C<< <thierry.moisan@gmail.com> >>
115 =head1 BUGS
117 This software is still in active development, we appreciate your detailed bug reports and
118 documentation patches. Please report any bugs or feature requests to the authors directly.
120 =head1 COMPILING ISSUES
122 Some operating system configurations will make the compilation of Math::GSL fail. One
123 common problem that happens on RedHat Linux (RHEL) and CentOS looks like this:
126 Error: Can't load '/usr/src/misc/perl-package/Math-GSL-0.20/blib/arch/auto/Math/GSL/Errno/Errno.so'
127 for module Math::GSL::Errno: /usr/src/misc/perl-package/Math-GSL-0.20/blib/arch/auto/Math/GSL/Errno/Errno.so:
128 cannot restore segment prot after reloc: Permission denied at /usr/lib/perl5/5.10.0/i386-linux-thread-multi/DynaLoader.pm line 203.
129 # at blib/lib/Math/GSL/Errno.pm line 10
131 This is due the the SE Linux setting being set to "enforcing". To Temporarily
132 disable enforcement on a running system:
134 /usr/sbin/setenforce 0
136 To permanently disable enforcement during a system startup change "enforcing" to
137 "disabled" in ''/etc/selinux/config'' and reboot.
140 =head1 SUPPORT
142 You can find documentation for this module with the perldoc command.
144 perldoc Math::GSL
146 or online at L<http://leto.net/code/Math-GSL/>
148 =over 4
150 =item * AnnoCPAN: Annotated CPAN documentation
152 L<http://annocpan.org/dist/Math::GSL>
154 =item * CPAN Ratings
156 L<http://cpanratings.perl.org/d/Math::GSL>
158 =item * Search CPAN
160 L<http://search.cpan.org/dist/Math::GSL>
162 =back
164 =head1 DEVELOPMENT
166 If you would like the help develop Math::GSL, email the authors
167 and do
169 git clone git://github.com/leto/math--gsl.git
170 cd math--gsl
171 # start hacking
173 to get the latest source, which is a two-headed beast with branches master and
174 bleed. The master branch is our stable branch, which is periodically sync-ed
175 with bleed. To view the latest source code online, go to
176 L<http://github.com/leto/math--gsl/tree/master>. The latest version of Git can be found at
177 L<http://git-scm.com> .
179 =head1 ACKNOWLEDGEMENTS
181 Thanks to PDX.pm, The Perl Foundation and everyone at Google who makes
182 the Summer of Code happen each year. You rock.
184 =head1 DEDICATION
186 This Perl module is dedicated in memory of Nick Ing-Simmons.
188 =head1 COPYRIGHT & LICENSE
190 Copyright 2008-2010 Jonathan Leto, Thierry Moisan all rights reserved.
192 This program is free software; you can redistribute it and/or modify it
193 under the same terms as Perl itself.
195 =cut
197 sub new
199 my ($self,$args) = @_;
200 my $class = ref $self || $self || 'Math::GSL';
201 my $this = { };
202 bless $this, $class;
204 sub gsl_fopen
206 my ($file, $mode) = @_;
207 $mode .= '+b' if (is_windows() and $mode !~ /\+b/);
208 return Math::GSL::Vector::fopen($file, $mode);
211 sub gsl_fclose
213 my $file = shift;
214 return Math::GSL::Vector::fclose($file);