blib/lib/Math/GSL.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 94.4% 34 / 36 CC 1 SCAR 0.3
CC
1
Cov
93%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Math/GSL/Test.pm ↑ Summary c/Matrix.c »
1 package Math::GSL;
2 34 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use base 'DynaLoader';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 34 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 34 ▶use Scalar::Util qw/tainted/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 34 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 0 ▶use Math::GSL::Test qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=2.6
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 use Math::GSL::Version;
16 use version;
17 our @EXPORT = qw();
18 our @EXPORT_OK = qw(
19 gsl_fopen gsl_fclose gsl_version
20 $GSL_MODE_DEFAULT $GSL_PREC_DOUBLE
21 $GSL_PREC_SINGLE $GSL_PREC_APPROX
22 );
23  
24  
25 our %EXPORT_TAGS = ( all => \@EXPORT_OK, );
26  
27 our ($GSL_PREC_DOUBLE, $GSL_PREC_SINGLE, $GSL_PREC_APPROX ) = 0 .. 2;
28 our $GSL_MODE_DEFAULT = $GSL_PREC_DOUBLE;
29 our $VERSION = '0.49';
30  
31 =head1 NAME
32  
33 Math::GSL - Perl interface to the GNU Scientific Library (GSL)
34  
35 =head1 VERSION
36  
37 Version 0.49
38  
39 =head1 SYNOPSIS
40  
41 use Math::GSL::Matrix;
42 my $matrix = Math::GSL::Matrix->new(5,5); # 5x5 zero matrix
43 # note that columns and rows are zero-based
44 $matrix->set_col(0, [1..5]) # set *first* column to 1,2,3,4,5
45 ->set_row(2, [5..9]); # set *third* column to 5,6,7,8,9
46 my @matrix = $matrix->as_list; # matrix as Perl list
47 my $gsl_matrix = $matrix->raw; # underlying GSL object
48  
49 use Math::GSL::RNG;
50 my $rng = Math::GSL::RNG->new;
51 my @random_numbers = $rng->get(1000);
52  
53 use Math::GSL::Deriv qw/:all/;
54 my $function = sub { my $x=shift; sin($x**2) };
55 my ($status,$val,$err) = gsl_deriv_central($function, 5, 0.01 );
56  
57 use Math::GSL qw/gsl_version/;
58 # get a version object for the version of the underlying GSL library,
59 # which will stringify to a version number
60 my $gsl_version = gsl_version();
61  
62 Each GSL subsystem has its own module. For example, the random number generator
63 subsystem is Math::GSL::RNG. Many subsystems have a more Perlish and
64 object-oriented frontend which can be used, as the above example shows. The raw
65 GSL object is useful for using the low-level GSL functions, which in the case of
66 the Matrix subsystem, would be of the form gsl_matrix_* . Each module has further
67 documentation about the low-level C functions as well as using the more
68 intuitive (but slightly slower) object-oriented interface.
69  
70 =head1 SUBSYSTEMS
71  
72 L<Math::GSL::BLAS> - Linear Algebra Functions
73  
74 L<Math::GSL::BSpline> - BSplines
75  
76 L<Math::GSL::CBLAS> - Linear Algebra Functions
77  
78 L<Math::GSL::CDF> - Cumulative Distribution Functions
79  
80 L<Math::GSL::Chebyshev> - Chebyshev Polynomials
81  
82 L<Math::GSL::Combination> - Combinatoric Functions
83  
84 L<Math::GSL::Complex> - Complex Numbers
85  
86 L<Math::GSL::Const> - Various Constants
87  
88 L<Math::GSL::DHT> - Discrete Hankel Transforms
89  
90 L<Math::GSL::Deriv> - Numerical Derivative
91  
92 L<Math::GSL::Eigen> - Eigenvalues and Eigenvectors
93  
94 L<Math::GSL::Errno> - Error Handling
95  
96 L<Math::GSL::FFT> - Fast Fourier Transform
97  
98 L<Math::GSL::Fit> - Curve Fitting
99  
100 L<Math::GSL::Heapsort> - Sorting Heaps
101  
102 L<Math::GSL::Histogram> - Histograms
103  
104 L<Math::GSL::Histogram2D> - 2D Histograms
105  
106 L<Math::GSL::Integration> - Numerical Integration
107  
108 L<Math::GSL::Interp> - Interpolation
109  
110 L<Math::GSL::Linalg> - Linear Algebra
111  
112 L<Math::GSL::Machine> - Machine Specific Information
113  
114 L<Math::GSL::Matrix> - NxM Matrices
115  
116 L<Math::GSL::Min> - Minimization
117  
118 L<Math::GSL::Monte> - Monte Carlo Integrations
119  
120 L<Math::GSL::Multifit> - Multivariable Fitting
121  
122 L<Math::GSL::Multimin> - Multivariable Minimization
123  
124 L<Math::GSL::Multiroots> - Muiltvariable Root Finding
125  
126 L<Math::GSL::NTuple> - N Tuples
127  
128 L<Math::GSL::ODEIV> - Ordinary Differential Equation Solvers (Initial Value Problems)
129  
130 L<Math::GSL::Permutation> - Permutations
131  
132 L<Math::GSL::Poly> - Polynmials
133  
134 L<Math::GSL::PowInt> - Integer Power Functions
135  
136 L<Math::GSL::QRNG> - Quasi-Random Number Generators
137  
138 L<Math::GSL::RNG> - Random Number Generators
139  
140 L<Math::GSL::Randist> - Random Number Distributions
141  
142 L<Math::GSL::Roots> - Root Finding Algorithms
143  
144 L<Math::GSL::Rstat> - Running Statistics
145  
146 L<Math::GSL::SF> - Special Functions
147  
148 L<Math::GSL::Siman> - Simulated Annealing
149  
150 L<Math::GSL::Sort> - Sorting
151  
152 L<Math::GSL::SparseMatrix> - Sparse Matrices
153  
154 L<Math::GSL::Spline> - Splines
155  
156 L<Math::GSL::Statistics> - Statistics Functions
157  
158 L<Math::GSL::Sum> - Summation
159  
160 L<Math::GSL::Sys> - Sytem utility functions
161  
162 L<Math::GSL::Vector> - N-dimensional Vectors
163  
164 L<Math::GSL::Wavelet> - Basic Wavelets
165  
166 L<Math::GSL::Wavelet2D> - 2D Wavelets
167  
168 =cut
169  
170 sub gsl_fopen
171 {
172 my ($file, $mode) = @_;
173  
174 croak __PACKAGE__, "- gsl_fopen doesn't work with tainted variables" if
175 tainted($file) || tainted($mode);
176  
177 $mode .= '+b' if (is_windows() and $mode !~ /\+b/);
178 return Math::GSL::Vector::fopen($file, $mode);
179 }
180  
181 sub gsl_fclose
182 {
183 my $file = shift;
184 return Math::GSL::Vector::fclose($file);
185 }
186  
187 sub gsl_version{
188 return version->parse($Math::GSL::Version::GSL_VERSION);
189 }
190  
191 =head1 AUTHORS
192  
193 Jonathan "Duke" Leto, C<< <jonathan@leto.net> >> and Thierry Moisan C<< <thierry.moisan@gmail.com> >>
194  
195 =head1 BUGS
196  
197 This software is still in active development, we appreciate your detailed bug reports and
198 documentation patches. Please report any bugs or feature requests to L<https://github.com/hakonhagland/perl-math-gsl/issues>.
199  
200  
201 =head1 DEVELOPMENT
202  
203 If you would like the help develop Math::GSL, visit us on Github
204 L<https://github.com/hakonhagland/perl-math-gsl/issues> and fork, send Pull Requests
205 and/or create issues.
206  
207 To view the latest source code online, go to
208 L<https://github.com/hakonhagland/perl-math-gsl>.
209  
210 =head1 DEDICATION
211  
212 This Perl module is dedicated in memory of Nick Ing-Simmons.
213  
214 =head1 COPYRIGHT & LICENSE
215  
216 Copyright (C) 2008-2024 Jonathan "Duke" Leto, Thierry Moisan all rights reserved.
217  
218 This program is free software; you can redistribute it and/or modify it
219 under the same terms as Perl itself.
220  
221 =cut
222  
223 42;
« blib/lib/Math/GSL/Test.pm ↑ Summary c/Matrix.c »