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