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