Version bump
[Math-GSL.git] / lib / Math / GSL.pm
blob75a6070f06360e19e4e7b6ec9af6a29437f45577
1 package Math::GSL;
2 use base qw(Exporter);
3 use base qw(DynaLoader);
4 use strict;
5 use warnings;
6 use Math::GSL::Machine qw/:all/;
7 use Math::GSL::Const qw/:all/;
8 use Math::GSL::Errno qw/:all/;
9 use Math::GSL::Vector qw/:file/;
10 use Math::GSL::Test qw/:all/;
11 use Carp qw/croak/;
12 use Config;
13 use Test::More;
14 our @EXPORT = qw();
15 our @EXPORT_OK = qw(
16 gsl_fopen gsl_fclose
17 $GSL_MODE_DEFAULT $GSL_PREC_DOUBLE
18 $GSL_PREC_SINGLE $GSL_PREC_APPROX
21 our %EXPORT_TAGS = (
22 all => \@EXPORT_OK,
25 our ($GSL_PREC_DOUBLE, $GSL_PREC_SINGLE, $GSL_PREC_APPROX ) = 0..2;
26 our $GSL_MODE_DEFAULT = $GSL_PREC_DOUBLE;
27 our $VERSION = '0.14';
30 =head1 NAME
32 Math::GSL - Perl interface to the GNU Scientific Library (GSL)
34 =head1 VERSION
36 Version 0.14
38 =cut
40 =head1 SYNOPSIS
42 use Math::GSL::Matrix;
43 my $matrix = Math::GSL::Matrix->new(5,5); # 5x5 zero matrix
44 # note that columns and rows are zero-based
45 $matrix->set_col(0, [1..5]) # set *first* column to 1,2,3,4,5
46 ->set_row(2, [5..9]); # set *third* column to 5,6,7,8,9
47 my @matrix = $matrix->as_list; # matrix as Perl list
48 my $gsl_matrix = $matrix->raw; # underlying GSL object
50 use Math::GSL::RNG;
51 my $rng = Math::GSL::RNG->new;
52 my @random_numbers = map { $rng->get } (1 .. 1000);
54 use Math::GSL::Deriv qw/:all/;
55 my $function = sub { my $x=shift; sin($x**2) };
56 my ($status,$val,$err) = gsl_deriv_central($function, 5, 0.01 );
58 Each GSL subsystem has it's own module. For example, the random number generator
59 subsystem is Math::GSL::RNG. Many subsystems have a more Perlish and
60 object-oriented frontend which can be used, as the above example shows. The raw
61 GSL object is useful for using the low-level GSL functions, which in the case of
62 the Matrix subsytem, would be of the form gsl_matrix_* . Each module has further
63 documentation about the low-level C functions as well as using the more
64 intuitive (but slightly slower) object-oriented interface.
66 =head1 SUBSYSTEMS
68 Math::GSL::BLAS - Linear Algebra Functions
69 Math::GSL::BSpline - BSplines
70 Math::GSL::CBLAS - Linear Algebra Functions
71 Math::GSL::CDF - Cumulative Distribution Functions
72 Math::GSL::Chebyshev - Chebyshev Polynomials
73 Math::GSL::Combination - Combinatoric Functions
74 Math::GSL::Complex - Complex Numbers
75 Math::GSL::Const - Various Constants
76 Math::GSL::DHT - Discrete Hilbert Transform
77 Math::GSL::Deriv - Numerical Derivative
78 Math::GSL::Eigen - Eigenvalues and Eigenvectors
79 Math::GSL::Errno - Error Handling
80 Math::GSL::FFT - Fast Fourier Transform
81 Math::GSL::Fit - Curve Fitting
82 Math::GSL::Heapsort - Sorting Heaps
83 Math::GSL::Histogram - Histograms
84 Math::GSL::Histogram2D - 2D Histograms
85 Math::GSL::Integration - Numerical Integration
86 Math::GSL::Interp - Interpolation
87 Math::GSL::Linalg - Linear Algebra
88 Math::GSL::Machine - Machine Specific Information
89 Math::GSL::Matrix - NxM Matrices
90 Math::GSL::Min - Minimization
91 Math::GSL::Monte - Monte Carlo Integrations
92 Math::GSL::Multifit - Multivariable Fitting
93 Math::GSL::Multimin - Multivariable Minimization
94 Math::GSL::Multiroots - Muiltvariable Root Finding
95 Math::GSL::NTuple - N Tuples
96 Math::GSL::ODEIV - Ordinary Differential Equation Solvers (Initial Value Problems)
97 Math::GSL::Permutation - Permutations
98 Math::GSL::Poly - Polynmials
99 Math::GSL::PowInt - Integer Power Functions
100 Math::GSL::QRNG - Quasi-Random Number Generators
101 Math::GSL::RNG - Random Number Generators
102 Math::GSL::Randist - Random Number Distributions
103 Math::GSL::Roots - Root Finding Algorithms
104 Math::GSL::SF - Special Functions
105 Math::GSL::Siman - Simulated Annealing
106 Math::GSL::Sort - Sorting
107 Math::GSL::Spline - Splines
108 Math::GSL::Statistics - Statistics Functions
109 Math::GSL::Sum - Summation
110 Math::GSL::Sys - Sytem utility functions
111 Math::GSL::Vector - N-dimensional Vectors
112 Math::GSL::Wavelet - Basic Wavelets
113 Math::GSL::Wavelet2D - 2D Wavelets
116 =head1 AUTHORS
118 Jonathan Leto, C<< <jonathan@leto.net> >> and Thierry Moisan C<< <thierry.moisan@gmail.com> >>
120 =head1 BUGS
122 This software is still in active development, we appreciate your detailed bug reports and
123 documentation patches. Please report any bugs or feature requests to the authors directly.
126 =head1 SUPPORT
128 You can find documentation for this module with the perldoc command.
130 perldoc Math::GSL
132 or online at L<http://leto.net/code/Math-GSL/>
134 =over 4
136 =item * AnnoCPAN: Annotated CPAN documentation
138 L<http://annocpan.org/dist/Math::GSL>
140 =item * CPAN Ratings
142 L<http://cpanratings.perl.org/d/Math::GSL>
144 =item * Search CPAN
146 L<http://search.cpan.org/dist/Math::GSL>
148 =back
150 =head1 DEVELOPMENT
152 If you would like the help develop Math::GSL, email the authors
153 and do
155 git clone http://leto.net/code/Math-GSL.git
156 cd Math-GSL
157 git checkout -b bleed # create new local branch
158 git pull origin bleed # pull in remote bleed
160 to get the latest source, which is a two-headed beast with branches master and
161 bleed. The master branch is our stable branch, which is periodically sync-ed
162 with bleed. To view the latest source code online, go to
163 L<http://leto.net/gitweb/>. The latest version of Git can be found at
164 L<http://git.or.cz>.
166 =head1 ACKNOWLEDGEMENTS
168 Thanks to PDX.pm, The Perl Foundation and everyone at Google who makes
169 the Summer of Code happen each year. You rock.
171 =head1 DEDICATION
173 This Perl module is dedicated in memory of Nick Ing-Simmons.
175 =head1 COPYRIGHT & LICENSE
177 Copyright 2008 Jonathan Leto, Thierry Moisan all rights reserved.
179 This program is free software; you can redistribute it and/or modify it
180 under the same terms as Perl itself.
182 =cut
184 sub new
186 my ($self,$args) = @_;
187 my $class = ref $self || $self || 'Math::GSL';
188 my $this = { };
189 bless $this, $class;
192 sub subsystems
194 return sort qw/
195 Diff Machine Statistics
196 Eigen Matrix Poly
197 BSpline Errno PowInt
198 CBLAS FFT Min IEEEUtils
199 CDF Fit QRNG
200 Chebyshev Monte RNG Vector
201 Heapsort Multifit Randist Roots
202 Combination Histogram Multimin Wavelet
203 Complex Histogram2D Multiroots Wavelet2D
204 Const Siman Sum Sys
205 NTuple Integration Sort Test
206 DHT Interp ODEIV SF
207 Deriv Linalg Permutation Spline
210 sub gsl_fopen
212 my ($file, $mode) = @_;
213 $mode .= '+b' if (is_windows() and $mode !~ /\+b/);
214 return Math::GSL::Vector::fopen($file, $mode);
217 sub gsl_fclose
219 my $file = shift;
220 return Math::GSL::Vector::fclose($file);