4bf166dca2c9a25e8bac5ea52f2e96b4ec15ba4f
[Math-GSL.git] / lib / Math / GSL.pm
blob4bf166dca2c9a25e8bac5ea52f2e96b4ec15ba4f
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_02';
27 =head1 NAME
29 Math::GSL - Perl interface to the GNU Scientific Library (GSL)
31 =head1 VERSION
33 Version 0.21_02
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.
121 =head1 SUPPORT
123 You can find documentation for this module with the perldoc command.
125 perldoc Math::GSL
127 or online at L<http://leto.net/code/Math-GSL/>
129 =over 4
131 =item * AnnoCPAN: Annotated CPAN documentation
133 L<http://annocpan.org/dist/Math::GSL>
135 =item * CPAN Ratings
137 L<http://cpanratings.perl.org/d/Math::GSL>
139 =item * Search CPAN
141 L<http://search.cpan.org/dist/Math::GSL>
143 =back
145 =head1 DEVELOPMENT
147 If you would like the help develop Math::GSL, email the authors
148 and do
150 git clone git://github.com/leto/math--gsl.git
151 cd Math-GSL
152 git checkout -b bleed # create new local branch
153 git pull origin bleed # pull in remote bleed
155 to get the latest source, which is a two-headed beast with branches master and
156 bleed. The master branch is our stable branch, which is periodically sync-ed
157 with bleed. To view the latest source code online, go to
158 L<http://github.com/leto/math--gsl/tree/master>. The latest version of Git can be found at
159 L<http://git-scm.com> .
161 =head1 ACKNOWLEDGEMENTS
163 Thanks to PDX.pm, The Perl Foundation and everyone at Google who makes
164 the Summer of Code happen each year. You rock.
166 =head1 DEDICATION
168 This Perl module is dedicated in memory of Nick Ing-Simmons.
170 =head1 COPYRIGHT & LICENSE
172 Copyright 2008-2009 Jonathan Leto, Thierry Moisan all rights reserved.
174 This program is free software; you can redistribute it and/or modify it
175 under the same terms as Perl itself.
177 =cut
179 sub new
181 my ($self,$args) = @_;
182 my $class = ref $self || $self || 'Math::GSL';
183 my $this = { };
184 bless $this, $class;
186 sub gsl_fopen
188 my ($file, $mode) = @_;
189 $mode .= '+b' if (is_windows() and $mode !~ /\+b/);
190 return Math::GSL::Vector::fopen($file, $mode);
193 sub gsl_fclose
195 my $file = shift;
196 return Math::GSL::Vector::fclose($file);