From 68d471ab131026f5ad804a8073f042ea0d54fa4c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 14 Nov 2008 00:23:51 -0800 Subject: [PATCH] Finish pod separation and add stub tests for remaining subsystems --- swig/Errno.i => pod/Errno.pod | 12 +- swig/FFT.i => pod/FFT.pod | 45 - swig/Fit.i => pod/Fit.pod | 15 - swig/Heapsort.i => pod/Heapsort.pod | 10 +- swig/Histogram.i => pod/Histogram.pod | 15 +- swig/Histogram2D.i => pod/Histogram2D.pod | 16 +- swig/IEEEUtils.i => pod/IEEEUtils.pod | 8 +- swig/Integration.i => pod/Integration.pod | 12 +- swig/Interp.i => pod/Interp.pod | 20 +- swig/Linalg.i => pod/Linalg.pod | 12 +- swig/Machine.i => pod/Machine.pod | 9 +- swig/Matrix.i => pod/Matrix.pod | 27 +- swig/Min.i => pod/Min.pod | 13 +- swig/Monte.i => pod/Monte.pod | 20 +- swig/Multifit.i => pod/Multifit.pod | 16 +- swig/Multimin.i => pod/Multimin.pod | 59 +- swig/Multiroots.i => pod/Multiroots.pod | 19 +- swig/NTuple.i => pod/NTuple.pod | 20 +- swig/ODEIV.i => pod/ODEIV.pod | 10 +- swig/Permutation.i => pod/Permutation.pod | 22 +- swig/Poly.i => pod/Poly.pod | 109 +- swig/PowInt.i => pod/PowInt.pod | 8 +- swig/QRNG.i => pod/QRNG.pod | 33 +- swig/RNG.i => pod/RNG.pod | 9 +- swig/Randist.i => pod/Randist.pod | 39 +- swig/Roots.i => pod/Roots.pod | 11 +- swig/SF.i => pod/SF.pod | 82 +- swig/Siman.i => pod/Siman.pod | 9 +- swig/Sort.i => pod/Sort.pod | 105 +- swig/Spline.i => pod/Spline.pod | 14 +- swig/Statistics.i => pod/Statistics.pod | 21 +- swig/Sys.i => pod/Sys.pod | 10 +- swig/Vector.i => pod/Vector.pod | 30 +- swig/Wavelet.i => pod/Wavelet.pod | 16 +- swig/Wavelet2D.i => pod/Wavelet2D.pod | 13 +- swig/Errno.i | 220 +- swig/FFT.i | 387 +--- swig/Fit.i | 122 +- swig/Heapsort.i | 71 +- swig/Histogram.i | 241 +-- swig/Histogram2D.i | 260 +-- swig/IEEEUtils.i | 47 +- swig/Integration.i | 269 +-- swig/Interp.i | 154 +- swig/Linalg.i | 418 +--- swig/Machine.i | 218 +- swig/Matrix.i | 1216 +---------- swig/Min.i | 128 +- swig/Monte.i | 135 +- swig/Multifit.i | 159 +- swig/Multimin.i | 145 +- swig/Multiroots.i | 146 +- swig/NTuple.i | 117 +- swig/ODEIV.i | 173 +- swig/Permutation.i | 249 +-- swig/Poly.i | 103 +- swig/PowInt.i | 73 +- swig/QRNG.i | 143 +- swig/RNG.i | 391 +--- swig/Randist.i | 486 +---- swig/Roots.i | 163 +- swig/SF.i | 3310 +---------------------------- swig/Siman.i | 71 +- swig/Sort.i | 379 +--- swig/Spline.i | 111 +- swig/Statistics.i | 453 +--- swig/Sys.i | 123 +- swig/Vector.i | 504 +---- swig/Wavelet.i | 139 +- swig/Wavelet2D.i | 45 +- swig/gsl_typemaps.i | 2 + t/Heapsort.t | 23 + t/IEEEUtils.t | 23 + t/Multimin.t | 23 + t/Siman.t | 23 + t/Wavelet2D.t | 23 + 76 files changed, 872 insertions(+), 11503 deletions(-) copy swig/Errno.i => pod/Errno.pod (94%) copy swig/FFT.i => pod/FFT.pod (92%) copy swig/Fit.i => pod/Fit.pod (96%) copy swig/Heapsort.i => pod/Heapsort.pod (88%) copy swig/Histogram.i => pod/Histogram.pod (98%) copy swig/Histogram2D.i => pod/Histogram2D.pod (98%) copy swig/IEEEUtils.i => pod/IEEEUtils.pod (91%) copy swig/Integration.i => pod/Integration.pod (97%) copy swig/Interp.i => pod/Interp.pod (95%) copy swig/Linalg.i => pod/Linalg.pod (99%) copy swig/Machine.i => pod/Machine.pod (97%) copy swig/Matrix.i => pod/Matrix.pod (98%) copy swig/Min.i => pod/Min.pod (89%) copy swig/Monte.i => pod/Monte.pod (82%) copy swig/Multifit.i => pod/Multifit.pod (96%) copy swig/Multimin.i => pod/Multimin.pod (64%) copy swig/Multiroots.i => pod/Multiroots.pod (90%) copy swig/NTuple.i => pod/NTuple.pod (90%) copy swig/ODEIV.i => pod/ODEIV.pod (97%) copy swig/Permutation.i => pod/Permutation.pod (93%) copy swig/Poly.i => pod/Poly.pod (58%) copy swig/PowInt.i => pod/PowInt.pod (94%) copy swig/QRNG.i => pod/QRNG.pod (82%) copy swig/RNG.i => pod/RNG.pod (99%) copy swig/Randist.i => pod/Randist.pod (96%) copy swig/Roots.i => pod/Roots.pod (98%) copy swig/SF.i => pod/SF.pod (96%) copy swig/Siman.i => pod/Siman.pod (91%) copy swig/Sort.i => pod/Sort.pod (72%) copy swig/Spline.i => pod/Spline.pod (91%) copy swig/Statistics.i => pod/Statistics.pod (98%) copy swig/Sys.i => pod/Sys.pod (96%) copy swig/Vector.i => pod/Vector.pod (96%) copy swig/Wavelet.i => pod/Wavelet.pod (94%) copy swig/Wavelet2D.i => pod/Wavelet2D.pod (72%) rewrite swig/Errno.i (95%) rewrite swig/FFT.i (92%) rewrite swig/Fit.i (96%) rewrite swig/Heapsort.i (91%) rewrite swig/Histogram.i (98%) rewrite swig/Histogram2D.i (98%) rewrite swig/IEEEUtils.i (91%) rewrite swig/Integration.i (97%) rewrite swig/Interp.i (96%) rewrite swig/Linalg.i (99%) rewrite swig/Machine.i (97%) rewrite swig/Matrix.i (98%) rewrite swig/Min.i (89%) rewrite swig/Monte.i (82%) rewrite swig/Multifit.i (96%) rewrite swig/Multimin.i (94%) rewrite swig/Multiroots.i (90%) rewrite swig/NTuple.i (90%) rewrite swig/ODEIV.i (97%) rewrite swig/Permutation.i (93%) rewrite swig/PowInt.i (94%) rewrite swig/QRNG.i (82%) rewrite swig/RNG.i (99%) rewrite swig/Randist.i (96%) rewrite swig/Roots.i (98%) rewrite swig/SF.i (96%) rewrite swig/Siman.i (91%) rewrite swig/Sort.i (72%) rewrite swig/Spline.i (91%) rewrite swig/Statistics.i (98%) rewrite swig/Sys.i (96%) rewrite swig/Vector.i (96%) rewrite swig/Wavelet.i (94%) rewrite swig/Wavelet2D.i (72%) create mode 100644 t/Heapsort.t create mode 100644 t/IEEEUtils.t create mode 100644 t/Multimin.t create mode 100644 t/Siman.t create mode 100644 t/Wavelet2D.t diff --git a/swig/Errno.i b/pod/Errno.pod similarity index 94% copy from swig/Errno.i copy to pod/Errno.pod index 12eea7a..ad0b6e7 100644 --- a/swig/Errno.i +++ b/pod/Errno.pod @@ -1,13 +1,3 @@ -%module "Math::GSL::Errno" -%include "typemaps.i" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_errno.h" - #include "gsl/gsl_types.h" -%} -%include "gsl/gsl_errno.h" -%include "gsl/gsl_types.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_error gsl_stream_printf gsl_strerror gsl_set_error_handler @@ -22,7 +12,7 @@ $GSL_ETABLE $GSL_ENOPROG $GSL_ENOPROGJ $GSL_ETOLF $GSL_ETOLX $GSL_ETOLG $GSL_EOF /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); +%EXPORT_TAGS = ( all => \@EXPORT_OK ); =head1 NAME diff --git a/swig/FFT.i b/pod/FFT.pod similarity index 92% copy from swig/FFT.i copy to pod/FFT.pod index 7effe19..a2726e6 100644 --- a/swig/FFT.i +++ b/pod/FFT.pod @@ -1,48 +1,3 @@ -%module "Math::GSL::FFT" -%include "typemaps.i" -%include "gsl_typemaps.i" - - -%typemap(argout) (double data[], const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < $3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (gsl_complex_packed_array data[], const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < 2*$3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%{ - #include "gsl/gsl_fft.h" - #include "gsl/gsl_fft_complex.h" - #include "gsl/gsl_fft_halfcomplex.h" - #include "gsl/gsl_fft_real.h" - #include "gsl/gsl_complex.h" -%} - -%include "gsl/gsl_complex.h" -%include "gsl/gsl_fft.h" -%include "gsl/gsl_fft_complex.h" -%include "gsl/gsl_fft_halfcomplex.h" -%include "gsl/gsl_fft_real.h" - %perlcode %{ @EXPORT_complex = qw/ gsl_fft_complex_radix2_forward diff --git a/swig/Fit.i b/pod/Fit.pod similarity index 96% copy from swig/Fit.i copy to pod/Fit.pod index 1d42b33..2ac1e0b 100644 --- a/swig/Fit.i +++ b/pod/Fit.pod @@ -1,17 +1,3 @@ -%module "Math::GSL::Fit" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * c0, double * c1, double * cov00, double * cov01, double * cov11, double * sumsq, double * chisq }; - -%{ -#include "gsl/gsl_fit.h" -%} - -%include "gsl/gsl_fit.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_fit_linear @@ -106,5 +92,4 @@ under the same terms as Perl itself. =cut - %} diff --git a/swig/Heapsort.i b/pod/Heapsort.pod similarity index 88% copy from swig/Heapsort.i copy to pod/Heapsort.pod index 183d95c..4a793f1 100644 --- a/swig/Heapsort.i +++ b/pod/Heapsort.pod @@ -1,11 +1,3 @@ -%module "Math::GSL::Heapsort" -%{ - #include "gsl/gsl_heapsort.h" -%} - -%include "gsl/gsl_heapsort.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_heapsort @@ -23,7 +15,7 @@ Math::GSL::Heapsort - Functions for sorting data, both directly and indirectly ( This module is not yet implemented. Patches Welcome! -use Math::GSL::Heapsort qw /:all/; + use Math::GSL::Heapsort qw /:all/; =head1 DESCRIPTION diff --git a/swig/Histogram.i b/pod/Histogram.pod similarity index 98% copy from swig/Histogram.i copy to pod/Histogram.pod index f033e61..1488c43 100644 --- a/swig/Histogram.i +++ b/pod/Histogram.pod @@ -1,16 +1,3 @@ -%module "Math::GSL::Histogram" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * lower, double * upper, size_t * i}; - -%{ - #include "gsl/gsl_histogram.h" -%} - -%include "gsl/gsl_histogram.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_histogram_alloc @@ -54,7 +41,7 @@ gsl_histogram_pdf_free gsl_histogram_pdf_sample /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); +%EXPORT_TAGS = ( all => \@EXPORT_OK ); =head1 NAME diff --git a/swig/Histogram2D.i b/pod/Histogram2D.pod similarity index 98% copy from swig/Histogram2D.i copy to pod/Histogram2D.pod index 7768f26..f9c7d35 100644 --- a/swig/Histogram2D.i +++ b/pod/Histogram2D.pod @@ -1,17 +1,3 @@ -%module "Math::GSL::Histogram2D" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * xlower, double * xupper, double * ylower, double * yupper, double * x, double * y}; -%apply int *OUTPUT { size_t * i, size_t * j }; - -%{ - #include "gsl/gsl_histogram2d.h" -%} - -%include "gsl/gsl_histogram2d.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_histogram2d_alloc @@ -245,3 +231,5 @@ under the same terms as Perl itself. =cut %} +%include "../pod/Histogram2D.pod" + diff --git a/swig/IEEEUtils.i b/pod/IEEEUtils.pod similarity index 91% copy from swig/IEEEUtils.i copy to pod/IEEEUtils.pod index 809b7e5..9fb6ebe 100644 --- a/swig/IEEEUtils.i +++ b/pod/IEEEUtils.pod @@ -1,10 +1,3 @@ -%module "Math::GSL::IEEEUtils" -%{ - #include "gsl/gsl_ieee_utils.h" -%} - -%include "gsl/gsl_ieee_utils.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_ieee_printf_float @@ -38,3 +31,4 @@ /; %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); %} + diff --git a/swig/Integration.i b/pod/Integration.pod similarity index 97% copy from swig/Integration.i copy to pod/Integration.pod index d7dd6a7..8ce18a6 100644 --- a/swig/Integration.i +++ b/pod/Integration.pod @@ -1,14 +1,3 @@ -%module "Math::GSL::Integration" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_integration.h" - #include "gsl/gsl_math.h" -%} -%include "gsl/gsl_integration.h" -%include "gsl/gsl_math.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_integration_workspace_alloc @@ -256,3 +245,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Interp.i b/pod/Interp.pod similarity index 95% copy from swig/Interp.i copy to pod/Interp.pod index 3fcad90..fa26226 100644 --- a/swig/Interp.i +++ b/pod/Interp.pod @@ -1,18 +1,3 @@ -%module "Math::GSL::Interp" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_interp.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_interp.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_interp_accel_alloc @@ -40,13 +25,13 @@ $gsl_interp_akima $gsl_interp_akima_periodic /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); +%EXPORT_TAGS = ( all => \@EXPORT_OK ); __END__ =head1 NAME -Math::GSL::Interp - Functions for performing interpolation +Math::GSL::Interp - Interpolation =head1 SYNOPSIS @@ -137,3 +122,4 @@ under the same terms as Perl itself. %} + diff --git a/swig/Linalg.i b/pod/Linalg.pod similarity index 99% copy from swig/Linalg.i copy to pod/Linalg.pod index e81f826..c5537df 100644 --- a/swig/Linalg.i +++ b/pod/Linalg.pod @@ -1,14 +1,3 @@ -%module "Math::GSL::Linalg" -%apply int *OUTPUT { int *signum }; - -%{ - #include "gsl/gsl_linalg.h" - #include "gsl/gsl_permutation.h" -%} - -%include "gsl/gsl_linalg.h" -%include "gsl/gsl_permutation.h" - %perlcode %{ @EXPORT_OK = qw/$GSL_LINALG_MOD_NONE $GSL_LINALG_MOD_TRANSPOSE $GSL_LINALG_MOD_CONJUGATE gsl_linalg_matmult gsl_linalg_matmult_mod @@ -405,3 +394,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Machine.i b/pod/Machine.pod similarity index 97% copy from swig/Machine.i copy to pod/Machine.pod index 7a51665..c25ccd1 100644 --- a/swig/Machine.i +++ b/pod/Machine.pod @@ -1,11 +1,3 @@ -%module "Math::GSL::Machine" -%{ - #include "gsl/gsl_machine.h" -%} - -%include "gsl/gsl_machine.h" - - %perlcode %{ @EXPORT_OK = qw/ $GSL_DBL_EPSILON @@ -209,3 +201,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Matrix.i b/pod/Matrix.pod similarity index 98% copy from swig/Matrix.i copy to pod/Matrix.pod index 049da1c..c34441a 100644 --- a/swig/Matrix.i +++ b/pod/Matrix.pod @@ -1,29 +1,3 @@ -%module "Math::GSL::Matrix" - -%include "typemaps.i" -%include "gsl_typemaps.i" -%apply int *OUTPUT { size_t *imin, size_t *imax, size_t *jmin, size_t *jmax }; -%apply double *OUTPUT { double * min_out, double * max_out }; - -%{ - #include "gsl/gsl_matrix.h" - #include "gsl/gsl_complex.h" - #include "gsl/gsl_vector_double.h" - #include "gsl/gsl_matrix_double.h" - #include "gsl/gsl_matrix_int.h" - #include "gsl/gsl_matrix_complex_double.h" - #include "gsl/gsl_matrix_char.h" -%} - -%include "gsl/gsl_matrix.h" -%include "gsl/gsl_complex.h" -%include "gsl/gsl_vector_double.h" -%include "gsl/gsl_matrix_double.h" -%include "gsl/gsl_matrix_int.h" -%include "gsl/gsl_matrix_complex_double.h" -%include "gsl/gsl_matrix_char.h" - - %perlcode %{ use Carp qw/croak/; @@ -1187,3 +1161,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Min.i b/pod/Min.pod similarity index 89% copy from swig/Min.i copy to pod/Min.pod index aae7f1f..66f2a50 100644 --- a/swig/Min.i +++ b/pod/Min.pod @@ -1,15 +1,3 @@ -%module "Math::GSL::Min" -%include "typemaps.i" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_min.h" - #include "gsl/gsl_math.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_min.h" -%include "gsl/gsl_math.h" - %perlcode %{ @EXPORT_OK = qw/ @@ -114,3 +102,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Monte.i b/pod/Monte.pod similarity index 82% copy from swig/Monte.i copy to pod/Monte.pod index ba0088a..57baebd 100644 --- a/swig/Monte.i +++ b/pod/Monte.pod @@ -1,22 +1,3 @@ -%module "Math::GSL::Monte" -%include "gsl/gsl_monte.h" -%include "gsl/gsl_monte_miser.h" -%include "gsl/gsl_monte_plain.h" -%include "gsl/gsl_monte_vegas.h" -%include "gsl/gsl_types.h" -%include "gsl/gsl_errno.h" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_monte.h" - #include "gsl/gsl_monte_miser.h" - #include "gsl/gsl_monte_plain.h" - #include "gsl/gsl_monte_vegas.h" - #include "gsl/gsl_types.h" - #include "gsl/gsl_errno.h" -%} - %perlcode %{ @EXPORT_OK = qw/ gsl_monte_miser_integrate @@ -114,3 +95,4 @@ under the same terms as Perl itself. %} + diff --git a/swig/Multifit.i b/pod/Multifit.pod similarity index 96% copy from swig/Multifit.i copy to pod/Multifit.pod index ffbba74..3239563 100644 --- a/swig/Multifit.i +++ b/pod/Multifit.pod @@ -1,18 +1,3 @@ -%module "Math::GSL::Multifit" - -%include "typemaps.i" -%apply double *OUTPUT { double * y, double * y_err, double * chisq, size_t * rank}; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multifit.h" - #include "gsl/gsl_multifit_nlin.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multifit.h" -%include "gsl/gsl_multifit_nlin.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_multifit_linear_alloc @@ -142,3 +127,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Multimin.i b/pod/Multimin.pod similarity index 64% copy from swig/Multimin.i copy to pod/Multimin.pod index 1b05c4a..8b83687 100644 --- a/swig/Multimin.i +++ b/pod/Multimin.pod @@ -1,40 +1,30 @@ -%module "Math::GSL::Multimin" - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multimin.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multimin.h" - %perlcode %{ @EXPORT_OK = qw/ - gsl_multimin_fdfminimizer_alloc - gsl_multimin_fminimizer_alloc - gsl_multimin_fdfminimizer_set - gsl_multimin_fdfminimizer_free - gsl_multimin_fminimizer_free - gsl_multimin_fdfminimizer_name - gsl_multimin_fminimizer_name - gsl_multimin_fdfminimizer_iterate - gsl_multimin_fminimizer_iterate - gsl_multimin_fdfminimizer_x - gsl_multimin_fminimizer_x - gsl_multimin_fdfminimizer_minimum - gsl_multimin_fminimizer_minimum - gsl_multimin_fdfminimizer_gradient - gsl_multimin_fminimizer_size - gsl_multimin_fdfminimizer_restart - gsl_multimin_test_gradient - gsl_multimin_test_size - $gsl_multimin_fdfminimizer_conjugate_fr - $gsl_multimin_fdfminimizer_conjugate_pr - $gsl_multimin_fdfminimizer_vector_bfgs2 - $gsl_multimin_fdfminimizer_vector_bfgs - $gsl_multimin_fdfminimizer_steepest_descent - $gsl_multimin_fminimizer_nmsimplex + gsl_multimin_fdfminimizer_alloc + gsl_multimin_fminimizer_alloc + gsl_multimin_fdfminimizer_set + gsl_multimin_fdfminimizer_free + gsl_multimin_fminimizer_free + gsl_multimin_fdfminimizer_name + gsl_multimin_fminimizer_name + gsl_multimin_fdfminimizer_iterate + gsl_multimin_fminimizer_iterate + gsl_multimin_fdfminimizer_x + gsl_multimin_fminimizer_x + gsl_multimin_fdfminimizer_minimum + gsl_multimin_fminimizer_minimum + gsl_multimin_fdfminimizer_gradient + gsl_multimin_fminimizer_size + gsl_multimin_fdfminimizer_restart + gsl_multimin_test_gradient + gsl_multimin_test_size + $gsl_multimin_fdfminimizer_conjugate_fr + $gsl_multimin_fdfminimizer_conjugate_pr + $gsl_multimin_fdfminimizer_vector_bfgs2 + $gsl_multimin_fdfminimizer_vector_bfgs + $gsl_multimin_fdfminimizer_steepest_descent + $gsl_multimin_fminimizer_nmsimplex /; %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); @@ -133,3 +123,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Multiroots.i b/pod/Multiroots.pod similarity index 90% copy from swig/Multiroots.i copy to pod/Multiroots.pod index d42dcb2..65d64c2 100644 --- a/swig/Multiroots.i +++ b/pod/Multiroots.pod @@ -1,21 +1,3 @@ -%module "Math::GSL::Multiroots" -%include "gsl_typemaps.i" - -%typemap(in) gsl_multiroot_function * { - gsl_multiroot_function *f; - /* stub */ - $1 = &f; -} - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multiroots.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multiroots.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_multiroot_fdjacobian @@ -126,3 +108,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/NTuple.i b/pod/NTuple.pod similarity index 90% copy from swig/NTuple.i copy to pod/NTuple.pod index b3eeba7..e1652cc 100644 --- a/swig/NTuple.i +++ b/pod/NTuple.pod @@ -1,22 +1,3 @@ -%module "Math::GSL::NTuple" - -%typemap(in) void *ntuple_data { - fprintf(stderr,"symname=$symname\n"); - if ($input) - $1 = (double *) $input; -}; - -%typemap(argout) void *ntuple_data { - //Perl_sv_dump($1); -} - -%{ - #include "gsl/gsl_ntuple.h" -%} - -%include "gsl/gsl_ntuple.h" - - %perlcode %{ # Intermittent failure happens *after* this @@ -89,3 +70,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/ODEIV.i b/pod/ODEIV.pod similarity index 97% copy from swig/ODEIV.i copy to pod/ODEIV.pod index 6becdc9..16a30a3 100644 --- a/swig/ODEIV.i +++ b/pod/ODEIV.pod @@ -1,12 +1,3 @@ -%module "Math::GSL::ODEIV" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_odeiv.h" - #include "gsl/gsl_types.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_odeiv.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_odeiv_step_alloc @@ -162,3 +153,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Permutation.i b/pod/Permutation.pod similarity index 93% copy from swig/Permutation.i copy to pod/Permutation.pod index 12f2c17..30ae068 100644 --- a/swig/Permutation.i +++ b/pod/Permutation.pod @@ -1,24 +1,3 @@ -%module "Math::GSL::Permutation" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_permute.h" - #include "gsl/gsl_permute_double.h" - #include "gsl/gsl_permute_int.h" - #include "gsl/gsl_permute_vector.h" - #include "gsl/gsl_permute_vector_double.h" - #include "gsl/gsl_permute_vector_int.h" - #include "gsl/gsl_permutation.h" -%} -%include "gsl/gsl_permute.h" -%include "gsl/gsl_permute_double.h" -%include "gsl/gsl_permute_int.h" -%include "gsl/gsl_permute_vector.h" -%include "gsl/gsl_permute_vector_double.h" -%include "gsl/gsl_permute_vector_int.h" -%include "gsl/gsl_permutation.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_permutation_alloc @@ -226,3 +205,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Poly.i b/pod/Poly.pod similarity index 58% copy from swig/Poly.i copy to pod/Poly.pod index 96bbaf8..948d95f 100644 --- a/swig/Poly.i +++ b/pod/Poly.pod @@ -1,111 +1,3 @@ -%module "Math::GSL::Poly" -// this brakes stuff -// %include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_sys.h" -%} -%include "gsl/gsl_sys.h" - -%typemap(in) double * (double dvalue) { - SV* tempsv; - if (!SvROK($input)) { - croak("$input is not a reference!\n"); - } - tempsv = SvRV($input); - if ((!SvNOK(tempsv)) && (!SvIOK(tempsv))) { - croak("$input is not a reference to number!\n"); - } - dvalue = SvNV(tempsv); - $1 = &dvalue; -} - -#gsl_complex gsl_complex_poly_complex_eval (const gsl_complex c [], const int len, const gsl_complex z); - -%typemap(argout) gsl_complex { - AV* tempav = newAV(); - double x,y; - if (argvi >= items) { - EXTEND(sp,1); - } - //fprintf(stderr,"--> %g <--\n", GSL_REAL($1)); - //fprintf(stderr,"--> %g <--\n", GSL_IMAG($1)); - - $result = sv_newmortal(); - - x = GSL_REAL($1); - y = GSL_IMAG($1); - - /* the next 2 lines blow up - sv_setnv($result, x); - argvi++; - */ -}; - -%typemap(argout) double * { - SV *tempsv; - tempsv = SvRV($input); - sv_setnv(tempsv, *$1); -} - -%typemap(in) gsl_complex const [] { - AV *tempav; - I32 len; - int i, magic, stuff; - double x,y; - gsl_complex z; - SV **elem, **helem, **real, **imag; - HV *hash, *htmp; - SV *svtmp, tmp; - double result[2]; - - printf("gsl_complex typemap\n"); - if (!SvROK($input)) - croak("Math::GSL : $input is not a reference!"); - if (SvTYPE(SvRV($input)) != SVt_PVAV) - croak("Math::GSL : $input is not an array ref!"); - - z = gsl_complex_rect(0,0); - tempav = (AV*)SvRV($input); - len = av_len(tempav); - $1 = (gsl_complex *) malloc((len+1)*sizeof(gsl_complex)); - for (i = 0; i <= len; i++) { - elem = av_fetch(tempav, i, 0); - - hash = (HV*) SvRV(*elem); - helem = hv_fetch(hash, "dat", 3, 0); - magic = mg_get(*helem); - if ( magic != 0) - croak("FETCH magic failed!\n"); - - printf("magic = %d\n", magic); - if( *helem == NULL) - croak("Structure does not contain 'dat' element\n"); - printf("helem is:\n"); - //Perl_sv_dump(*helem); - if( i == 0){ - svtmp = (SV*)SvRV(*helem); - //Perl_sv_dump(svtmp); - } - printf("re z = %f\n", GSL_REAL(z) ); - printf("im z = %f\n", GSL_IMAG(z) ); - $1[i] = z; - } -} -%{ - #include "gsl/gsl_nan.h" - #include "gsl/gsl_poly.h" - #include "gsl/gsl_complex.h" - #include "gsl/gsl_complex_math.h" -%} - -%include "gsl/gsl_nan.h" -%include "gsl/gsl_poly.h" -%include "gsl/gsl_complex.h" -%include "gsl/gsl_complex_math.h" - - %perlcode %{ @EXPORT_OK = qw/ @@ -207,3 +99,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/PowInt.i b/pod/PowInt.pod similarity index 94% copy from swig/PowInt.i copy to pod/PowInt.pod index e4ca548..d6f7eae 100644 --- a/swig/PowInt.i +++ b/pod/PowInt.pod @@ -1,10 +1,3 @@ -%module "Math::GSL::PowInt" -%{ - #include "gsl/gsl_pow_int.h" -%} - -%include "gsl/gsl_pow_int.h" - %perlcode %{ our @EXPORT_OK = qw/gsl_pow_2 gsl_pow_2 gsl_pow_3 @@ -64,3 +57,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/QRNG.i b/pod/QRNG.pod similarity index 82% copy from swig/QRNG.i copy to pod/QRNG.pod index 7bcdc9d..8c9e35f 100644 --- a/swig/QRNG.i +++ b/pod/QRNG.pod @@ -1,35 +1,3 @@ -%module "Math::GSL::QRNG" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double x[] }; - - -%typemap(argout) double x[] { - AV *tempav; - I32 len; - int i; - SV **tv; - if (argvi >= items) { - EXTEND(sp,1); - } - $result = sv_newmortal(); - sv_setnv($result,(NV) *($1)); - argvi++; - - $result = sv_newmortal(); - sv_setnv($result,(NV) *($1+1)); - argvi++; -} - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_qrng.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_qrng.h" - %perlcode %{ @EXPORT_OK = qw($gsl_qrng_niederreiter_2 $gsl_qrng_sobol $gsl_qrng_halton $gsl_qrng_reversehalton @@ -110,3 +78,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/RNG.i b/pod/RNG.pod similarity index 99% copy from swig/RNG.i copy to pod/RNG.pod index bc75795..5f67d42 100644 --- a/swig/RNG.i +++ b/pod/RNG.pod @@ -1,11 +1,3 @@ -%module "Math::GSL::RNG" -%{ - #include "gsl/gsl_rng.h" -%} -%import "gsl/gsl_types.h" - -%include "gsl/gsl_rng.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_rng_alloc gsl_rng_set gsl_rng_get gsl_rng_free gsl_rng_memcpy @@ -381,3 +373,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Randist.i b/pod/Randist.pod similarity index 96% copy from swig/Randist.i copy to pod/Randist.pod index adb0649..0889211 100644 --- a/swig/Randist.i +++ b/pod/Randist.pod @@ -1,41 +1,3 @@ -%module "Math::GSL::Randist" -%include "typemaps.i" - -void gsl_ran_dir_2d (const gsl_rng * r, double *OUTPUT, double *OUTPUT); -void gsl_ran_dir_2d_trig_method (const gsl_rng * r, double *OUTPUT, double *OUTPUT); -void gsl_ran_dir_3d (const gsl_rng * r, double *OUTPUT, double *OUTPUT, double *OUTPUT); -void gsl_ran_bivariate_gaussian (const gsl_rng * r, double sigma_x, double sigma_y, double rho, double *OUTPUT, double *OUTPUT); - -%typemap(in) void * { - AV *tempav; - I32 len; - int i,x; - SV **tv; - - if (!SvROK($input)) - croak("Argument $argnum is not a reference."); - if (SvTYPE(SvRV($input)) != SVt_PVAV) - croak("Argument $argnum is not an array."); - - tempav = (AV*)SvRV($input); - len = av_len(tempav); - $1 = (int **) malloc((len+2)*sizeof(int *)); - for (i = 0; i <= len; i++) { - tv = av_fetch(tempav, i, 0); - x = SvIV(*tv); - memset((int*)($1+i), x , 1); - //printf("curr = %d\n", (int)($1+i) ); - } -}; -%typemap(freearg) void * { - free($1); -} - -%{ - #include "gsl/gsl_randist.h" -%} -%include "gsl/gsl_randist.h" - %perlcode %{ our @EXPORT_OK = qw/gsl_ran_bernoulli gsl_ran_bernoulli_pdf gsl_ran_beta @@ -446,3 +408,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Roots.i b/pod/Roots.pod similarity index 98% copy from swig/Roots.i copy to pod/Roots.pod index b278a85..c8be079 100644 --- a/swig/Roots.i +++ b/pod/Roots.pod @@ -1,13 +1,3 @@ -%module "Math::GSL::Roots" -%include "gsl_typemaps.i" -%include "typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_roots.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_roots.h" - %perlcode %{ @EXPORT_OK = qw/ gsl_root_fsolver_alloc @@ -151,3 +141,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/SF.i b/pod/SF.pod similarity index 96% copy from swig/SF.i copy to pod/SF.pod index cb02021..5c84b64 100644 --- a/swig/SF.i +++ b/pod/SF.pod @@ -1,84 +1,3 @@ -%module "Math::GSL::SF" -%include "typemaps.i" - -%apply double *OUTPUT { double * sn, double * cn, double * dn, double * sgn }; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_version.h" - #include "gsl/gsl_mode.h" - #include "gsl/gsl_sf.h" - #include "gsl/gsl_sf_airy.h" - #include "gsl/gsl_sf_bessel.h" - #include "gsl/gsl_sf_clausen.h" - #include "gsl/gsl_sf_coulomb.h" - #include "gsl/gsl_sf_coupling.h" - #include "gsl/gsl_sf_dawson.h" - #include "gsl/gsl_sf_debye.h" - #include "gsl/gsl_sf_dilog.h" - #include "gsl/gsl_sf_elementary.h" - #include "gsl/gsl_sf_ellint.h" - #include "gsl/gsl_sf_elljac.h" - #include "gsl/gsl_sf_erf.h" - #include "gsl/gsl_sf_exp.h" - #include "gsl/gsl_sf_expint.h" - #include "gsl/gsl_sf_fermi_dirac.h" - #include "gsl/gsl_sf_gamma.h" - #include "gsl/gsl_sf_gegenbauer.h" - #include "gsl/gsl_sf_hyperg.h" - #include "gsl/gsl_sf_laguerre.h" - #include "gsl/gsl_sf_lambert.h" - #include "gsl/gsl_sf_legendre.h" - #include "gsl/gsl_sf_log.h" -#ifdef GSL_VERSION && GSL_VERSION == "1.11" - #include "gsl/gsl_sf_mathieu.h" -#endif - #include "gsl/gsl_sf_pow_int.h" - #include "gsl/gsl_sf_psi.h" - #include "gsl/gsl_sf_result.h" - #include "gsl/gsl_sf_synchrotron.h" - #include "gsl/gsl_sf_transport.h" - #include "gsl/gsl_sf_trig.h" - #include "gsl/gsl_sf_zeta.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_version.h" -%include "gsl/gsl_mode.h" -%include "gsl/gsl_sf.h" -%include "gsl/gsl_sf_airy.h" -%include "gsl/gsl_sf_bessel.h" -%include "gsl/gsl_sf_clausen.h" -%include "gsl/gsl_sf_coulomb.h" -%include "gsl/gsl_sf_coupling.h" -%include "gsl/gsl_sf_dawson.h" -%include "gsl/gsl_sf_debye.h" -%include "gsl/gsl_sf_dilog.h" -%include "gsl/gsl_sf_elementary.h" -%include "gsl/gsl_sf_ellint.h" -%include "gsl/gsl_sf_elljac.h" -%include "gsl/gsl_sf_erf.h" -%include "gsl/gsl_sf_exp.h" -%include "gsl/gsl_sf_expint.h" -%include "gsl/gsl_sf_fermi_dirac.h" -%include "gsl/gsl_sf_gamma.h" -%include "gsl/gsl_sf_gegenbauer.h" -%include "gsl/gsl_sf_hyperg.h" -%include "gsl/gsl_sf_laguerre.h" -%include "gsl/gsl_sf_lambert.h" -%include "gsl/gsl_sf_legendre.h" -%include "gsl/gsl_sf_log.h" -#ifdef GSL_VERSION && GSL_VERSION == '1.11' - %include "gsl/gsl_sf_mathieu.h" -#endif -%include "gsl/gsl_sf_pow_int.h" -%include "gsl/gsl_sf_psi.h" -%include "gsl/gsl_sf_result.h" -%include "gsl/gsl_sf_synchrotron.h" -%include "gsl/gsl_sf_transport.h" -%include "gsl/gsl_sf_trig.h" -%include "gsl/gsl_sf_zeta.h" - - %perlcode %{ @EXPORT_airy = qw/ @@ -3227,3 +3146,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Siman.i b/pod/Siman.pod similarity index 91% copy from swig/Siman.i copy to pod/Siman.pod index f2978ef..24dc31a 100644 --- a/swig/Siman.i +++ b/pod/Siman.pod @@ -1,11 +1,3 @@ -%module "Math::GSL::Siman" -%{ - #include "gsl/gsl_siman.h" -%} - -%include "gsl/gsl_siman.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_siman_solve @@ -60,3 +52,4 @@ under the same terms as Perl itself. %} + diff --git a/swig/Sort.i b/pod/Sort.pod similarity index 72% copy from swig/Sort.i copy to pod/Sort.pod index c548f36..5bc408e 100644 --- a/swig/Sort.i +++ b/pod/Sort.pod @@ -1,107 +1,3 @@ -%module "Math::GSL::Sort" -/* Danger Will Robinson! */ - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%typemap(argout) (double * data, const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < $3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - //Perl_sv_dump($result); - argvi++; -} -%typemap(argout) (double * dest, const size_t k, const gsl_vector * v) { - int i=0; - AV* tempav = newAV(); - - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (double * dest, const size_t k, const double * src, const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} -%typemap(argout) (size_t * p, const size_t k, const gsl_vector * v) -{ - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (size_t * p, const double * data, const size_t stride, const size_t n) -{ - int i=0; - AV* tempav = newAV(); - while( i < $4 ) { - av_push(tempav, newSVnv((size_t) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (size_t * p, const size_t k, const double * src, const size_t stride, const size_t n) -{ - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((size_t) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%apply double * { double *data, double *dest }; - -%{ - #include "gsl/gsl_nan.h" - #include "gsl/gsl_sort.h" - #include "gsl/gsl_sort_double.h" - #include "gsl/gsl_sort_int.h" - #include "gsl/gsl_sort_vector.h" - #include "gsl/gsl_sort_vector_double.h" - #include "gsl/gsl_sort_vector_int.h" - #include "gsl/gsl_permutation.h" -%} -%include "gsl/gsl_nan.h" -%include "gsl/gsl_sort.h" -%include "gsl/gsl_sort_double.h" -%include "gsl/gsl_sort_int.h" -%include "gsl/gsl_sort_vector.h" -%include "gsl/gsl_sort_vector_double.h" -%include "gsl/gsl_sort_vector_int.h" -%include "gsl/gsl_permutation.h" - - %perlcode %{ @EXPORT_plain = qw/ gsl_sort gsl_sort_index @@ -273,3 +169,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Spline.i b/pod/Spline.pod similarity index 91% copy from swig/Spline.i copy to pod/Spline.pod index 27abd94..e9a7dba 100644 --- a/swig/Spline.i +++ b/pod/Spline.pod @@ -1,16 +1,3 @@ -%module "Math::GSL::Spline" - -%include "typemaps.i" -%include "gsl_typemaps.i" -%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; - -%{ - #include "gsl/gsl_spline.h" -%} - -%include "gsl/gsl_spline.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_spline_alloc @@ -96,3 +83,4 @@ under the same terms as Perl itself. %} + diff --git a/swig/Statistics.i b/pod/Statistics.pod similarity index 98% copy from swig/Statistics.i copy to pod/Statistics.pod index 2e3831e..88daa8d 100644 --- a/swig/Statistics.i +++ b/pod/Statistics.pod @@ -1,23 +1,3 @@ -%module "Math::GSL::Statistics" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * min, double * max }; - -%apply int *OUTPUT { size_t * min_index, size_t * max_index }; - -%{ - #include "gsl/gsl_statistics_double.h" - #include "gsl/gsl_statistics_int.h" - #include "gsl/gsl_statistics_char.h" -%} - -%include "gsl/gsl_statistics_double.h" -%include "gsl/gsl_statistics_int.h" -%include "gsl/gsl_statistics_char.h" - - %perlcode %{ @EXPORT_OK = qw/ gsl_stats_mean @@ -431,3 +411,4 @@ under the same terms as Perl itself. %} + diff --git a/swig/Sys.i b/pod/Sys.pod similarity index 96% copy from swig/Sys.i copy to pod/Sys.pod index 1520939..a3115bd 100644 --- a/swig/Sys.i +++ b/pod/Sys.pod @@ -1,12 +1,3 @@ -%module "Math::GSL::Sys" - -%include "typemaps.i" -%apply int *OUTPUT { int * e }; - -%{ - #include "gsl/gsl_sys.h" -%} -%include "gsl/gsl_sys.h" %perlcode %{ our @EXPORT = qw(); our @EXPORT_OK = qw/ @@ -111,3 +102,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Vector.i b/pod/Vector.pod similarity index 96% copy from swig/Vector.i copy to pod/Vector.pod index 35d9455..69071ce 100644 --- a/swig/Vector.i +++ b/pod/Vector.pod @@ -1,32 +1,3 @@ -%module "Math::GSL::Vector" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -FILE * fopen(char *, char *); -int fclose(FILE *); - -%{ - #include "gsl/gsl_nan.h" - #include "gsl/gsl_vector.h" - #include "gsl/gsl_vector_char.h" - #include "gsl/gsl_vector_complex.h" - #include "gsl/gsl_vector_complex_double.h" - #include "gsl/gsl_vector_double.h" - #include "gsl/gsl_vector_float.h" - #include "gsl/gsl_vector_int.h" -%} - -%include "gsl/gsl_nan.h" -%include "gsl/gsl_vector.h" -%include "gsl/gsl_vector_char.h" -%include "gsl/gsl_vector_complex.h" -%include "gsl/gsl_vector_complex_double.h" -%include "gsl/gsl_vector_double.h" -%include "gsl/gsl_vector_int.h" - - - %perlcode %{ use Scalar::Util 'blessed'; use Data::Dumper; @@ -475,3 +446,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Wavelet.i b/pod/Wavelet.pod similarity index 94% copy from swig/Wavelet.i copy to pod/Wavelet.pod index bf30e70..11f052c 100644 --- a/swig/Wavelet.i +++ b/pod/Wavelet.pod @@ -1,18 +1,3 @@ -%module "Math::GSL::Wavelet" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_wavelet.h" -%} - -typedef int size_t; - -%include "gsl/gsl_types.h" -%include "gsl/gsl_wavelet.h" - -%include "typemaps.i" - - %perlcode %{ @@ -125,3 +110,4 @@ under the same terms as Perl itself. =cut %} + diff --git a/swig/Wavelet2D.i b/pod/Wavelet2D.pod similarity index 72% copy from swig/Wavelet2D.i copy to pod/Wavelet2D.pod index ef730a8..2ae5544 100644 --- a/swig/Wavelet2D.i +++ b/pod/Wavelet2D.pod @@ -1,15 +1,3 @@ -%module "Math::GSL::Wavelet2D" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_wavelet2d.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_wavelet2d.h" - %perlcode %{ @EXPORT_OK = qw/ @@ -31,3 +19,4 @@ %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); %} + diff --git a/swig/Errno.i b/swig/Errno.i dissimilarity index 95% index 12eea7a..2a93a34 100644 --- a/swig/Errno.i +++ b/swig/Errno.i @@ -1,210 +1,10 @@ -%module "Math::GSL::Errno" -%include "typemaps.i" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_errno.h" - #include "gsl/gsl_types.h" -%} -%include "gsl/gsl_errno.h" -%include "gsl/gsl_types.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_error gsl_stream_printf gsl_strerror gsl_set_error_handler - gsl_set_error_handler_off gsl_set_stream_handler gsl_set_stream - $GSL_SUCCESS $GSL_FAILURE $GSL_CONTINUE $GSL_EDOM - $GSL_ERANGE $GSL_EFAULT $GSL_EINVAL $GSL_EFAILED - $GSL_EFACTOR $GSL_ESANITY $GSL_ENOMEM $GSL_EBADFUNC - $GSL_ERUNAWAY $GSL_EMAXITER $GSL_EZERODIV $GSL_EBADTOL - $GSL_ETOL $GSL_EUNDRFLW $GSL_EOVRFLW $GSL_ELOSS - $GSL_EROUND $GSL_EBADLEN $GSL_ENOTSQR $GSL_ESING - $GSL_EDIVERGE $GSL_EUNSUP $GSL_EUNIMPL $GSL_ECACHE - $GSL_ETABLE $GSL_ENOPROG $GSL_ENOPROGJ $GSL_ETOLF - $GSL_ETOLX $GSL_ETOLG $GSL_EOF - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -=head1 NAME - -Math::GSL::Errno - Error Handling - -=cut - -=head1 SYNOPSIS - - use Math::GSL::Errno qw/:all/; - gsl_set_error_handler_off(); - - print gsl_strerror($GSL_EDOM) . "\n"; - -=head1 STATUS CODES - -=over 4 - -=item * $GSL_SUCCESS - -Success - -=item * $GSL_FAILURE - -General Failure - -=item * $GSL_CONTINUE - -Iteration has not converged - -=item * $GSL_EDOM - -Domain error; used by mathematical functions when an argument value does not fall into the domain over which the function is defined (like EDOM in the C library) - -=item * $GSL_ERANGE - -Range error; used by mathematical functions when the result value is not representable because of overflow or underflow (like ERANGE in the C library) - -=item * $GSL_EFAULT - -Invalid Pointer - -=item * $GSL_EINVAL - -Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function (like EINVAL in the C library).Invalid argument. This is used to indicate various kinds of problems with passing the wrong argument to a library function (like EINVAL in the C library). - -=item * $GSL_EFAILED - -Generic Failure - -=item * $GSL_EFACTOR - -Factorization Failed - -=item * $GSL_ESANITY - -Sanity Check Failed - -=item * $GSL_ENOMEM - -No memory available. The system cannot allocate more virtual memory because its capacity is full (like ENOMEM in the C library). This error is reported when a GSL routine encounters problems when trying to allocate memory with malloc. - -=item * $GSL_EBADFUNC - -Problem with user-supplied function - -=item * $GSL_ERUNAWAY - -Iterative process is our of control - -=item * $GSL_EMAXITER - -Exceeded max number of iterations - -=item * $GSL_EZERODIV - -Division by zero - -=item * $GSL_EBADTOL - -Invalid user-specified tolerance - -=item * $GSL_ETOL - -Failed to reach the specified tolerance - -=item * $GSL_EUNDRFLW - -Underflow - -=item * $GSL_EOVRFLW - -Overflow - -=item * $GSL_ELOSS - -Loss of accuracy - -=item * $GSL_EROUND - -Failed due to roundoff error - -=item * $GSL_EBADLEN - -Matrix/vector lengths not compatible - -=item * $GSL_ENOTSQR - -Not a square matrix - -=item * $GSL_ESING - -Singularity Detected - -=item * $GSL_EDIVERGE - -Integral/Series is divergent - -=item * $GSL_EUNSUP - -Not supported by hardware - -=item * $GSL_EUNIMPL - -Not implemented - -=item * $GSL_ECACHE - -Cache limit exceeded - -=item * $GSL_ETABLE - -Table limit exceeded - -=item * $GSL_ENOPROG - -Iteration not converging - -=item * $GSL_ENOPROGJ - -Jacobian not improving solution - -=item * $GSL_ETOLF - -Cannot reach tolerance in F - -=item * $GSL_ETOLX - -Cannot reach tolerance in X - -=item * $GSL_ETOLG - -Cannot reach tolerance in Gradient - -=item * $GSL_EOF - -End of file - -=back - -=head1 FUNCTIONS - -=over - -=item * gsl_error - -=item * gsl_stream_printf - -=item * gsl_strerror($gsl_errno) - This function returns a pointer to a string describing the error code gsl_errno. For example, print ("error: gsl_strerror ($status)\n"); would print an error message like error: output range error for a status value of GSL_ERANGE. - -=item * gsl_set_error_handler - -=item * gsl_set_error_handler_off() - This function turns off the error handler by defining an error handler which does nothing. This will cause the program to continue after any error, so the return values from any library routines must be checked. This is the recommended behavior for production programs. The previous handler is returned (so that you can restore it later). - -=item * gsl_set_stream_handler - -=item * gsl_set_stream - -=back - -=cut - -1; - -%} +%module "Math::GSL::Errno" +%include "typemaps.i" +%include "gsl_typemaps.i" +%{ + #include "gsl/gsl_errno.h" + #include "gsl/gsl_types.h" +%} +%include "gsl/gsl_errno.h" +%include "gsl/gsl_types.h" +%include "../pod/Errno.pod" diff --git a/swig/FFT.i b/swig/FFT.i dissimilarity index 92% index 7effe19..47a0278 100644 --- a/swig/FFT.i +++ b/swig/FFT.i @@ -1,342 +1,45 @@ -%module "Math::GSL::FFT" -%include "typemaps.i" -%include "gsl_typemaps.i" - - -%typemap(argout) (double data[], const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < $3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (gsl_complex_packed_array data[], const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < 2*$3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%{ - #include "gsl/gsl_fft.h" - #include "gsl/gsl_fft_complex.h" - #include "gsl/gsl_fft_halfcomplex.h" - #include "gsl/gsl_fft_real.h" - #include "gsl/gsl_complex.h" -%} - -%include "gsl/gsl_complex.h" -%include "gsl/gsl_fft.h" -%include "gsl/gsl_fft_complex.h" -%include "gsl/gsl_fft_halfcomplex.h" -%include "gsl/gsl_fft_real.h" - -%perlcode %{ -@EXPORT_complex = qw/ - gsl_fft_complex_radix2_forward - gsl_fft_complex_radix2_backward - gsl_fft_complex_radix2_inverse - gsl_fft_complex_radix2_transform - gsl_fft_complex_radix2_dif_forward - gsl_fft_complex_radix2_dif_backward - gsl_fft_complex_radix2_dif_inverse - gsl_fft_complex_radix2_dif_transform - gsl_fft_complex_wavetable_alloc - gsl_fft_complex_wavetable_free - gsl_fft_complex_workspace_alloc - gsl_fft_complex_workspace_free - gsl_fft_complex_memcpy - gsl_fft_complex_forward - gsl_fft_complex_backward - gsl_fft_complex_inverse - gsl_fft_complex_transform - /; -@EXPORT_halfcomplex = qw/ - gsl_fft_halfcomplex_radix2_backward - gsl_fft_halfcomplex_radix2_inverse - gsl_fft_halfcomplex_radix2_transform - gsl_fft_halfcomplex_wavetable_alloc - gsl_fft_halfcomplex_wavetable_free - gsl_fft_halfcomplex_backward - gsl_fft_halfcomplex_inverse - gsl_fft_halfcomplex_transform - gsl_fft_halfcomplex_unpack - gsl_fft_halfcomplex_radix2_unpack - /; -@EXPORT_real = qw/ - gsl_fft_real_radix2_transform - gsl_fft_real_wavetable_alloc - gsl_fft_real_wavetable_free - gsl_fft_real_workspace_alloc - gsl_fft_real_workspace_free - gsl_fft_real_transform - gsl_fft_real_unpack - /; -@EXPORT_vars = qw/ - $gsl_fft_forward - $gsl_fft_backward - /; -@EXPORT_OK = ( - @EXPORT_real, - @EXPORT_complex, - @EXPORT_halfcomplex, - @EXPORT_vars, - ); -%EXPORT_TAGS = ( - all => \@EXPORT_OK, - real => \@EXPORT_real, - complex => \@EXPORT_complex, - halfcomplex => \@EXPORT_halfcomplex, - vars => \@EXPORT_vars, - ); -__END__ - -=head1 NAME - -Math::GSL::FFT - Fast Fourier Transforms (FFT) - -=head1 SYNOPSIS - - use Math::GSL::FFT qw /:all/; - # alternating elements are real/imaginary part, hence 256 element array - my $data = [ (1) x 10, (0) x 236, (1) x 10 ]; - - # use every element of the array - my $stride = 1; - - # But it contains 128 complex numbers - my ($status, $fft) = gsl_fft_complex_radix2_forward ($data, $stride, 128); - -=head1 DESCRIPTION - -This module and this documentation is still in a very early state. Danger Will Robinson! -An OO interface will evolve soon. - -=over - -=item * C - -This function computes the forward FFTs of length $n with stride $stride, on -the array reference $data using an in-place radix-2 decimation-in-time -algorithm. The length of the transform $n is restricted to powers of two. For -the transform version of the function the sign argument can be either forward -(-1) or backward (+1). The functions return a value of $GSL_SUCCESS if no -errors were detected, or $GSL_EDOM if the length of the data $n is not a power -of two. The complex functions of the FFT module are not yet fully implemented. - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -This function prepares a trigonometric lookup table for a complex FFT of length -$n. The function returns a pointer to the newly allocated -gsl_fft_complex_wavetable if no errors were detected, and a null pointer in the -case of error. The length $n is factorized into a product of subtransforms, and -the factors and their trigonometric coefficients are stored in the wavetable. -The trigonometric coefficients are computed using direct calls to sin and cos, -for accuracy. Recursion relations could be used to compute the lookup table -faster, but if an application performs many FFTs of the same length then this -computation is a one-off overhead which does not affect the final throughput. -The wavetable structure can be used repeatedly for any transform of the same -length. The table is not modified by calls to any of the other FFT functions. -The same wavetable can be used for both forward and backward (or inverse) -transforms of a given length. - -=item * C - -This function frees the memory associated with the wavetable $wavetable. The -wavetable can be freed if no further FFTs of the same length will be needed. - -=item * C - -This function allocates a workspace for a complex transform of length $n. - -=item * C - -This function frees the memory associated with the workspace $workspace. The -workspace can be freed if no further FFTs of the same length will be needed. - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -This function computes the backwards in-place radix-2 FFT of length $n and -stride $stride on the half-complex sequence data stored according the output -scheme used by gsl_fft_real_radix2. The result is a real array stored in -natural order. - -=item * C - -This function computes the inverse in-place radix-2 FFT of length $n and stride -$stride on the half-complex sequence data stored according the output scheme -used by gsl_fft_real_radix2. The result is a real array stored in natural -order. - -=item * C - -=item * C - -This function prepares trigonometric lookup tables for an FFT of size $n real -elements. The functions return a pointer to the newly allocated struct if no -errors were detected, and a null pointer in the case of error. The length $n is -factorized into a product of subtransforms, and the factors and their -trigonometric coefficients are stored in the wavetable. The trigonometric -coefficients are computed using direct calls to sin and cos, for accuracy. -Recursion relations could be used to compute the lookup table faster, but if an -application performs many FFTs of the same length then computing the wavetable -is a one-off overhead which does not affect the final throughput. The -wavetable structure can be used repeatedly for any transform of the same -length. The table is not modified by calls to any of the other FFT functions. -The appropriate type of wavetable must be used for forward real or inverse -half-complex transforms. - -=item * C - -This function frees the memory associated with the wavetable $wavetable. The -wavetable can be freed if no further FFTs of the same length will be needed. - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -This function computes an in-place radix-2 FFT of length $n and stride $stride -on the real array reference $data. The output is a half-complex sequence, which -is stored in-place. The arrangement of the half-complex terms uses the -following scheme: for k < N/2 the real part of the k-th term is stored in -location k, and the corresponding imaginary part is stored in location N-k. -Terms with k > N/2 can be reconstructed using the symmetry z_k = z^*_{N-k}. The -terms for k=0 and k=N/2 are both purely real, and count as a special case. -Their real parts are stored in locations 0 and N/2 respectively, while their -imaginary parts which are zero are not stored. The following table shows the -correspondence between the output data and the equivalent results obtained by -considering the input data as a complex sequence with zero imaginary part, - - complex[0].real = data[0] - complex[0].imag = 0 - complex[1].real = data[1] - complex[1].imag = data[N-1] - ............... ................ - complex[k].real = data[k] - complex[k].imag = data[N-k] - ............... ................ - complex[N/2].real = data[N/2] - complex[N/2].imag = 0 - ............... ................ - complex[k'].real = data[k] k' = N - k - complex[k'].imag = -data[N-k] - ............... ................ - complex[N-1].real = data[1] - complex[N-1].imag = -data[N-1] - -=for notyou #' - -Note that the output data can be converted into the full complex sequence using -the function gsl_fft_halfcomplex_unpack. - -=item * C - -This function prepares trigonometric lookup tables for an FFT of size $n real -elements. The functions return a pointer to the newly allocated struct if no -errors were detected, and a null pointer in the case of error. The length $n is -factorized into a product of subtransforms, and the factors and their -trigonometric coefficients are stored in the wavetable. The trigonometric -coefficients are computed using direct calls to sin and cos, for accuracy. -Recursion relations could be used to compute the lookup table faster, but if an -application performs many FFTs of the same length then computing the wavetable -is a one-off overhead which does not affect the final throughput. The -wavetable structure can be used repeatedly for any transform of the same -length. The table is not modified by calls to any of the other FFT functions. -The appropriate type of wavetable must be used for forward real or inverse -half-complex transforms. - -=item * C - -This function frees the memory associated with the wavetable $wavetable. The -wavetable can be freed if no further FFTs of the same length will be needed. - -=item * C - -This function allocates a workspace for a real transform of length $n. The same -workspace can be used for both forward real and inverse halfcomplex transforms. - -=item * C - -This function frees the memory associated with the workspace $workspace. The -workspace can be freed if no further FFTs of the same length will be needed. - -=item * C - -=item * C - -=back - -This module also includes the following constants : - -=over - -=item * C<$gsl_fft_forward> - -=item * C<$gsl_fft_backward> - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::FFT" +%include "typemaps.i" +%include "gsl_typemaps.i" + + +%typemap(argout) (double data[], const size_t stride, const size_t n) { + int i=0; + AV* tempav = newAV(); + + while( i < $3 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%typemap(argout) (gsl_complex_packed_array data[], const size_t stride, const size_t n) { + int i=0; + AV* tempav = newAV(); + + while( i < 2*$3 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%{ + #include "gsl/gsl_fft.h" + #include "gsl/gsl_fft_complex.h" + #include "gsl/gsl_fft_halfcomplex.h" + #include "gsl/gsl_fft_real.h" + #include "gsl/gsl_complex.h" +%} + +%include "gsl/gsl_complex.h" +%include "gsl/gsl_fft.h" +%include "gsl/gsl_fft_complex.h" +%include "gsl/gsl_fft_halfcomplex.h" +%include "gsl/gsl_fft_real.h" +%include "../pod/FFT.pod" diff --git a/swig/Fit.i b/swig/Fit.i dissimilarity index 96% index 1d42b33..09542db 100644 --- a/swig/Fit.i +++ b/swig/Fit.i @@ -1,110 +1,12 @@ -%module "Math::GSL::Fit" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * c0, double * c1, double * cov00, double * cov01, double * cov11, double * sumsq, double * chisq }; - -%{ -#include "gsl/gsl_fit.h" -%} - -%include "gsl/gsl_fit.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_fit_linear - gsl_fit_wlinear - gsl_fit_linear_est - gsl_fit_mul - gsl_fit_wmul - gsl_fit_mul_est - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Fit - Least-squares functions for a general linear model with one- or two-parameter regression - -=head1 SYNOPSIS - -use Math::GSL::Fit qw /:all/; - -=head1 DESCRIPTION - -The functions in this module perform least-squares fits to a general linear model, y = X c where y is a vector of n observations, X is an n by p matrix of predictor variables, and the elements of the vector c are the p unknown best-fit parameters which are to be estimated. - -Here is a list of all the functions in this module : - -=over - -=item C - This function computes the best-fit linear regression coefficients (c0,c1) of the model Y = c_0 + c_1 X for the dataset ($x, $y), two vectors (in form of arrays) of length $n with strides $xstride and $ystride. The errors on y are assumed unknown so the variance-covariance matrix for the parameters (c0, c1) is estimated from the scatter of the points around the best-fit line and returned via the parameters (cov00, cov01, cov11). The sum of squares of the residuals from the best-fit line is returned in sumsq. Note: the correlation coefficient of the data can be computed using gsl_stats_correlation (see Correlation), it does not depend on the fit. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, c0, c1, cov00, cov01, cov11 and sumsq. - -=item C - This function computes the best-fit linear regression coefficients (c0,c1) of the model Y = c_0 + c_1 X for the weighted dataset ($x, $y), two vectors (in form of arrays) of length $n with strides $xstride and $ystride. The vector (also in the form of an array) $w, of length $n and stride $wstride, specifies the weight of each datapoint. The weight is the reciprocal of the variance for each datapoint in y. The covariance matrix for the parameters (c0, c1) is computed using the weights and returned via the parameters (cov00, cov01, cov11). The weighted sum of squares of the residuals from the best-fit line, \chi^2, is returned in chisq. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, c0, c1, cov00, cov01, cov11 and sumsq. - -=item C - This function uses the best-fit linear regression coefficients $c0, $c1 and their covariance $cov00, $cov01, $cov11 to compute the fitted function y and its standard deviation y_err for the model Y = c_0 + c_1 X at the point $x. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, y and y_err. - -=item C - This function computes the best-fit linear regression coefficient c1 of the model Y = c_1 X for the datasets ($x, $y), two vectors (in form of arrays) of length $n with strides $xstride and $ystride. The errors on y are assumed unknown so the variance of the parameter c1 is estimated from the scatter of the points around the best-fit line and returned via the parameter cov11. The sum of squares of the residuals from the best-fit line is returned in sumsq. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, c1, cov11 and sumsq. - -=item C - This function computes the best-fit linear regression coefficient c1 of the model Y = c_1 X for the weighted datasets ($x, $y), two vectors (in form of arrays) of length $n with strides $xstride and $ystride. The vector (also in the form of an array) $w, of length $n and stride $wstride, specifies the weight of each datapoint. The weight is the reciprocal of the variance for each datapoint in y. The variance of the parameter c1 is computed using the weights and returned via the parameter cov11. The weighted sum of squares of the residuals from the best-fit line, \chi^2, is returned in chisq. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, c1, cov11 and sumsq. - -=item C - This function uses the best-fit linear regression coefficient $c1 and its covariance $cov11 to compute the fitted function y and its standard deviation y_err for the model Y = c_1 X at the point $x. The function returns the following values in this order : 0 if the operation succeeded, 1 otherwise, y and y_err. - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - -This example shows how to use the function gsl_fit_linear. It's important to see that the array passed to to function must be an array reference, not a simple array. Also when you use strides, you need to initialize all the value in the range used, unless you will get warnings. - - my @norris_x = (0.2, 337.4, 118.2, 884.6, 10.1, 226.5, 666.3, 996.3, - 448.6, 777.0, 558.2, 0.4, 0.6, 775.5, 666.9, 338.0, - 447.5, 11.6, 556.0, 228.1, 995.8, 887.6, 120.2, 0.3, - 0.3, 556.8, 339.1, 887.2, 999.0, 779.0, 11.1, 118.3, - 229.2, 669.1, 448.9, 0.5 ) ; - my @norris_y = ( 0.1, 338.8, 118.1, 888.0, 9.2, 228.1, 668.5, 998.5, - 449.1, 778.9, 559.2, 0.3, 0.1, 778.1, 668.8, 339.3, - 448.9, 10.8, 557.7, 228.3, 998.0, 888.8, 119.6, 0.3, - 0.6, 557.6, 339.3, 888.0, 998.5, 778.9, 10.2, 117.6, - 228.9, 668.4, 449.2, 0.2); - my $xstride = 2; - my $wstride = 3; - my $ystride = 5; - my ($x, $w, $y); - for my $i (0 .. 175) - { - $x->[$i] = 0; - $w->[$i] = 0; - $y->[$i] = 0; - } - - for my $i (0 .. 35) - { - $x->[$i*$xstride] = $norris_x[$i]; - $w->[$i*$wstride] = 1.0; - $y->[$i*$ystride] = $norris_y[$i]; - } - my ($status, @results) = gsl_fit_linear($x, $xstride, $y, $ystride, 36); - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - -%} +%module "Math::GSL::Fit" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double * c0, double * c1, double * cov00, double * cov01, double * cov11, double * sumsq, double * chisq }; + +%{ + #include "gsl/gsl_fit.h" +%} + +%include "gsl/gsl_fit.h" +%include "../pod/Fit.pod" diff --git a/swig/Heapsort.i b/swig/Heapsort.i dissimilarity index 91% index 183d95c..a64c309 100644 --- a/swig/Heapsort.i +++ b/swig/Heapsort.i @@ -1,59 +1,12 @@ -%module "Math::GSL::Heapsort" -%{ - #include "gsl/gsl_heapsort.h" -%} - -%include "gsl/gsl_heapsort.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_heapsort - gsl_heapsort_index - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Heapsort - Functions for sorting data, both directly and indirectly (using an index) - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - -use Math::GSL::Heapsort qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * gsl_heapsort - -=item * gsl_heapsort_index - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Heapsort" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%{ + #include "gsl/gsl_heapsort.h" + #include "gsl/gsl_permutation.h" +%} + +%include "gsl/gsl_permutation.h" +%include "gsl/gsl_heapsort.h" +%include "../pod/Heapsort.pod" diff --git a/swig/Histogram.i b/swig/Histogram.i dissimilarity index 98% index f033e61..dca65ab 100644 --- a/swig/Histogram.i +++ b/swig/Histogram.i @@ -1,229 +1,12 @@ -%module "Math::GSL::Histogram" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * lower, double * upper, size_t * i}; - -%{ - #include "gsl/gsl_histogram.h" -%} - -%include "gsl/gsl_histogram.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_histogram_alloc - gsl_histogram_calloc - gsl_histogram_calloc_uniform - gsl_histogram_free - gsl_histogram_increment - gsl_histogram_accumulate - gsl_histogram_find - gsl_histogram_get - gsl_histogram_get_range - gsl_histogram_max - gsl_histogram_min - gsl_histogram_bins - gsl_histogram_reset - gsl_histogram_calloc_range - gsl_histogram_set_ranges - gsl_histogram_set_ranges_uniform - gsl_histogram_memcpy - gsl_histogram_clone - gsl_histogram_max_val - gsl_histogram_max_bin - gsl_histogram_min_val - gsl_histogram_min_bin - gsl_histogram_equal_bins_p - gsl_histogram_add - gsl_histogram_sub - gsl_histogram_mul - gsl_histogram_div - gsl_histogram_scale - gsl_histogram_shift - gsl_histogram_sigma - gsl_histogram_mean - gsl_histogram_sum - gsl_histogram_fwrite - gsl_histogram_fread - gsl_histogram_fprintf - gsl_histogram_fscanf - gsl_histogram_pdf_alloc - gsl_histogram_pdf_init - gsl_histogram_pdf_free - gsl_histogram_pdf_sample - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -=head1 NAME - -Math::GSL::Histogram - Create and manipulate histograms of data - -=head1 SYNOPSIS - - use Math::GSL::Histogram qw/:all/; - - my $H = gsl_histogram_alloc(100); - gsl_histogram_set_ranges_uniform($H,0,101); - gsl_histogram_increment($H, -50 ); # ignored - gsl_histogram_increment($H, 70 ); - gsl_histogram_increment($H, 85.2 ); - - my $G = gsl_histogram_clone($H); - my $value = gsl_histogram_get($G, 70); - my ($max,$min) = (gsl_histogram_min_val($H), gsl_histogram_max_val($H) ); - my $sum = gsl_histogram_sum($H); - -=cut - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over 1 - -=item C - This function allocates memory for a histogram with $n bins, and returns a pointer to a newly created gsl_histogram struct. The bins and ranges are not initialized, and should be prepared using one of the range-setting functions below in order to make the histogram ready for use. - -=item C - -=item C - -=item C - This function frees the histogram $h and all of the memory associated with it. - -=item C - This function updates the histogram $h by adding one (1.0) to the bin whose range contains the coordinate $x. If $x lies in the valid range of the histogram then the function returns zero to indicate success. If $x is less than the lower limit of the histogram then the function returns $GSL_EDOM, and none of bins are modified. Similarly, if the value of $x is greater than or equal to the upper limit of the histogram then the function returns $GSL_EDOM, and none of the bins are modified. The error handler is not called, however, since it is often necessary to compute histograms for a small range of a larger dataset, ignoring the values outside the range of interest. - -=item C - This function is similar to gsl_histogram_increment but increases the value of the appropriate bin in the histogram $h by the floating-point number weight. - -=item C - This function finds the bin number which covers the coordinate $x in the histogram $h. The bin is located using a binary search. The search includes an optimization for histograms with uniform range, and will return the correct bin immediately in this case. If $x is found in the range of the histogram then the function returns the bin number and returns $GSL_SUCCESS. If $x lies outside the valid range of the histogram then the function returns $GSL_EDOM and the error handler is invoked. - -=item C - This function returns the contents of the $i-th bin of the histogram $h. If $i lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM and the function returns 0. - -=item C - This function finds the upper and lower range limits of the $i-th bin of the histogram $h. If the index $i is valid then the corresponding range limits are returned after the 0 in this order : lower and then upper. The lower limit is inclusive (i.e. events with this coordinate are included in the bin) and the upper limit is exclusive (i.e. events with the coordinate of the upper limit are excluded and fall in the neighboring higher bin, if it exists). The function returns 0 to indicate success. If i lies outside the valid range of indices for the histogram then the error handler is called and the function returns an error code of $GSL_EDOM. - -=item C - This function returns the maximum upper limit of the histogram $h. It provides a way of determining this value without accessing the gsl_histogram struct directly. - -=item C - This function returns the minimum lower range limit of the histogram $h. It provides a way of determining this value without accessing the gsl_histogram struct directly. - -=item C - This function returns the number of bins of the histogram $h limit. It provides a way of determining this value without accessing the gsl_histogram struct directly. - -=item C - This function resets all the bins in the histogram $h to zero. - -=item C - -=item C - This function sets the ranges of the existing histogram $h using the array $range of size $size. The values of the histogram bins are reset to zero. The $range array should contain the desired bin limits. The ranges can be arbitrary, subject to the restriction that they are monotonically increasing. Note that the size of the $range array should be defined to be one element bigger than the number of bins. The additional element is required for the upper value of the final bin. - -=item C - This function sets the ranges of the existing histogram $h to cover the range $xmin to $xmax uniformly. The values of the histogram bins are reset to zero. The bin ranges are shown in the table below, - -=back - -=over - -=item bin[0] corresponds to xmin <= x < xmin + d - -=item bin[1] corresponds to xmin + d <= x < xmin + 2 d - -=item ...... - -=item bin[n-1] corresponds to xmin + (n-1)d <= x < xmax - -=back - -where d is the bin spacing, d = (xmax-xmin)/n. - -=over - -=item C - This function copies the histogram $src into the pre-existing histogram $dest, making $dest into an exact copy of $src. The two histograms must be of the same size. - -=item C - This function returns a pointer to a newly created histogram which is an exact copy of the histogram $src. - -=item C - This function returns the maximum value contained in the histogram bins. - -=item C - This function returns the index of the bin containing the maximum value. In the case where several bins contain the same maximum value the smallest index is returned. - -=item C - This function returns the minimum value contained in the histogram bins. - -=item C - This function returns the index of the bin containing the minimum value. In the case where several bins contain the same maximum value the smallest index is returned. - -=item C - This function returns 1 if the all of the individual bin ranges of the two histograms are identical, and 0 otherwise. - -=item C - This function adds the contents of the bins in histogram $h2 to the corresponding bins of histogram $h1, i.e. h'_1(i) = h_1(i) + h_2(i). The two histograms must have identical bin ranges. - -=item C - This function subtracts the contents of the bins in histogram $h2 from the corresponding bins of histogram $h1, i.e. h'_1(i) = h_1(i) - h_2(i). The two histograms must have identical bin ranges. - -=item C - This function multiplies the contents of the bins of histogram $h1 by the contents of the corresponding bins in histogram $h2, i.e. h'_1(i) = h_1(i) * h_2(i). The two histograms must have identical bin ranges. - -=item C - This function divides the contents of the bins of histogram $h1 by the contents of the corresponding bins in histogram $h2, i.e. h'_1(i) = h_1(i) / h_2(i). The two histograms must have identical bin ranges. - -=item C - This function multiplies the contents of the bins of histogram $h by the constant $scale, i.e. h'_1(i) = h_1(i) * scale. - -=item C - This function shifts the contents of the bins of histogram $h by the constant $offset, i.e. h'_1(i) = h_1(i) + offset. - -=item C - This function returns the standard deviation of the histogrammed variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. The accuracy of the result is limited by the bin width. - -=item C - This function returns the mean of the histogrammed variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. The accuracy of the result is limited by the bin width. - -=item C - This function returns the sum of all bin values. Negative bin values are included in the sum. - -=item C - This function writes the ranges and bins of the histogram $h to the stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, in binary format. The return value is 0 for success and $GSL_EFAILED if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures. - -=item C - This function reads into the histogram $h from the open stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of bins in $h to determine how many bytes to read. The return value is 0 for success and $GSL_EFAILED if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture. - -=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (from the gsl_fopen function from the Math::GSL module) using the format specifiers $range_format and $bin_format. These should be one of the %g, %e or %f formats for floating point numbers. The function returns 0 for success and $GSL_EFAILED if there was a problem writing to the file. The histogram output is formatted in three columns, and the columns are separated by spaces, like this, - -=over - -=item range[0] range[1] bin[0] - -=item range[1] range[2] bin[1] - -=item range[2] range[3] bin[2] - -=item .... - -=item range[n-1] range[n] bin[n-1] - -=back - -The values of the ranges are formatted using range_format and the value of the bins are formatted using bin_format. Each line contains the lower and upper limit of the range of the bins and the value of the bin itself. Since the upper limit of one bin is the lower limit of the next there is duplication of these values between lines but this allows the histogram to be manipulated with line-oriented tools. - -=item C - This function reads formatted data from the stream $stream, which has been opened by the gsl_fopen function from the Math::GSL module, into the histogram $h. The data is assumed to be in the three-column format used by gsl_histogram_fprintf. The histogram $h must be preallocated with the correct length since the function uses the size of $h to determine how many numbers to read. The function returns 0 for success and $GSL_EFAILED if there was a problem reading from the file. - -=item C - This function allocates memory for a probability distribution with $n bins and returns a pointer to a newly initialized gsl_histogram_pdf struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of $GSL_ENOMEM. - -=item C - This function initializes the probability distribution $p with the contents of the histogram $h. If any of the bins of $h are negative then the error handler is invoked with an error code of $GSL_EDOM because a probability distribution cannot contain negative values. - -=item C - This function frees the probability distribution function $p and all of the memory associated with it. - -=item C - This function uses $r, a uniform random number between zero and one, to compute a single random sample from the probability distribution $p. The algorithm used to compute the sample s is given by the following formula, s = range[i] + delta * (range[i+1] - range[i]) where i is the index which satisfies sum[i] <= r < sum[i+1] and delta is (r - sum[i])/(sum[i+1] - sum[i]). - -=back - -=head1 EXAMPLES - - The following example shows how to create a histogram with logarithmic bins with ranges [1,10), [10,100) and [100,1000). - - $h = gsl_histogram_alloc (3); - - # bin[0] covers the range 1 <= x < 10 - # bin[1] covers the range 10 <= x < 100 - # bin[2] covers the range 100 <= x < 1000 - - $range = [ 1.0, 10.0, 100.0, 1000.0 ]; - - gsl_histogram_set_ranges($h, $range, 4); - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Histogram" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double * lower, double * upper, size_t * i}; + +%{ + #include "gsl/gsl_histogram.h" +%} + +%include "gsl/gsl_histogram.h" +%include "../pod/Histogram.pod" diff --git a/swig/Histogram2D.i b/swig/Histogram2D.i dissimilarity index 98% index 7768f26..aec3a93 100644 --- a/swig/Histogram2D.i +++ b/swig/Histogram2D.i @@ -1,247 +1,13 @@ -%module "Math::GSL::Histogram2D" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * xlower, double * xupper, double * ylower, double * yupper, double * x, double * y}; -%apply int *OUTPUT { size_t * i, size_t * j }; - -%{ - #include "gsl/gsl_histogram2d.h" -%} - -%include "gsl/gsl_histogram2d.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_histogram2d_alloc - gsl_histogram2d_calloc - gsl_histogram2d_calloc_uniform - gsl_histogram2d_free - gsl_histogram2d_increment - gsl_histogram2d_accumulate - gsl_histogram2d_find - gsl_histogram2d_get - gsl_histogram2d_get_xrange - gsl_histogram2d_get_yrange - gsl_histogram2d_xmax - gsl_histogram2d_xmin - gsl_histogram2d_nx - gsl_histogram2d_ymax - gsl_histogram2d_ymin - gsl_histogram2d_ny - gsl_histogram2d_reset - gsl_histogram2d_calloc_range - gsl_histogram2d_set_ranges_uniform - gsl_histogram2d_set_ranges - gsl_histogram2d_memcpy - gsl_histogram2d_clone - gsl_histogram2d_max_val - gsl_histogram2d_max_bin - gsl_histogram2d_min_val - gsl_histogram2d_min_bin - gsl_histogram2d_xmean - gsl_histogram2d_ymean - gsl_histogram2d_xsigma - gsl_histogram2d_ysigma - gsl_histogram2d_cov - gsl_histogram2d_sum - gsl_histogram2d_equal_bins_p - gsl_histogram2d_add - gsl_histogram2d_sub - gsl_histogram2d_mul - gsl_histogram2d_div - gsl_histogram2d_scale - gsl_histogram2d_shift - gsl_histogram2d_fwrite - gsl_histogram2d_fread - gsl_histogram2d_fprintf - gsl_histogram2d_fscanf - gsl_histogram2d_pdf_alloc - gsl_histogram2d_pdf_init - gsl_histogram2d_pdf_free - gsl_histogram2d_pdf_sample - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -=head1 NAME - -Math::GSL::Histogram2D - Create and manipulate histograms of data in 2 dimensions - -=head1 SYNOPSIS - - use Math::GSL::Histogram2D qw/:all/; - - my $H = gsl_histogram2d_alloc(100, 100); - gsl_histogram2d_set_ranges_uniform($H,0,101, 0, 101); - gsl_histogram2d_increment($H, -50, -12); # ignored - gsl_histogram2d_increment($H, 70 ); - gsl_histogram2d_increment($H, 85.2 ); - - my $G = gsl_histogram2d_clone($H); - my $value = gsl_histogram2d_get($G, 70, 33); - my ($max,$min) = (gsl_histogram2d_min_val($H), gsl_histogram2d_max_val($H) ); - my $sum = gsl_histogram2d_sum($H); - -=cut - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over - -=item C - This function allocates memory for a two-dimensional histogram with $nx bins in the x direction and $ny bins in the y direction. The function returns a pointer to a newly created gsl_histogram2d struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of $GSL_ENOMEM. The bins and ranges must be initialized with one of the functions below before the histogram is ready for use. - -=item C - -=item C - -=item C - This function frees the 2D histogram h and all of the memory associated with it. - -=item C - This function sets the ranges of the existing histogram $h to cover the ranges $xmin to $xmax and $ymin to $ymax uniformly. The values of the histogram bins are reset to zero. - -=item C - This function is similar to gsl_histogram2d_increment but increases the value of the appropriate bin in the histogram $h by the floating-point number $weight. - -=item C - This function finds indices i and j to the to the bin which covers the coordinates ($x,$y). The bin is located using a binary search. The search includes an optimization for histograms with uniform ranges, and will return the correct bin immediately in this case. If ($x,$y) is found then the function return GSL_SUCCESS, i and j in this order. If ($x,$y) lies outside the valid range of the histogram then the function returns $GSL_EDOM and the error handler is invoked. - -=item C - This function returns the contents of the ($i,$j)-th bin of the histogram $h. If ($i,$j) lies outside the valid range of indices for the histogram then the error handler is called with an error code of $GSL_EDOM and the function returns 0. - -=item C - This functions finds the upper and lower range limits of the $i-th in the x direction of the histogram $h. The range limits are stored in returned after 0 or 1 in this order : xlower and xupper. The lower limits are inclusive (i.e. events with these coordinates are included in the bin) and the upper limits are exclusive (i.e. events with the value of the upper limit are not included and fall in the neighboring higher bin, if it exists). The functions returns 0 has first value to indicate success. If $i lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM. - -=item C - This functions finds the upper and lower range limits of the $j-th in the y direction of the histogram $h. The range limits are stored in returned after 0 or 1 in this order : ylower and yupper. The lower limits are inclusive (i.e. events with these coordinates are included in the bin) and the upper limits are exclusive (i.e. events with the value of the upper limit are not included and fall in the neighboring higher bin, if it exists). The functions returns 0 has first value to indicate success. If $j lies outside the valid range of indices for the histogram then the error handler is called with an error code of GSL_EDOM. - -=item C - This functions returns the maximum upper range limit for the x direction of the histogram $h. - -=item C - This functions returns the minimum lower range limit for the x direction of the histogram $h. - -=item C - This functions the number of bins for the x direction. - -=item C - This functions returns the maximum upper range limit for the y direction of the histogram $h. - -=item C - This functions returns the minimum lower range limit for the y direction of the histogram $h. - -=item C - This functions the number of bins for the y direction. - -=item C - This function resets all the bins of the histogram $h to zero. - -=item C - -=item C - This function sets the ranges of the existing histogram $h using the arrays $xrange and $yrange of size $xsize and $ysize respectively. The values of the histogram bins are reset to zero. - -=item C - This function sets the ranges of the existing histogram $h to cover the ranges $xmin to $xmax and $ymin to $ymax uniformly. The values of the histogram bins are reset to zero. - -=item C - This function copies the histogram $src into the pre-existing histogram $dest, making $dest into an exact copy of $src. The two histograms must be of the same size. - -=item C - This function returns a pointer to a newly created histogram which is an exact copy of the histogram $src. - -=item C - This function returns the maximum value contained in the histogram bins. - -=item C - This function finds the indices of the bin containing the maximum value in the histogram $h and returns the result in this order : 0 if the operation succeded, 1 otherwise, i and j. In the case where several bins contain the same maximum value the first bin found is returned. - -=item C - This function returns the minimum value contained in the histogram bins. - -=item C - This function finds the indices of the bin containing the minimum value in the histogram $h and returns the result in this order : 0 if the operation succeded, 1 otherwise, i and j. In the case where several bins contain the same minimum value the first bin found is returned. - -=item C - This function returns the mean of the histogrammed x variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. - -=item C - This function returns the mean of the histogrammed y variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. - -=item C - This function returns the standard deviation of the histogrammed x variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. - -=item C - This function returns the standard deviation of the histogrammed y variable, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. - -=item C - This function returns the covariance of the histogrammed x and y variables, where the histogram is regarded as a probability distribution. Negative bin values are ignored for the purposes of this calculation. - -=item C - This function returns the sum of all bin values. Negative bin values are included in the sum. - -=item C - This function returns 1 if all the individual bin ranges of the two histograms are identical, and 0 otherwise. - -=item C - This function adds the contents of the bins in histogram $h2 to the corresponding bins of histogram $h1, i.e. h'_1(i,j) = h_1(i,j) + h_2(i,j). The two histograms must have identical bin ranges. - -=item C - This function subtracts the contents of the bins in histogram $h2 from the corresponding bins of histogram $h1, i.e. h'_1(i,j) = h_1(i,j) - h_2(i,j). The two histograms must have identical bin ranges. - -=item C - This function multiplies the contents of the bins of histogram $h1 by the contents of the corresponding bins in histogram $h2, i.e. h'_1(i,j) = h_1(i,j) * h_2(i,j). The two histograms must have identical bin ranges. - -=item C - This function divides the contents of the bins of histogram $h1 by the contents of the corresponding bins in histogram $h2, i.e. h'_1(i,j) = h_1(i,j) / h_2(i,j). The two histograms must have identical bin ranges. - -=item C - This function multiplies the contents of the bins of histogram $h by the constant scale, i.e. h'_1(i,j) = h_1(i,j) $scale. - -=item C - This function shifts the contents of the bins of histogram $h by the constant offset, i.e. h'_1(i,j) = h_1(i,j) + $offset. - -=item C - This function writes the ranges and bins of the histogram $h to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The return value is 0 for success and $GSL_EFAILED if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures. - -=item C - This function reads into the histogram $h from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The histogram $h must be preallocated with the correct size since the function uses the number of x and y bins in $h to determine how many bytes to read. The return value is 0 for success and $GSL_EFAILED if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture. - -=item C - This function writes the ranges and bins of the histogram $h line-by-line to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) using the format specifiers $range_format and $bin_format. These should be one of the %g, %e or %f formats for floating point numbers. The function returns 0 for success and $GSL_EFAILED if there was a problem writing to the file. The histogram output is formatted in five columns, and the columns are separated by spaces, like this, - -=over - -=item xrange[0] xrange[1] yrange[0] yrange[1] bin(0,0) - -=item xrange[0] xrange[1] yrange[1] yrange[2] bin(0,1) - -=item xrange[0] xrange[1] yrange[2] yrange[3] bin(0,2) - -=item .... - -=item xrange[0] xrange[1] yrange[ny-1] yrange[ny] bin(0,ny-1) - -=item - -=item xrange[1] xrange[2] yrange[0] yrange[1] bin(1,0) - -=item xrange[1] xrange[2] yrange[1] yrange[2] bin(1,1) - -=item xrange[1] xrange[2] yrange[1] yrange[2] bin(1,2) - -=item .... - -=item xrange[1] xrange[2] yrange[ny-1] yrange[ny] bin(1,ny-1) - -=item - -=item .... - -=item - -=item xrange[nx-1] xrange[nx] yrange[0] yrange[1] bin(nx-1,0) - -=item xrange[nx-1] xrange[nx] yrange[1] yrange[2] bin(nx-1,1) - -=item xrange[nx-1] xrange[nx] yrange[1] yrange[2] bin(nx-1,2) - -=item .... - -=item xrange[nx-1] xrange[nx] yrange[ny-1] yrange[ny] bin(nx-1,ny-1) - -=back - -Each line contains the lower and upper limits of the bin and the contents of the bin. Since the upper limits of the each bin are the lower limits of the neighboring bins there is duplication of these values but this allows the histogram to be manipulated with line-oriented tools. - -=item C - This function reads formatted data from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) into the histogram $h. The data is assumed to be in the five-column format used by gsl_histogram2d_fprintf. The histogram $h must be preallocated with the correct lengths since the function uses the sizes of $h to determine how many numbers to read. The function returns 0 for success and $GSL_EFAILED if there was a problem reading from the file. - -=item C - This function allocates memory for a two-dimensional probability distribution of size $nx-by-$ny and returns a pointer to a newly initialized gsl_histogram2d_pdf struct. If insufficient memory is available a null pointer is returned and the error handler is invoked with an error code of $GSL_ENOMEM. - -=item C - This function initializes the two-dimensional probability distribution calculated $p from the histogram $h. If any of the bins of $h are negative then the error handler is invoked with an error code of GSL_EDOM because a probability distribution cannot contain negative values. - -=item C - This function frees the two-dimensional probability distribution function $p and all of the memory associated with it. - -=item C - This function uses two uniform random numbers between zero and one, $r1 and $r2, to compute a single random sample from the two-dimensional probability distribution p. The function returns 0 if the operation succeeded, 1 otherwise followed by the x and y values of the sample. - -=back - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Histogram2D" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double * xlower, double * xupper, double * ylower, double * yupper, double * x, double * y}; +%apply int *OUTPUT { size_t * i, size_t * j }; + +%{ + #include "gsl/gsl_histogram2d.h" +%} + +%include "gsl/gsl_histogram2d.h" +%include "../pod/Histogram2D.pod" diff --git a/swig/IEEEUtils.i b/swig/IEEEUtils.i dissimilarity index 91% index 809b7e5..700efe2 100644 --- a/swig/IEEEUtils.i +++ b/swig/IEEEUtils.i @@ -1,40 +1,7 @@ -%module "Math::GSL::IEEEUtils" -%{ - #include "gsl/gsl_ieee_utils.h" -%} - -%include "gsl/gsl_ieee_utils.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_ieee_printf_float - gsl_ieee_printf_double - gsl_ieee_fprintf_float - gsl_ieee_fprintf_double - gsl_ieee_float_to_rep - gsl_ieee_double_to_rep - gsl_ieee_env_setup - gsl_ieee_read_mode_string - gsl_ieee_set_mode - $GSL_IEEE_TYPE_NAN - $GSL_IEEE_TYPE_INF - $GSL_IEEE_TYPE_NORMAL - $GSL_IEEE_TYPE_DENORMAL - $GSL_IEEE_TYPE_ZERO - $GSL_IEEE_SINGLE_PRECISION - $GSL_IEEE_DOUBLE_PRECISION - $GSL_IEEE_EXTENDED_PRECISION - $GSL_IEEE_ROUND_TO_NEAREST - $GSL_IEEE_ROUND_DOWN - $GSL_IEEE_ROUND_UP - $GSL_IEEE_ROUND_TO_ZERO - $GSL_IEEE_MASK_INVALID - $GSL_IEEE_MASK_DENORMALIZED - $GSL_IEEE_MASK_DIVISION_BY_ZERO - $GSL_IEEE_MASK_OVERFLOW - $GSL_IEEE_MASK_UNDERFLOW - $GSL_IEEE_MASK_ALL - $GSL_IEEE_TRAP_INEXACT - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); -%} +%module "Math::GSL::IEEEUtils" +%{ + #include "gsl/gsl_ieee_utils.h" +%} + +%include "gsl/gsl_ieee_utils.h" +%include "../pod/IEEEUtils.pod" diff --git a/swig/Integration.i b/swig/Integration.i dissimilarity index 97% index d7dd6a7..e09249e 100644 --- a/swig/Integration.i +++ b/swig/Integration.i @@ -1,258 +1,11 @@ -%module "Math::GSL::Integration" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_integration.h" - #include "gsl/gsl_math.h" -%} -%include "gsl/gsl_integration.h" -%include "gsl/gsl_math.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_integration_workspace_alloc - gsl_integration_workspace_free - gsl_integration_qaws_table_alloc - gsl_integration_qaws_table_set - gsl_integration_qaws_table_free - gsl_integration_qawo_table_alloc - gsl_integration_qawo_table_set - gsl_integration_qawo_table_set_length - gsl_integration_qawo_table_free - gsl_integration_qk15 - gsl_integration_qk21 - gsl_integration_qk31 - gsl_integration_qk41 - gsl_integration_qk51 - gsl_integration_qk61 - gsl_integration_qcheb - gsl_integration_qk - gsl_integration_qng - gsl_integration_qag - gsl_integration_qagi - gsl_integration_qagiu - gsl_integration_qagil - gsl_integration_qags - gsl_integration_qagp - gsl_integration_qawc - gsl_integration_qaws - gsl_integration_qawo - gsl_integration_qawf - $GSL_INTEG_COSINE - $GSL_INTEG_SINE - $GSL_INTEG_GAUSS15 - $GSL_INTEG_GAUSS21 - $GSL_INTEG_GAUSS31 - $GSL_INTEG_GAUSS41 - $GSL_INTEG_GAUSS51 - $GSL_INTEG_GAUSS61 - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Integration - Routines for performing numerical integration (quadrature) of a function in one dimension - -=head1 SYNOPSIS - - use Math::GSL::Integration qw /:all/; - - my $function = sub { $_[0]**2 } ; - my ($lower, $upper ) = (0,1); - my ($relerr,$abserr) = (0,1e-7); - - my ($status, $result, $abserr, $num_evals) = gsl_integration_qng ( $function, - $lower, $upper, $relerr, $abserr - ); - -=head1 DESCRIPTION - -This module allows you to numerically integrate a Perl subroutine. Depending -on the properties of your function (singularities, smoothness) and the type -of integration range (finite, infinite, semi-infinite), you will need to -choose a quadrature routine that fits your needs. - - -=over - -=item * C - -This function allocates a workspace sufficient to hold $n double precision -intervals, their integration results and error estimates. - -=item * C - - This function frees the memory associated with the workspace $w. - -=item * C - - This function allocates space for a gsl_integration_qaws_table struct - describing a singular weight function W(x) with the parameters ($alpha, $beta, - $mu, $nu), W(x) = (x-a)^alpha (b-x)^beta log^mu (x-a) log^nu (b-x) where - $alpha > -1, $beta > -1, and $mu = 0, 1, $nu = 0, 1. The weight function can - take four different forms depending on the values of $mu and $nu, - - W(x) = (x-a)^alpha (b-x)^beta (mu = 0, nu = 0) - W(x) = (x-a)^alpha (b-x)^beta log(x-a) (mu = 1, nu = 0) - W(x) = (x-a)^alpha (b-x)^beta log(b-x) (mu = 0, nu = 1) - W(x) = (x-a)^alpha (b-x)^beta log(x-a) log(b-x) (mu = 1, nu = 1) - -The singular points (a,b) do not have to be specified until the integral is -computed, where they are the endpoints of the integration range. The function -returns a pointer to the newly allocated table gsl_integration_qaws_table if no -errors were detected, and 0 in the case of error. - -=item * C - - This function modifies the parameters ($alpha, $beta, $mu, $nu) of an existing - gsl_integration_qaws_table struct $t. - -=item * C - - This function frees all the memory associated with the - gsl_integration_qaws_table struct $t. - -=item * C - -=item * C - - This function changes the parameters omega, L and sine of the existing - workspace $t. - -=item * C - - This function allows the length parameter $L of the workspace $t to be - changed. - -=item * C - - This function frees all the memory associated with the workspace $t. - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -This routine QNG (Quadrature Non-Adaptive Gaussian) is inexpensive is the sense -that it will evaluate the function much fewer times than the adaptive routines. -Because of this it does not need any workspaces, so it is also more memory -efficient. It should be perfectly fine for well-behaved functions (smooth and -nonsingular), but will not be able to get the required accuracy or may not -converge for more complicated functions. - -=item * C - -This routine QAG (Quadrature Adaptive Gaussian) ... - -=item * C - -=item * C - -=item * C - -=item * C - - ($status, $result, $abserr) = gsl_integration_qags ( - sub { 1/$_[0]} , - 1, 10, 0, 1e-7, 1000, - $workspace, - ); - - This function applies the Gauss-Kronrod 21-point integration rule - adaptively until an estimate of the integral of $func over ($a,$b) is - achieved within the desired absolute and relative error limits, - $epsabs and $epsrel. - - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -This module also includes the following constants : - -=over - -=item * $GSL_INTEG_COSINE - -=item * $GSL_INTEG_SINE - -=item * $GSL_INTEG_GAUSS15 - -=item * $GSL_INTEG_GAUSS21 - -=item * $GSL_INTEG_GAUSS31 - -=item * $GSL_INTEG_GAUSS41 - -=item * $GSL_INTEG_GAUSS51 - -=item * $GSL_INTEG_GAUSS61 - -=back - -The following error constants are part of the Math::GSL::Errno module and can -be returned by the gsl_integration_* functions : - -=over - -=item * $GSL_EMAXITER - -Maximum number of subdivisions was exceeded. - -=item * $GSL_EROUND - -Cannot reach tolerance because of roundoff error, or roundoff error was detected in the extrapolation table. - -=item * GSL_ESING - -A non-integrable singularity or other bad integrand behavior was found in the integration interval. - -=item * GSL_EDIVERGE - -The integral is divergent, or too slowly convergent to be integrated numerically. - -=back - -=head1 MORE INFO - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Integration" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%{ + #include "gsl/gsl_integration.h" + #include "gsl/gsl_math.h" +%} +%include "gsl/gsl_integration.h" +%include "gsl/gsl_math.h" +%include "../pod/Integration.pod" diff --git a/swig/Interp.i b/swig/Interp.i dissimilarity index 96% index 3fcad90..5cc6dfe 100644 --- a/swig/Interp.i +++ b/swig/Interp.i @@ -1,139 +1,15 @@ -%module "Math::GSL::Interp" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_interp.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_interp.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_interp_accel_alloc - gsl_interp_accel_find - gsl_interp_accel_reset - gsl_interp_accel_free - gsl_interp_alloc - gsl_interp_init - gsl_interp_name - gsl_interp_min_size - gsl_interp_eval_e - gsl_interp_eval - gsl_interp_eval_deriv_e - gsl_interp_eval_deriv - gsl_interp_eval_deriv2_e - gsl_interp_eval_deriv2 - gsl_interp_eval_integ_e - gsl_interp_eval_integ - gsl_interp_free - gsl_interp_bsearch - $gsl_interp_linear - $gsl_interp_polynomial - $gsl_interp_cspline - $gsl_interp_cspline_periodic - $gsl_interp_akima - $gsl_interp_akima_periodic - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Interp - Functions for performing interpolation - -=head1 SYNOPSIS - - use Math::GSL::Interp qw/:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over 1 - -=item C - This function returns a pointer to an accelerator object, which is a kind of iterator for interpolation lookups. It tracks the state of lookups, thus allowing for application of various acceleration strategies. - -=item C - This function performs a lookup action on the data array $x_array of size $size, using the given accelerator $a. This is how lookups are performed during evaluation of an interpolation. The function returns an index i such that $x_array[i] <= $x < $x_array[i+1]. - -=item C - -=item C - This function frees the accelerator object $a. - -=item C - This function returns a newly allocated interpolation object of type $T for $size data-points. $T must be one of the constants below. - -=item C - This function initializes the interpolation object interp for the data (xa,ya) where xa and ya are arrays of size size. The interpolation object (gsl_interp) does not save the data arrays xa and ya and only stores the static state computed from the data. The xa data array is always assumed to be strictly ordered, with increasing x values; the behavior for other arrangements is not defined. - -=item C - This function returns the name of the interpolation type used by $interp. - -=item C - This function returns the minimum number of points required by the interpolation type of $interp. For example, Akima spline interpolation requires a minimum of 5 points. - -=item C - This functions returns the interpolated value of y for a given point $x, using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. The function returns 0 if the operation succeeded, 1 otherwise and the y value. - -=item C - This functions returns the interpolated value of y for a given point $x, using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. - -=item C - This function computes the derivative value of y for a given point $x, using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. The function returns 0 if the operation succeeded, 1 otherwise and the d value. - -=item C - This function returns the derivative d of an interpolated function for a given point $x, using the interpolation object interp, data arrays $xa and $ya and the accelerator $acc. - -=item C - This function computes the second derivative d2 of an interpolated function for a given point $x, using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. The function returns 0 if the operation succeeded, 1 otherwise and the d2 value. - -=item C - This function returns the second derivative d2 of an interpolated function for a given point $x, using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. - -=item C - This function computes the numerical integral result of an interpolated function over the range [$a, $b], using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. The function returns 0 if the operation succeeded, 1 otherwise and the result value. - -=item C - This function returns the numerical integral result of an interpolated function over the range [$a, $b], using the interpolation object $interp, data arrays $xa and $ya and the accelerator $acc. - -=item C - This function frees the interpolation object $interp. - -=item C - This function returns the index i of the array $x_array such that $x_array[i] <= x < $x_array[i+1]. The index is searched for in the range [$index_lo,$index_hi]. - -=back - -This module also includes the following constants : - -=over 1 - -=item C<$gsl_interp_linear> - Linear interpolation - -=item C<$gsl_interp_polynomial> - Polynomial interpolation. This method should only be used for interpolating small numbers of points because polynomial interpolation introduces large oscillations, even for well-behaved datasets. The number of terms in the interpolating polynomial is equal to the number of points. - -=item C<$gsl_interp_cspline> - Cubic spline with natural boundary conditions. The resulting curve is piecewise cubic on each interval, with matching first and second derivatives at the supplied data-points. The second derivative is chosen to be zero at the first point and last point. - -=item C<$gsl_interp_cspline_periodic> - Cubic spline with periodic boundary conditions. The resulting curve is piecewise cubic on each interval, with matching first and second derivatives at the supplied data-points. The derivatives at the first and last points are also matched. Note that the last point in the data must have the same y-value as the first point, otherwise the resulting periodic interpolation will have a discontinuity at the boundary. - -=item C<$gsl_interp_akima> - Non-rounded Akima spline with natural boundary conditions. This method uses the non-rounded corner algorithm of Wodicka. - -=item C<$gsl_interp_akima_periodic> - Non-rounded Akima spline with periodic boundary conditions. This method uses the non-rounded corner algorithm of Wodicka. - -=back - -=head1 EXAMPLES - - use Math::GSL::Interp qw/:all/; - my $x_array = [ 0.0, 1.0, 2.0, 3.0, 4.0 ]; - # check that we get the last interval if x == last value - $index_result = gsl_interp_bsearch($x_array, 4.0, 0, 4); - print "The last interval is $index_result \n"; - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - -%} +%module "Math::GSL::Interp" + +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_interp.h" +%} +%include "gsl/gsl_types.h" +%include "gsl/gsl_interp.h" + +%include "../pod/Interp.pod" diff --git a/swig/Linalg.i b/swig/Linalg.i dissimilarity index 99% index e81f826..2ad8080 100644 --- a/swig/Linalg.i +++ b/swig/Linalg.i @@ -1,407 +1,11 @@ -%module "Math::GSL::Linalg" -%apply int *OUTPUT { int *signum }; - -%{ - #include "gsl/gsl_linalg.h" - #include "gsl/gsl_permutation.h" -%} - -%include "gsl/gsl_linalg.h" -%include "gsl/gsl_permutation.h" - -%perlcode %{ -@EXPORT_OK = qw/$GSL_LINALG_MOD_NONE $GSL_LINALG_MOD_TRANSPOSE $GSL_LINALG_MOD_CONJUGATE - gsl_linalg_matmult gsl_linalg_matmult_mod - gsl_linalg_exponential_ss - gsl_linalg_householder_transform - gsl_linalg_complex_householder_transform - gsl_linalg_householder_hm - gsl_linalg_householder_mh - gsl_linalg_householder_hv - gsl_linalg_householder_hm1 - gsl_linalg_complex_householder_hm - gsl_linalg_complex_householder_mh - gsl_linalg_complex_householder_hv - gsl_linalg_hessenberg_decomp - gsl_linalg_hessenberg_unpack - gsl_linalg_hessenberg_unpack_accum - gsl_linalg_hessenberg_set_zero - gsl_linalg_hessenberg_submatrix - gsl_linalg_hessenberg - gsl_linalg_hesstri_decomp - gsl_linalg_SV_decomp - gsl_linalg_SV_decomp_mod - gsl_linalg_SV_decomp_jacobi - gsl_linalg_SV_solve - gsl_linalg_LU_decomp - gsl_linalg_LU_solve - gsl_linalg_LU_svx - gsl_linalg_LU_refine - gsl_linalg_LU_invert - gsl_linalg_LU_det - gsl_linalg_LU_lndet - gsl_linalg_LU_sgndet - gsl_linalg_complex_LU_decomp - gsl_linalg_complex_LU_solve - gsl_linalg_complex_LU_svx - gsl_linalg_complex_LU_refine - gsl_linalg_complex_LU_invert - gsl_linalg_complex_LU_det - gsl_linalg_complex_LU_lndet - gsl_linalg_complex_LU_sgndet - gsl_linalg_QR_decomp - gsl_linalg_QR_solve - gsl_linalg_QR_svx - gsl_linalg_QR_lssolve - gsl_linalg_QR_QRsolve - gsl_linalg_QR_Rsolve - gsl_linalg_QR_Rsvx - gsl_linalg_QR_update - gsl_linalg_QR_QTvec - gsl_linalg_QR_Qvec - gsl_linalg_QR_QTmat - gsl_linalg_QR_unpack - gsl_linalg_R_solve - gsl_linalg_R_svx - gsl_linalg_QRPT_decomp - gsl_linalg_QRPT_decomp2 - gsl_linalg_QRPT_solve - gsl_linalg_QRPT_svx - gsl_linalg_QRPT_QRsolve - gsl_linalg_QRPT_Rsolve - gsl_linalg_QRPT_Rsvx - gsl_linalg_QRPT_update - gsl_linalg_LQ_decomp - gsl_linalg_LQ_solve_T - gsl_linalg_LQ_svx_T - gsl_linalg_LQ_lssolve_T - gsl_linalg_LQ_Lsolve_T - gsl_linalg_LQ_Lsvx_T - gsl_linalg_L_solve_T - gsl_linalg_LQ_vecQ - gsl_linalg_LQ_vecQT - gsl_linalg_LQ_unpack - gsl_linalg_LQ_update - gsl_linalg_LQ_LQsolve - gsl_linalg_PTLQ_decomp - gsl_linalg_PTLQ_decomp2 - gsl_linalg_PTLQ_solve_T - gsl_linalg_PTLQ_svx_T - gsl_linalg_PTLQ_LQsolve_T - gsl_linalg_PTLQ_Lsolve_T - gsl_linalg_PTLQ_Lsvx_T - gsl_linalg_PTLQ_update - gsl_linalg_cholesky_decomp - gsl_linalg_cholesky_solve - gsl_linalg_cholesky_svx - gsl_linalg_cholesky_decomp_unit - gsl_linalg_complex_cholesky_decomp - gsl_linalg_complex_cholesky_solve - gsl_linalg_complex_cholesky_svx - gsl_linalg_symmtd_decomp - gsl_linalg_symmtd_unpack - gsl_linalg_symmtd_unpack_T - gsl_linalg_hermtd_decomp - gsl_linalg_hermtd_unpack - gsl_linalg_hermtd_unpack_T - gsl_linalg_HH_solve - gsl_linalg_HH_svx - gsl_linalg_solve_symm_tridiag - gsl_linalg_solve_tridiag - gsl_linalg_solve_symm_cyc_tridiag - gsl_linalg_solve_cyc_tridiag - gsl_linalg_bidiag_decomp - gsl_linalg_bidiag_unpack - gsl_linalg_bidiag_unpack2 - gsl_linalg_bidiag_unpack_B - gsl_linalg_balance_matrix - gsl_linalg_balance_accum - gsl_linalg_balance_columns - /; -%EXPORT_TAGS = ( all =>[ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Linalg - Functions for solving linear systems - -=head1 SYNOPSIS - - use Math::GSL::Linalg qw/:all/; - -=head1 DESCRIPTION - - -Here is a list of all the functions included in this module : - -=over - -=item gsl_linalg_matmult - -=item gsl_linalg_matmult_mod - -=item gsl_linalg_exponential_ss - -=item gsl_linalg_householder_transform - -=item gsl_linalg_complex_householder_transform - -=item gsl_linalg_householder_hm($tau, $v, $A) - This function applies the Householder matrix P defined by the scalar $tau and the vector $v to the left-hand side of the matrix $A. On output the result P A is stored in $A. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_householder_mh($tau, $v, $A) - This function applies the Householder matrix P defined by the scalar $tau and the vector $v to the right-hand side of the matrix $A. On output the result A P is stored in $A. - -=item gsl_linalg_householder_hv($tau, $v, $w) - This function applies the Householder transformation P defined by the scalar $tau and the vector $v to the vector $w. On output the result P w is stored in $w. - -=item gsl_linalg_householder_hm1 - -=item gsl_linalg_complex_householder_hm($tau, $v, $A) - Does the same operation than gsl_linalg_householder_hm but with the complex matrix $A, the complex value $tau and the complex vector $v. - -=item gsl_linalg_complex_householder_mh($tau, $v, $A) - Does the same operation than gsl_linalg_householder_mh but with the complex matrix $A, the complex value $tau and the complex vector $v. - -=item gsl_linalg_complex_householder_hv($tau, $v, $w) - Does the same operation than gsl_linalg_householder_hv but with the complex value $tau and the complex vectors $v and $w. - -=item gsl_linalg_hessenberg_decomp($A, $tau) - This function computes the Hessenberg decomposition of the matrix $A by applying the similarity transformation H = U^T A U. On output, H is stored in the upper portion of $A. The information required to construct the matrix U is stored in the lower triangular portion of $A. U is a product of N - 2 Householder matrices. The Householder vectors are stored in the lower portion of $A (below the subdiagonal) and the Householder coefficients are stored in the vector $tau. tau must be of length N. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_hessenberg_unpack($H, $tau, $U) - This function constructs the orthogonal matrix $U from the information stored in the Hessenberg matrix $H along with the vector $tau. $H and $tau are outputs from gsl_linalg_hessenberg_decomp. - -=item gsl_linalg_hessenberg_unpack_accum($H, $tau, $V) - This function is similar to gsl_linalg_hessenberg_unpack, except it accumulates the matrix U into $V, so that V' = VU. The matrix $V must be initialized prior to calling this function. Setting $V to the identity matrix provides the same result as gsl_linalg_hessenberg_unpack. If $H is order N, then $V must have N columns but may have any number of rows. - -=item gsl_linalg_hessenberg_set_zero($H) - This function sets the lower triangular portion of $H, below the subdiagonal, to zero. It is useful for clearing out the Householder vectors after calling gsl_linalg_hessenberg_decomp. - -=item gsl_linalg_hessenberg_submatrix - -=item gsl_linalg_hessenberg - -=item gsl_linalg_hesstri_decomp($A, $B, $U, $V, $work) - This function computes the Hessenberg-Triangular decomposition of the matrix pair ($A, $B). On output, H is stored in $A, and R is stored in $B. If $U and $V are provided (they may be null), the similarity transformations are stored in them. Additional workspace of length N is needed in the vector $work. - -=item gsl_linalg_SV_decomp($A, $V, $S, $work) - This function factorizes the M-by-N matrix $A into the singular value decomposition A = U S V^T for M >= N. On output the matrix $A is replaced by U. The diagonal elements of the singular value matrix S are stored in the vector $S. The singular values are non-negative and form a non-increasing sequence from S_1 to S_N. The matrix $V contains the elements of V in untransposed form. To form the product U S V^T it is necessary to take the transpose of V. A workspace of length N is required in vector $work. This routine uses the Golub-Reinsch SVD algorithm. - -=item gsl_linalg_SV_decomp_mod($A, $X, $V, $S, $work) - This function computes the SVD using the modified Golub-Reinsch algorithm, which is faster for M>>N. It requires the vector $work of length N and the N-by-N matrix $X as additional working space. $A and $V are matrices while $S is a vector. - -=item gsl_linalg_SV_decomp_jacobi($A, $V, $S) - This function computes the SVD of the M-by-N matrix $A using one-sided Jacobi orthogonalization for M >= N. The Jacobi method can compute singular values to higher relative accuracy than Golub-Reinsch algorithms. $V is a matrix while $S is a vector. - -=item gsl_linalg_SV_solve($U, $V, $S, $b, $x) - This function solves the system A x = b using the singular value decomposition ($U, $S, $V) of A given by gsl_linalg_SV_decomp. Only non-zero singular values are used in computing the solution. The parts of the solution corresponding to singular values of zero are ignored. Other singular values can be edited out by setting them to zero before calling this function. In the over-determined case where A has more rows than columns the system is solved in the least squares sense, returning the solution x which minimizes ||A x - b||_2. - -=item gsl_linalg_LU_decomp($a, $p) - factorize the matrix $a into the LU decomposition PA = LU. On output the diagonal and upper triangular part of the input matrix A contain the matrix U. The lower triangular part of the input matrix (excluding the diagonal) contains L. The diagonal elements of L are unity, and are not stored. The function returns two value, the first is 0 if the operation succeeded, 1 otherwise, and the second is the sign of the permutation. - -=item gsl_linalg_LU_solve($LU, $p, $b, $x) - This function solves the square system A x = b using the LU decomposition of the matrix A into (LU, p) given by gsl_linalg_LU_decomp. $LU is a matrix, $p a permutation and $b and $x are vectors. The function returns 1 if the operation succeded, 0 otherwise. - -=item gsl_linalg_LU_svx($LU, $p, $x) - This function solves the square system A x = b in-place using the LU decomposition of A into (LU,p). On input $x should contain the right-hand side b, which is replaced by the solution on output. $LU is a matrix, $p a permutation and $x is a vector. The function returns 1 if the operation succeded, 0 otherwise. - -=item gsl_linalg_LU_refine($A, $LU, $p, $b, $x, $residual) - This function apply an iterative improvement to $x, the solution of $A $x = $b, using the LU decomposition of $A into ($LU,$p). The initial residual $r = $A $x - $b (where $x and $b are vectors) is also computed and stored in the vector $residual. - -=item gsl_linalg_LU_invert($LU, $p, $inverse) - This function computes the inverse of a matrix A from its LU decomposition stored in the matrix $LU and the permutation $p, storing the result in the matrix $inverse. - -=item gsl_linalg_LU_det($LU, $signum) - This function returns the determinant of a matrix A from its LU decomposition stored in the $LU matrix. It needs the integer $signum which is the sign of the permutation returned by gsl_linalg_LU_decomp. - -=item gsl_linalg_LU_lndet($LU) - This function returns the logarithm of the absolute value of the determinant of a matrix A, from its LU decomposition stored in the $LU matrix. - -=item gsl_linalg_LU_sgndet($LU, $signum) - This functions computes the sign or phase factor of the determinant of a matrix A, det(A)/|det(A)|, from its LU decomposition, $LU. - -=item gsl_linalg_complex_LU_decomp($A, $p) - Does the same operation than gsl_linalg_LU_decomp but on the complex matrix $A. - -=item gsl_linalg_complex_LU_solve($LU, $p, $b, $x) - This functions solve the square system A x = b using the LU decomposition of A into ($LU, $p) given by gsl_linalg_complex_LU_decomp. - -=item gsl_linalg_complex_LU_svx($LU, $p, $x) - Does the same operation than gsl_linalg_LU_svx but on the complex matrix $LU and the complex vector $x. - -=item gsl_linalg_complex_LU_refine($A, $LU, $p, $b, $x, $residual) - Does the same operation than gsl_linalg_LU_refine but on the complex matrices $A and $LU and with the complex vectors $b, $x and $residual. - -=item gsl_linalg_complex_LU_invert($LU, $p, $inverse) - Does the same operation than gsl_linalg_LU_invert but on the complex matrces $LU and $inverse. - -=item gsl_linalg_complex_LU_det($LU, $signum) - Does the same operation than gsl_linalg_LU_det but on the complex matrix $LU. - -=item gsl_linalg_complex_LU_lndet($LU) - Does the same operation than gsl_linalg_LU_det but on the complex matrix $LU. - -=item gsl_linalg_complex_LU_sgndet($LU, $signum) - Does the same operation than gsl_linalg_LU_sgndet but on the complex matrix $LU. - -=item gsl_linalg_QR_decomp($a, $tau) - factorize the M-by-N matrix A into the QR decomposition A = Q R. On output the diagonal and upper triangular part of the input matrix $a contain the matrix R. The vector $tau and the columns of the lower triangular part of the matrix $a contain the Householder coefficients and Householder vectors which encode the orthogonal matrix Q. The vector tau must be of length k= min(M,N). - -=item gsl_linalg_QR_solve($QR, $tau, $b, $x) - This function solves the square system A x = b using the QR decomposition of A into (QR, tau) given by gsl_linalg_QR_decomp. $QR is matrix, and $tau, $b and $x are vectors. - -=item gsl_linalg_QR_svx($QR, $tau, $x) - This function solves the square system A x = b in-place using the QR decomposition of A into the matrix $QR and the vector $tau given by gsl_linalg_QR_decomp. On input, the vector $x should contain the right-hand side b, which is replaced by the solution on output. - -=item gsl_linalg_QR_lssolve($QR, $tau, $b, $x, $residual) - This function finds the least squares solution to the overdetermined system $A $x = $b where the matrix $A has more rows than columns. The least squares solution minimizes the Euclidean norm of the residual, ||Ax - b||.The routine uses the $QR decomposition of $A into ($QR, $tau) given by gsl_linalg_QR_decomp. The solution is returned in $x. The residual is computed as a by-product and stored in residual. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_QRsolve($Q, $R, $b, $x) - This function solves the system $R $x = $Q**T $b for $x. It can be used when the $QR decomposition of a matrix is available in unpacked form as ($Q, $R). The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_Rsolve($QR, $b, $x) - This function solves the triangular system R $x = $b for $x. It may be useful if the product b' = Q^T b has already been computed using gsl_linalg_QR_QTvec. - -=item gsl_linalg_QR_Rsvx($QR, $x) - This function solves the triangular system R $x = b for $x in-place. On input $x should contain the right-hand side b and is replaced by the solution on output. This function may be useful if the product b' = Q^T b has already been computed using gsl_linalg_QR_QTvec. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_update($Q, $R, $b, $x) - This function performs a rank-1 update $w $v**T of the QR decomposition ($Q, $R). The update is given by Q'R' = Q R + w v^T where the output matrices Q' and R' are also orthogonal and right triangular. Note that w is destroyed by the update. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_QTvec($QR, $tau, $v) - This function applies the matrix Q^T encoded in the decomposition ($QR,$tau) to the vector $v, storing the result Q^T v in $v. The matrix multiplication is carried out directly using the encoding of the Householder vectors without needing to form the full matrix Q^T. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_Qvec($QR, $tau, $v) - This function applies the matrix Q encoded in the decomposition ($QR,$tau) to the vector $v, storing the result Q v in $v. The matrix multiplication is carried out directly using the encoding of the Householder vectors without needing to form the full matrix Q. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_QTmat($QR, $tau, $A) - This function applies the matrix Q^T encoded in the decomposition ($QR,$tau) to the matrix $A, storing the result Q^T A in $A. The matrix multiplication is carried out directly using the encoding of the Householder vectors without needing to form the full matrix Q^T. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QR_unpack($QR, $tau, $Q, $R) - This function unpacks the encoded QR decomposition ($QR,$tau) into the matrices $Q and $R, where $Q is M-by-M and $R is M-by-N. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_R_solve($R, $b, $x) - This function solves the triangular system $R $x = $b for the N-by-N matrix $R. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_R_svx($R, $x) - This function solves the triangular system $R $x = b in-place. On input $x should contain the right-hand side b, which is replaced by the solution on output. The function returns 0 if it succeded, 1 otherwise. - -=item gsl_linalg_QRPT_decomp($A, $tau, $p, $norm) - This function factorizes the M-by-N matrix $A into the QRP^T decomposition A = Q R P^T. On output the diagonal and upper triangular part of the input matrix contain the matrix R. The permutation matrix P is stored in the permutation $p. There's two value returned by this function : the first is 0 if the operation succeeded, 1 otherwise. The second is sign of the permutation. It has the value (-1)^n, where n is the number of interchanges in the permutation. The vector $tau and the columns of the lower triangular part of the matrix $A contain the Householder coefficients and vectors which encode the orthogonal matrix Q. The vector tau must be of length k=\min(M,N). The matrix Q is related to these components by, Q = Q_k ... Q_2 Q_1 where Q_i = I - \tau_i v_i v_i^T and v_i is the Householder vector v_i = (0,...,1,A(i+1,i),A(i+2,i),...,A(m,i)). This is the same storage scheme as used by lapack. The vector norm is a workspace of length N used for column pivoting. The algorithm used to perform the decomposition is Householder QR with column pivoting (Golub & Van Loan, Matrix Computations, Algorithm 5.4.1). - -=item gsl_linalg_QRPT_decomp2($A, $q, $r, $tau, $p, $norm) - This function factorizes the matrix $A into the decomposition A = Q R P^T without modifying $A itself and storing the output in the separate matrices $q and $r. For the rest, it operates exactly like gsl_linalg_QRPT_decomp - -=item gsl_linalg_QRPT_solve - -=item gsl_linalg_QRPT_svx - -=item gsl_linalg_QRPT_QRsolve - -=item gsl_linalg_QRPT_Rsolve - -=item gsl_linalg_QRPT_Rsvx - -=item gsl_linalg_QRPT_update - -=item gsl_linalg_LQ_decomp - -=item gsl_linalg_LQ_solve_T - -=item gsl_linalg_LQ_svx_T - -=item gsl_linalg_LQ_lssolve_T - -=item gsl_linalg_LQ_Lsolve_T - -=item gsl_linalg_LQ_Lsvx_T - -=item gsl_linalg_L_solve_T - -=item gsl_linalg_LQ_vecQ - -=item gsl_linalg_LQ_vecQT - -=item gsl_linalg_LQ_unpack - -=item gsl_linalg_LQ_update - -=item gsl_linalg_LQ_LQsolve - -=item gsl_linalg_PTLQ_decomp - -=item gsl_linalg_PTLQ_decomp2 - -=item gsl_linalg_PTLQ_solve_T - -=item gsl_linalg_PTLQ_svx_T - -=item gsl_linalg_PTLQ_LQsolve_T - -=item gsl_linalg_PTLQ_Lsolve_T - -=item gsl_linalg_PTLQ_Lsvx_T - -=item gsl_linalg_PTLQ_update - -=item gsl_linalg_cholesky_decomp($A) - Factorize the symmetric, positive-definite square matrix $A into the Cholesky decomposition A = L L^T and stores it into the matrix $A. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_cholesky_solve($cholesky, $b, $x) - This function solves the system A x = b using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_cholesky_decomp. $b and $x are vectors. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_cholesky_svx($cholesky, $x) - This function solves the system A x = b in-place using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_cholesky_decomp. On input the vector $x should contain the right-hand side b, which is replaced by the solution on output. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_cholesky_decomp_unit - -=item gsl_linalg_complex_cholesky_decomp($A) - Factorize the symmetric, positive-definite square matrix $A which contains complex numbers into the Cholesky decomposition A = L L^T and stores it into the matrix $A. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_complex_cholesky_solve($cholesky, $b, $x) - This function solves the system A x = b using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_complex_cholesky_decomp. $b and $x are vectors. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_complex_cholesky_svx($cholesky, $x) - This function solves the system A x = b in-place using the Cholesky decomposition of A into the matrix $cholesky given by gsl_linalg_complex_cholesky_decomp. On input the vector $x should contain the right-hand side b, which is replaced by the solution on output. The funtcion returns 0 if the operation succeeded, 0 otherwise. - -=item gsl_linalg_symmtd_decomp($A, $tau) - This function factorizes the symmetric square matrix $A into the symmetric tridiagonal decomposition Q T Q^T. On output the diagonal and subdiagonal part of the input matrix $A contain the tridiagonal matrix T. The remaining lower triangular part of the input matrix contains the Householder vectors which, together with the Householder coefficients $tau, encode the orthogonal matrix Q. This storage scheme is the same as used by lapack. The upper triangular part of $A is not referenced. $tau is a vector. - -=item gsl_linalg_symmtd_unpack($A, $tau, $Q, $diag, $subdiag) - This function unpacks the encoded symmetric tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_symmtd_decomp into the orthogonal matrix $Q, the vector of diagonal elements $diag and the vector of subdiagonal elements $subdiag. - -=item gsl_linalg_symmtd_unpack_T($A, $diag, $subdiag) - This function unpacks the diagonal and subdiagonal of the encoded symmetric tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_symmtd_decomp into the vectors $diag and $subdiag. - -=item gsl_linalg_hermtd_decomp($A, $tau) - This function factorizes the hermitian matrix $A into the symmetric tridiagonal decomposition U T U^T. On output the real parts of the diagonal and subdiagonal part of the input matrix $A contain the tridiagonal matrix T. The remaining lower triangular part of the input matrix contains the Householder vectors which, together with the Householder coefficients $tau, encode the orthogonal matrix Q. This storage scheme is the same as used by lapack. The upper triangular part of $A and imaginary parts of the diagonal are not referenced. $A is a complex matrix and $tau a complex vector. - -=item gsl_linalg_hermtd_unpack($A, $tau, $U, $diag, $subdiag) - This function unpacks the encoded tridiagonal decomposition ($A, $tau) obtained from gsl_linalg_hermtd_decomp into the unitary complex matrix $U, the real vector of diagonal elements $diag and the real vector of subdiagonal elements $subdiag. - -=item gsl_linalg_hermtd_unpack_T($A, $diag, $subdiag) - This function unpacks the diagonal and subdiagonal of the encoded tridiagonal decomposition (A, tau) obtained from the gsl_linalg_hermtd_decomp into the real vectors $diag and $subdiag. - -=item gsl_linalg_HH_solve($a, $b, $x) - This function solves the system $A $x = $b directly using Householder transformations where $A is a matrix, $b and $x vectors. On output the solution is stored in $x and $b is not modified. $A is destroyed by the Householder transformations. - -=item gsl_linalg_HH_svx($A, $x) - This function solves the system $A $x = b in-place using Householder transformations where $A is a matrix, $b is a vector. On input $x should contain the right-hand side b, which is replaced by the solution on output. The matrix $A is destroyed by the Householder transformations. - -=item gsl_linalg_solve_symm_tridiag - -=item gsl_linalg_solve_tridiag - -=item gsl_linalg_solve_symm_cyc_tridiag - -=item gsl_linalg_solve_cyc_tridiag - -=item gsl_linalg_bidiag_decomp - -=item gsl_linalg_bidiag_unpack - -=item gsl_linalg_bidiag_unpack2 - -=item gsl_linalg_bidiag_unpack_B - -=item gsl_linalg_balance_matrix - -=item gsl_linalg_balance_accum - -=item gsl_linalg_balance_columns - - - You have to add the functions you want to use inside the qw /put_funtion_here / with spaces between each function. You can also write use Math::GSL::Complex qw/:all/ to use all avaible functions of the module. - -For more informations on the functions, we refer you to the GSL offcial documentation: L - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=back - -=head1 EXAMPLES - -This example shows how to compute the determinant of a matrix with the LU decomposition: - - use Math::GSL::Matrix qw/:all/; - use Math::GSL::Permutation qw/:all/; - use Math::GSL::Linalg qw/:all/; - - my $Matrix = gsl_matrix_alloc(4,4); - map { gsl_matrix_set($Matrix, 0, $_, $_+1) } (0..3); - - gsl_matrix_set($Matrix,1, 0, 2); - gsl_matrix_set($Matrix, 1, 1, 3); - gsl_matrix_set($Matrix, 1, 2, 4); - gsl_matrix_set($Matrix, 1, 3, 1); - - gsl_matrix_set($Matrix, 2, 0, 3); - gsl_matrix_set($Matrix, 2, 1, 4); - gsl_matrix_set($Matrix, 2, 2, 1); - gsl_matrix_set($Matrix, 2, 3, 2); - - gsl_matrix_set($Matrix, 3, 0, 4); - gsl_matrix_set($Matrix, 3, 1, 1); - gsl_matrix_set($Matrix, 3, 2, 2); - gsl_matrix_set($Matrix, 3, 3, 3); - - my $permutation = gsl_permutation_alloc(4); - gsl_permutation_init($permutation); - my ($result, $signum) = gsl_linalg_LU_decomp($Matrix, $permutation); - my $det = gsl_linalg_LU_det($Matrix, $signum); - print "The value of the determinant of the matrix is $det \n"; - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} - +%module "Math::GSL::Linalg" +%apply int *OUTPUT { int *signum }; + +%{ + #include "gsl/gsl_linalg.h" + #include "gsl/gsl_permutation.h" +%} + +%include "gsl/gsl_linalg.h" +%include "gsl/gsl_permutation.h" +%include "../pod/Linalg.pod" diff --git a/swig/Machine.i b/swig/Machine.i dissimilarity index 97% index 7a51665..43d1b6c 100644 --- a/swig/Machine.i +++ b/swig/Machine.i @@ -1,211 +1,7 @@ -%module "Math::GSL::Machine" -%{ - #include "gsl/gsl_machine.h" -%} - -%include "gsl/gsl_machine.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - $GSL_DBL_EPSILON - $GSL_SQRT_DBL_EPSILON - $GSL_ROOT3_DBL_EPSILON - $GSL_ROOT4_DBL_EPSILON - $GSL_ROOT5_DBL_EPSILON - $GSL_ROOT6_DBL_EPSILON - $GSL_LOG_DBL_EPSILON - $GSL_DBL_MIN - $GSL_SQRT_DBL_MIN - $GSL_ROOT3_DBL_MIN - $GSL_ROOT4_DBL_MIN - $GSL_ROOT5_DBL_MIN - $GSL_ROOT6_DBL_MIN - $GSL_LOG_DBL_MIN - $GSL_DBL_MAX - $GSL_SQRT_DBL_MAX - $GSL_ROOT3_DBL_MAX - $GSL_ROOT4_DBL_MAX - $GSL_ROOT5_DBL_MAX - $GSL_ROOT6_DBL_MAX - $GSL_LOG_DBL_MAX - $GSL_FLT_EPSILON - $GSL_SQRT_FLT_EPSILON - $GSL_ROOT3_FLT_EPSILON - $GSL_ROOT4_FLT_EPSILON - $GSL_ROOT5_FLT_EPSILON - $GSL_ROOT6_FLT_EPSILON - $GSL_LOG_FLT_EPSILON - $GSL_FLT_MIN - $GSL_SQRT_FLT_MIN - $GSL_ROOT3_FLT_MIN - $GSL_ROOT4_FLT_MIN - $GSL_ROOT5_FLT_MIN - $GSL_ROOT6_FLT_MIN - $GSL_LOG_FLT_MIN - $GSL_FLT_MAX - $GSL_SQRT_FLT_MAX - $GSL_ROOT3_FLT_MAX - $GSL_ROOT4_FLT_MAX - $GSL_ROOT5_FLT_MAX - $GSL_ROOT6_FLT_MAX - $GSL_LOG_FLT_MAX - $GSL_SFLT_EPSILON - $GSL_SQRT_SFLT_EPSILON - $GSL_ROOT3_SFLT_EPSILON - $GSL_ROOT4_SFLT_EPSILON - $GSL_ROOT5_SFLT_EPSILON - $GSL_ROOT6_SFLT_EPSILON - $GSL_LOG_SFLT_EPSILON - $GSL_MACH_EPS - $GSL_SQRT_MACH_EPS - $GSL_ROOT3_MACH_EPS - $GSL_ROOT4_MACH_EPS - $GSL_ROOT5_MACH_EPS - $GSL_ROOT6_MACH_EPS - $GSL_LOG_MACH_EPS - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); -__END__ - -=head1 NAME - -Math::GSL::Machine - Machine constants - -=head1 SYNOPSIS - - use Math::GSL::Machine qw/:all/; - print "The GSL_DBL_EPSILON Constant is $GSL_DBL_EPSILON\n"; - -Here is a list of all the constants included in this module : - -=over - -=item * $GSL_DBL_EPSILON - -=item * $GSL_SQRT_DBL_EPSILON - -=item * $GSL_ROOT3_DBL_EPSILON - -=item * $GSL_ROOT4_DBL_EPSILON - -=item * $GSL_ROOT5_DBL_EPSILON - -=item * $GSL_ROOT6_DBL_EPSILON - -=item * $GSL_LOG_DBL_EPSILON - -=item * $GSL_DBL_MIN - -=item * $GSL_SQRT_DBL_MIN - -=item * $GSL_ROOT3_DBL_MIN - -=item * $GSL_ROOT4_DBL_MIN - -=item * $GSL_ROOT5_DBL_MIN - -=item * $GSL_ROOT6_DBL_MIN - -=item * $GSL_LOG_DBL_MIN - -=item * $GSL_DBL_MAX - -=item * $GSL_SQRT_DBL_MAX - -=item * $GSL_ROOT3_DBL_MAX - -=item * $GSL_ROOT4_DBL_MAX - -=item * $GSL_ROOT5_DBL_MAX - -=item * $GSL_ROOT6_DBL_MAX - -=item * $GSL_LOG_DBL_MAX - -=item * $GSL_FLT_EPSILON - -=item * $GSL_SQRT_FLT_EPSILON - -=item * $GSL_ROOT3_FLT_EPSILON - -=item * $GSL_ROOT4_FLT_EPSILON - -=item * $GSL_ROOT5_FLT_EPSILON - -=item * $GSL_ROOT6_FLT_EPSILON - -=item * $GSL_LOG_FLT_EPSILON - -=item * $GSL_FLT_MIN - -=item * $GSL_SQRT_FLT_MIN - -=item * $GSL_ROOT3_FLT_MIN - -=item * $GSL_ROOT4_FLT_MIN - -=item * $GSL_ROOT5_FLT_MIN - -=item * $GSL_ROOT6_FLT_MIN - -=item * $GSL_LOG_FLT_MIN - -=item * $GSL_FLT_MAX - -=item * $GSL_SQRT_FLT_MAX - -=item * $GSL_ROOT3_FLT_MAX - -=item * $GSL_ROOT4_FLT_MAX - -=item * $GSL_ROOT5_FLT_MAX - -=item * $GSL_ROOT6_FLT_MAX - -=item * $GSL_LOG_FLT_MAX - -=item * $GSL_SFLT_EPSILON - -=item * $GSL_SQRT_SFLT_EPSILON - -=item * $GSL_ROOT3_SFLT_EPSILON - -=item * $GSL_ROOT4_SFLT_EPSILON - -=item * $GSL_ROOT5_SFLT_EPSILON - -=item * $GSL_ROOT6_SFLT_EPSILON - -=item * $GSL_LOG_SFLT_EPSILON - -=item * $GSL_MACH_EPS - -=item * $GSL_SQRT_MACH_EPS - -=item * $GSL_ROOT3_MACH_EPS - -=item * $GSL_ROOT4_MACH_EPS - -=item * $GSL_ROOT5_MACH_EPS - -=item * $GSL_ROOT6_MACH_EPS - -=item * $GSL_LOG_MACH_EPS - -=back - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Machine" +%{ + #include "gsl/gsl_machine.h" +%} + +%include "gsl/gsl_machine.h" +%include "../pod/Machine.pod" diff --git a/swig/Matrix.i b/swig/Matrix.i dissimilarity index 98% index 049da1c..290aff4 100644 --- a/swig/Matrix.i +++ b/swig/Matrix.i @@ -1,1189 +1,27 @@ -%module "Math::GSL::Matrix" - -%include "typemaps.i" -%include "gsl_typemaps.i" -%apply int *OUTPUT { size_t *imin, size_t *imax, size_t *jmin, size_t *jmax }; -%apply double *OUTPUT { double * min_out, double * max_out }; - -%{ - #include "gsl/gsl_matrix.h" - #include "gsl/gsl_complex.h" - #include "gsl/gsl_vector_double.h" - #include "gsl/gsl_matrix_double.h" - #include "gsl/gsl_matrix_int.h" - #include "gsl/gsl_matrix_complex_double.h" - #include "gsl/gsl_matrix_char.h" -%} - -%include "gsl/gsl_matrix.h" -%include "gsl/gsl_complex.h" -%include "gsl/gsl_vector_double.h" -%include "gsl/gsl_matrix_double.h" -%include "gsl/gsl_matrix_int.h" -%include "gsl/gsl_matrix_complex_double.h" -%include "gsl/gsl_matrix_char.h" - - -%perlcode %{ - -use Carp qw/croak/; -use Math::GSL qw/:all/; -use Math::GSL::Errno qw/:all/; - -@EXPORT_OK = qw/ - gsl_matrix_alloc gsl_matrix_calloc gsl_matrix_alloc_from_block - gsl_matrix_alloc_from_matrix gsl_vector_alloc_row_from_matrix - gsl_vector_alloc_col_from_matrix gsl_matrix_free gsl_matrix_submatrix - gsl_matrix_row gsl_matrix_column gsl_matrix_diagonal - gsl_matrix_subdiagonal gsl_matrix_superdiagonal gsl_matrix_subrow - gsl_matrix_subcolumn gsl_matrix_view_array - gsl_matrix_view_array_with_tda gsl_matrix_view_vector - gsl_matrix_view_vector_with_tda gsl_matrix_const_submatrix - gsl_matrix_const_row gsl_matrix_const_column gsl_matrix_const_diagonal - gsl_matrix_const_subdiagonal gsl_matrix_const_superdiagonal - gsl_matrix_const_subrow gsl_matrix_const_subcolumn - gsl_matrix_const_view_array gsl_matrix_const_view_array_with_tda - gsl_matrix_const_view_vector gsl_matrix_const_view_vector_with_tda - gsl_matrix_get gsl_matrix_set gsl_matrix_ptr gsl_matrix_const_ptr - gsl_matrix_set_zero gsl_matrix_set_identity gsl_matrix_set_all - gsl_matrix_fread gsl_matrix_fwrite gsl_matrix_fscanf gsl_matrix_fprintf - gsl_matrix_memcpy gsl_matrix_swap gsl_matrix_swap_rows - gsl_matrix_swap_columns gsl_matrix_swap_rowcol gsl_matrix_transpose - gsl_matrix_transpose_memcpy gsl_matrix_max gsl_matrix_min - gsl_matrix_minmax gsl_matrix_max_index gsl_matrix_min_index - gsl_matrix_minmax_index gsl_matrix_isnull gsl_matrix_ispos - gsl_matrix_isneg gsl_matrix_isnonneg gsl_matrix_add gsl_matrix_sub - gsl_matrix_mul_elements gsl_matrix_div_elements gsl_matrix_scale - gsl_matrix_add_constant gsl_matrix_add_diagonal - gsl_matrix_char_alloc gsl_matrix_char_calloc gsl_matrix_char_alloc_from_block - gsl_matrix_char_alloc_from_matrix gsl_vector_char_alloc_row_from_matrix gsl_vector_char_alloc_col_from_matrix - gsl_matrix_char_free gsl_matrix_char_submatrix - gsl_matrix_char_row gsl_matrix_char_column - gsl_matrix_char_diagonal gsl_matrix_char_subdiagonal gsl_matrix_char_superdiagonal - gsl_matrix_char_subrow gsl_matrix_char_subcolumn gsl_matrix_char_view_array - gsl_matrix_char_view_array_with_tda gsl_matrix_char_view_vector gsl_matrix_char_view_vector_with_tda - gsl_matrix_char_const_submatrix gsl_matrix_char_const_row gsl_matrix_char_const_column - gsl_matrix_char_const_diagonal gsl_matrix_char_const_subdiagonal gsl_matrix_char_const_superdiagonal - gsl_matrix_char_const_subrow gsl_matrix_char_const_subcolumn gsl_matrix_char_const_view_array - gsl_matrix_char_const_view_array_with_tda gsl_matrix_char_const_view_vector gsl_matrix_char_const_view_vector_with_tda - gsl_matrix_char_get gsl_matrix_char_set gsl_matrix_char_ptr gsl_matrix_char_const_ptr - gsl_matrix_char_set_zero gsl_matrix_char_set_identity - gsl_matrix_char_set_all gsl_matrix_char_fread - gsl_matrix_char_fwrite gsl_matrix_char_fscanf gsl_matrix_char_fprintf - gsl_matrix_char_memcpy gsl_matrix_char_swap - gsl_matrix_char_swap_rows gsl_matrix_char_swap_columns - gsl_matrix_char_swap_rowcol gsl_matrix_char_transpose gsl_matrix_char_transpose_memcpy - gsl_matrix_char_max gsl_matrix_char_min - gsl_matrix_char_minmax gsl_matrix_char_max_index - gsl_matrix_char_min_index gsl_matrix_char_minmax_index - gsl_matrix_char_isnull gsl_matrix_char_ispos gsl_matrix_char_isneg - gsl_matrix_char_isnonneg gsl_matrix_char_add - gsl_matrix_char_sub gsl_matrix_char_mul_elements gsl_matrix_char_div_elements - gsl_matrix_char_scale gsl_matrix_char_add_constant gsl_matrix_char_add_diagonal - gsl_matrix_int_alloc gsl_matrix_int_calloc gsl_matrix_int_alloc_from_block - gsl_matrix_int_alloc_from_matrix gsl_vector_int_alloc_row_from_matrix gsl_vector_int_alloc_col_from_matrix - gsl_matrix_int_free gsl_matrix_int_submatrix gsl_matrix_int_row - gsl_matrix_int_column gsl_matrix_int_diagonal gsl_matrix_int_subdiagonal - gsl_matrix_int_superdiagonal gsl_matrix_int_subrow gsl_matrix_int_subcolumn gsl_matrix_int_view_array - gsl_matrix_int_view_array_with_tda gsl_matrix_int_view_vector gsl_matrix_int_view_vector_with_tda - gsl_matrix_int_const_submatrix gsl_matrix_int_const_row gsl_matrix_int_const_column - gsl_matrix_int_const_diagonal gsl_matrix_int_const_subdiagonal gsl_matrix_int_const_superdiagonal - gsl_matrix_int_const_subrow gsl_matrix_int_const_subcolumn gsl_matrix_int_const_view_array - gsl_matrix_int_const_view_array_with_tda gsl_matrix_int_const_view_vector gsl_matrix_int_const_view_vector_with_tda - gsl_matrix_int_get gsl_matrix_int_set - gsl_matrix_int_ptr gsl_matrix_int_const_ptr - gsl_matrix_int_set_zero gsl_matrix_int_set_identity gsl_matrix_int_set_all - gsl_matrix_int_fread gsl_matrix_int_fwrite - gsl_matrix_int_fscanf gsl_matrix_int_fprintf - gsl_matrix_int_memcpy gsl_matrix_int_swap - gsl_matrix_int_swap_rows gsl_matrix_int_swap_columns gsl_matrix_int_swap_rowcol - gsl_matrix_int_transpose gsl_matrix_int_transpose_memcpy - gsl_matrix_int_max gsl_matrix_int_min gsl_matrix_int_minmax - gsl_matrix_int_max_index gsl_matrix_int_min_index - gsl_matrix_int_minmax_index gsl_matrix_int_isnull - gsl_matrix_int_ispos gsl_matrix_int_isneg gsl_matrix_int_isnonneg - gsl_matrix_int_add gsl_matrix_int_sub - gsl_matrix_int_mul_elements gsl_matrix_int_div_elements gsl_matrix_int_scale - gsl_matrix_int_add_constant gsl_matrix_int_add_diagonal - gsl_matrix_get_row gsl_matrix_get_col gsl_matrix_set_row gsl_matrix_set_col - gsl_matrix_complex_alloc gsl_matrix_complex_calloc gsl_matrix_complex_alloc_from_block - gsl_matrix_complex_alloc_from_matrix gsl_vector_complex_alloc_row_from_matrix gsl_vector_complex_alloc_col_from_matrix - gsl_matrix_complex_free gsl_matrix_complex_submatrix gsl_matrix_complex_row - gsl_matrix_complex_column gsl_matrix_complex_diagonal gsl_matrix_complex_subdiagonal - gsl_matrix_complex_superdiagonal gsl_matrix_complex_subrow gsl_matrix_complex_subcolumn - gsl_matrix_complex_view_array gsl_matrix_complex_view_array_with_tda gsl_matrix_complex_view_vector - gsl_matrix_complex_view_vector_with_tda gsl_matrix_complex_const_submatrix gsl_matrix_complex_const_row - gsl_matrix_complex_const_column gsl_matrix_complex_const_diagonal gsl_matrix_complex_const_subdiagonal - gsl_matrix_complex_const_superdiagonal gsl_matrix_complex_const_subrow gsl_matrix_complex_const_subcolumn - gsl_matrix_complex_const_view_array gsl_matrix_complex_const_view_array_with_tda gsl_matrix_complex_const_view_vector - gsl_matrix_complex_const_view_vector_with_tda gsl_matrix_complex_get gsl_matrix_complex_set - gsl_matrix_complex_ptr gsl_matrix_complex_const_ptr gsl_matrix_complex_set_zero - gsl_matrix_complex_set_identity gsl_matrix_complex_set_all gsl_matrix_complex_fread - gsl_matrix_complex_fwrite gsl_matrix_complex_fscanf gsl_matrix_complex_fprintf - gsl_matrix_complex_memcpy gsl_matrix_complex_swap gsl_matrix_complex_swap_rows - gsl_matrix_complex_swap_columns gsl_matrix_complex_swap_rowcol gsl_matrix_complex_transpose - gsl_matrix_complex_transpose_memcpy gsl_matrix_complex_isnull gsl_matrix_complex_ispos - gsl_matrix_complex_isneg gsl_matrix_complex_add gsl_matrix_complex_sub - gsl_matrix_complex_mul_elements gsl_matrix_complex_div_elements gsl_matrix_complex_scale - gsl_matrix_complex_add_constant gsl_matrix_complex_add_diagonal gsl_matrix_complex_get_row - gsl_matrix_complex_get_col gsl_matrix_complex_set_row gsl_matrix_complex_set_col /; - - - -%EXPORT_TAGS = ( all => [ @EXPORT_OK ], - char => [ qw/ - gsl_matrix_char_alloc - gsl_matrix_char_calloc - gsl_matrix_char_alloc_from_block - gsl_matrix_char_alloc_from_matrix - gsl_vector_char_alloc_row_from_matrix - gsl_vector_char_alloc_col_from_matrix - gsl_matrix_char_free - gsl_matrix_char_submatrix - gsl_matrix_char_row - gsl_matrix_char_column - gsl_matrix_char_diagonal - gsl_matrix_char_subdiagonal - gsl_matrix_char_superdiagonal - gsl_matrix_char_subrow - gsl_matrix_char_subcolumn - gsl_matrix_char_view_array - gsl_matrix_char_view_array_with_tda - gsl_matrix_char_view_vector - gsl_matrix_char_view_vector_with_tda - gsl_matrix_char_const_submatrix - gsl_matrix_char_const_row - gsl_matrix_char_const_column - gsl_matrix_char_const_diagonal - gsl_matrix_char_const_subdiagonal - gsl_matrix_char_const_superdiagonal - gsl_matrix_char_const_subrow - gsl_matrix_char_const_subcolumn - gsl_matrix_char_const_view_array - gsl_matrix_char_const_view_array_with_tda - gsl_matrix_char_const_view_vector - gsl_matrix_char_const_view_vector_with_tda - gsl_matrix_char_get - gsl_matrix_char_set - gsl_matrix_char_ptr - gsl_matrix_char_const_ptr - gsl_matrix_char_set_zero - gsl_matrix_char_set_identity - gsl_matrix_char_set_all - gsl_matrix_char_fread - gsl_matrix_char_fwrite - gsl_matrix_char_fscanf - gsl_matrix_char_fprintf - gsl_matrix_char_memcpy - gsl_matrix_char_swap - gsl_matrix_char_swap_rows - gsl_matrix_char_swap_columns - gsl_matrix_char_swap_rowcol - gsl_matrix_char_transpose - gsl_matrix_char_transpose_memcpy - gsl_matrix_char_max - gsl_matrix_char_min - gsl_matrix_char_minmax - gsl_matrix_char_max_index - gsl_matrix_char_min_index - gsl_matrix_char_minmax_index - gsl_matrix_char_isnull - gsl_matrix_char_ispos - gsl_matrix_char_isneg - gsl_matrix_char_isnonneg - gsl_matrix_char_add - gsl_matrix_char_sub - gsl_matrix_char_mul_elements - gsl_matrix_char_div_elements - gsl_matrix_char_scale - gsl_matrix_char_add_constant - gsl_matrix_char_add_diagonal - /], - - double => [ qw/ - gsl_matrix_alloc - gsl_matrix_calloc - gsl_matrix_alloc_from_block - gsl_matrix_alloc_from_matrix - gsl_vector_alloc_row_from_matrix - gsl_vector_alloc_col_from_matrix - gsl_matrix_free - gsl_matrix_submatrix - gsl_matrix_row - gsl_matrix_column - gsl_matrix_diagonal - gsl_matrix_subdiagonal - gsl_matrix_superdiagonal - gsl_matrix_subrow - gsl_matrix_subcolumn - gsl_matrix_view_array - gsl_matrix_view_array_with_tda - gsl_matrix_view_vector - gsl_matrix_view_vector_with_tda - gsl_matrix_const_submatrix - gsl_matrix_const_row - gsl_matrix_const_column - gsl_matrix_const_diagonal - gsl_matrix_const_subdiagonal - gsl_matrix_const_superdiagonal - gsl_matrix_const_subrow - gsl_matrix_const_subcolumn - gsl_matrix_const_view_array - gsl_matrix_const_view_array_with_tda - gsl_matrix_const_view_vector - gsl_matrix_const_view_vector_with_tda - gsl_matrix_get - gsl_matrix_set - gsl_matrix_ptr - gsl_matrix_const_ptr - gsl_matrix_set_zero - gsl_matrix_set_identity - gsl_matrix_set_all - gsl_matrix_fread - gsl_matrix_fwrite - gsl_matrix_fscanf - gsl_matrix_fprintf - gsl_matrix_memcpy - gsl_matrix_swap - gsl_matrix_swap_rows - gsl_matrix_swap_columns - gsl_matrix_swap_rowcol - gsl_matrix_transpose - gsl_matrix_transpose_memcpy - gsl_matrix_max - gsl_matrix_minmax - gsl_matrix_max_index - gsl_matrix_min_index - gsl_matrix_minmax_index - gsl_matrix_isnull - gsl_matrix_ispos - gsl_matrix_isneg - gsl_matrix_isnonneg - gsl_matrix_add - gsl_matrix_mul_elements - gsl_matrix_div_elements - gsl_matrix_scale - gsl_matrix_add_constant - gsl_matrix_add_diagonal - /], -int => [ qw/ - gsl_matrix_int_alloc - gsl_matrix_int_alloc_from_matrix - gsl_matrix_int_free - gsl_matrix_int_column - gsl_matrix_int_superdiagonal - gsl_matrix_int_view_array_with_tda - gsl_matrix_int_const_submatrix - gsl_matrix_int_const_diagonal - gsl_matrix_int_const_subrow - gsl_matrix_int_const_view_array_with_tda - gsl_matrix_int_get - gsl_matrix_int_ptr - gsl_matrix_int_set_zero - gsl_matrix_int_fread - gsl_matrix_int_fscanf - gsl_matrix_int_memcpy - gsl_matrix_int_swap_rows - gsl_matrix_int_transpose - gsl_matrix_int_max - gsl_matrix_int_max_index - gsl_matrix_int_minmax_index - gsl_matrix_int_ispos - gsl_matrix_int_add - gsl_matrix_int_mul_elements - gsl_matrix_int_add_constant - /], - complex => [ qw/ - gsl_matrix_complex_alloc - gsl_matrix_complex_calloc - gsl_matrix_complex_alloc_from_block - gsl_matrix_complex_alloc_from_matrix - gsl_vector_complex_alloc_row_from_matrix - gsl_vector_complex_alloc_col_from_matrix - gsl_matrix_complex_free - gsl_matrix_complex_submatrix - gsl_matrix_complex_row - gsl_matrix_complex_column - gsl_matrix_complex_diagonal - gsl_matrix_complex_subdiagonal - gsl_matrix_complex_superdiagonal - gsl_matrix_complex_subrow - gsl_matrix_complex_subcolumn - gsl_matrix_complex_view_array - gsl_matrix_complex_view_array_with_tda - gsl_matrix_complex_view_vector - gsl_matrix_complex_view_vector_with_tda - gsl_matrix_complex_const_submatrix - gsl_matrix_complex_const_row - gsl_matrix_complex_const_column - gsl_matrix_complex_const_diagonal - gsl_matrix_complex_const_subdiagonal - gsl_matrix_complex_const_superdiagonal - gsl_matrix_complex_const_subrow - gsl_matrix_complex_const_subcolumn - gsl_matrix_complex_const_view_array - gsl_matrix_complex_const_view_array_with_tda - gsl_matrix_complex_const_view_vector - gsl_matrix_complex_const_view_vector_with_tda - gsl_matrix_complex_get - gsl_matrix_complex_set - gsl_matrix_complex_ptr - gsl_matrix_complex_const_ptr - gsl_matrix_complex_set_zero gsl_matrix_complex_set_identity - gsl_matrix_complex_set_all - gsl_matrix_complex_fread - gsl_matrix_complex_fwrite - gsl_matrix_complex_fscanf - gsl_matrix_complex_fprintf - gsl_matrix_complex_memcpygsl_matrix_complex_swap - gsl_matrix_complex_swap_rows - gsl_matrix_complex_swap_columns - gsl_matrix_complex_swap_rowcol - gsl_matrix_complex_transpose - gsl_matrix_complex_transpose_memcpy - gsl_matrix_complex_isnull - gsl_matrix_complex_ispos - gsl_matrix_complex_isneg - gsl_matrix_complex_add - gsl_matrix_complex_sub - gsl_matrix_complex_mul_elements - gsl_matrix_complex_div_elements - gsl_matrix_complex_scale - gsl_matrix_complex_add_constant - gsl_matrix_complex_add_diagonal - gsl_matrix_complex_get_row - gsl_matrix_complex_get_col - gsl_matrix_complex_set_row - gsl_matrix_complex_set_col - /]); - -=head1 NAME - -Math::GSL::Matrix - Mathematical functions concerning Matrices - -=head1 SYNOPSIS - - use Math::GSL::Matrix qw/:all/; - my $matrix1 = Math::GSL::Matrix->new(5,5); # OO interface - my $matrix2 = gsl_matrix_alloc(5,5); # standard interface - - -=head1 Objected Oriented Interface to GSL Math::GSL::Matrix - -=head2 Math::GSL::Matrix->new() - -Creates a new Matrix of the given size. - - my $matrix = Math::GSL::Matrix->new(10,10); -=cut - -sub new -{ - my ($class, $rows, $cols) = @_; - my $this = {}; - my $matrix; - if ( defined $rows && defined $cols && - $rows > 0 && $cols > 0 && - (int $rows == $rows) && (int $cols == $cols)){ - - $matrix = gsl_matrix_alloc($rows,$cols); - } else { - croak( __PACKAGE__.'::new($x,$y) - $x and $y must be positive integers'); - } - gsl_matrix_set_zero($matrix); - $this->{_matrix} = $matrix; - ($this->{_rows}, $this->{_cols}) = ($rows,$cols); - bless $this, $class; -} -=head2 raw() - -Get the underlying GSL matrix object created by SWIG, useful for using gsl_matrix_* functions which do not have an OO counterpart. - - my $matrix = Math::GSL::Matrix->new(3,3); - my $gsl_matrix = $matrix->raw; - my $stuff = gsl_matrix_get($gsl_matrix, 1, 2); - -=cut -sub raw { (shift)->{_matrix} } -=head2 rows() - -Returns the number of rows in the matrix. - - my $rows = $matrix->rows; -=cut - -sub rows { (shift)->{_rows} } - -=head2 cols() - -Returns the number of columns in the matrix. - - my $cols = $matrix->cols; -=cut - -sub cols { (shift)->{_cols} } - -=head2 as_list() - -Get the contents of a Math::GSL::Matrix object as a Perl list. - - my $matrix = Math::GSL::Matrix->new(3,3); - ... - my @matrix = $matrix->as_list; -=cut - - -sub as_list -{ - my $self = shift; - my $line; - my @part; - my @total; - for($line=0; $line<$self->rows; $line++){ - @part = map { - gsl_matrix_get($self->raw, $line, $_) - } (0 .. $self->cols-1 ); - push(@total, @part); - } - return @total; -} - -=head2 row() - -Returns a row matrix of the row you enter. - - my $matrix = Math::GSL::Matrix->new(3,3); - ... - my $matrix_row = $matrix->row(0); - -=cut - -sub row -{ - my ($self, $row) = @_; - croak (__PACKAGE__.'::$matrix->row($row) - invalid $row value') - unless (($row < $self->rows) and $row >= 0); - - my $rowmat = Math::GSL::Matrix->new(1,$self->cols); - - my @got; - for my $n (0 .. $self->cols-1) { - push (@got, gsl_matrix_get($self->raw, $row, $n)); - } - for my $n (0 .. $self->cols-1) { - gsl_matrix_set($rowmat->raw, 0, $n, $got[$n]); } - - return $rowmat; -} - -=head2 col() - -Returns a col matrix of the column you enter. - - my $matrix = Math::GSL::Matrix->new(3,3); - ... - my $matrix_col = $matrix->col(0); - -=cut - -sub col -{ - my ($self, $col) = @_; - croak (__PACKAGE__."::\$matrix->col(\$col) - $col not a valid column") - unless ($col < $self->cols and $col >= 0); - - my $colvec = Math::GSL::Vector->new($self->cols); - my $colmat = Math::GSL::Matrix->new($self->rows, 1); - - my @got; - for my $n (0 .. $self->rows-1) { - push (@got, gsl_matrix_get($self->raw, $n, $col)); - } - for my $n (0 .. $self->rows-1) { - gsl_matrix_set($colmat->raw, $n, 0, $got[$n]); } - - return $colmat; -} - -=head2 set_row() - -Sets a the values of a row with the elements of an array. - - my $matrix = Math::GSL::Matrix->new(3,3); - $matrix->set_row(0, [8, 6, 2]); - -You can also set multiple rows at once with chained calls: - my $matrix = Math::GSL::Matrix->new(3,3); - $matrix->set_row(0, [8, 6, 2]) - ->set_row(1, [2, 4, 1]); - ... - -=cut - -sub set_row { - my ($self, $row, $values) = @_; - my $length = $#$values; - die __PACKAGE__.'::new($x, $values) - $values must be a nonempty array reference' if $length == -1; - die __PACKAGE__.'::set_row($x, $values) - $x must be a valid row number' if ($row < 0 || $row >= $self->rows); - die __PACKAGE__.'::set_row($x, $values) - $values must contains the same number of elements as there is columns in the matrix' if($length != $self->cols-1); - map { gsl_matrix_set($self->raw, $row, $_, $values->[$_]) } (0..$length); - return $self; -} - -=head2 set_col() - -Sets a the values of a column with the elements of an array. - - my $matrix = Math::GSL::Matrix->new(3,3); - $matrix->set_col(0, [8, 6, 2]); - -You can also set multiple columns at once with chained calls: - my $matrix = Math::GSL::Matrix->new(3,3); - $matrix->set_col(0, [8, 6, 2]) - ->set_col(1, [2, 4, 1]); - ... - -=cut - -sub set_col { - my ($self, $col, $values) = @_; - my $length = $#$values; - die __PACKAGE__.'::new($x, $values) - $values must be a nonempty array reference' if $length == -1; - die __PACKAGE__.'::set_row($x, $values) - $x must be a valid column number' if ($col < 0 || $col >= $self->cols); - die __PACKAGE__.'::set_row($x, $values) - $values must contains the same number of elements as there is rowss in the matrix' if($length != $self->rows-1); - map { gsl_matrix_set($self->raw, $_, $col, $values->[$_]) } (0..$length); - return $self; -} - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over 1 - -=item C - Return a gsl_matrix of $i rows and $j columns - -=item C - Return a gsl_matrix of $i rows and $j columns and initialize all of the elements of the matrix to zero - -=item C - - -=item C - - -=item C - - -=item C - - -=item C - - -=item C - Return a matrix view of the matrix $m. The upper-left element of the submatrix is the element ($k1,$k2) of the original matrix. The submatrix has $n1 rows and $n2 columns. - -=item C - Return a vector view of the $i-th row of the matrix $m - -=item C - Return a vector view of the $j-th column of the matrix $m - -=item C - Return a vector view of the diagonal of the vector. The matrix doesn't have to be square. - -=item C - Return a vector view of the $k-th subdiagonal of the matrix $m. The diagonal of the matrix corresponds to k=0. - -=item C - Return a vector view of the $k-th superdiagonal of the matrix $m. The matrix doesn't have to be square. - -=item C - Return a vector view of the $i-th row of the matrix $m beginning at offset elements and containing n elements. - -=item C - Return a vector view of the $j-th column of the matrix $m beginning at offset elements and containing n elements. - -=item C - This function returns a matrix view of the array reference $base. The matrix has $n1 rows and $n2 columns. The physical number of columns in memory is also given by $n2. Mathematically, the (i,j)-th element of the new matrix is given by, m'(i,j) = $base->[i*$n2 + j] where the index i runs from 0 to $n1-1 and the index j runs from 0 to $n2-1. The new matrix is only a view of the array reference $base. When the view goes out of scope the original array reference $base will continue to exist. The original memory can only be deallocated by freeing the original array. Of course, the original array should not be deallocated while the view is still in use. - -=item C - This function returns a matrix view of the array reference $base with a physical number of columns $tda which may differ from the corresponding dimension of the matrix. The matrix has $n1 rows and $n2 columns, and the physical number of columns in memory is given by $tda. Mathematically, the (i,j)-th element of the new matrix is given by, m'(i,j) = $base->[i*$tda + j] where the index i runs from 0 to $n1-1 and the index j runs from 0 to $n2-1. The new matrix is only a view of the array reference $base. When the view goes out of scope the original array reference $base will continue to exist. The original memory can only be deallocated by freeing the original array. Of course, the original array should not be deallocated while the view is still in use. - -=item C - - -=item C - - -=item C - - -=item C - Return the (i,j)-th element of the matrix $m - -=item C - Set the value of the (i,j)-th element of the matrix $m to $x - -=item C - - -=item C - - -=item C - Set all the elements of the matrix $m to zero - -=item C - Set the elements of the matrix $m to the corresponding elements of the identity matrix - -=item C - Set all the elements of the matrix $m to the value $x - -=item C - Read a file which has been written with gsl_matrix_fwrite from the stream $fh opened with the gsl_fopen function from the Math::GSL module and stores the data inside the matrix $m - -=item C - Write the elements of the matrix $m in binary format to a stream $fh opened with the gsl_fopen function from the Math::GSL module - -=item C - Read a file which has been written with gsl_matrix_fprintf from the stream $fh opened with the gsl_fopenfunction from the Math::GSL module and stores the data inside the matrix $m - -=item C - Write the elements of the matrix $m in the format $format (for example "%f" is the format for double) to a stream $fh opened with the gsl_fopen function from the Math::GSL module - -=item C - Copy the elements of the matrix $src to the matrix $dest. The two matrices must have the same size. - -=item C - Exchange the elements of the matrices $m1 and $m2 by copying. The two matrices must have the same size. - -=item C - Exchange the $i-th and $j-th row of the matrix $m. The function returns 0 if the operation suceeded, 1 otherwise. - -=item C - Exchange the $i-th and $j-th column of the matrix $m. The function returns 0 if the operation suceeded, 1 otherwise. - -=item C - Exchange the $i-th row and the $j-th column of the matrix $m. The matrix must be square. The function returns 0 if the operation suceeded, 1 otherwise. - -=item C - This function replaces the matrix m by its transpose by copying the elements of the matrix in-place. The matrix must be square for this operation to be possible. - -=item C - Make the matrix $dest the transpose of the matrix $src. This function works for all matrices provided that the dimensions of the matrix dest match the transposed dimensions of the matrix src. - -=item C - Return the maximum value in the matrix $m - -=item C - Return the minimum value in the matrix $m - -=item C - Return two values, the first is the minimum value of the Matrix $m and the second is the maximum of the same the same matrix. - -=item C - Return two values, the first is the the i indice of the maximum value of the matrix $m and the second is the j indice of the same value. - -=item C - Return two values, the first is the the i indice of the minimum value of the matrix $m and the second is the j indice of the same value. - -=item C - Return four values, the first is the i indice of the minimum of the matrix $m, the second is the j indice of the same value, the third is the i indice of the maximum of the matrix $m and the fourth is the j indice of the same value - -=item C - Return 1 if all the elements of the matrix $m are zero, 0 otherwise - -=item C - Return 1 if all the elements of the matrix $m are strictly positve, 0 otherwise - -=item C - Return 1 if all the elements of the matrix $m are strictly negative, 0 otherwise - -=item C - Return 1 if all the elements of the matrix $m are non-negatuive, 0 otherwise - -=item C - Add the elements of matrix $b to the elements of matrix $a - -=item C - Subtract the elements of matrix $b from the elements of matrix $a - -=item C - Multiplie the elements of matrix $a by the elements of matrix $b - -=item C - Divide the elements of matrix $a by the elements of matrix $b - -=item C - Multiplie the elements of matrix $a by the constant factor $x - -=item C - Add the constant value $x to the elements of the matrix $a - -=item C - Add the constant value $x to the elements of the diagonal of the matrix $a - -=item C - Copy the elements of the $i-th row of the matrix $m into the vector $v. The lenght of the vector must be of the same as the lenght of the row. The function returns 0 if it succeded, 1 otherwise. - -=item C - Copy the elements of the $j-th column of the matrix $m into the vector $v. The lenght of the vector must be of the same as the lenght of the column. The function returns 0 if it succeded, 1 otherwise. - -=item C - Copy the elements of vector $v into the $i-th row of the matrix $m The lenght of the vector must be of the same as the lenght of the row. The function returns 0 if it succeded, 1 otherwise. - -=item C - Copy the elements of vector $v into the $j-th row of the matrix $m The lenght of the vector must be of the same as the lenght of the column. The function returns 0 if it succeded, 1 otherwise. - -=back - -The following functions are specific to matrices containing complex numbers : - -=over 1 - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - -These are related to constant views of a matrix. - -=over 1 - - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - - -The following functions are similar to those above but work with C's and C's. We are not quite -sure if anyone wants these. Please speak up if you do and/or submit some patches to this documentation, please! - -=over 1 - - -=item gsl_matrix_const_view_vector - -=item gsl_matrix_const_view_vector_with_tda - -=item gsl_matrix_char_alloc - -=item gsl_matrix_char_calloc - -=item gsl_matrix_char_alloc_from_block - -=item gsl_matrix_char_alloc_from_matrix - -=item gsl_vector_char_alloc_row_from_matrix - -=item gsl_vector_char_alloc_col_from_matrix - -=item gsl_matrix_char_free - -=item gsl_matrix_char_submatrix - -=item gsl_matrix_char_row - -=item gsl_matrix_char_column - -=item gsl_matrix_char_diagonal - -=item gsl_matrix_char_subdiagonal - -=item gsl_matrix_char_superdiagonal - -=item gsl_matrix_char_subrow - -=item gsl_matrix_char_subcolumn - -=item gsl_matrix_char_view_array - -=item gsl_matrix_char_view_array_with_tda - -=item gsl_matrix_char_view_vector - -=item gsl_matrix_char_view_vector_with_tda - -=item gsl_matrix_char_const_submatrix - -=item gsl_matrix_char_const_row - -=item gsl_matrix_char_const_column - -=item gsl_matrix_char_const_diagonal - -=item gsl_matrix_char_const_subdiagonal - -=item gsl_matrix_char_const_superdiagonal - -=item gsl_matrix_char_const_subrow - -=item gsl_matrix_char_const_subcolumn - -=item gsl_matrix_char_const_view_array - -=item gsl_matrix_char_const_view_array_with_tda - -=item gsl_matrix_char_const_view_vector - -=item gsl_matrix_char_const_view_vector_with_tda - -=item gsl_matrix_char_get - -=item gsl_matrix_char_set - -=item gsl_matrix_char_ptr - -=item gsl_matrix_char_const_ptr - -=item gsl_matrix_char_set_zero - -=item gsl_matrix_char_set_identity - -=item gsl_matrix_char_set_all - -=item gsl_matrix_char_fread - -=item gsl_matrix_char_fwrite - -=item gsl_matrix_char_fscanf - -=item gsl_matrix_char_fprintf - -=item gsl_matrix_char_memcpy - -=item gsl_matrix_char_swap - -=item gsl_matrix_char_swap_rows - -=item gsl_matrix_char_swap_columns - -=item gsl_matrix_char_swap_rowcol - -=item gsl_matrix_char_transpose - -=item gsl_matrix_char_transpose_memcpy - -=item gsl_matrix_char_max - -=item gsl_matrix_char_min - -=item gsl_matrix_char_minmax - -=item gsl_matrix_char_max_index - -=item gsl_matrix_char_min_index - -=item gsl_matrix_char_minmax_index - -=item gsl_matrix_char_isnull - -=item gsl_matrix_char_ispos - -=item gsl_matrix_char_isneg - -=item gsl_matrix_char_isnonneg - -=item gsl_matrix_char_add - -=item gsl_matrix_char_sub - -=item gsl_matrix_char_mul_elements - -=item gsl_matrix_char_div_elements - -=item gsl_matrix_char_scale - -=item gsl_matrix_char_add_constant - -=item gsl_matrix_char_add_diagonal - -=item gsl_matrix_int_alloc - -=item gsl_matrix_int_calloc - -=item gsl_matrix_int_alloc_from_block - -=item gsl_matrix_int_alloc_from_matrix - -=item gsl_vector_int_alloc_row_from_matrix - -=item gsl_vector_int_alloc_col_from_matrix - -=item gsl_matrix_int_free - -=item gsl_matrix_int_submatrix - -=item gsl_matrix_int_row - -=item gsl_matrix_int_column - -=item gsl_matrix_int_diagonal - -=item gsl_matrix_int_subdiagonal - -=item gsl_matrix_int_superdiagonal - -=item gsl_matrix_int_subrow - -=item gsl_matrix_int_subcolumn - -=item gsl_matrix_int_view_array - -=item gsl_matrix_int_view_array_with_tda - -=item gsl_matrix_int_view_vector - -=item gsl_matrix_int_view_vector_with_tda - -=item gsl_matrix_int_const_submatrix - -=item gsl_matrix_int_const_row - -=item gsl_matrix_int_const_column - -=item gsl_matrix_int_ptr - -=item gsl_matrix_int_const_ptr - -=item gsl_matrix_int_set_zero - -=item gsl_matrix_int_set_identity - -=item gsl_matrix_int_set_all - -=item gsl_matrix_int_fread - -=item gsl_matrix_int_fwrite - -=item gsl_matrix_int_fscanf - -=item gsl_matrix_int_fprintf - -=item gsl_matrix_int_memcpy - -=item gsl_matrix_int_swap - -=item gsl_matrix_int_swap_rows - -=item gsl_matrix_int_swap_columns - -=item gsl_matrix_int_swap_rowcol - -=item gsl_matrix_int_transpose - -=item gsl_matrix_int_transpose_memcpy - -=item gsl_matrix_int_max - -=item gsl_matrix_int_min - -=item gsl_matrix_int_minmax - -=item gsl_matrix_int_max_index - -=item gsl_matrix_int_min_index - -=item gsl_matrix_int_minmax_index - -=item gsl_matrix_int_isnull - -=item gsl_matrix_int_ispos - -=item gsl_matrix_int_isneg - -=item gsl_matrix_int_isnonneg - -=item gsl_matrix_int_add - -=item gsl_matrix_int_sub - -=item gsl_matrix_int_mul_elements - -=item gsl_matrix_int_div_elements - -=item gsl_matrix_int_scale - -=item gsl_matrix_int_add_constant - -=item gsl_matrix_int_add_diagonal - -=back - -You have to add the functions you want to use inside the qw /put_funtion_here /. -You can also write use Math::GSL::Matrix qw/:all/ to use all avaible functions of the module. -Other tags are also avaible, here is a complete list of all tags for this module : - -=over 1 - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - -For more informations on the functions, we refer you to the GSL offcial documentation -L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/name_of_the_function_you_want - -=head1 EXAMPLES - - Most of the examples from this section are perl versions of the examples at L - - The program below shows how to allocate, initialize and read from a matrix using the functions gsl_matrix_alloc, gsl_matrix_set and gsl_matrix_get. - - use Math::GSL::Matrix qw/:all/; - my $m = gsl_matrix_alloc (10,3); - for my $i (0..9){ - for my $j (0..2){ - gsl_matrix_set($m, $i, $j, 0.23 + 100*$i + $j); - } - } - - for my $i (0..99){ # OUT OF RANGE ERROR - for my $j (0..2){ - print "m($i, $j) = " . gsl_matrix_get ($m, $i, $j) . "\n"; - } - } - gsl_matrix_free ($m); - - - use Math::GSL::Matrix qw/:all/; - - my $m = gsl_matrix_alloc (100, 100); - my $a = gsl_matrix_alloc (100, 100); - - for my $i (0..99){ - for my $j (0..99){ - gsl_matrix_set ($m, $i, $j, 0.23 + $i + $j); - } - } - - The next program shows how to write a matrix to a file. - - my $out = gsl_fopen("test.dat", "wb"); - gsl_matrix_fwrite ($out, $m); - gsl_fclose ($out); - - my $in = gsl_fopen("test.dat", "rb"); - gsl_matrix_fread ($in, $a); - gsl_fclose($in); - - my $k=0; - for my $i (0..99){ - for my $j (0..99){ - $mij = gsl_matrix_get ($m, $i, $j); - $aij = gsl_matrix_get ($a, $i, $j); - $k++ if ($mij != $aij); - } - } - - gsl_matrix_free($m); - gsl_matrix_free($a); - - print "differences = $k (should be zero)\n"; - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +// Red Pill or Blue Pill ? +%module "Math::GSL::Matrix" + +%include "typemaps.i" +%include "gsl_typemaps.i" +%apply int *OUTPUT { size_t *imin, size_t *imax, size_t *jmin, size_t *jmax }; +%apply double *OUTPUT { double * min_out, double * max_out }; + +%{ + #include "gsl/gsl_matrix.h" + #include "gsl/gsl_complex.h" + #include "gsl/gsl_vector_double.h" + #include "gsl/gsl_matrix_double.h" + #include "gsl/gsl_matrix_int.h" + #include "gsl/gsl_matrix_complex_double.h" + #include "gsl/gsl_matrix_char.h" +%} + +%include "gsl/gsl_matrix.h" +%include "gsl/gsl_complex.h" +%include "gsl/gsl_vector_double.h" +%include "gsl/gsl_matrix_double.h" +%include "gsl/gsl_matrix_int.h" +%include "gsl/gsl_matrix_complex_double.h" +%include "gsl/gsl_matrix_char.h" + +%include "../pod/Matrix.pod" diff --git a/swig/Min.i b/swig/Min.i dissimilarity index 89% index aae7f1f..42551e3 100644 --- a/swig/Min.i +++ b/swig/Min.i @@ -1,116 +1,12 @@ -%module "Math::GSL::Min" -%include "typemaps.i" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_min.h" - #include "gsl/gsl_math.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_min.h" -%include "gsl/gsl_math.h" - -%perlcode %{ - -@EXPORT_OK = qw/ - gsl_min_fminimizer_alloc - gsl_min_fminimizer_free - gsl_min_fminimizer_set - gsl_min_fminimizer_set_with_values - gsl_min_fminimizer_iterate - gsl_min_fminimizer_name - gsl_min_fminimizer_x_minimum - gsl_min_fminimizer_x_lower - gsl_min_fminimizer_x_upper - gsl_min_fminimizer_f_minimum - gsl_min_fminimizer_f_lower - gsl_min_fminimizer_f_upper - gsl_min_fminimizer_minimum - gsl_min_test_interval - gsl_min_find_bracket - $gsl_min_fminimizer_brent - $gsl_min_fminimizer_goldensection -/; - -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Min - One-dimensional Minimization - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - -use Math::GSL::Min qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -This module also includes the following constants : - -=over - -=item * C<$gsl_min_fminimizer_brent> - -=item * C<$gsl_min_fminimizer_goldensection> - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Min" +%include "typemaps.i" +%include "gsl_typemaps.i" +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_min.h" + #include "gsl/gsl_math.h" +%} +%include "gsl/gsl_types.h" +%include "gsl/gsl_min.h" +%include "gsl/gsl_math.h" +%include "../pod/Min.pod" diff --git a/swig/Monte.i b/swig/Monte.i dissimilarity index 82% index ba0088a..e570b2b 100644 --- a/swig/Monte.i +++ b/swig/Monte.i @@ -1,116 +1,19 @@ -%module "Math::GSL::Monte" -%include "gsl/gsl_monte.h" -%include "gsl/gsl_monte_miser.h" -%include "gsl/gsl_monte_plain.h" -%include "gsl/gsl_monte_vegas.h" -%include "gsl/gsl_types.h" -%include "gsl/gsl_errno.h" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_monte.h" - #include "gsl/gsl_monte_miser.h" - #include "gsl/gsl_monte_plain.h" - #include "gsl/gsl_monte_vegas.h" - #include "gsl/gsl_types.h" - #include "gsl/gsl_errno.h" -%} - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_monte_miser_integrate - gsl_monte_miser_alloc - gsl_monte_miser_init - gsl_monte_miser_free - gsl_monte_plain_integrate - gsl_monte_plain_alloc - gsl_monte_plain_init - gsl_monte_plain_free - gsl_monte_vegas_integrate - gsl_monte_vegas_alloc - gsl_monte_vegas_init - gsl_monte_vegas_free - $GSL_VEGAS_MODE_IMPORTANCE - $GSL_VEGAS_MODE_IMPORTANCE_ONLY - $GSL_VEGAS_MODE_STRATIFIED - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Monte - Routines for multidimensional Monte Carlo integration - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - - use Math::GSL::Monte qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -This module also includes the following constants : - -=over - -=item * $GSL_VEGAS_MODE_IMPORTANCE - -=item * $GSL_VEGAS_MODE_IMPORTANCE_ONLY - -=item * $GSL_VEGAS_MODE_STRATIFIED - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - -%} +%module "Math::GSL::Monte" +%include "gsl/gsl_monte.h" +%include "gsl/gsl_monte_miser.h" +%include "gsl/gsl_monte_plain.h" +%include "gsl/gsl_monte_vegas.h" +%include "gsl/gsl_types.h" +%include "gsl/gsl_errno.h" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%{ + #include "gsl/gsl_monte.h" + #include "gsl/gsl_monte_miser.h" + #include "gsl/gsl_monte_plain.h" + #include "gsl/gsl_monte_vegas.h" + #include "gsl/gsl_types.h" + #include "gsl/gsl_errno.h" +%} +%include "../pod/Monte.pod" diff --git a/swig/Multifit.i b/swig/Multifit.i dissimilarity index 96% index ffbba74..5bb6376 100644 --- a/swig/Multifit.i +++ b/swig/Multifit.i @@ -1,144 +1,15 @@ -%module "Math::GSL::Multifit" - -%include "typemaps.i" -%apply double *OUTPUT { double * y, double * y_err, double * chisq, size_t * rank}; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multifit.h" - #include "gsl/gsl_multifit_nlin.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multifit.h" -%include "gsl/gsl_multifit_nlin.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_multifit_linear_alloc - gsl_multifit_linear_free - gsl_multifit_linear - gsl_multifit_linear_svd - gsl_multifit_wlinear - gsl_multifit_wlinear_svd - gsl_multifit_linear_est - gsl_multifit_linear_residuals - gsl_multifit_gradient - gsl_multifit_covar - gsl_multifit_fsolver_alloc - gsl_multifit_fsolver_free - gsl_multifit_fsolver_set - gsl_multifit_fsolver_iterate - gsl_multifit_fsolver_name - gsl_multifit_fsolver_position - gsl_multifit_fdfsolver_alloc - gsl_multifit_fdfsolver_set - gsl_multifit_fdfsolver_iterate - gsl_multifit_fdfsolver_free - gsl_multifit_fdfsolver_name - gsl_multifit_fdfsolver_position - gsl_multifit_test_delta - gsl_multifit_test_gradient - $gsl_multifit_fdfsolver_lmder - $gsl_multifit_fdfsolver_lmsder; - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Multifit - Least-squares functions for a general linear model with multiple parameters - -=head1 SYNOPSIS - -use Math::GSL::Multifit qw /:all/; - -=head1 DESCRIPTION - -The functions in this module perform least-squares fits to a general linear model, y = X c where y is a vector of n observations, X is an n by p matrix of predictor variables, and the elements of the vector c are the p unknown best-fit parameters which are to be estimated. - -Here is a list of all the functions in this module : - -=over - -=item C - This function allocates a workspace for fitting a model to $n observations using $p parameters. - -=item C - This function frees the memory associated with the workspace w. - -=item C - This function computes the best-fit parameters vector $c of the model y = X c for the observations vector $y and the matrix of predictor variables $X. The variance-covariance matrix of the model parameters vector $cov is estimated from the scatter of the observations about the best-fit. The sum of squares of the residuals from the best-fit, \chi^2, is returned after 0 if the operation succeeded, 1 otherwise. If the coefficient of determination is desired, it can be computed from the expression R^2 = 1 - \chi^2 / TSS, where the total sum of squares (TSS) of the observations y may be computed from gsl_stats_tss. The best-fit is found by singular value decomposition of the matrix $X using the preallocated workspace provided in $work. The modified Golub-Reinsch SVD algorithm is used, with column scaling to improve the accuracy of the singular values. Any components which have zero singular value (to machine precision) are discarded from the fit. - -=item C - This function computes the best-fit parameters c of the model y = X c for the observations vector $y and the matrix of predictor variables $X. The variance-covariance matrix of the model parameters vector $cov is estimated from the scatter of the observations about the best-fit. The sum of squares of the residuals from the best-fit, \chi^2, is returned after 0 if the operation succeeded, 1 otherwise. If the coefficient of determination is desired, it can be computed from the expression R^2 = 1 - \chi^2 / TSS, where the total sum of squares (TSS) of the observations y may be computed from gsl_stats_tss. In this second form of the function the components are discarded if the ratio of singular values s_i/s_0 falls below the user-specified tolerance $tol, and the effective rank is returned after the sum of squares of the residuals from the best-fit. - -=item C - This function computes the best-fit parameters vector $c of the weighted model y = X c for the observations y with weights $w and the matrix of predictor variables $X. The covariance matrix of the model parameters $cov is computed with the given weights. The weighted sum of squares of the residuals from the best-fit, \chi^2, is returned after 0 if the operation succeeded, 1 otherwise. If the coefficient of determination is desired, it can be computed from the expression R^2 = 1 - \chi^2 / WTSS, where the weighted total sum of squares (WTSS) of the observations y may be computed from gsl_stats_wtss. The best-fit is found by singular value decomposition of the matrix $X using the preallocated workspace provided in $work. Any components which have zero singular value (to machine precision) are discarded from the fit. - -=item C This function computes the best-fit parameters vector $c of the weighted model y = X c for the observations y with weights $w and the matrix of predictor variables $X. The covariance matrix of the model parameters $cov is computed with the given weights. The weighted sum of squares of the residuals from the best-fit, \chi^2, is returned after 0 if the operation succeeded, 1 otherwise. If the coefficient of determination is desired, it can be computed from the expression R^2 = 1 - \chi^2 / WTSS, where the weighted total sum of squares (WTSS) of the observations y may be computed from gsl_stats_wtss. The best-fit is found by singular value decomposition of the matrix $X using the preallocated workspace provided in $work. In this second form of the function the components are discarded if the ratio of singular values s_i/s_0 falls below the user-specified tolerance $tol, and the effective rank is returned after the sum of squares of the residuals from the best-fit.. - -=item C - This function uses the best-fit multilinear regression coefficients vector $c and their covariance matrix $cov to compute the fitted function value $y and its standard deviation $y_err for the model y = x.c at the point $x, in the form of a vector. The functions returns 3 values in this order : 0 if the operation succeeded, 1 otherwise, the fittes function value and its standard deviation. - -=item C - This function computes the vector of residuals r = y - X c for the observations vector $y, coefficients vector $c and matrix of predictor variables $X. $r is also a vector. - -=item C - This function computes the gradient $g of \Phi(x) = (1/2) ||F(x)||^2 from the Jacobian matrix $J and the function values $f, using the formula $g = $J^T $f. $g and $f are vectors. - -=item C - This function tests the residual gradient vector $g against the absolute error bound $epsabs. Mathematically, the gradient should be exactly zero at the minimum. The test returns $GSL_SUCCESS if the following condition is achieved, \sum_i |g_i| < $epsabs and returns $GSL_CONTINUE otherwise. This criterion is suitable for situations where the precise location of the minimum, x, is unimportant provided a value can be found where the gradient is small enough. - -=item C - This function tests for the convergence of the sequence by comparing the last step vector $dx with the absolute error $epsabs and relative error $epsrel to the current position x. The test returns $GSL_SUCCESS if the following condition is achieved, |dx_i| < epsabs + epsrel |x_i| for each component of x and returns $GSL_CONTINUE otherwise. - -=back - -The following functions are not yet implemented. Patches Welcome! - -=over - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Multifit" + +%include "typemaps.i" +%apply double *OUTPUT { double * y, double * y_err, double * chisq, size_t * rank}; + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_multifit.h" + #include "gsl/gsl_multifit_nlin.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_multifit.h" +%include "gsl/gsl_multifit_nlin.h" +%include "../pod/Multifit.pod" diff --git a/swig/Multimin.i b/swig/Multimin.i dissimilarity index 94% index 1b05c4a..4e5a4f1 100644 --- a/swig/Multimin.i +++ b/swig/Multimin.i @@ -1,135 +1,10 @@ -%module "Math::GSL::Multimin" - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multimin.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multimin.h" - -%perlcode %{ - -@EXPORT_OK = qw/ - gsl_multimin_fdfminimizer_alloc - gsl_multimin_fminimizer_alloc - gsl_multimin_fdfminimizer_set - gsl_multimin_fdfminimizer_free - gsl_multimin_fminimizer_free - gsl_multimin_fdfminimizer_name - gsl_multimin_fminimizer_name - gsl_multimin_fdfminimizer_iterate - gsl_multimin_fminimizer_iterate - gsl_multimin_fdfminimizer_x - gsl_multimin_fminimizer_x - gsl_multimin_fdfminimizer_minimum - gsl_multimin_fminimizer_minimum - gsl_multimin_fdfminimizer_gradient - gsl_multimin_fminimizer_size - gsl_multimin_fdfminimizer_restart - gsl_multimin_test_gradient - gsl_multimin_test_size - $gsl_multimin_fdfminimizer_conjugate_fr - $gsl_multimin_fdfminimizer_conjugate_pr - $gsl_multimin_fdfminimizer_vector_bfgs2 - $gsl_multimin_fdfminimizer_vector_bfgs - $gsl_multimin_fdfminimizer_steepest_descent - $gsl_multimin_fminimizer_nmsimplex -/; - -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Multimin - Routines for finding minima of arbitrary multidimensional functions - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - -use Math::GSL::Multimin qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -This module also includes the following constants : - -=over - -=item * C<$gsl_multimin_fdfminimizer_conjugate_fr> - -=item * C<$gsl_multimin_fdfminimizer_conjugate_pr> - -=item * C<$gsl_multimin_fdfminimizer_vector_bfgs2> - -=item * C<$gsl_multimin_fdfminimizer_vector_bfgs> - -=item * C<$gsl_multimin_fdfminimizer_steepest_descent> - -=item * C<$gsl_multimin_fminimizer_nmsimplex> - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Multimin" + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_multimin.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_multimin.h" +%include "../pod/Multimin.pod" diff --git a/swig/Multiroots.i b/swig/Multiroots.i dissimilarity index 90% index d42dcb2..8845a7d 100644 --- a/swig/Multiroots.i +++ b/swig/Multiroots.i @@ -1,128 +1,18 @@ -%module "Math::GSL::Multiroots" -%include "gsl_typemaps.i" - -%typemap(in) gsl_multiroot_function * { - gsl_multiroot_function *f; - /* stub */ - $1 = &f; -} - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_multiroots.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_multiroots.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_multiroot_fdjacobian - gsl_multiroot_fsolver_alloc - gsl_multiroot_fsolver_free - gsl_multiroot_fsolver_set - gsl_multiroot_fsolver_iterate - gsl_multiroot_fsolver_name - gsl_multiroot_fsolver_root - gsl_multiroot_fsolver_dx - gsl_multiroot_fsolver_f - gsl_multiroot_fdfsolver_alloc - gsl_multiroot_fdfsolver_set - gsl_multiroot_fdfsolver_iterate - gsl_multiroot_fdfsolver_free - gsl_multiroot_fdfsolver_name - gsl_multiroot_fdfsolver_root - gsl_multiroot_fdfsolver_dx - gsl_multiroot_fdfsolver_f - gsl_multiroot_test_delta - gsl_multiroot_test_residual - $gsl_multiroot_fsolver_dnewton - $gsl_multiroot_fsolver_broyden - $gsl_multiroot_fsolver_hybrid - $gsl_multiroot_fsolver_hybrids - $gsl_multiroot_fdfsolver_newton - $gsl_multiroot_fdfsolver_gnewton - $gsl_multiroot_fdfsolver_hybridj - $gsl_multiroot_fdfsolver_hybridsj - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Multiroots -Functions for multidimensional root-finding (solving nonlinear systems with n equations in n unknowns). - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - -use Math::GSL::Multiroots qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Multiroots" +%include "gsl_typemaps.i" + +%typemap(in) gsl_multiroot_function * { + gsl_multiroot_function *f; + /* stub */ + $1 = &f; +} + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_multiroots.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_multiroots.h" + +%include "../pod/Multiroots.pod" diff --git a/swig/NTuple.i b/swig/NTuple.i dissimilarity index 90% index b3eeba7..68bec1c 100644 --- a/swig/NTuple.i +++ b/swig/NTuple.i @@ -1,91 +1,26 @@ -%module "Math::GSL::NTuple" - -%typemap(in) void *ntuple_data { - fprintf(stderr,"symname=$symname\n"); - if ($input) - $1 = (double *) $input; -}; - -%typemap(argout) void *ntuple_data { - //Perl_sv_dump($1); -} - -%{ - #include "gsl/gsl_ntuple.h" -%} - -%include "gsl/gsl_ntuple.h" - - -%perlcode %{ - -# Intermittent failure happens *after* this -# END { warn "This is the end" } - - -@EXPORT_OK = qw/ - gsl_ntuple_open - gsl_ntuple_create - gsl_ntuple_write - gsl_ntuple_read - gsl_ntuple_bookdata - gsl_ntuple_project - gsl_ntuple_close - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::NTuple - Functions for creating and manipulating ntuples, sets of values associated with events - -=head1 SYNOPSIS - -This module is partially implemented. Patches Welcome! - - use Math::GSL::NTuple qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * - This function opens an existing ntuple file $filename for reading and returns a pointer to a corresponding ntuple struct. The ntuples in the file must have size $size. A pointer to memory for the current ntuple row $ntuple_data, which is an array reference, must be supplied—this is used to copy ntuples in and out of the file. - -=item * - This function creates a new write-only ntuple file $filename for ntuples of size $size and returns a pointer to the newly created ntuple struct. Any existing file with the same name is truncated to zero length and overwritten. A pointer to memory for the current ntuple row $ntuple_data, which is an array reference, must be supplied—this is used to copy ntuples in and out of the file. - - -=item * - This function writes the current $ntuple $ntuple->{ntuple_data} of size $ntuple->{size} to the corresponding file. - -=item * - This function is a synonym for gsl_ntuple_write. - -=item * - This function reads the current row of the ntuple file for ntuple and stores the values in $ntuple->{data}. - -=item * - -=item * - This function closes the ntuple file ntuple and frees its associated allocated memory. - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::NTuple" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%typemap(in) void *ntuple_data { + fprintf(stderr,"symname=$symname\n"); + if ($input) + $1 = (double *) $input; + // should have a croak in an else +}; + +%typemap(argout) void *ntuple_data { + //Perl_sv_dump($1); +} + +%{ + #include "gsl/gsl_ntuple.h" + #include "gsl/gsl_errno.h" + #include "gsl/gsl_histogram.h" +%} + +%include "gsl/gsl_ntuple.h" +%include "gsl/gsl_errno.h" +%include "gsl/gsl_histogram.h" + +%include "../pod/NTuple.pod" diff --git a/swig/ODEIV.i b/swig/ODEIV.i dissimilarity index 97% index 6becdc9..f6a0e98 100644 --- a/swig/ODEIV.i +++ b/swig/ODEIV.i @@ -1,164 +1,9 @@ -%module "Math::GSL::ODEIV" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_odeiv.h" - #include "gsl/gsl_types.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_odeiv.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_odeiv_step_alloc - gsl_odeiv_step_reset - gsl_odeiv_step_free - gsl_odeiv_step_name - gsl_odeiv_step_order - gsl_odeiv_step_apply - gsl_odeiv_control_alloc - gsl_odeiv_control_init - gsl_odeiv_control_free - gsl_odeiv_control_hadjust - gsl_odeiv_control_name - gsl_odeiv_control_standard_new - gsl_odeiv_control_y_new - gsl_odeiv_control_yp_new - gsl_odeiv_control_scaled_new - gsl_odeiv_evolve_alloc - gsl_odeiv_evolve_apply - gsl_odeiv_evolve_reset - gsl_odeiv_evolve_free - $gsl_odeiv_step_rk2 - $gsl_odeiv_step_rk4 - $gsl_odeiv_step_rkf45 - $gsl_odeiv_step_rkck - $gsl_odeiv_step_rk8pd - $gsl_odeiv_step_rk2imp - $gsl_odeiv_step_rk2simp - $gsl_odeiv_step_rk4imp - $gsl_odeiv_step_bsimp - $gsl_odeiv_step_gear1 - $gsl_odeiv_step_gear2 - $GSL_ODEIV_HADJ_INC - $GSL_ODEIV_HADJ_NIL - $GSL_ODEIV_HADJ_DEC - $gsl_odeiv_control_standard - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::ODEIV - functions for solving ordinary differential equation (ODE) initial value problems - -=head1 SYNOPSIS - -use Math::GSL::ODEIV qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - This function returns a pointer to a newly allocated instance of a stepping function of type $T for a system of $dim dimensions.$T must be one of the step type constant above. - -=item * C - This function resets the stepping function $s. It should be used whenever the next use of s will not be a continuation of a previous step. - -=item * C - This function frees all the memory associated with the stepping function $s. - -=item * C - This function returns a pointer to the name of the stepping function. - -=item * C - This function returns the order of the stepping function on the previous step. This order can vary if the stepping function itself is adaptive. - -=item * C - -=item * C - This function returns a pointer to a newly allocated instance of a control function of type $T. This function is only needed for defining new types of control functions. For most purposes the standard control functions described above should be sufficient. $T is a gsl_odeiv_control_type. - -=item * C - This function initializes the control function c with the parameters eps_abs (absolute error), eps_rel (relative error), a_y (scaling factor for y) and a_dydt (scaling factor for derivatives). - -=item * C - -=item * C - -=item * C - -=item * C - The standard control object is a four parameter heuristic based on absolute and relative errors $eps_abs and $eps_rel, and scaling factors $a_y and $a_dydt for the system state y(t) and derivatives y'(t) respectively. The step-size adjustment procedure for this method begins by computing the desired error level D_i for each component, D_i = eps_abs + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) and comparing it with the observed error E_i = |yerr_i|. If the observed error E exceeds the desired error level D by more than 10% for any component then the method reduces the step-size by an appropriate factor, h_new = h_old * S * (E/D)^(-1/q) where q is the consistency order of the method (e.g. q=4 for 4(5) embedded RK), and S is a safety factor of 0.9. The ratio E/D is taken to be the maximum of the ratios E_i/D_i. If the observed error E is less than 50% of the desired error level D for the maximum ratio E_i/D_i then the algorithm takes the opportunity to increase the step-size to bring the error in line with the desired level, h_new = h_old * S * (E/D)^(-1/(q+1)) This encompasses all the standard error scaling methods. To avoid uncontrolled changes in the stepsize, the overall scaling factor is limited to the range 1/5 to 5. - -=item * C - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the solution y_i(t). This is equivalent to the standard control object with a_y=1 and a_dydt=0. - -=item * C - This function creates a new control object which will keep the local error on each step within an absolute error of $eps_abs and relative error of $eps_rel with respect to the derivatives of the solution y'_i(t). This is equivalent to the standard control object with a_y=0 and a_dydt=1. - -=item * C - This function creates a new control object which uses the same algorithm as gsl_odeiv_control_standard_new but with an absolute error which is scaled for each component by the array reference $scale_abs. The formula for D_i for this control object is, D_i = eps_abs * s_i + eps_rel * (a_y |y_i| + a_dydt h |y'_i|) where s_i is the i-th component of the array scale_abs. The same error control heuristic is used by the Matlab ode suite. - -=item * C - This function returns a pointer to a newly allocated instance of an evolution function for a system of $dim dimensions. - -=item * C - -=item * C - This function resets the evolution function $e. It should be used whenever the next use of $e will not be a continuation of a previous step. - -=item * C - This function frees all the memory associated with the evolution function $e. - -=back - -This module also includes the following constants : - -=over - -=item * C<$GSL_ODEIV_HADJ_INC> - -=item * C<$GSL_ODEIV_HADJ_NIL> - -=item * C<$GSL_ODEIV_HADJ_DEC> - -=back - -=head2 Step Type - -=over - -=item * C<$gsl_odeiv_step_rk2> - Embedded Runge-Kutta (2, 3) method. - -=item * C<$gsl_odeiv_step_rk4> - 4th order (classical) Runge-Kutta. The error estimate is obtained by halving the step-size. For more efficient estimate of the error, use the Runge-Kutta-Fehlberg method described below. - -=item * C<$gsl_odeiv_step_rkf45> - Embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator. - -=item * C<$gsl_odeiv_step_rkck> - Embedded Runge-Kutta Cash-Karp (4, 5) method. - -=item * C<$gsl_odeiv_step_rk8pd> - Embedded Runge-Kutta Prince-Dormand (8,9) method. - -=item * C<$gsl_odeiv_step_rk2imp> - Implicit 2nd order Runge-Kutta at Gaussian points. - -=item * C<$gsl_odeiv_step_rk2simp> - -=item * C<$gsl_odeiv_step_rk4imp> - Implicit 4th order Runge-Kutta at Gaussian points. - -=item * C<$gsl_odeiv_step_bsimp> - Implicit Bulirsch-Stoer method of Bader and Deuflhard. This algorithm requires the Jacobian. - -=item * C<$gsl_odeiv_step_gear1> - M=1 implicit Gear method. - -=item * C<$gsl_odeiv_step_gear2> - M=2 implicit Gear method. - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::ODEIV" +%include "gsl_typemaps.i" +%{ + #include "gsl/gsl_odeiv.h" + #include "gsl/gsl_types.h" +%} +%include "gsl/gsl_types.h" +%include "gsl/gsl_odeiv.h" +%include "../pod/ODEIV.pod" diff --git a/swig/Permutation.i b/swig/Permutation.i dissimilarity index 93% index 12f2c17..9f30b7b 100644 --- a/swig/Permutation.i +++ b/swig/Permutation.i @@ -1,228 +1,21 @@ -%module "Math::GSL::Permutation" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_permute.h" - #include "gsl/gsl_permute_double.h" - #include "gsl/gsl_permute_int.h" - #include "gsl/gsl_permute_vector.h" - #include "gsl/gsl_permute_vector_double.h" - #include "gsl/gsl_permute_vector_int.h" - #include "gsl/gsl_permutation.h" -%} -%include "gsl/gsl_permute.h" -%include "gsl/gsl_permute_double.h" -%include "gsl/gsl_permute_int.h" -%include "gsl/gsl_permute_vector.h" -%include "gsl/gsl_permute_vector_double.h" -%include "gsl/gsl_permute_vector_int.h" -%include "gsl/gsl_permutation.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_permutation_alloc - gsl_permutation_calloc - gsl_permutation_init - gsl_permutation_free - gsl_permutation_memcpy - gsl_permutation_fread - gsl_permutation_fwrite - gsl_permutation_fscanf - gsl_permutation_fprintf - gsl_permutation_size - gsl_permutation_data - gsl_permutation_get - gsl_permutation_swap - gsl_permutation_valid - gsl_permutation_reverse - gsl_permutation_inverse - gsl_permutation_next - gsl_permutation_prev - gsl_permutation_mul - gsl_permutation_linear_to_canonical - gsl_permutation_canonical_to_linear - gsl_permutation_inversions - gsl_permutation_linear_cycles - gsl_permutation_canonical_cycles - gsl_permute - gsl_permute_inverse - gsl_permute_int - gsl_permute_int_inverse - gsl_permute_vector - gsl_permute_vector_inverse - gsl_permute_vector_int - gsl_permute_vector_int_inverse - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -### wrapper interface ### -sub new { - my ($class, $value) = @_; - my $this = {}; - $this->{_length} = $value; - $this->{_permutation} = gsl_permutation_calloc($value); - bless $this, $class; -} - -sub as_list { - my $self=shift; - $self->get( [ 0 .. $self->length - 1 ] ); -} - -sub get { - my ($self, $indices) = @_; - return map { gsl_permutation_get($self->{_permutation}, $_ ) } @$indices ; -} - -sub raw { (shift)->{_permutation} } -sub length { (shift)->{_length} } - - - - -__END__ - -=head1 NAME - -Math::GSL::Permutation - functions for creating and manipulating permutations - -=head1 SYNOPSIS - - use Math::GSL::Permutation qw/:all/; - my $permutation = Math::GSL::Permutation->new(30); # allocate and initialize a permutation of size 30 - my $lenght = $permutation->lenght; # returns the lenght of the permutation object, here it is 30 - gsl_permutation_swap($permutation->raw, 2,7); - # the raw method is made to use the underlying permutation structure of the permutation object - my $value = $permutation->get(2); # returns the third value (starting from 0) of the permutation - my @values = $permutation->as_list; # returns all the values of the permutation - my @set = $permutation->get([0,1,2,3]); # returns the four first values of the permutation - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over - -=item gsl_permutation_alloc($n) - return a newly allocated permutation of size $n - -=item gsl_permutation_calloc($n) - return a newly allocated permutation of size $n which is initialized to the identity - -=item gsl_permutation_init($p) - initialize the permutation $p to the identity i.e. (0,1,2, ..., n-1) - -=item gsl_permutation_free($p) - free all the memory use by the permutaion $p - -=item gsl_permutation_memcpy($dest, $src) - copy the permutation $src into the permutation $dest, the two permutations must have the same lenght and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_fread($stream, $p) - This function reads into the permutation $p from the open stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many bytes to read. The function returns 1 if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture. - -=item gsl_permutation_fwrite($stream, $p) - This function writes the elements of the permutation $p to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The function returns 1 if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures. - -=item gsl_permutation_fscanf($stream, $p) - This function reads formatted data from the stream $stream (opened with the gsl_fopen function from the Math::GSL module) into the permutation $p. The permutation $p must be preallocated with the correct length since the function uses the size of $p to determine how many numbers to read. The function returns 1 if there was a problem reading from the file. - -=item gsl_permutation_fprintf($stream, $p, $format) - This function writes the elements of the permutation $p line-by-line to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) using the format specifier $format, which should be suitable. "%zu\n" is a suitable format. The function returns 1 if there was a problem writing to the file. - -=item gsl_permutation_size($p) - return the size of the permutation $p - -=item gsl_permutation_data - -=item gsl_permutation_get($p, $i) - return the $i-th element of the permutation $p, return 0 if $i is outside the range of 0 to n-1 - -=item gsl_permutation_swap($p, $i, $j) - exchange the $i-th position and the $j-th position of the permutation $p and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_valid($p) - return 0 if the permutation $p is valid (if the n elements contain each of the numbers 0 to n-1 once and only once), 1 otherwise - -=item gsl_permutation_reverse($p) - reverse the elements of the permutation $p - -=item gsl_permutation_inverse($inv, $p) - compute the inverse of the permutation $p, storing it in $inv and return 0 if the operation succeeded, 1 otherwise - -=item gsl_permutation_next($p) - advance the permutation $p to the next permutation in lexicographic order and return 0 if the operation succeeded, 1 otherwise - -=item gsl_permutation_prev($p) - step backward from the permutation $p to the previous permutation in lexicographic order and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_mul($p, $pa, $pb) - combine the two permutation $pa and $pb into a single permutation $p and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_linear_to_canonical($q, $p) - compute the canonical form the permutation $p and store it in $q and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_canonical_to_linear($p, $q) - convert a canonical permutation $q back into linear form and store it in $p and return 0 if the operation suceeded, 1 otherwise - -=item gsl_permutation_inversions($p) - return the number of inversions in the permutation $p - -=item gsl_permutation_linear_cycles($p) - return the number of cycles in the permutation $p, given a linear form - -=item gsl_permute_vector_int_inversegsl_permutation_canonical_cycles($p) - return the number of cycles in the permutation $p, given a canonical form - -=item gsl_permute - -=item gsl_permute_inverse - -=item gsl_permute_int - -=item gsl_permute_int_inverse - -=item gsl_permute_vector - -=item gsl_permute_vector_inverse - -=item gsl_permute_vector_int - -=back - - You have to add the functions you want to use inside the qw/put_funtion_here/ with spaces between each function. - You can also write use Math::GSL::CDF qw/:all/ to use all avaible functions of the module. - Other tags are also avaible, here is a complete list of all tags for this module. -For more informations on the functions, we refer you to the GSL offcial documentation: -L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - - use Math::GSL::Permutation qw/:all/; - $p->{permutation} = gsl_permutation_calloc(5); - print "The permutation contains ["; - map { print gsl_permutation_get($p->{permutation}, $_) . ", " } (0..3); - print gsl_permutation_get($p->{permutation}, 4); - print "] \n"; - print "We'll then swap the first and last elements of the permutation...\n"; - gsl_permutation_swap($p->{permutation}, 0, 4); - print "The permutation now contains ["; - map { print gsl_permutation_get($p->{permutation},$_) . ", " } (0..3); - print gsl_permutation_get($p->{permutation}, 4); - print "] \n"; - - - use Math::GSL::Permutation qw/:all/; - use Math::GSL::Vector qw/:all/; - my $p->{permutation} = gsl_permutation_calloc(6); - gsl_permutation_init($p->{permutation}); - gsl_permutation_swap($p->{permutation}, 0, 1); - print "The permutation has his first and second elements swapped : ["; - map { print gsl_permutation_get($p->{permutation}, $_) . "," } (0..4); - print gsl_permutation_get($p->{permutation}, 5) . "] \n"; - my $vec->{vector} = gsl_vector_alloc(6); - map { gsl_vector_set($vec->{vector}, $_, $_) } (0..5); - - print "We will now apply the permutation to this vector : ["; - map { print gsl_vector_get($vec->{vector}, $_) . "," } (0..4); - print gsl_vector_get($vec->{vector}, 5) . "] \n"; - gsl_permute_vector($p->{permutation}, $vec->{vector}); - print "The vector is now : ["; - map { print gsl_vector_get($vec->{vector}, $_) . "," } (0..4); - print gsl_vector_get($vec->{vector}, 5) . "] \n"; - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} - +%module "Math::GSL::Permutation" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%{ + #include "gsl/gsl_permute.h" + #include "gsl/gsl_permute_double.h" + #include "gsl/gsl_permute_int.h" + #include "gsl/gsl_permute_vector.h" + #include "gsl/gsl_permute_vector_double.h" + #include "gsl/gsl_permute_vector_int.h" + #include "gsl/gsl_permutation.h" +%} +%include "gsl/gsl_permute.h" +%include "gsl/gsl_permute_double.h" +%include "gsl/gsl_permute_int.h" +%include "gsl/gsl_permute_vector.h" +%include "gsl/gsl_permute_vector_double.h" +%include "gsl/gsl_permute_vector_int.h" +%include "gsl/gsl_permutation.h" +%include "../pod/Permutation.pod" diff --git a/swig/Poly.i b/swig/Poly.i index 96bbaf8..8656cd2 100644 --- a/swig/Poly.i +++ b/swig/Poly.i @@ -104,106 +104,5 @@ %include "gsl/gsl_poly.h" %include "gsl/gsl_complex.h" %include "gsl/gsl_complex_math.h" - - -%perlcode %{ - -@EXPORT_OK = qw/ - gsl_poly_eval - gsl_poly_complex_eval - gsl_complex_poly_complex_eval - gsl_poly_dd_init - gsl_poly_dd_eval - gsl_poly_dd_taylor - gsl_poly_solve_quadratic - gsl_poly_complex_solve_quadratic - gsl_poly_solve_cubic - gsl_poly_complex_solve_cubic - gsl_poly_complex_workspace_alloc - gsl_poly_complex_workspace_free - gsl_poly_complex_solve - $GSL_POSZERO $GSL_NEGZERO $GSL_NAN - /; -our $GSL_NAN = gsl_nan(); - -%EXPORT_TAGS = ( all => \@EXPORT_OK ); - -__END__ - -=head1 NAME - -Math::GSL::Poly - Functions for evaluating and solving polynomials - -=head1 SYNOPSIS - -use Math::GSL::Poly qw/:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over - -=item * gsl_poly_eval(@values, $length, $x) - This function evaluates a polynomial with real coefficients for the real variable $x. $length is the number of elements inside @values. The function returns a complex number. - -=item * gsl_poly_complex_eval(@values, $length, $z) - This function evaluates a polynomial with real coefficients for the complex variable $z. $length is the number of elements inside @valuesi. The function returns a complex number. - -=item * gsl_complex_poly_complex_eval(@values, $length, $z) - This function evaluates a polynomial with real coefficients for the complex variable $z. $length is the number of elements inside @values. $length is the number of elements inside @values. The function returns a complex number. - -=item * gsl_poly_dd_init - -=item * gsl_poly_dd_eval - -=item * gsl_poly_dd_taylor - -=item * gsl_poly_solve_quadratic( $a, $b, $c, \$x0, \$x1) - find the real roots of the quadratic equation $a*x**2+$b*x+$c = 0, return the number of real root (either zero, one or two) and the real roots are returned by $x0, $x1 and $x2 which are deferenced. - -=item * gsl_poly_complex_solve_quadratic - -=item * gsl_poly_solve_cubic($a, $b, $c, \$x0, \$x1, \$x2) - find the real roots of the cubic equation x**3+$a*x**2+$b*x+$c = 0, return the number of real root (either one or three) and the real roots are returned by $x0, $x1 and $x2 which are deferenced. - -=item * gsl_poly_complex_solve_cubic - -=item * gsl_poly_complex_workspace_alloc($n) - This function allocates space for a gsl_poly_complex_workspace struct and a workspace suitable for solving a polynomial with $n coefficients using the routine gsl_poly_complex_solve. - -=item * gsl_poly_complex_workspace_free($w) - This function frees all the memory associated with the workspace w. - -=item * gsl_poly_complex_solve - -=back - -For more informations on the functions, we refer you to the GSL offcial documentation: -L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - -=over 1 - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%include "../pod/Poly.pod" diff --git a/swig/PowInt.i b/swig/PowInt.i dissimilarity index 94% index e4ca548..cb290c9 100644 --- a/swig/PowInt.i +++ b/swig/PowInt.i @@ -1,66 +1,7 @@ -%module "Math::GSL::PowInt" -%{ - #include "gsl/gsl_pow_int.h" -%} - -%include "gsl/gsl_pow_int.h" - -%perlcode %{ - -our @EXPORT_OK = qw/gsl_pow_2 gsl_pow_2 gsl_pow_3 - gsl_pow_4 gsl_pow_5 gsl_pow_6 - gsl_pow_7 gsl_pow_8 gsl_pow_9 gsl_pow_int - /; -our %EXPORT_TAGS = ( all => \@EXPORT_OK ); - -__END__ - -=head1 NAME - -Math::GSL::PowInt - Integer Power functions - -=head1 SYNOPSIS - - use Math::GSL::PowInt qw /gsl_pow_2 gsl_pow_4 gsl_pow_int/; - print '2**4 = ' . gsl_pow_2(4) . "\n"; - print '4**7 = ' . gsl_pow_4(7) . "\n"; - print '17**5 = ' . gsl_pow_int(17,5) . "\n"; - -=head1 DESCRIPTION - -This module implements the GSL Integer Power functions, which allow one to -quickly compute a given integer raised to any real number. It contains -gsl_pow_2 to gsl_pow_9 and gsl_pow_int. If you need a power higher than 9, you -can use gsl_pow_int, which takes a base as the first argument and power being -raised to as the second argument. - -You can also write - -C - -to use all avaible functions of the module. - -=head1 PURPOSE - -This module is used to speed up arithmetic operations. The underlying code -decomposes the multiplication in the most efficient way. Since it is -implemented in XS (via SWIG), it should lend a large performance increase over -the Perl builtin exponentiation operator, '**' . - -=head1 BENCHMARKS - -Would someone like to submit some benchmarks? - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::PowInt" +%{ + #include "gsl/gsl_pow_int.h" +%} + +%include "gsl/gsl_pow_int.h" +%include "../pod/PowInt.pod" diff --git a/swig/QRNG.i b/swig/QRNG.i dissimilarity index 82% index 7bcdc9d..6fdee27 100644 --- a/swig/QRNG.i +++ b/swig/QRNG.i @@ -1,112 +1,31 @@ -%module "Math::GSL::QRNG" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double x[] }; - - -%typemap(argout) double x[] { - AV *tempav; - I32 len; - int i; - SV **tv; - if (argvi >= items) { - EXTEND(sp,1); - } - $result = sv_newmortal(); - sv_setnv($result,(NV) *($1)); - argvi++; - - $result = sv_newmortal(); - sv_setnv($result,(NV) *($1+1)); - argvi++; -} - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_qrng.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_qrng.h" - -%perlcode %{ - -@EXPORT_OK = qw($gsl_qrng_niederreiter_2 $gsl_qrng_sobol $gsl_qrng_halton $gsl_qrng_reversehalton - gsl_qrng_alloc gsl_qrng_memcpy gsl_qrng_clone - gsl_qrng_free gsl_qrng_init gsl_qrng_name - gsl_qrng_size gsl_qrng_state gsl_qrng_get - ); -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - - -__END__ - -=head1 NAME - -Math::GSL::QRNG - Quasi-random number generator - -=head1 SYNOPSIS - -use Math::GSL::QRNG qw/:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over - -=item C - This function returns a pointer to a newly-created instance of a quasi-random sequence generator of type $T and dimension $d. The type $T must be one of the constants included in this module. - -=item C - This function returns a pointer to a newly created generator which is an exact copy of the generator $q. - -=item C - This function copies the quasi-random sequence generator $src into the pre-existing generator $dest, making $dest into an exact copy of $src. The two generators must be of the same type. - -=item C - This function frees all the memory associated with the generator $q. - -=item C - This function reinitializes the generator $q to its starting point. Note that quasi-random sequences do not use a seed and always produce the same set of values. - -=item C - This function returns a pointer to the name of the generator $q. - -=item C - This function returns the size of the state of generator r from the generator $q. You can use this information to access the state directly. - -=item C - This function returns a pointer to the state of generator r from the generator $q. You can use this information to access the state directly. - -=item C - -=back - -This module also contains the following constants : - -=over - -=item C<$gsl_qrng_niederreiter_2> - -=item C<$gsl_qrng_sobol> - -=item C<$gsl_qrng_halton> - -=item C<$gsl_qrng_reversehalton> - -=back - -For more informations on the functions, we refer you to the GSL offcial documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 EXAMPLES - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::QRNG" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double x[] }; + +%typemap(argout) double x[] { + AV *tempav; + I32 len; + int i; + SV **tv; + if (argvi >= items) { + EXTEND(sp,1); + } + $result = sv_newmortal(); + sv_setnv($result,(NV) *($1)); + argvi++; + + $result = sv_newmortal(); + sv_setnv($result,(NV) *($1+1)); + argvi++; +} + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_qrng.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_qrng.h" +%include "../pod/QRNG.pod" diff --git a/swig/RNG.i b/swig/RNG.i dissimilarity index 99% index bc75795..00753fa 100644 --- a/swig/RNG.i +++ b/swig/RNG.i @@ -1,383 +1,8 @@ -%module "Math::GSL::RNG" -%{ - #include "gsl/gsl_rng.h" -%} -%import "gsl/gsl_types.h" - -%include "gsl/gsl_rng.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_rng_alloc gsl_rng_set gsl_rng_get gsl_rng_free gsl_rng_memcpy - gsl_rng_fwrite gsl_rng_fread gsl_rng_clone gsl_rng_max gsl_rng_min - gsl_rng_name gsl_rng_size gsl_rng_state gsl_rng_print_state gsl_rng_uniform gsl_rng_uniform_pos gsl_rng_uniform_int - $gsl_rng_default $gsl_rng_knuthran $gsl_rng_ran0 $gsl_rng_borosh13 - $gsl_rng_coveyou $gsl_rng_cmrg $gsl_rng_fishman18 $gsl_rng_fishman20 $gsl_rng_fishman2x - $gsl_rng_gfsr4 $gsl_rng_knuthran $gsl_rng_knuthran2 $gsl_rng_knuthran2002 $gsl_rng_lecuyer21 - $gsl_rng_minstd $gsl_rng_mrg $gsl_rng_mt19937 $gsl_rng_mt19937_1999 $gsl_rng_mt19937_1998 - $gsl_rng_r250 $gsl_rng_ran0 $gsl_rng_ran1 $gsl_rng_ran2 $gsl_rng_ran3 - $gsl_rng_rand $gsl_rng_rand48 $gsl_rng_random128_bsd $gsl_rng_random128_gli $gsl_rng_random128_lib - $gsl_rng_random256_bsd $gsl_rng_random256_gli $gsl_rng_random256_lib $gsl_rng_random32_bsd - $gsl_rng_random32_glib $gsl_rng_random32_libc $gsl_rng_random64_bsd $gsl_rng_random64_glib - $gsl_rng_random64_libc $gsl_rng_random8_bsd $gsl_rng_random8_glibc $gsl_rng_random8_libc5 - $gsl_rng_random_bsd $gsl_rng_random_glibc2 $gsl_rng_random_libc5 $gsl_rng_randu - $gsl_rng_ranf $gsl_rng_ranlux $gsl_rng_ranlux389 $gsl_rng_ranlxd1 $gsl_rng_ranlxd2 $gsl_rng_ranlxs0 - $gsl_rng_ranlxs1 $gsl_rng_ranlxs2 $gsl_rng_ranmar $gsl_rng_slatec $gsl_rng_taus $gsl_rng_taus2 - $gsl_rng_taus113 $gsl_rng_transputer $gsl_rng_tt800 $gsl_rng_uni $gsl_rng_uni32 $gsl_rng_vax - $gsl_rng_waterman14 $gsl_rng_zuf - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -=head1 NAME - -Math::GSL::RNG - Random Number Generators - -=head1 SYNOPSIS - - use Math::GSL::RNG qw/:all/; - my $rng = Math::GSL::RNG->new; - my @random = map { $rng->get } (1..100); - -=head2 Math::GSL::RNG->new($type, $seed) - - my $rng = Math::GSL::RNG->new; - my $rng = Math::GSL::RNG->new($gsl_rng_knuthran,5); - -Creates a new RNG object of type $type, seeded with $seed. Both of these -parameters are optional. The type $gsl_rng_default is used when no $type -is given. - -=cut - -sub new { - my ($class, $type, $seed) = @_; - $type ||= $gsl_rng_default; - $seed ||= int 100*rand; - - my $self = {}; - my $rng = gsl_rng_alloc($type); - gsl_rng_set($rng, $seed); - - $self->{_rng} = $rng; - bless $self, $class; -} - -=head2 copy() - - my $copy = $rng->copy; - -Make a copy of a RNG object. - -=cut - -sub copy { - my ($self) = @_; - my $copy = Math::GSL::RNG->new; - $copy->{_rng} = gsl_rng_clone($self->{_rng}); - - return $copy; -} - -=head2 free() - - $rng->free(); - -Free memory associated with RNG object. - -=cut - -sub free { - my ($self) = @_; - gsl_rng_free($self->{_rng}); -} - -=head2 name() - - my $name = $rng->name(); - -Get the name of the RNG object as a string. - -=cut - -sub name { - my ($self) = @_; - gsl_rng_name($self->{_rng}); -} - -=head2 get() - - my $nextval = $rng->get(); - -Get the next random value from the RNG object. - -=cut - -sub get { - my ($self) = @_; - - gsl_rng_get($self->{_rng}); -} - -=head2 raw() - - my $raw = $rng->raw(); - -Return the raw GSL RNG object, useful for functions which take a RNG, such as the Monte Carlo integration functions. - -=cut - -sub raw { - my $self = shift; - return $self->{_rng}; -} - -__END__ - - -=head1 DESCRIPTION - -=over 1 - -=item gsl_rng_alloc($T) - This function returns a pointer to a newly-created instance of a random number generator of type $T. $T must be one of the constants below. The generator is automatically initialized with the default seed, $gsl_rng_default. - -=item gsl_rng_set($r, $s) - This function initializes (or `seeds') the random number generator. If the generator is seeded with the same value of $s on two different runs, the same stream of random numbers will be generated by successive calls to the routines below. If different values of $s are supplied, then the generated streams of random numbers should be completely different. If the seed $s is zero then the standard seed from the original implementation is used instead. For example, the original Fortran source code for the ranlux generator used a seed of 314159265, and so choosing $s equal to zero reproduces this when using $gsl_rng_ranlux. - -=item gsl_rng_get($r) - This function returns a random integer from the generator $r. The minimum and maximum values depend on the algorithm used, but all integers in the range [min,max] are equally likely. The values of min and max can determined using the auxiliary functions gsl_rng_max($r) and gsl_rng_min($r). - -=item gsl_rng_free($r) - This function frees all the memory associated with the generator $r. - -=item gsl_rng_memcpy($dest, $src) - This function copies the random number generator $src into the pre-existing generator $dest, making $dest into an exact copy of $src. The two generators must be of the same type. - -=item gsl_rng_uniform($r) - This function returns a double precision floating point number uniformly distributed in the range [0,1). The range includes 0.0 but excludes 1.0. The value is typically obtained by dividing the result of gsl_rng_get($r) by gsl_rng_max($r) + 1.0 in double precision. Some generators compute this ratio internally so that they can provide floating point numbers with more than 32 bits of randomness (the maximum number of bits that can be portably represented in a single unsigned long int). - -=item gsl_rng_uniform_pos($r) - This function returns a positive double precision floating point number uniformly distributed in the range (0,1), excluding both 0.0 and 1.0. The number is obtained by sampling the generator with the algorithm of gsl_rng_uniform until a non-zero value is obtained. You can use this function if you need to avoid a singularity at 0.0. - -=item gsl_rng_uniform_int($r, $n) - This function returns a random integer from 0 to $n-1 inclusive by scaling down and/or discarding samples from the generator $r. All integers in the range [0,$n-1] are produced with equal probability. For generators with a non-zero minimum value an offset is applied so that zero is returned with the correct probability. Note that this function is designed for sampling from ranges smaller than the range of the underlying generator. The parameter $n must be less than or equal to the range of the generator $r. If $n is larger than the range of the generator then the function calls the error handler with an error code of $GSL_EINVAL and returns zero. In particular, this function is not intended for generating the full range of unsigned integer values [0,2^32-1]. Instead choose a generator with the maximal integer range and zero mimimum value, such as $gsl_rng_ranlxd1, $gsl_rng_mt19937 or $gsl_rng_taus, and sample it directly using gsl_rng_get. The range of each generator can be found using the auxiliary functions described in the next section. - -=item gsl_rng_fwrite($stream, $r) - This function writes the random number state of the random number generator $r to the stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The return value is 0 for success and $GSL_EFAILED if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures. - -=item gsl_rng_fread($stream, $r) - This function reads the random number state into the random number generator $r from the open stream $stream (opened with the gsl_fopen function from the Math::GSL module) in binary format. The random number generator $r must be preinitialized with the correct random number generator type since type information is not saved. The return value is 0 for success and $GSL_EFAILED if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture. - -=item gsl_rng_clone($r) - This function returns a pointer to a newly created generator which is an exact copy of the generator $r. - -=item gsl_rng_max($r) - This function returns the largest value that gsl_rng_get can return. - -=item gsl_rng_min($r) - gsl_rng_min returns the smallest value that gsl_rng_get can return. Usually this value is zero. There are some generators with algorithms that cannot return zero, and for these generators the minimum value is 1. - -=item gsl_rng_name($r) - This function returns a pointer to the name of the generator. For example, - -=over - -=item print "r is a " . gsl_rng_name($r) . "generator\n"; - -=item would print something like r is a 'taus' generator. - -=back - -=item gsl_rng_size($r) - This function returns the size of the state of generator $r. You can use this information to access the state directly. - -=item gsl_rng_state($r) - This function returns a pointer to the state of generator $r. You can use this information to access the state directly. - -=item gsl_rng_print_state($r) - -=back - -=head1 Random Number Generator Types - -=over 1 - -=item $gsl_rng_default - -=item $gsl_rng_knuthran - -=item $gsl_rng_ran0 - -=item $gsl_rng_borosh13 - -=item $gsl_rng_coveyou - -=item $gsl_rng_cmrg - -=item $gsl_rng_fishman18 - -=item $gsl_rng_fishman20 - -=item $gsl_rng_fishman2x - This is the L'Ecuyer–Fishman random number generator. It is taken from Knuth's Seminumerical Algorithms, 3rd Ed., page 108. Its sequence is, z_{n+1} = (x_n - y_n) mod m with m = 2^31 - 1. x_n and y_n are given by the fishman20 and lecuyer21 algorithms. The seed specifies the initial value, x_1. - -=item $gsl_rng_gfsr4 - -=item $gsl_rng_knuthran - -=item $gsl_rng_knuthran2 - -=item $gsl_rng_knuthran2002 - -=item $gsl_rng_lecuyer21 - -=item $gsl_rng_minstd - -=item $gsl_rng_mrg - -=item $gsl_rng_mt19937 - -=item $gsl_rng_mt19937_1999 - -=item $gsl_rng_mt19937_1998 - -=item $gsl_rng_r250 - -=item $gsl_rng_ran0 - -=item $gsl_rng_ran1 - -=item $gsl_rng_ran2 - -=item $gsl_rng_ran3 - -=item $gsl_rng_rand - This is the BSD rand generator. Its sequence is x_{n+1} = (a x_n + c) mod m with a = 1103515245, c = 12345 and m = 2^31. The seed specifies the initial value, x_1. The period of this generator is 2^31, and it uses 1 word of storage per generator. - -=item $gsl_rng_rand48 - -=item $gsl_rng_random128_bsd - -=item $gsl_rng_random128_gli - -=item $gsl_rng_random128_lib - -=item $gsl_rng_random256_bsd - -=item $gsl_rng_random256_gli - -=item $gsl_rng_random256_lib - -=item $gsl_rng_random32_bsd - -=item $gsl_rng_random32_glib - -=item $gsl_rng_random32_libc - -=item $gsl_rng_random64_bsd - -=item $gsl_rng_random64_glib - -=item $gsl_rng_random64_libc - -=item $gsl_rng_random8_bsd - -=item $gsl_rng_random8_glibc - -=item $gsl_rng_random8_libc5 - -=item $gsl_rng_random_bsd - -=item $gsl_rng_random_glibc2 - -=item $gsl_rng_random_libc5 - -=item $gsl_rng_randu - -=item $gsl_rng_ranf - -=item $gsl_rng_ranlux - -=item $gsl_rng_ranlux389 - -=item $gsl_rng_ranlxd1 - -=item $gsl_rng_ranlxd2 - -=item $gsl_rng_ranlxs0 - -=item $gsl_rng_ranlxs1 - -=item $gsl_rng_ranlxs2 - -=item $gsl_rng_ranmar - This is the RANMAR lagged-fibonacci generator of Marsaglia, Zaman and Tsang. It is a 24-bit generator, originally designed for single-precision IEEE floating point numbers. It was included in the CERNLIB high-energy physics library. - -=item $gsl_rng_slatec - This is the SLATEC random number generator RAND. It is ancient. The original source code is available from NETLIB. - -=item $gsl_rng_taus - -=item $gsl_rng_taus2 - -=item $gsl_rng_taus113 - -=item $gsl_rng_transputer - -=item $gsl_rng_tt800 - -=item $gsl_rng_uni - -=item $gsl_rng_uni32 - -=item $gsl_rng_vax - This is the VAX generator MTH$RANDOM. Its sequence is, x_{n+1} = (a x_n + c) mod m with a = 69069, c = 1 and m = 2^32. The seed specifies the initial value, x_1. The period of this generator is 2^32 and it uses 1 word of storage per generator. - -=item $gsl_rng_waterman14 - -=item $gsl_rng_zuf - This is the ZUFALL lagged Fibonacci series generator of Peterson. Its sequence is, - -=over - -=item t = u_{n-273} + u_{n-607} - -=item u_n = t - floor(t) - -=back - - The original source code is available from NETLIB. For more information see, - - * W. Petersen, “Lagged Fibonacci Random Number Generators for the NEC SX-3”, International Journal of High Speed Computing (1994). - -=back - -For more informations on the functions, we refer you to the GSL offcial documentation: - -L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - -The following example will print out a list a random integers between certain -minimum and maximum values. The command line arguments are first the number of -random numbers wanted, the minimum and then maximum. The defaults are 10, 0 and -100, respectively. - - use Math::GSL::RNG qw/:all/; - my $seed = int rand(100); - my $rng = Math::GSL::RNG->new($gsl_rng_knuthran, $seed ); - my ($num,$min,$max) = @ARGV; - $num ||= 10; - $min ||= 0; - $max ||= 100; - print join "\n", map { $min + $rng->get % ($max-$min+1) } (1..$num); - print "\n"; - -The C<$seed> argument is optional but encouraged. This program is available in -the B directory that comes with the source of this module. - -If you would like a series of random non-integer numbers, then you can generate one "scaling factor" -and multiple by that, such as - - use Math::GSL::RNG qw/:all/; - my $scale= rand(10); - my $seed = int rand(100); - my $rng = Math::GSL::RNG->new($gsl_rng_knuthran, $seed ); - my ($num,$min,$max) = (10,0,100); - print join "\n", map { $scale*($min + $rng->get % ($max-$min+1)) } (1..$num); - print "\n"; - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::RNG" +%{ + #include "gsl/gsl_rng.h" +%} +%import "gsl/gsl_types.h" + +%include "gsl/gsl_rng.h" +%include "../pod/RNG.pod" diff --git a/swig/Randist.i b/swig/Randist.i dissimilarity index 96% index adb0649..28460b6 100644 --- a/swig/Randist.i +++ b/swig/Randist.i @@ -1,448 +1,38 @@ -%module "Math::GSL::Randist" -%include "typemaps.i" - -void gsl_ran_dir_2d (const gsl_rng * r, double *OUTPUT, double *OUTPUT); -void gsl_ran_dir_2d_trig_method (const gsl_rng * r, double *OUTPUT, double *OUTPUT); -void gsl_ran_dir_3d (const gsl_rng * r, double *OUTPUT, double *OUTPUT, double *OUTPUT); -void gsl_ran_bivariate_gaussian (const gsl_rng * r, double sigma_x, double sigma_y, double rho, double *OUTPUT, double *OUTPUT); - -%typemap(in) void * { - AV *tempav; - I32 len; - int i,x; - SV **tv; - - if (!SvROK($input)) - croak("Argument $argnum is not a reference."); - if (SvTYPE(SvRV($input)) != SVt_PVAV) - croak("Argument $argnum is not an array."); - - tempav = (AV*)SvRV($input); - len = av_len(tempav); - $1 = (int **) malloc((len+2)*sizeof(int *)); - for (i = 0; i <= len; i++) { - tv = av_fetch(tempav, i, 0); - x = SvIV(*tv); - memset((int*)($1+i), x , 1); - //printf("curr = %d\n", (int)($1+i) ); - } -}; -%typemap(freearg) void * { - free($1); -} - -%{ - #include "gsl/gsl_randist.h" -%} -%include "gsl/gsl_randist.h" - -%perlcode %{ - -our @EXPORT_OK = qw/gsl_ran_bernoulli gsl_ran_bernoulli_pdf gsl_ran_beta - gsl_ran_beta_pdf gsl_ran_binomial gsl_ran_binomial_knuth - gsl_ran_binomial_tpe gsl_ran_binomial_pdf gsl_ran_exponential - gsl_ran_exponential_pdf gsl_ran_exppow gsl_ran_exppow_pdf - gsl_ran_cauchy gsl_ran_cauchy_pdf gsl_ran_chisq - gsl_ran_chisq_pdf gsl_ran_dirichlet gsl_ran_dirichlet_pdf - gsl_ran_dirichlet_lnpdf gsl_ran_erlang gsl_ran_erlang_pdf - gsl_ran_fdist gsl_ran_fdist_pdf gsl_ran_flat - gsl_ran_flat_pdf gsl_ran_gamma gsl_ran_gamma_int - gsl_ran_gamma_pdf gsl_ran_gamma_mt gsl_ran_gamma_knuth - gsl_ran_gaussian gsl_ran_gaussian_ratio_method gsl_ran_gaussian_ziggurat - gsl_ran_gaussian_pdf gsl_ran_ugaussian gsl_ran_ugaussian_ratio_method - gsl_ran_ugaussian_pdf gsl_ran_gaussian_tail gsl_ran_gaussian_tail_pdf - gsl_ran_ugaussian_tail gsl_ran_ugaussian_tail_pdf gsl_ran_bivariate_gaussian - gsl_ran_bivariate_gaussian_pdf gsl_ran_landau gsl_ran_landau_pdf - gsl_ran_geometric gsl_ran_geometric_pdf gsl_ran_hypergeometric - gsl_ran_hypergeometric_pdf gsl_ran_gumbel1 gsl_ran_gumbel1_pdf - gsl_ran_gumbel2 gsl_ran_gumbel2_pdf gsl_ran_logistic - gsl_ran_logistic_pdf gsl_ran_lognormal gsl_ran_lognormal_pdf - gsl_ran_logarithmic gsl_ran_logarithmic_pdf gsl_ran_multinomial - gsl_ran_multinomial_pdf gsl_ran_multinomial_lnpdf - gsl_ran_negative_binomial gsl_ran_negative_binomial_pdf gsl_ran_pascal - gsl_ran_pascal_pdf gsl_ran_pareto gsl_ran_pareto_pdf - gsl_ran_poisson gsl_ran_poisson_array - gsl_ran_poisson_pdf gsl_ran_rayleigh gsl_ran_rayleigh_pdf - gsl_ran_rayleigh_tail gsl_ran_rayleigh_tail_pdf gsl_ran_tdist - gsl_ran_tdist_pdf gsl_ran_laplace gsl_ran_laplace_pdf - gsl_ran_levy gsl_ran_levy_skew gsl_ran_weibull - gsl_ran_weibull_pdf gsl_ran_dir_2d gsl_ran_dir_2d_trig_method - gsl_ran_dir_3d gsl_ran_dir_nd gsl_ran_shuffle - gsl_ran_choose gsl_ran_sample - gsl_ran_discrete_t gsl_ran_discrete_free gsl_ran_discrete_preproc - gsl_ran_discrete gsl_ran_discrete_pdf - /; - -our %EXPORT_TAGS = ( - all => [ @EXPORT_OK ], - logarithmic => [ gsl_ran_logarithmic , gsl_ran_logarithmic_pdf ], - choose => [ gsl_ran_choose ], - exponential => [ gsl_ran_exponential , gsl_ran_exponential_pdf ], - gumbel1 => [ gsl_ran_gumbel1 , gsl_ran_gumbel1_pdf ], - exppow => [ gsl_ran_exppow , gsl_ran_exppow_pdf ], - sample => [ gsl_ran_sample ], - logistic => [ gsl_ran_logistic , gsl_ran_logistic_pdf ], - gaussian => [ - gsl_ran_gaussian , gsl_ran_gaussian_ratio_method , gsl_ran_gaussian_ziggurat, - gsl_ran_gaussian_pdf , gsl_ran_gaussian_tail , gsl_ran_gaussian_tail_pdf - ], - poisson => [ gsl_ran_poisson , gsl_ran_poisson_array , gsl_ran_poisson_pdf ], - binomial => [ gsl_ran_binomial , gsl_ran_binomial_knuth , gsl_ran_binomial_tpe , - gsl_ran_binomial_pdf ], - fdist => [ gsl_ran_fdist , gsl_ran_fdist_pdf ], - chisq => [ gsl_ran_chisq , gsl_ran_chisq_pdf ], - gamma => [ gsl_ran_gamma , gsl_ran_gamma_int , gsl_ran_gamma_pdf , gsl_ran_gamma_mt , gsl_ran_gamma_knuth ], - hypergeometric => [ gsl_ran_hypergeometric , gsl_ran_hypergeometric_pdf ], - dirichlet => [ gsl_ran_dirichlet , gsl_ran_dirichlet_pdf , gsl_ran_dirichlet_lnpdf ], - negative => [ gsl_ran_negative_binomial , gsl_ran_negative_binomial_pdf ], - flat => [ gsl_ran_flat , gsl_ran_flat_pdf ], - geometric => [ gsl_ran_geometric , gsl_ran_geometric_pdf ], - discrete => [ gsl_ran_discrete , gsl_ran_discrete_pdf], - tdist => [ gsl_ran_tdist , gsl_ran_tdist_pdf ], - ugaussian => [ gsl_ran_ugaussian , gsl_ran_ugaussian_ratio_method , gsl_ran_ugaussian_pdf , - gsl_ran_ugaussian_tail , gsl_ran_ugaussian_tail_pdf ], - rayleigh => [ gsl_ran_rayleigh , gsl_ran_rayleigh_pdf , gsl_ran_rayleigh_tail , - gsl_ran_rayleigh_tail_pdf ], - dir => [ gsl_ran_dir_2d , gsl_ran_dir_2d_trig_method , gsl_ran_dir_3d , gsl_ran_dir_nd ], - pascal => [ gsl_ran_pascal , gsl_ran_pascal_pdf ], - gumbel2 => [ gsl_ran_gumbel2 , gsl_ran_gumbel2_pdf ], - shuffle => [ gsl_ran_shuffle ], - landau => [ gsl_ran_landau , gsl_ran_landau_pdf ], - bernoulli => [ gsl_ran_bernoulli , gsl_ran_bernoulli_pdf ], - weibull => [ gsl_ran_weibull , gsl_ran_weibull_pdf ], - multinomial => [ gsl_ran_multinomial , gsl_ran_multinomial_pdf , gsl_ran_multinomial_lnpdf ], - beta => [ gsl_ran_beta , gsl_ran_beta_pdf ], - lognormal => [ gsl_ran_lognormal , gsl_ran_lognormal_pdf ], - laplace => [ gsl_ran_laplace , gsl_ran_laplace_pdf ], - erlang => [ gsl_ran_erlang , gsl_ran_erlang_pdf ], - cauchy => [ gsl_ran_cauchy , gsl_ran_cauchy_pdf ], - levy => [ gsl_ran_levy , gsl_ran_levy_skew ], - bivariate => [ gsl_ran_bivariate_gaussian , gsl_ran_bivariate_gaussian_pdf ], - pareto => [ gsl_ran_pareto , gsl_ran_pareto_pdf ] -); - -__END__ - -=head1 NAME - -Math::GSL::Randist - Probability Distributions - -=head1 SYNOPSIS - -use Math::GSL::Randist qw/:all/; - -=head1 DESCRIPTION - - Here is a list of all the functions included in this module : - -=over - -=item gsl_ran_bernoulli($r, $p) - This function returns either 0 or 1, the result of a Bernoulli trial with probability $p. The probability distribution for a Bernoulli trial is, p(0) = 1 - $p and p(1) = $p. $r is a gsl_rng structure. - -=item gsl_ran_bernoulli_pdf($k, $p) - This function computes the probability p($k) of obtaining $k from a Bernoulli distribution with probability parameter $p, using the formula given above. - -=item gsl_ran_beta($r, $a, $b) - This function returns a random variate from the beta distribution. The distribution function is, p($x) dx = {Gamma($a+$b) \ Gamma($a) Gamma($b)} $x**{$a-1} (1-$x)**{$b-1} dx for 0 <= $x <= 1.$r is a gsl_rng structure. - -=item gsl_ran_beta_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a beta distribution with parameters $a and $b, using the formula given above. - -=item gsl_ran_binomial($k, $p, $n) - This function returns a random integer from the binomial distribution, the number of successes in n independent trials with probability $p. The probability distribution for binomial variates is p($k) = {$n! \ $k! ($n-$k)! } $p**$k (1-$p)^{$n-$k} for 0 <= $k <= $n. - -=item gsl_ran_binomial_knuth - -=item gsl_ran_binomial_tpe - -=item gsl_ran_binomial_pdf($k, $p, $n) - This function computes the probability p($k) of obtaining $k from a binomial distribution with parameters $p and $n, using the formula given above. - -=item gsl_ran_exponential($r, $mu) - This function returns a random variate from the exponential distribution with mean $mu. The distribution is, p($x) dx = {1 \ $mu} exp(-$x/$mu) dx for $x >= 0. $r is a gsl_rng structure. - -=item gsl_ran_exponential_pdf($x, $mu) - This function computes the probability density p($x) at $x for an exponential distribution with mean $mu, using the formula given above. - -=item gsl_ran_exppow($r, $a, $b) - This function returns a random variate from the exponential power distribution with scale parameter $a and exponent $b. The distribution is, p(x) dx = {1 / 2 $a Gamma(1+1/$b)} exp(-|$x/$a|**$b) dx for $x >= 0. For $b = 1 this reduces to the Laplace distribution. For $b = 2 it has the same form as a gaussian distribution, but with $a = sqrt(2) sigma. $r is a gsl_rng structure. - -=item gsl_ran_exppow_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for an exponential power distribution with scale parameter $a and exponent $b, using the formula given above. - -=item gsl_ran_cauchy($r, $a) - This function returns a random variate from the Cauchy distribution with scale parameter $a. The probability distribution for Cauchy random variates is, p(x) dx = {1 / a pi (1 + (x/$a)**2) } dx for x in the range -infinity to +infinity. The Cauchy distribution is also known as the Lorentz distribution. $r is a gsl_rng structure. - -=item gsl_ran_cauchy_pdf($x, $a) - This function computes the probability density p($x) at $x for a Cauchy distribution with scale parameter $a, using the formula given above. - -=item gsl_ran_chisq($r, $nu) - This function returns a random variate from the chi-squared distribution with $nu degrees of freedom. The distribution function is, p(x) dx = {1 / 2 Gamma($nu/2) } (x/2)**{$nu/2 - 1} exp(-x/2) dx for $x >= 0. $r is a gsl_rng structure. - -=item gsl_ran_chisq_pdf($x, $nu) - This function computes the probability density p($x) at $x for a chi-squared distribution with $nu degrees of freedom, using the formula given above. - -=item gsl_ran_dirichlet - -=item gsl_ran_dirichlet_pdf - -=item gsl_ran_dirichlet_lnpdf - -=item gsl_ran_erlang - -=item gsl_ran_erlang_pdf - -=item gsl_ran_fdist($r, $nu1, $nu2) - This function returns a random variate from the F-distribution with degrees of freedom nu1 and nu2. The distribution function is, p(x) dx = { Gamma(($nu_1 + $nu_2)/2) / Gamma($nu_1/2) Gamma($nu_2/2) } $nu_1**{$nu_1/2} $nu_2**{$nu_2/2} x**{$nu_1/2 - 1} ($nu_2 + $nu_1 x)**{-$nu_1/2 -$nu_2/2} for $x >= 0. $r is a gsl_rng structure. - -=item gsl_ran_fdist_pdf($x, $nu1, $nu2) - This function computes the probability density p(x) at x for an F-distribution with nu1 and nu2 degrees of freedom, using the formula given above. - -=item gsl_ran_flat($r, $a, $b) - This function returns a random variate from the flat (uniform) distribution from a to b. The distribution is, p(x) dx = {1 / ($b-$a)} dx if $a <= x < $b and 0 otherwise. $r is a gsl_rng structure. - -=item gsl_ran_flat_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a uniform distribution from $a to $b, using the formula given above. - -=item gsl_ran_gamma($r, $a, $b) - This function returns a random variate from the flat (uniform) distribution from $a to $b. The distribution is, p(x) dx = {1 / ($b-$a)} dx if $a <= x < $b and 0 otherwise. $r is a gsl_rng structure. - -=item gsl_ran_gamma_int - -=item gsl_ran_gamma_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a uniform distribution from $a to $b, using the formula given above. - -=item gsl_ran_gamma_mt - -=item gsl_ran_gamma_knuth - -=item gsl_ran_gaussian($r, $sigma) - This function returns a Gaussian random variate, with mean zero and standard deviation $sigma. The probability distribution for Gaussian random variates is, p(x) dx = {1 / sqrt{2 pi $sigma**2}} exp(-x**2 / 2 $sigma**2) dx for x in the range -infinity to +infinity. $r is a gsl_rng structure. - -=item gsl_ran_gaussian_ratio_method($r, $sigma) - This function computes a Gaussian random variate using the alternative Kinderman-Monahan-Leva ratio method. - -=item gsl_ran_gaussian_ziggurat($r, $sigma) - This function computes a Gaussian random variate using the alternative Marsaglia-Tsang ziggurat ratio method. The Ziggurat algorithm is the fastest available algorithm in most cases. $r is a gsl_rng structure. - -=item gsl_ran_gaussian_pdf($x, $sigma) - This function computes the probability density p($x) at $x for a Gaussian distribution with standard deviation sigma, using the formula given above. - -=item gsl_ran_ugaussian($r) - This function computes results for the unit Gaussian distribution. It is equivalent to the gaussian functions above with a standard deviation of one, sigma = 1. $r is a gsl_rng structure. - -=item gsl_ran_ugaussian_ratio_method($r) - This function computes results for the unit Gaussian distribution. It is equivalent to the gaussian functions above with a standard deviation of one, sigma = 1. $r is a gsl_rng structure. - -=item gsl_ran_ugaussian_pdf($x) - This function computes results for the unit Gaussian distribution. It is equivalent to the gaussian functions above with a standard deviation of one, sigma = 1. - -=item gsl_ran_gaussian_tail($r, $a, $sigma) - This function provides random variates from the upper tail of a Gaussian distribution with standard deviation sigma. The values returned are larger than the lower limit a, which must be positive. The probability distribution for Gaussian tail random variates is, p(x) dx = {1 / N($a; $sigma) sqrt{2 pi sigma**2}} exp(- x**2/(2 sigma**2)) dx for x > $a where N($a; $sigma) is the normalization constant, N($a; $sigma) = (1/2) erfc($a / sqrt(2 $sigma**2)). $r is a gsl_rng structure. - -=item gsl_ran_gaussian_tail_pdf($x, $a, $gaussian) - This function computes the probability density p($x) at $x for a Gaussian tail distribution with standard deviation sigma and lower limit $a, using the formula given above. - -=item gsl_ran_ugaussian_tail($r, $a) - This functions compute results for the tail of a unit Gaussian distribution. It is equivalent to the functions above with a standard deviation of one, $sigma = 1. $r is a gsl_rng structure. - -=item gsl_ran_ugaussian_tail_pdf($x, $a) - This functions compute results for the tail of a unit Gaussian distribution. It is equivalent to the functions above with a standard deviation of one, $sigma = 1. - -=item gsl_ran_bivariate_gaussian($r, $sigma_x, $sigma_y, $rho) - This function generates a pair of correlated Gaussian variates, with mean zero, correlation coefficient rho and standard deviations $sigma_x and $sigma_y in the x and y directions. The first value returned is x and the second y. The probability distribution for bivariate Gaussian random variates is, p(x,y) dx dy = {1 / 2 pi $sigma_x $sigma_y sqrt{1-$rho**2}} exp (-(x**2/$sigma_x**2 + y**2/$sigma_y**2 - 2 $rho x y/($sigma_x $sigma_y))/2(1- $rho**2)) dx dy for x,y in the range -infinity to +infinity. The correlation coefficient $rho should lie between 1 and -1. $r is a gsl_rng structure. - -=item gsl_ran_bivariate_gaussian_pdf($x, $y, $sigma_x, $sigma_y, $rho) - This function computes the probability density p($x,$y) at ($x,$y) for a bivariate Gaussian distribution with standard deviations $sigma_x, $sigma_y and correlation coefficient $rho, using the formula given above. - -=item gsl_ran_landau($r) - This function returns a random variate from the Landau distribution. The probability distribution for Landau random variates is defined analytically by the complex integral, p(x) = (1/(2 \pi i)) \int_{c-i\infty}^{c+i\infty} ds exp(s log(s) + x s) For numerical purposes it is more convenient to use the following equivalent form of the integral, p(x) = (1/\pi) \int_0^\infty dt \exp(-t \log(t) - x t) \sin(\pi t). $r is a gsl_rng structure. - -=item gsl_ran_landau_pdf($x) - This function computes the probability density p($x) at $x for the Landau distribution using an approximation to the formula given above. - -=item gsl_ran_geometric($r, $p) - This function returns a random integer from the geometric distribution, the number of independent trials with probability $p until the first success. The probability distribution for geometric variates is, p(k) = p (1-$p)^(k-1) for k >= 1. Note that the distribution begins with k=1 with this definition. There is another convention in which the exponent k-1 is replaced by k. $r is a gsl_rng structure. - -=item gsl_ran_geometric_pdf($k, $p) - This function computes the probability p($k) of obtaining $k from a geometric distribution with probability parameter p, using the formula given above. - -=item gsl_ran_hypergeometric($r, $n1, $n2, $t) - This function returns a random integer from the hypergeometric distribution. The probability distribution for hypergeometric random variates is, p(k) = C(n_1, k) C(n_2, t - k) / C(n_1 + n_2, t) where C(a,b) = a!/(b!(a-b)!) and t <= n_1 + n_2. The domain of k is max(0,t-n_2), ..., min(t,n_1). If a population contains n_1 elements of “type 1” and n_2 elements of “type 2” then the hypergeometric distribution gives the probability of obtaining k elements of “type 1” in t samples from the population without replacement. $r is a gsl_rng structure. - -=item gsl_ran_hypergeometric_pdf($k, $n1, $n2, $t) - This function computes the probability p(k) of obtaining k from a hypergeometric distribution with parameters $n1, $n2 $t, using the formula given above. - -=item gsl_ran_gumbel1($r, $a, $b) - This function returns a random variate from the Type-1 Gumbel distribution. The Type-1 Gumbel distribution function is, p(x) dx = a b \exp(-(b \exp(-ax) + ax)) dx for -\infty < x < \infty. $r is a gsl_rng structure. - -=item gsl_ran_gumbel1_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a Type-1 Gumbel distribution with parameters $a and $b, using the formula given above. - -=item gsl_ran_gumbel2($r, $a, $b) - This function returns a random variate from the Type-2 Gumbel distribution. The Type-2 Gumbel distribution function is, p(x) dx = a b x^{-a-1} \exp(-b x^{-a}) dx for 0 < x < \infty. $r is a gsl_rng structure. - -=item gsl_ran_gumbel2_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a Type-2 Gumbel distribution with parameters $a and $b, using the formula given above. - -=item gsl_ran_logistic($r, $a) - This function returns a random variate from the logistic distribution. The distribution function is, p(x) dx = { \exp(-x/a) \over a (1 + \exp(-x/a))^2 } dx for -\infty < x < +\infty. $r is a gsl_rng structure. - -=item gsl_ran_logistic_pdf($x, $a) - This function computes the probability density p($x) at $x for a logistic distribution with scale parameter $a, using the formula given above. - -=item gsl_ran_lognormal($r, $zeta, $sigma) - This function returns a random variate from the lognormal distribution. The distribution function is, p(x) dx = {1 \over x \sqrt{2 \pi \sigma^2} } \exp(-(\ln(x) - \zeta)^2/2 \sigma^2) dx for x > 0. $r is a gsl_rng structure. - -=item gsl_ran_lognormal_pdf($x, $zeta, $sigma) - This function computes the probability density p($x) at $x for a lognormal distribution with parameters $zeta and $sigma, using the formula given above. - -=item gsl_ran_logarithmic($r, $p) - This function returns a random integer from the logarithmic distribution. The probability distribution for logarithmic random variates is, p(k) = {-1 \over \log(1-p)} {(p^k \over k)} for k >= 1. $r is a gsl_rng structure. - -=item gsl_ran_logarithmic_pdf($k, $p) - This function computes the probability p($k) of obtaining $k from a logarithmic distribution with probability parameter $p, using the formula given above. - -=item gsl_ran_multinomial - -=item gsl_ran_multinomial_pdf - -=item gsl_ran_multinomial_lnpdf - -=item gsl_ran_negative_binomial($r, $p, $n) - This function returns a random integer from the negative binomial distribution, the number of failures occurring before n successes in independent trials with probability p of success. The probability distribution for negative binomial variates is, p(k) = {\Gamma(n + k) \over \Gamma(k+1) \Gamma(n) } p^n (1-p)^k Note that n is not required to be an integer. - -=item gsl_ran_negative_binomial_pdf($k, $p, $n) - This function computes the probability p($k) of obtaining $k from a negative binomial distribution with parameters $p and $n, using the formula given above. - -=item gsl_ran_pascal($r, $p, $n) - This function returns a random integer from the Pascal distribution. The Pascal distribution is simply a negative binomial distribution with an integer value of $n. p($k) = {($n + $k - 1)! \ $k! ($n - 1)! } $p**$n (1-$p)**$k for $k >= 0. $r is gsl_rng structure - -=item gsl_ran_pascal_pdf($k, $p, $n) - This function computes the probability p($k) of obtaining $k from a Pascal distribution with parameters $p and $n, using the formula given above. - -=item gsl_ran_pareto($r, $a, $b) - This function returns a random variate from the Pareto distribution of order $a. The distribution function is p($x) dx = ($a/$b) / ($x/$b)^{$a+1} dx for $x >= $b. $r is a gsl_rng structure - -=item gsl_ran_pareto_pdf($x, $a, $b) - This function computes the probability density p(x) at x for a Pareto distribution with exponent a and scale b, using the formula given above. - -=item gsl_ran_poisson($r, $mu) -This function returns a random integer from the Poisson distribution with mean $mu. $r is a gsl_rng structure. The probability distribution for Poisson variates is, p(k) = {$mu**$k \ $k!} exp(-$mu) for $k >= 0. $r is a gsl_rng structure - -=item gsl_ran_poisson_array - -=item gsl_ran_poisson_pdf($k, $mu) - This function computes the probability p($k) of obtaining $k from a Poisson distribution with mean $mu, using the formula given above. - -=item gsl_ran_rayleigh($r, $sigma) - This function returns a random variate from the Rayleigh distribution with scale parameter sigma. The distribution is, p(x) dx = {x \over \sigma^2} \exp(- x^2/(2 \sigma^2)) dx for x > 0. $r is a gsl_rng structure - -=item gsl_ran_rayleigh_pdf($x, $sigma) - This function computes the probability density p($x) at $x for a Rayleigh distribution with scale parameter sigma, using the formula given above. - -=item gsl_ran_rayleigh_tail($r, $a, $sigma) - This function returns a random variate from the tail of the Rayleigh distribution with scale parameter $sigma and a lower limit of $a. The distribution is, p(x) dx = {x \over \sigma^2} \exp ((a^2 - x^2) /(2 \sigma^2)) dx for x > a. $r is a gsl_rng structure - -=item gsl_ran_rayleigh_tail_pdf($x, $a, $sigma) - This function computes the probability density p($x) at $x for a Rayleigh tail distribution with scale parameter $sigma and lower limit $a, using the formula given above. - -=item gsl_ran_tdist($r, $nu) - This function returns a random variate from the t-distribution. The distribution function is, p(x) dx = {\Gamma((\nu + 1)/2) \over \sqrt{\pi \nu} \Gamma(\nu/2)} (1 + x^2/\nu)^{-(\nu + 1)/2} dx for -\infty < x < +\infty. - -=item gsl_ran_tdist_pdf($x, $nu) - This function computes the probability density p($x) at $x for a t-distribution with nu degrees of freedom, using the formula given above. - -=item gsl_ran_laplace($r, $a) - This function returns a random variate from the Laplace distribution with width $a. The distribution is, p(x) dx = {1 \over 2 a} \exp(-|x/a|) dx for -\infty < x < \infty. - -=item gsl_ran_laplace_pdf($x, $a) - This function computes the probability density p($x) at $x for a Laplace distribution with width $a, using the formula given above. - -=item gsl_ran_levy($r, $c, $alpha) - This function returns a random variate from the Levy symmetric stable distribution with scale $c and exponent $alpha. The symmetric stable probability distribution is defined by a fourier transform, p(x) = {1 \over 2 \pi} \int_{-\infty}^{+\infty} dt \exp(-it x - |c t|^alpha) There is no explicit solution for the form of p(x) and the library does not define a corresponding pdf function. For \alpha = 1 the distribution reduces to the Cauchy distribution. For \alpha = 2 it is a Gaussian distribution with \sigma = \sqrt{2} c. For \alpha < 1 the tails of the distribution become extremely wide. The algorithm only works for 0 < alpha <= 2. $r is a gsl_rng structure - -=item gsl_ran_levy_skew($r, $c, $alpha, $beta) - This function returns a random variate from the Levy skew stable distribution with scale $c, exponent $alpha and skewness parameter $beta. The skewness parameter must lie in the range [-1,1]. The Levy skew stable probability distribution is defined by a fourier transform, p(x) = {1 \over 2 \pi} \int_{-\infty}^{+\infty} dt \exp(-it x - |c t|^alpha (1-i beta sign(t) tan(pi alpha/2))) When \alpha = 1 the term \tan(\pi \alpha/2) is replaced by -(2/\pi)\log|t|. There is no explicit solution for the form of p(x) and the library does not define a corresponding pdf function. For $alpha = 2 the distribution reduces to a Gaussian distribution with $sigma = sqrt(2) $c and the skewness parameter has no effect. For $alpha < 1 the tails of the distribution become extremely wide. The symmetric distribution corresponds to $beta = 0. The algorithm only works for 0 < $alpha <= 2. The Levy alpha-stable distributions have the property that if N alpha-stable variates are drawn from the distribution p(c, \alpha, \beta) then the sum Y = X_1 + X_2 + \dots + X_N will also be distributed as an alpha-stable variate, p(N^(1/\alpha) c, \alpha, \beta). $r is a gsl_rng structure - -=item gsl_ran_weibull($r, $a, $b) - This function returns a random variate from the Weibull distribution. The distribution function is, p(x) dx = {b \over a^b} x^{b-1} \exp(-(x/a)^b) dx for x >= 0. $r is a gsl_rng structure - -=item gsl_ran_weibull_pdf($x, $a, $b) - This function computes the probability density p($x) at $x for a Weibull distribution with scale $a and exponent $b, using the formula given above. - -=item gsl_ran_dir_2d($r) - This function returns two values. The first is $x and the second is $y of a random direction vector v = ($x,$y) in two dimensions. The vector is normalized such that |v|^2 = $x^2 + $y^2 = 1. $r is a gsl_rng structure - -=item gsl_ran_dir_2d_trig_method($r) - This function returns two values. The first is $x and the second is $y of a random direction vector v = ($x,$y) in two dimensions. The vector is normalized such that |v|^2 = $x^2 + $y^2 = 1. $r is a gsl_rng structure - -=item gsl_ran_dir_3d($r) - This function returns three values. The first is $x, the second $y and the third $z of a random direction vector v = ($x,$y,$z) in three dimensions. The vector is normalized such that |v|^2 = x^2 + y^2 + z^2 = 1. The method employed is due to Robert E. Knop (CACM 13, 326 (1970)), and explained in Knuth, v2, 3rd ed, p136. It uses the surprising fact that the distribution projected along any axis is actually uniform (this is only true for 3 dimensions). - -=item gsl_ran_dir_nd - -=item gsl_ran_shuffle - -=item gsl_ran_choose - -=item gsl_ran_sample - -=item gsl_ran_discrete_preproc - -=item gsl_ran_discrete($r, $g) - After gsl_ran_discrete_preproc has been called, you use this function to get the discrete random numbers. $r is a gsl_rng structure and $g is a gsl_ran_discrete structure -=item gsl_ran_discrete_pdf($k, $g) - Returns the probability P[$k] of observing the variable $k. Since P[$k] is not stored as part of the lookup table, it must be recomputed; this computation takes O(K), so if K is large and you care about the original array P[$k] used to create the lookup table, then you should just keep this original array P[$k] around. $r is a gsl_rng structure and $g is a gsl_ran_discrete structure - -=item gsl_ran_discrete_free($g) - De-allocates the gsl_ran_discrete pointed to by g. - -=back - - You have to add the functions you want to use inside the qw /put_funtion_here /. - You can also write use Math::GSL::Randist qw/:all/; to use all avaible functions of the module. - Other tags are also avaible, here is a complete list of all tags for this module : - -=over - -=item logarithmic - -=item choose - -=item exponential - -=item gumbel1 - -=item exppow - -=item sample - -=item logistic - -=item gaussian - -=item poisson - -=item binomial - -=item fdist - -=item chisq - -=item gamma - -=item hypergeometric - -=item dirichlet - -=item negative - -=item flat - -=item geometric - -=item discrete - -=item tdist - -=item ugaussian - -=item rayleigh - -=item dir - -=item pascal - -=item gumbel2 - -=item shuffle - -=item landau - -=item bernoulli - -=item weibull - -=item multinomial - -=item beta - -=item lognormal - -=item laplace - -=item erlang - -=item cauchy - -=item levy - -=item bivariate - -=item pareto - -=back - - For example the beta tag contains theses functions : gsl_ran_beta, gsl_ran_beta_pdf. - -For more informations on the functions, we refer you to the GSL offcial documentation: -L - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - You might also want to write - use Math::GSL::RNG qw/:all/; - since a lot of the functions of Math::GSL::Randist take as argument a structure that is created by Math::GSL::RNG. - Refer to Math::GSL::RNG documentation to see how to create such a structure. - - Math::GSL::CDF also contains a structure named gsl_ran_discrete_t. An example is given in the EXAMPLES part on how to use the function related to this structure. - - -=head1 EXAMPLES - - use Math::GSL::Randist qw/:all/; - print gsl_ran_exponential_pdf(5,2) . "\n"; - - use Math::GSL::Randist qw/:all/; - $x= Math::GSL::gsl_ran_discrete_t::new; - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::Randist" +%include "typemaps.i" + +void gsl_ran_dir_2d (const gsl_rng * r, double *OUTPUT, double *OUTPUT); +void gsl_ran_dir_2d_trig_method (const gsl_rng * r, double *OUTPUT, double *OUTPUT); +void gsl_ran_dir_3d (const gsl_rng * r, double *OUTPUT, double *OUTPUT, double *OUTPUT); +void gsl_ran_bivariate_gaussian (const gsl_rng * r, double sigma_x, double sigma_y, double rho, double *OUTPUT, double *OUTPUT); + +%typemap(in) void * { + AV *tempav; + I32 len; + int i,x; + SV **tv; + + if (!SvROK($input)) + croak("Argument $argnum is not a reference."); + if (SvTYPE(SvRV($input)) != SVt_PVAV) + croak("Argument $argnum is not an array."); + + tempav = (AV*)SvRV($input); + len = av_len(tempav); + $1 = (int **) malloc((len+2)*sizeof(int *)); + for (i = 0; i <= len; i++) { + tv = av_fetch(tempav, i, 0); + x = SvIV(*tv); + memset((int*)($1+i), x , 1); + //printf("curr = %d\n", (int)($1+i) ); + } +}; +%typemap(freearg) void * { + free($1); +} + +%{ + #include "gsl/gsl_randist.h" +%} +%include "gsl/gsl_randist.h" +%include "../pod/Randist.pod" diff --git a/swig/Roots.i b/swig/Roots.i dissimilarity index 98% index b278a85..a86d3d5 100644 --- a/swig/Roots.i +++ b/swig/Roots.i @@ -1,153 +1,10 @@ -%module "Math::GSL::Roots" -%include "gsl_typemaps.i" -%include "typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_roots.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_roots.h" - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_root_fsolver_alloc - gsl_root_fsolver_free - gsl_root_fsolver_set - gsl_root_fsolver_iterate - gsl_root_fsolver_name - gsl_root_fsolver_root - gsl_root_fsolver_x_lower - gsl_root_fsolver_x_upper - gsl_root_fdfsolver_alloc - gsl_root_fdfsolver_set - gsl_root_fdfsolver_iterate - gsl_root_fdfsolver_free - gsl_root_fdfsolver_name - gsl_root_fdfsolver_root - gsl_root_test_interval - gsl_root_test_residual - gsl_root_test_delta - $gsl_root_fsolver_bisection - $gsl_root_fsolver_brent - $gsl_root_fsolver_falsepos - $gsl_root_fdfsolver_newton - $gsl_root_fdfsolver_secant - $gsl_root_fdfsolver_steffenson - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Roots - Routines for finding roots of arbitrary one-dimensional functions. - -=head1 SYNOPSIS - -use Math::GSL::Roots qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - This function returns a pointer to a newly allocated instance of a solver of type $T. $T must be one of the constant included with this module. If there is insufficient memory to create the solver then the function returns a null pointer and the error handler is invoked with an error code of $GSL_ENOMEM. - -=item * C - This function frees all the memory associated with the solver $s. - -=item * C - This function initializes, or reinitializes, an existing solver $s to use the function $f and the initial search interval [$x_lower, $x_upper]. $f has to be of this form : sub { my $x=shift; function_with_$x }. For example, sub { my $x=shift; ($x-3.2)**3 } is a valid value for $f. - -=item * C - This function performs a single iteration of the solver $s. If the iteration encounters an unexpected problem then an error code will be returned (the Math::GSL::Errno has to be included), - $GSL_EBADFUNC - the iteration encountered a singular point where the function or its derivative evaluated to Inf or NaN. - $GSL_EZERODIV - the derivative of the function vanished at the iteration point, preventing the algorithm from continuing without a division by zero. - -=item * C - This function returns the name of the solver use within the $s solver. - -=item * C - This function returns the current estimate of the root for the solver $s. - -=item * C - This function returns the current lower value of the bracketing interval for the solver $s. - -=item * C - This function returns the current lower value of the bracketing interval for the solver $s. - -=item * C - This function returns a pointer to a newly allocated instance of a derivative-based solver of type $T. If there is insufficient memory to create the solver then the function returns a null pointer and the error handler is invoked with an error code of $GSL_ENOMEM. - -=item * C - This function initializes, or reinitializes, an existing solver $s to use the function and derivative $fdf and the initial guess $root. $f has to be of this form : sub { my $x=shift; function_with_$x }. For example, sub { my $x=shift; ($x-3.2)**3 } is a valid value for $fdf. - -=item * C - This function performs a single iteration of the solver $s. If the iteration encounters an unexpected problem then an error code will be returned (the Math::GSL::Errno has to be included), - $GSL_EBADFUNC - the iteration encountered a singular point where the function or its derivative evaluated to Inf or NaN. - $GSL_EZERODIV - the derivative of the function vanished at the iteration point, preventing the algorithm from continuing without a division by zero. - -=item * C - This function frees all the memory associated with the solver $s. - -=item * C - This function returns the name of the solver use within the $s solver. - -=item * C - This function returns the current estimate of the root for the solver $s. - -=item * C - This function tests for the convergence of the interval [$x_lower, $x_upper] with absolute error epsabs and relative error $epsrel. The test returns $GSL_SUCCESS if the following condition is achieved, - |a - b| < epsabs + epsrel min(|a|,|b|) - when the interval x = [a,b] does not include the origin. If the interval includes the origin then \min(|a|,|b|) is replaced by zero (which is the minimum value of |x| over the interval). This ensures that the relative error is accurately estimated for roots close to the origin. - This condition on the interval also implies that any estimate of the root r in the interval satisfies the same condition with respect to the true root r^*, - |r - r^*| < epsabs + epsrel r^* - assuming that the true root r^* is contained within the interval. - -=item * C - This function tests the residual value $f against the absolute error bound $epsabs. The test returns $GSL_SUCCESS if the following condition is achieved, - |$f| < $epsabs - and returns $GSL_CONTINUE otherwise. This criterion is suitable for situations where the precise location of the root, x, is unimportant provided a value can be found where the residual, |f(x)|, is small enough. - -=item * C - This function tests for the convergence of the sequence ..., $x0, $x1 with absolute error $epsabs and relative error $epsrel. The test returns $GSL_SUCCESS if the following condition is achieved, - |x_1 - x_0| < epsabs + epsrel |x_1| - and returns $GSL_CONTINUE otherwise. - -=back - -This module also includes the following constants : - -=over - -=item * C<$gsl_root_fsolver_bisection> - The bisection algorithm is the simplest method of bracketing the roots of a function. It is the slowest algorithm provided by the library, with linear convergence. On each iteration, the interval is bisected and the value of the function at the midpoint is calculated. The sign of this value is used to determine which half of the interval does not contain a root. That half is discarded to give a new, smaller interval containing the root. This procedure can be continued indefinitely until the interval is sufficiently small. At any time the current estimate of the root is taken as the midpoint of the interval. - -=item * C<$gsl_root_fsolver_brent> - The Brent-Dekker method (referred to here as Brent's method) combines an interpolation strategy with the bisection algorithm. This produces a fast algorithm which is still robust. On each iteration Brent's method approximates the function using an interpolating curve. On the first iteration this is a linear interpolation of the two endpoints. For subsequent iterations the algorithm uses an inverse quadratic fit to the last three points, for higher accuracy. The intercept of the interpolating curve with the x-axis is taken as a guess for the root. If it lies within the bounds of the current interval then the interpolating point is accepted, and used to generate a smaller interval. If the interpolating point is not accepted then the algorithm falls back to an ordinary bisection step. The best estimate of the root is taken from the most recent interpolation or bisection. - -=item * C<$gsl_root_fsolver_falsepos> - The false position algorithm is a method of finding roots based on linear interpolation. Its convergence is linear, but it is usually faster than bisection. On each iteration a line is drawn between the endpoints (a,f(a)) and (b,f(b)) and the point where this line crosses the x-axis taken as a “midpoint”. The value of the function at this point is calculated and its sign is used to determine which side of the interval does not contain a root. That side is discarded to give a new, smaller interval containing the root. This procedure can be continued indefinitely until the interval is sufficiently small. The best estimate of the root is taken from the linear interpolation of the interval on the current iteration. - -=item * C<$gsl_root_fdfsolver_newton> - Newton's Method is the standard root-polishing algorithm. The algorithm begins with an initial guess for the location of the root. On each iteration, a line tangent to the function f is drawn at that position. The point where this line crosses the x-axis becomes the new guess. The iteration is defined by the following sequence, x_{i+1} = x_i - f(x_i)/f'(x_i) Newton's method converges quadratically for single roots, and linearly for multiple roots. - -=item * C<$gsl_root_fdfsolver_secant> - The secant method is a simplified version of Newton's method which does not require the computation of the derivative on every step. -On its first iteration the algorithm begins with Newton's method, using the derivative to compute a first step, - x_1 = x_0 - f(x_0)/f'(x_0) - Subsequent iterations avoid the evaluation of the derivative by replacing it with a numerical estimate, the slope of the line through the previous two points, - x_{i+1} = x_i f(x_i) / f'_{est} where - f'_{est} = (f(x_i) - f(x_{i-1})/(x_i - x_{i-1}) - When the derivative does not change significantly in the vicinity of the root the secant method gives a useful saving. Asymptotically the secant method is faster than Newton's method whenever the cost of evaluating the derivative is more than 0.44 times the cost of evaluating the function itself. As with all methods of computing a numerical derivative the estimate can suffer from cancellation errors if the separation of the points becomes too small. - - On single roots, the method has a convergence of order (1 + \sqrt 5)/2 (approximately 1.62). It converges linearly for multiple roots. - -=item * C<$gsl_root_fdfsolver_steffenson> - The Steffenson Method provides the fastest convergence of all the routines. It combines the basic Newton algorithm with an Aitken “delta-squared” acceleration. If the Newton iterates are x_i then the acceleration procedure generates a new sequence R_i, - R_i = x_i - (x_{i+1} - x_i)^2 / (x_{i+2} - 2 x_{i+1} + x_{i}) - which converges faster than the original sequence under reasonable conditions. The new sequence requires three terms before it can produce its first value so the method returns accelerated values on the second and subsequent iterations. On the first iteration it returns the ordinary Newton estimate. The Newton iterate is also returned if the denominator of the acceleration term ever becomes zero. - -As with all acceleration procedures this method can become unstable if the function is not well-behaved. - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Roots" +%include "gsl_typemaps.i" +%include "typemaps.i" +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_roots.h" +%} +%include "gsl/gsl_types.h" +%include "gsl/gsl_roots.h" +%include "../pod/Roots.pod" diff --git a/swig/SF.i b/swig/SF.i dissimilarity index 96% index cb02021..13ed515 100644 --- a/swig/SF.i +++ b/swig/SF.i @@ -1,3229 +1,81 @@ -%module "Math::GSL::SF" -%include "typemaps.i" - -%apply double *OUTPUT { double * sn, double * cn, double * dn, double * sgn }; - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_version.h" - #include "gsl/gsl_mode.h" - #include "gsl/gsl_sf.h" - #include "gsl/gsl_sf_airy.h" - #include "gsl/gsl_sf_bessel.h" - #include "gsl/gsl_sf_clausen.h" - #include "gsl/gsl_sf_coulomb.h" - #include "gsl/gsl_sf_coupling.h" - #include "gsl/gsl_sf_dawson.h" - #include "gsl/gsl_sf_debye.h" - #include "gsl/gsl_sf_dilog.h" - #include "gsl/gsl_sf_elementary.h" - #include "gsl/gsl_sf_ellint.h" - #include "gsl/gsl_sf_elljac.h" - #include "gsl/gsl_sf_erf.h" - #include "gsl/gsl_sf_exp.h" - #include "gsl/gsl_sf_expint.h" - #include "gsl/gsl_sf_fermi_dirac.h" - #include "gsl/gsl_sf_gamma.h" - #include "gsl/gsl_sf_gegenbauer.h" - #include "gsl/gsl_sf_hyperg.h" - #include "gsl/gsl_sf_laguerre.h" - #include "gsl/gsl_sf_lambert.h" - #include "gsl/gsl_sf_legendre.h" - #include "gsl/gsl_sf_log.h" -#ifdef GSL_VERSION && GSL_VERSION == "1.11" - #include "gsl/gsl_sf_mathieu.h" -#endif - #include "gsl/gsl_sf_pow_int.h" - #include "gsl/gsl_sf_psi.h" - #include "gsl/gsl_sf_result.h" - #include "gsl/gsl_sf_synchrotron.h" - #include "gsl/gsl_sf_transport.h" - #include "gsl/gsl_sf_trig.h" - #include "gsl/gsl_sf_zeta.h" -%} -%include "gsl/gsl_types.h" -%include "gsl/gsl_version.h" -%include "gsl/gsl_mode.h" -%include "gsl/gsl_sf.h" -%include "gsl/gsl_sf_airy.h" -%include "gsl/gsl_sf_bessel.h" -%include "gsl/gsl_sf_clausen.h" -%include "gsl/gsl_sf_coulomb.h" -%include "gsl/gsl_sf_coupling.h" -%include "gsl/gsl_sf_dawson.h" -%include "gsl/gsl_sf_debye.h" -%include "gsl/gsl_sf_dilog.h" -%include "gsl/gsl_sf_elementary.h" -%include "gsl/gsl_sf_ellint.h" -%include "gsl/gsl_sf_elljac.h" -%include "gsl/gsl_sf_erf.h" -%include "gsl/gsl_sf_exp.h" -%include "gsl/gsl_sf_expint.h" -%include "gsl/gsl_sf_fermi_dirac.h" -%include "gsl/gsl_sf_gamma.h" -%include "gsl/gsl_sf_gegenbauer.h" -%include "gsl/gsl_sf_hyperg.h" -%include "gsl/gsl_sf_laguerre.h" -%include "gsl/gsl_sf_lambert.h" -%include "gsl/gsl_sf_legendre.h" -%include "gsl/gsl_sf_log.h" -#ifdef GSL_VERSION && GSL_VERSION == '1.11' - %include "gsl/gsl_sf_mathieu.h" -#endif -%include "gsl/gsl_sf_pow_int.h" -%include "gsl/gsl_sf_psi.h" -%include "gsl/gsl_sf_result.h" -%include "gsl/gsl_sf_synchrotron.h" -%include "gsl/gsl_sf_transport.h" -%include "gsl/gsl_sf_trig.h" -%include "gsl/gsl_sf_zeta.h" - - -%perlcode %{ - -@EXPORT_airy = qw/ - gsl_sf_airy_Ai_e - gsl_sf_airy_Ai - gsl_sf_airy_Bi_e - gsl_sf_airy_Bi - gsl_sf_airy_Ai_scaled_e - gsl_sf_airy_Ai_scaled - gsl_sf_airy_Bi_scaled_e - gsl_sf_airy_Bi_scaled - gsl_sf_airy_Ai_deriv_e - gsl_sf_airy_Ai_deriv - gsl_sf_airy_Bi_deriv_e - gsl_sf_airy_Bi_deriv - gsl_sf_airy_Ai_deriv_scaled_e - gsl_sf_airy_Ai_deriv_scaled - gsl_sf_airy_Bi_deriv_scaled_e - gsl_sf_airy_Bi_deriv_scaled - gsl_sf_airy_zero_Ai_e - gsl_sf_airy_zero_Ai - gsl_sf_airy_zero_Bi_e - gsl_sf_airy_zero_Bi - gsl_sf_airy_zero_Ai_deriv_e - gsl_sf_airy_zero_Ai_deriv - gsl_sf_airy_zero_Bi_deriv_e - gsl_sf_airy_zero_Bi_deriv - /; -@EXPORT_bessel =qw/ - gsl_sf_bessel_J0_e - gsl_sf_bessel_J0 - gsl_sf_bessel_J1_e - gsl_sf_bessel_J1 - gsl_sf_bessel_Jn_e - gsl_sf_bessel_Jn - gsl_sf_bessel_Jn_array - gsl_sf_bessel_Y0_e - gsl_sf_bessel_Y0 - gsl_sf_bessel_Y1_e - gsl_sf_bessel_Y1 - gsl_sf_bessel_Yn_e - gsl_sf_bessel_Yn - gsl_sf_bessel_Yn_array - gsl_sf_bessel_I0_e - gsl_sf_bessel_I0 - gsl_sf_bessel_I1_e - gsl_sf_bessel_I1 - gsl_sf_bessel_In_e - gsl_sf_bessel_In - gsl_sf_bessel_In_array - gsl_sf_bessel_I0_scaled_e - gsl_sf_bessel_I0_scaled - gsl_sf_bessel_I1_scaled_e - gsl_sf_bessel_I1_scaled - gsl_sf_bessel_In_scaled_e - gsl_sf_bessel_In_scaled - gsl_sf_bessel_In_scaled_array - gsl_sf_bessel_K0_e - gsl_sf_bessel_K0 - gsl_sf_bessel_K1_e - gsl_sf_bessel_K1 - gsl_sf_bessel_Kn_e - gsl_sf_bessel_Kn - gsl_sf_bessel_Kn_array - gsl_sf_bessel_K0_scaled_e - gsl_sf_bessel_K0_scaled - gsl_sf_bessel_K1_scaled_e - gsl_sf_bessel_K1_scaled - gsl_sf_bessel_Kn_scaled_e - gsl_sf_bessel_Kn_scaled - gsl_sf_bessel_Kn_scaled_array - gsl_sf_bessel_j0_e - gsl_sf_bessel_j0 - gsl_sf_bessel_j1_e - gsl_sf_bessel_j1 - gsl_sf_bessel_j2_e - gsl_sf_bessel_j2 - gsl_sf_bessel_jl_e - gsl_sf_bessel_jl - gsl_sf_bessel_jl_array - gsl_sf_bessel_jl_steed_array - gsl_sf_bessel_y0_e - gsl_sf_bessel_y0 - gsl_sf_bessel_y1_e - gsl_sf_bessel_y1 - gsl_sf_bessel_y2_e - gsl_sf_bessel_y2 - gsl_sf_bessel_yl_e - gsl_sf_bessel_yl - gsl_sf_bessel_yl_array - gsl_sf_bessel_i0_scaled_e - gsl_sf_bessel_i0_scaled - gsl_sf_bessel_i1_scaled_e - gsl_sf_bessel_i1_scaled - gsl_sf_bessel_i2_scaled_e - gsl_sf_bessel_i2_scaled - gsl_sf_bessel_il_scaled_e - gsl_sf_bessel_il_scaled - gsl_sf_bessel_il_scaled_array - gsl_sf_bessel_k0_scaled_e - gsl_sf_bessel_k0_scaled - gsl_sf_bessel_k1_scaled_e - gsl_sf_bessel_k1_scaled - gsl_sf_bessel_k2_scaled_e - gsl_sf_bessel_k2_scaled - gsl_sf_bessel_kl_scaled_e - gsl_sf_bessel_kl_scaled - gsl_sf_bessel_kl_scaled_array - gsl_sf_bessel_Jnu_e - gsl_sf_bessel_Jnu - gsl_sf_bessel_Ynu_e - gsl_sf_bessel_Ynu - gsl_sf_bessel_sequence_Jnu_e - gsl_sf_bessel_Inu_scaled_e - gsl_sf_bessel_Inu_scaled - gsl_sf_bessel_Inu_e - gsl_sf_bessel_Inu - gsl_sf_bessel_Knu_scaled_e - gsl_sf_bessel_Knu_scaled - gsl_sf_bessel_Knu_e - gsl_sf_bessel_Knu - gsl_sf_bessel_lnKnu_e - gsl_sf_bessel_lnKnu - gsl_sf_bessel_zero_J0_e - gsl_sf_bessel_zero_J0 - gsl_sf_bessel_zero_J1_e - gsl_sf_bessel_zero_J1 - gsl_sf_bessel_zero_Jnu_e - gsl_sf_bessel_zero_Jnu - /; -@EXPORT_clausen = qw/ - gsl_sf_clausen_e - gsl_sf_clausen - /; -@EXPORT_hydrogenic = qw/ - gsl_sf_hydrogenicR_1_e - gsl_sf_hydrogenicR_1 - gsl_sf_hydrogenicR_e - gsl_sf_hydrogenicR - /; -@EXPORT_coulumb = qw/ - gsl_sf_coulomb_wave_FG_e - gsl_sf_coulomb_wave_F_array - gsl_sf_coulomb_wave_FG_array - gsl_sf_coulomb_wave_FGp_array - gsl_sf_coulomb_wave_sphF_array - gsl_sf_coulomb_CL_e - gsl_sf_coulomb_CL_array - /; -@EXPORT_coupling = qw/ - gsl_sf_coupling_3j_e - gsl_sf_coupling_3j - gsl_sf_coupling_6j_e - gsl_sf_coupling_6j - gsl_sf_coupling_RacahW_e - gsl_sf_coupling_RacahW - gsl_sf_coupling_9j_e - gsl_sf_coupling_9j - gsl_sf_coupling_6j_INCORRECT_e - gsl_sf_coupling_6j_INCORRECT - /; -@EXPORT_dawson = qw/ - gsl_sf_dawson_e - gsl_sf_dawson - /; -@EXPORT_debye = qw/ - gsl_sf_debye_1_e - gsl_sf_debye_1 - gsl_sf_debye_2_e - gsl_sf_debye_2 - gsl_sf_debye_3_e - gsl_sf_debye_3 - gsl_sf_debye_4_e - gsl_sf_debye_4 - gsl_sf_debye_5_e - gsl_sf_debye_5 - gsl_sf_debye_6_e - gsl_sf_debye_6 - /; -@EXPORT_dilog = qw/ - gsl_sf_dilog_e - gsl_sf_dilog - gsl_sf_complex_dilog_xy_e - gsl_sf_complex_dilog_e - /; - -@EXPORT_misc = qw/ - gsl_sf_complex_spence_xy_e - gsl_sf_multiply_e - gsl_sf_multiply - gsl_sf_multiply_err_e - /; -@EXPORT_elliptic = qw/ - gsl_sf_ellint_Kcomp_e - gsl_sf_ellint_Kcomp - gsl_sf_ellint_Ecomp_e - gsl_sf_ellint_Ecomp - gsl_sf_ellint_Pcomp_e - gsl_sf_ellint_Pcomp - gsl_sf_ellint_Dcomp_e - gsl_sf_ellint_Dcomp - gsl_sf_ellint_F_e - gsl_sf_ellint_F - gsl_sf_ellint_E_e - gsl_sf_ellint_E - gsl_sf_ellint_P_e - gsl_sf_ellint_P - gsl_sf_ellint_D_e - gsl_sf_ellint_D - gsl_sf_ellint_RC_e - gsl_sf_ellint_RC - gsl_sf_ellint_RD_e - gsl_sf_ellint_RD - gsl_sf_ellint_RF_e - gsl_sf_ellint_RF - gsl_sf_ellint_RJ_e - gsl_sf_ellint_RJ - gsl_sf_elljac_e - /; -@EXPORT_error = qw/ - gsl_sf_erfc_e - gsl_sf_erfc - gsl_sf_log_erfc_e - gsl_sf_log_erfc - gsl_sf_erf_e - gsl_sf_erf - gsl_sf_erf_Z_e - gsl_sf_erf_Q_e - gsl_sf_erf_Z - gsl_sf_erf_Q - gsl_sf_hazard_e - gsl_sf_hazard - /; -push @EXPORT_misc, qw/ - gsl_sf_exp_e - gsl_sf_exp - gsl_sf_exp_e10_e - gsl_sf_exp_mult_e - gsl_sf_exp_mult - gsl_sf_exp_mult_e10_e - gsl_sf_expm1_e - gsl_sf_expm1 - gsl_sf_exprel_e - gsl_sf_exprel - gsl_sf_exprel_2_e - gsl_sf_exprel_2 - gsl_sf_exprel_n_e - gsl_sf_exprel_n - gsl_sf_exp_err_e - gsl_sf_exp_err_e10_e - gsl_sf_exp_mult_err_e - gsl_sf_exp_mult_err_e10_e - gsl_sf_expint_E1_e - gsl_sf_expint_E1 - gsl_sf_expint_E2_e - gsl_sf_expint_E2 - gsl_sf_expint_En_e - gsl_sf_expint_En - gsl_sf_expint_E1_scaled_e - gsl_sf_expint_E1_scaled - gsl_sf_expint_E2_scaled_e - gsl_sf_expint_E2_scaled - gsl_sf_expint_En_scaled_e - gsl_sf_expint_En_scaled - gsl_sf_expint_Ei_e - gsl_sf_expint_Ei - gsl_sf_expint_Ei_scaled_e - gsl_sf_expint_Ei_scaled - gsl_sf_Shi_e - gsl_sf_Shi - gsl_sf_Chi_e - gsl_sf_Chi - gsl_sf_expint_3_e - gsl_sf_expint_3 - gsl_sf_Si_e - gsl_sf_Si - gsl_sf_Ci_e - gsl_sf_Ci - /; -@EXPORT_fermi_dirac = qw/ - gsl_sf_fermi_dirac_m1_e - gsl_sf_fermi_dirac_m1 - gsl_sf_fermi_dirac_0_e - gsl_sf_fermi_dirac_0 - gsl_sf_fermi_dirac_1_e - gsl_sf_fermi_dirac_1 - gsl_sf_fermi_dirac_2_e - gsl_sf_fermi_dirac_2 - gsl_sf_fermi_dirac_int_e - gsl_sf_fermi_dirac_int - gsl_sf_fermi_dirac_mhalf_e - gsl_sf_fermi_dirac_mhalf - gsl_sf_fermi_dirac_half_e - gsl_sf_fermi_dirac_half - gsl_sf_fermi_dirac_3half_e - gsl_sf_fermi_dirac_3half - gsl_sf_fermi_dirac_inc_0_e - gsl_sf_fermi_dirac_inc_0 - /; -@EXPORT_legendre = qw/ - gsl_sf_legendre_Pl_e - gsl_sf_legendre_Pl - gsl_sf_legendre_Pl_array - gsl_sf_legendre_Pl_deriv_array - gsl_sf_legendre_P1_e - gsl_sf_legendre_P2_e - gsl_sf_legendre_P3_e - gsl_sf_legendre_P1 - gsl_sf_legendre_P2 - gsl_sf_legendre_P3 - gsl_sf_legendre_Q0_e - gsl_sf_legendre_Q0 - gsl_sf_legendre_Q1_e - gsl_sf_legendre_Q1 - gsl_sf_legendre_Ql_e - gsl_sf_legendre_Ql - gsl_sf_legendre_Plm_e - gsl_sf_legendre_Plm - gsl_sf_legendre_Plm_array - gsl_sf_legendre_Plm_deriv_array - gsl_sf_legendre_sphPlm_e - gsl_sf_legendre_sphPlm - gsl_sf_legendre_sphPlm_array - gsl_sf_legendre_sphPlm_deriv_array - gsl_sf_legendre_array_size - gsl_sf_legendre_H3d_0_e - gsl_sf_legendre_H3d_0 - gsl_sf_legendre_H3d_1_e - gsl_sf_legendre_H3d_1 - gsl_sf_legendre_H3d_e - gsl_sf_legendre_H3d - gsl_sf_legendre_H3d_array - /; -@EXPORT_gamma = qw/ - gsl_sf_lngamma_e - gsl_sf_lngamma - gsl_sf_lngamma_sgn_e - gsl_sf_gamma_e - gsl_sf_gamma - gsl_sf_gammastar_e - gsl_sf_gammastar - gsl_sf_gammainv_e - gsl_sf_gammainv - gsl_sf_lngamma_complex_e - gsl_sf_gamma_inc_Q_e - gsl_sf_gamma_inc_Q - gsl_sf_gamma_inc_P_e - gsl_sf_gamma_inc_P - gsl_sf_gamma_inc_e - gsl_sf_gamma_inc - /; -@EXPORT_factorial = qw/ - gsl_sf_fact_e - gsl_sf_fact - gsl_sf_doublefact_e - gsl_sf_doublefact - gsl_sf_lnfact_e - gsl_sf_lnfact - gsl_sf_lndoublefact_e - gsl_sf_lndoublefact - /; -@EXPORT_hypergeometric = qw/ - gsl_sf_hyperg_0F1_e - gsl_sf_hyperg_0F1 - gsl_sf_hyperg_1F1_int_e - gsl_sf_hyperg_1F1_int - gsl_sf_hyperg_1F1_e - gsl_sf_hyperg_1F1 - gsl_sf_hyperg_U_int_e - gsl_sf_hyperg_U_int - gsl_sf_hyperg_U_int_e10_e - gsl_sf_hyperg_U_e - gsl_sf_hyperg_U - gsl_sf_hyperg_U_e10_e - gsl_sf_hyperg_2F1_e - gsl_sf_hyperg_2F1 - gsl_sf_hyperg_2F1_conj_e - gsl_sf_hyperg_2F1_conj - gsl_sf_hyperg_2F1_renorm_e - gsl_sf_hyperg_2F1_renorm - gsl_sf_hyperg_2F1_conj_renorm_e - gsl_sf_hyperg_2F1_conj_renorm - gsl_sf_hyperg_2F0_e - gsl_sf_hyperg_2F0 - /; -@EXPORT_laguerre = qw/ - gsl_sf_laguerre_1_e - gsl_sf_laguerre_2_e - gsl_sf_laguerre_3_e - gsl_sf_laguerre_1 - gsl_sf_laguerre_2 - gsl_sf_laguerre_3 - gsl_sf_laguerre_n_e - gsl_sf_laguerre_n - /; -push @EXPORT_misc, qw/ - gsl_sf_taylorcoeff_e - gsl_sf_taylorcoeff - gsl_sf_lnchoose_e - gsl_sf_lnchoose - gsl_sf_choose_e - gsl_sf_choose - gsl_sf_lnpoch_e - gsl_sf_lnpoch - gsl_sf_lnpoch_sgn_e - gsl_sf_poch_e - gsl_sf_poch - gsl_sf_pochrel_e - gsl_sf_pochrel - gsl_sf_lnbeta_e - gsl_sf_lnbeta - gsl_sf_lnbeta_sgn_e - gsl_sf_beta_e - gsl_sf_beta - gsl_sf_beta_inc_e - gsl_sf_beta_inc - gsl_sf_gegenpoly_1_e - gsl_sf_gegenpoly_2_e - gsl_sf_gegenpoly_3_e - gsl_sf_gegenpoly_1 - gsl_sf_gegenpoly_2 - gsl_sf_gegenpoly_3 - gsl_sf_gegenpoly_n_e - gsl_sf_gegenpoly_n - gsl_sf_gegenpoly_array - gsl_sf_lambert_W0_e - gsl_sf_lambert_W0 - gsl_sf_lambert_Wm1_e - gsl_sf_lambert_Wm1 - gsl_sf_conicalP_half_e - gsl_sf_conicalP_half - gsl_sf_conicalP_mhalf_e - gsl_sf_conicalP_mhalf - gsl_sf_conicalP_0_e - gsl_sf_conicalP_0 - gsl_sf_conicalP_1_e - gsl_sf_conicalP_1 - gsl_sf_conicalP_sph_reg_e - gsl_sf_conicalP_sph_reg - gsl_sf_conicalP_cyl_reg_e - gsl_sf_conicalP_cyl_reg - gsl_sf_log_e - gsl_sf_log - gsl_sf_log_abs_e - gsl_sf_log_abs - gsl_sf_complex_log_e - gsl_sf_log_1plusx_e - gsl_sf_log_1plusx - gsl_sf_log_1plusx_mx_e - gsl_sf_log_1plusx_mx - gsl_sf_pow_int_e - gsl_sf_pow_int - gsl_sf_psi_int_e - gsl_sf_psi_int - gsl_sf_psi_e - gsl_sf_psi - gsl_sf_psi_1piy_e - gsl_sf_psi_1piy - gsl_sf_complex_psi_e - gsl_sf_psi_1_int_e - gsl_sf_psi_1_int - gsl_sf_psi_1_e - gsl_sf_psi_1 - gsl_sf_psi_n_e - gsl_sf_psi_n - gsl_sf_result_smash_e - gsl_sf_synchrotron_1_e - gsl_sf_synchrotron_1 - gsl_sf_synchrotron_2_e - gsl_sf_synchrotron_2 - /; -@EXPORT_mathieu = qw/ - gsl_sf_mathieu_a_array - gsl_sf_mathieu_b_array - gsl_sf_mathieu_a - gsl_sf_mathieu_b - gsl_sf_mathieu_a_coeff - gsl_sf_mathieu_b_coeff - gsl_sf_mathieu_alloc - gsl_sf_mathieu_free - gsl_sf_mathieu_ce - gsl_sf_mathieu_se - gsl_sf_mathieu_ce_array - gsl_sf_mathieu_se_array - gsl_sf_mathieu_Mc - gsl_sf_mathieu_Ms - gsl_sf_mathieu_Mc_array - gsl_sf_mathieu_Ms_array - /; -@EXPORT_transport = qw/ - gsl_sf_transport_2_e - gsl_sf_transport_2 - gsl_sf_transport_3_e - gsl_sf_transport_3 - gsl_sf_transport_4_e - gsl_sf_transport_4 - gsl_sf_transport_5_e - gsl_sf_transport_5 - /; -@EXPORT_trig = qw/ - gsl_sf_sin_e - gsl_sf_sin - gsl_sf_sin_pi_x_e - gsl_sf_cos_e - gsl_sf_cos_pi_x_e - gsl_sf_cos - gsl_sf_hypot_e - gsl_sf_hypot - gsl_sf_complex_sin_e - gsl_sf_complex_cos_e - gsl_sf_complex_logsin_e - gsl_sf_sinc_e - gsl_sf_sinc - gsl_sf_lnsinh_e - gsl_sf_lnsinh - gsl_sf_lncosh_e - gsl_sf_lncosh - gsl_sf_polar_to_rect - gsl_sf_rect_to_polar - gsl_sf_sin_err_e - gsl_sf_cos_err_e - gsl_sf_angle_restrict_symm_e - gsl_sf_angle_restrict_symm - gsl_sf_angle_restrict_pos_e - gsl_sf_angle_restrict_pos - gsl_sf_angle_restrict_symm_err_e - gsl_sf_angle_restrict_pos_err_e - gsl_sf_atanint_e - gsl_sf_atanint - /; -@EXPORT_zeta = qw/ - gsl_sf_zeta_int_e - gsl_sf_zeta_int - gsl_sf_zeta_e - gsl_sf_zeta - gsl_sf_zetam1_e - gsl_sf_zetam1 - gsl_sf_zetam1_int_e - gsl_sf_zetam1_int - gsl_sf_hzeta_e - gsl_sf_hzeta - /; -@EXPORT_eta = qw/ - gsl_sf_eta_int_e - gsl_sf_eta_int - gsl_sf_eta_e - gsl_sf_eta - /; -@EXPORT_vars = qw/ - GSL_SF_GAMMA_XMAX - GSL_SF_FACT_NMAX - GSL_SF_DOUBLEFACT_NMAX - GSL_SF_MATHIEU_COEFF - /; - -@EXPORT_OK = ( - @EXPORT_airy, @EXPORT_bessel, @EXPORT_clausen, @EXPORT_hydrogenic, - @EXPORT_coulumb, @EXPORT_coupling, @EXPORT_dawson, @EXPORT_debye, - @EXPORT_dilog, @EXPORT_misc, @EXPORT_elliptic, @EXPORT_error, @EXPORT_legendre, - @EXPORT_gamma, @EXPORT_transport, @EXPORT_trig, @EXPORT_zeta, @EXPORT_eta, - @EXPORT_vars - ); - -%EXPORT_TAGS = ( - all => [ @EXPORT_OK ], - airy => [ @EXPORT_airy ], - bessel => [ @EXPORT_bessel ], - clausen => [ @EXPORT_clausen ], - coulumb => [ @EXPORT_coulumb ], - coupling => [ @EXPORT_coupling ], - dawson => [ @EXPORT_dawson ], - debye => [ @EXPORT_debye ], - dilog => [ @EXPORT_dilog ], - eta => [ @EXPORT_eta ], - elliptic => [ @EXPORT_elliptic ], - error => [ @EXPORT_error ], - factorial => [ @EXPORT_factorial ], - gamma => [ @EXPORT_gamma ], - hydrogenic => [ @EXPORT_hydrogenic ], - hypergeometric => [ @EXPORT_hypergeometric ], - laguerre => [ @EXPORT_laguerre ], - legendre => [ @EXPORT_legendre ], - mathieu => [ @EXPORT_mathieu ], - misc => [ @EXPORT_misc ], - transport => [ @EXPORT_transport ], - trig => [ @EXPORT_trig ], - vars => [ @EXPORT_vars ], - zeta => [ @EXPORT_zeta ], - ); - -__END__ - -=head1 NAME - -Math::GSL::SF - Special Functions - -=head1 SYNOPSIS - - use Math::GSL::SF qw /:all/; - -=head1 DESCRIPTION - -This module contains a data structure named gsl_sf_result. To create a new one use - - $r = Math::GSL::SF::gsl_sf_result_struct->new; - -You can then access the elements of the structure in this way : - - my $val = $r->{val}; - - my $error = $r->{err}; - -Here is a list of all included functions: - -=over - -=item C - -=item C - -- These routines compute the Airy function Ai($x) with an accuracy specified by $mode. $mode should be $GSL_PREC_DOUBLE, $GSL_PREC_SINGLE or $GSL_PREC_APPROX. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute the Airy function Bi($x) with an accuracy specified by $mode. $mode should be $GSL_PREC_DOUBLE, $GSL_PREC_SINGLE or $GSL_PREC_APPROX. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute a scaled version of the Airy function S_A($x) Ai($x). For $x>0 the scaling factor S_A($x) is \exp(+(2/3) $x**(3/2)), and is 1 for $x<0. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute a scaled version of the Airy function S_B($x) Bi($x). For $x>0 the scaling factor S_B($x) is exp(-(2/3) $x**(3/2)), and is 1 for $x<0. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute the Airy function derivative Ai'($x) with an accuracy specified by $mode. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the Airy function derivative Bi'($x) with an accuracy specified by $mode. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the scaled Airy function derivative S_A(x) Ai'(x). For x>0 the scaling factor S_A(x) is \exp(+(2/3) x^(3/2)), and is 1 for x<0. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the scaled Airy function derivative S_B(x) Bi'(x). For x>0 the scaling factor S_B(x) is exp(-(2/3) x^(3/2)), and is 1 for x<0. $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the location of the s-th zero of the Airy function Ai($x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the location of the s-th zero of the Airy function Bi($x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the location of the s-th zero of the Airy function derivative Ai'(x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute the location of the s-th zero of the Airy function derivative Bi'(x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the regular cylindrical Bessel function of zeroth order, J_0($x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - -- These routines compute the regular cylindrical Bessel function of first order, J_1($x). $result is a gsl_sf_result structure. - -=back - -=over - -=item C - -=item C - --These routines compute the regular cylindrical Bessel function of order n, J_n($x). - -=back - -=over - -=item C - This routine computes the values of the regular cylindrical Bessel functions J_n($x) for n from $nmin to $nmax inclusive, storing the results in the array $result_array. The values are computed using recurrence relations for efficiency, and therefore may differ slightly from the exact values. - -=back - -=over - -=item C - -=item C - -- These routines compute the irregular spherical Bessel function of zeroth order, y_0(x) = -\cos(x)/x. - -=back - -=over - -=item C - -=item C - --These routines compute the irregular spherical Bessel function of first order, y_1(x) = -(\cos(x)/x + \sin(x))/x. - -=back - -=over - -=item C($n, $x, $result) - -=item C - --These routines compute the irregular cylindrical Bessel function of order $n, Y_n(x), for x>0. - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the regular modified cylindrical Bessel function of zeroth order, I_0(x). - -=back - -=over - -=item C - -=item C - --These routines compute the regular modified cylindrical Bessel function of first order, I_1(x). - -=back - -=over - -=item C - -=item C - --These routines compute the regular modified cylindrical Bessel function of order $n, I_n(x). - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the scaled regular modified cylindrical Bessel function of zeroth order \exp(-|x|) I_0(x). - -=back - -=over - -=item C - -=item C - --These routines compute the scaled regular modified cylindrical Bessel function of first order \exp(-|x|) I_1(x). - -=back - -=over - -=item C - -=item C - --These routines compute the scaled regular modified cylindrical Bessel function of order $n, \exp(-|x|) I_n(x) - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the irregular modified cylindrical Bessel function of zeroth order, K_0(x), for x > 0. - -=back - -=over - -=item C - -=item C - --These routines compute the irregular modified cylindrical Bessel function of first order, K_1(x), for x > 0. - -=back - -=over - -=item C - -=item C - --These routines compute the irregular modified cylindrical Bessel function of order $n, K_n(x), for x > 0. - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the scaled irregular modified cylindrical Bessel function of zeroth order \exp(x) K_0(x) for x>0. - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - This function computes the Coulomb wave functions F_L(\eta,x), G_{L-k}(\eta,x) and their derivatives F'_L(\eta,x), G'_{L-k}(\eta,x) with respect to $x. The parameters are restricted to L, L-k > -1/2, x > 0 and integer $k. Note that L itself is not restricted to being an integer. The results are stored in the parameters $F, $G for the function values and $Fp, $Gp for the derivative values. $F, $G, $Fp, $Gp are all gsl_result structs. If an overflow occurs, $GSL_EOVRFLW is returned and scaling exponents are returned as second and third values. - -=item C - - -=item C - - -=item C - - -=item C - - -=item C - This function computes the Coulomb wave function normalization constant C_L($eta) for $L > -1. - -=item C - - -=back - -=over - -=item C - -=item C - -- These routines compute the Wigner 3-j coefficient, - (ja jb jc - ma mb mc) - where the arguments are given in half-integer units, ja = $two_ja/2, ma = $two_ma/2, etc. - -=back - -=over - -=item C - -=item C - -- These routines compute the Wigner 6-j coefficient, - {ja jb jc - jd je jf} - where the arguments are given in half-integer units, ja = $two_ja/2, ma = $two_ma/2, etc. - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the Wigner 9-j coefficient, - - {ja jb jc - jd je jf - jg jh ji} - where the arguments are given in half-integer units, ja = two_ja/2, ma = two_ma/2, etc. - -=back - -=over - -=item C - -=item C - --These routines compute the value of Dawson's integral for $x. - -=back - -=over - -=item C - -=item C - --These routines compute the first-order Debye function D_1(x) = (1/x) \int_0^x dt (t/(e^t - 1)). - -=back - -=over - -=item C - -=item C - --These routines compute the second-order Debye function D_2(x) = (2/x^2) \int_0^x dt (t^2/(e^t - 1)). - -=back - -=over - -=item C - -=item C - --These routines compute the third-order Debye function D_3(x) = (3/x^3) \int_0^x dt (t^3/(e^t - 1)). - -=back - -=over - -=item C - -=item C - --These routines compute the fourth-order Debye function D_4(x) = (4/x^4) \int_0^x dt (t^4/(e^t - 1)). - -=back - -=over - -=item C - -=item C - --These routines compute the fifth-order Debye function D_5(x) = (5/x^5) \int_0^x dt (t^5/(e^t - 1)). - -=back - -=over - -=item C - -=item C - --These routines compute the sixth-order Debye function D_6(x) = (6/x^6) \int_0^x dt (t^6/(e^t - 1)). - -=back - -=over - -=item C - -=item C - -- These routines compute the dilogarithm for a real argument. In Lewin's notation this is Li_2(x), the real part of the dilogarithm of a real x. It is defined by the integral representation Li_2(x) = - \Re \int_0^x ds \log(1-s) / s. Note that \Im(Li_2(x)) = 0 for x <= 1, and -\pi\log(x) for x > 1. Note that Abramowitz & Stegun refer to the Spence integral S(x)=Li_2(1-x) as the dilogarithm rather than Li_2(x). - -=back - -=over - -=item C - - -=item C - This function computes the full complex-valued dilogarithm for the complex argument z = r \exp(i \theta). The real and imaginary parts of the result are returned in the $result_re and $result_im gsl_result structs. - -=item C - - -=back - -=over - -=item C - -=item C - This function multiplies $x and $y storing the product and its associated error in $result. - -=item C - This function multiplies $x and $y with associated absolute errors $dx and $dy. The product xy +/- xy \sqrt((dx/x)^2 +(dy/y)^2) is stored in $result. - -- - -=back - -=over - - -=item C - -=item C - --These routines compute the complete elliptic integral K($k) to the accuracy specified by the mode variable mode. Note that Abramowitz & Stegun define this function in terms of the parameter m = k^2. - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the incomplete elliptic integral F($phi,$k) to the accuracy specified by the mode variable mode. Note that Abramowitz & Stegun define this function in terms of the parameter m = k^2. - -=back - -=over - -=item C - -=item C - --These routines compute the incomplete elliptic integral E($phi,$k) to the accuracy specified by the mode variable mode. Note that Abramowitz & Stegun define this function in terms of the parameter m = k^2. - -=back - -=over - -=item C - -=item C - --These routines compute the incomplete elliptic integral \Pi(\phi,k,n) to the accuracy specified by the mode variable mode. Note that Abramowitz & Stegun define this function in terms of the parameters m = k^2 and \sin^2(\alpha) = k^2, with the change of sign n \to -n. - -=back - -=over - -=item C - -=item C - --These functions compute the incomplete elliptic integral D(\phi,k) which is defined through the Carlson form RD(x,y,z) by the following relation, D(\phi,k,n) = (1/3)(\sin(\phi))^3 RD (1-\sin^2(\phi), 1-k^2 \sin^2(\phi), 1). The argument $n is not used and will be removed in a future release. - -=back - -=over - -=item C - -=item C - -- These routines compute the incomplete elliptic integral RC($x,$y) to the accuracy specified by the mode variable $mode. - -=back - -=over - -=item C - -=item C - -- These routines compute the incomplete elliptic integral RD($x,$y,$z) to the accuracy specified by the mode variable $mode. - -=back - -=over - -=item C - -=item C - -- These routines compute the incomplete elliptic integral RF($x,$y,$z) to the accuracy specified by the mode variable $mode. - -=back - -=over - -=item C - -=item C - -- These routines compute the incomplete elliptic integral RJ($x,$y,$z,$p) to the accuracy specified by the mode variable $mode. - -=back - -=over - -=item C - This function computes the Jacobian elliptic functions sn(u|m), cn(u|m), dn(u|m) by descending Landen transformations. The function returns 0 if the operation succeded, 1 otherwise and then returns the result of sn, cn and dn in this order. - -=item C - -=item C - --These routines compute the complementary error function erfc(x) = 1 - erf(x) = (2/\sqrt(\pi)) \int_x^\infty \exp(-t^2). - -=back - -=over - -=item C - -=item C - --These routines compute the logarithm of the complementary error function \log(\erfc(x)). - -=back - -=over - -=item C - -=item C - --These routines compute the error function erf(x), where erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2). - -=back - -=over - -=item C - -=item C - --These routines compute the Gaussian probability density function Z(x) = (1/\sqrt{2\pi}) \exp(-x^2/2). - -=back - -=over - -=item C - -=item C - -- These routines compute the upper tail of the Gaussian probability function Q(x) = (1/\sqrt{2\pi}) \int_x^\infty dt \exp(-t^2/2). The hazard function for the normal distribution, also known as the inverse Mill's ratio, is defined as, h(x) = Z(x)/Q(x) = \sqrt{2/\pi} \exp(-x^2 / 2) / \erfc(x/\sqrt 2) It decreases rapidly as x approaches -\infty and asymptotes to h(x) \sim x as x approaches +\infty. - -=back - -=over - -=item C - -=item C - -- These routines compute the hazard function for the normal distribution. - -=back - -=over - -=item C - -=item C - -- These routines provide an exponential function \exp(x) using GSL semantics and error checking. - -=back - -=over - -=item C - - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - - -=back - -=over - -=item C - -=item C - --These routines compute the quantity \exp(x)-1 using an algorithm that is accurate for small x. - -=back - -=over - -=item C - -=item C - --These routines compute the quantity (\exp(x)-1)/x using an algorithm that is accurate for small x. For small x the algorithm is based on the expansion (\exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + \dots. - -=back - -=over - -=item C - -=item C - --These routines compute the quantity 2(\exp(x)-1-x)/x^2 using an algorithm that is accurate for small x. For small x the algorithm is based on the expansion 2(\exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + \dots. - -=back - -=over - -=item C - -=item C - --These routines compute the N-relative exponential, which is the n-th generalization of the functions gsl_sf_exprel and gsl_sf_exprel2. The N-relative exponential is given by, - exprel_N(x) = N!/x^N (\exp(x) - \sum_{k=0}^{N-1} x^k/k!) - = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ... - = 1F1 (1,1+N,x) - -=back - -=over - -=item C - This function exponentiates $x with an associated absolute error $dx. - -=item C - - -=item C - - -=item C - - -=back - -=over - -=item C - -=item C - --These routines compute the exponential integral E_1(x), E_1(x) := \Re \int_1^\infty dt \exp(-xt)/t. - -=back - -=over - -=item C - -=item C - --These routines compute the second-order exponential integral E_2(x), - E_2(x) := \Re \int_1^\infty dt \exp(-xt)/t^2. - - -=back - -=over - -=item C - -=item C - --These routines compute the exponential integral E_n(x) of order n, - E_n(x) := \Re \int_1^\infty dt \exp(-xt)/t^n. - - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the exponential integral Ei(x), Ei(x) := - PV(\int_{-x}^\infty dt \exp(-t)/t) where PV denotes the principal value of the integral. - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the integral Shi(x) = \int_0^x dt \sinh(t)/t. - -=back - -=over - -=item C - -=item C - --These routines compute the integral Chi(x) := \Re[ \gamma_E + \log(x) + \int_0^x dt (\cosh[t]-1)/t] , where \gamma_E is the Euler constant (available as $M_EULER from the Math::GSL::Const module). - -=back - -=over - -=item C - -=item C - --These routines compute the third-order exponential integral Ei_3(x) = \int_0^xdt \exp(-t^3) for x >= 0. - -=back - -=over - -=item C - -=item C - --These routines compute the Sine integral Si(x) = \int_0^x dt \sin(t)/t. - -=back - -=over - -=item C - -=item C - --These routines compute the Cosine integral Ci(x) = -\int_x^\infty dt \cos(t)/t for x > 0. - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral with an index of -1. This integral is given by F_{-1}(x) = e^x / (1 + e^x). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral with an index of 0. This integral is given by F_0(x) = \ln(1 + e^x). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral with an index of 1, F_1(x) = \int_0^\infty dt (t /(\exp(t-x)+1)). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral with an index of 2, F_2(x) = (1/2) \int_0^\infty dt (t^2 /(\exp(t-x)+1)). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral with an integer index of j, F_j(x) = (1/\Gamma(j+1)) \int_0^\infty dt (t^j /(\exp(t-x)+1)). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral F_{-1/2}(x). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral F_{1/2}(x). - -=back - -=over - -=item C - -=item C - --These routines compute the complete Fermi-Dirac integral F_{3/2}(x). - -=back - -=over - -=item C - -=item C - --These routines compute the incomplete Fermi-Dirac integral with an index of zero, F_0(x,b) = \ln(1 + e^{b-x}) - (b-x). - -=back - -=over - -=item C - -=item C - --These functions evaluate the Legendre polynomial P_l(x) for a specific value of l, x subject to l >= 0, |x| <= 1 - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - --These functions evaluate the Legendre polynomials P_l(x) using explicit representations for l=1, 2, 3. - -=back - -=over - -=item C - -=item C - --These routines compute the Legendre function Q_0(x) for x > -1, x != 1. - -=back - -=over - -=item C - -=item C - --These routines compute the Legendre function Q_1(x) for x > -1, x != 1. - -=back - -=over - -=item C - -=item C - --These routines compute the Legendre function Q_l(x) for x > -1, x != 1 and l >= 0. - -=back - -=over - -=item C - -=item C - --These routines compute the associated Legendre polynomial P_l^m(x) for m >= 0, l >= m, |x| <= 1. - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - --These routines compute the normalized associated Legendre polynomial $\sqrt{(2l+1)/(4\pi)} \sqrt{(l-m)!/(l+m)!} P_l^m(x)$ suitable for use in spherical harmonics. The parameters must satisfy m >= 0, l >= m, |x| <= 1. Theses routines avoid the overflows that occur for the standard normalization of P_l^m(x). - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - - -=back - -=over - -=item C - -=item C - --These routines compute the logarithm of the Gamma function, \log(\Gamma(x)), subject to x not being a negative integer or zero. For x<0 the real part of \log(\Gamma(x)) is returned, which is equivalent to \log(|\Gamma(x)|). The function is computed using the real Lanczos method. - -=back - -=over - -=item C - This routine returns the sign of the gamma function and the logarithm of its magnitude into this order, subject to $x not being a negative integer or zero. The function is computed using the real Lanczos method. The value of the gamma function can be reconstructed using the relation \Gamma(x) = sgn * \exp(resultlg). - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -- - -=back - -=over - -=item C - -=item C - -=over - -=item C - -=item C - --These routines compute the Arctangent integral, which is defined as AtanInt(x) = \int_0^x dt \arctan(t)/t. - -=back - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - -This module also contains the following constants used as mode in various of those functions : - -=over - -=item * GSL_PREC_DOUBLE - Double-precision, a relative accuracy of approximately 2 * 10^-16. - -=item * GSL_PREC_SINGLE - Single-precision, a relative accuracy of approximately 10^-7. - -=item * GSL_PREC_APPROX - Approximate values, a relative accuracy of approximately 5 * 10^-4. - -=back - - You can import the functions that you want to use by giving a space separated - list to Math::GSL::SF when you use the package. You can also write - use Math::GSL::SF qw/:all/ - to use all avaible functions of the module. Note that - the tag names begin with a colon. Other tags are also available, here is a - complete list of all tags for this module : - -=over - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=item C - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/name_of_the_function_you_want - -=head1 EXAMPLES - -This example computes the dilogarithm of 1/10 : - - use Math::GSL::SF qw/dilog/; - my $x = gsl_sf_dilog(0.1); - print "gsl_sf_dilog(0.1) = $x\n"; - -An example using Math::GSL::SF and gnuplot is in the B folder of the source code. - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::SF" +%include "typemaps.i" + +%apply double *OUTPUT { double * sn, double * cn, double * dn, double * sgn }; + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_version.h" + #include "gsl/gsl_mode.h" + #include "gsl/gsl_sf.h" + #include "gsl/gsl_sf_airy.h" + #include "gsl/gsl_sf_bessel.h" + #include "gsl/gsl_sf_clausen.h" + #include "gsl/gsl_sf_coulomb.h" + #include "gsl/gsl_sf_coupling.h" + #include "gsl/gsl_sf_dawson.h" + #include "gsl/gsl_sf_debye.h" + #include "gsl/gsl_sf_dilog.h" + #include "gsl/gsl_sf_elementary.h" + #include "gsl/gsl_sf_ellint.h" + #include "gsl/gsl_sf_elljac.h" + #include "gsl/gsl_sf_erf.h" + #include "gsl/gsl_sf_exp.h" + #include "gsl/gsl_sf_expint.h" + #include "gsl/gsl_sf_fermi_dirac.h" + #include "gsl/gsl_sf_gamma.h" + #include "gsl/gsl_sf_gegenbauer.h" + #include "gsl/gsl_sf_hyperg.h" + #include "gsl/gsl_sf_laguerre.h" + #include "gsl/gsl_sf_lambert.h" + #include "gsl/gsl_sf_legendre.h" + #include "gsl/gsl_sf_log.h" +#ifdef GSL_VERSION && GSL_VERSION == "1.11" + #include "gsl/gsl_sf_mathieu.h" +#endif + #include "gsl/gsl_sf_pow_int.h" + #include "gsl/gsl_sf_psi.h" + #include "gsl/gsl_sf_result.h" + #include "gsl/gsl_sf_synchrotron.h" + #include "gsl/gsl_sf_transport.h" + #include "gsl/gsl_sf_trig.h" + #include "gsl/gsl_sf_zeta.h" +%} +%include "gsl/gsl_types.h" +%include "gsl/gsl_version.h" +%include "gsl/gsl_mode.h" +%include "gsl/gsl_sf.h" +%include "gsl/gsl_sf_airy.h" +%include "gsl/gsl_sf_bessel.h" +%include "gsl/gsl_sf_clausen.h" +%include "gsl/gsl_sf_coulomb.h" +%include "gsl/gsl_sf_coupling.h" +%include "gsl/gsl_sf_dawson.h" +%include "gsl/gsl_sf_debye.h" +%include "gsl/gsl_sf_dilog.h" +%include "gsl/gsl_sf_elementary.h" +%include "gsl/gsl_sf_ellint.h" +%include "gsl/gsl_sf_elljac.h" +%include "gsl/gsl_sf_erf.h" +%include "gsl/gsl_sf_exp.h" +%include "gsl/gsl_sf_expint.h" +%include "gsl/gsl_sf_fermi_dirac.h" +%include "gsl/gsl_sf_gamma.h" +%include "gsl/gsl_sf_gegenbauer.h" +%include "gsl/gsl_sf_hyperg.h" +%include "gsl/gsl_sf_laguerre.h" +%include "gsl/gsl_sf_lambert.h" +%include "gsl/gsl_sf_legendre.h" +%include "gsl/gsl_sf_log.h" +#ifdef GSL_VERSION && GSL_VERSION == '1.11' + %include "gsl/gsl_sf_mathieu.h" +#endif +%include "gsl/gsl_sf_pow_int.h" +%include "gsl/gsl_sf_psi.h" +%include "gsl/gsl_sf_result.h" +%include "gsl/gsl_sf_synchrotron.h" +%include "gsl/gsl_sf_transport.h" +%include "gsl/gsl_sf_trig.h" +%include "gsl/gsl_sf_zeta.h" + +%include "../pod/SF.pod" diff --git a/swig/Siman.i b/swig/Siman.i dissimilarity index 91% index f2978ef..efe07f8 100644 --- a/swig/Siman.i +++ b/swig/Siman.i @@ -1,62 +1,9 @@ -%module "Math::GSL::Siman" -%{ - #include "gsl/gsl_siman.h" -%} - -%include "gsl/gsl_siman.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_siman_solve - gsl_siman_solve_many - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Siman - Simulated Annealing - -=head1 SYNOPSIS - -This module is not yet implemented. Patches Welcome! - -use Math::GSL::Siman qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=back - - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - - -%} +%module "Math::GSL::Siman" +%include "typemaps.i" +%include "gsl_typemaps.i" +%{ + #include "gsl/gsl_siman.h" +%} + +%include "gsl/gsl_siman.h" +%include "../pod/Siman.pod" diff --git a/swig/Sort.i b/swig/Sort.i dissimilarity index 72% index c548f36..e2c10cb 100644 --- a/swig/Sort.i +++ b/swig/Sort.i @@ -1,275 +1,104 @@ -%module "Math::GSL::Sort" -/* Danger Will Robinson! */ - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%typemap(argout) (double * data, const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - - while( i < $3 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - //Perl_sv_dump($result); - argvi++; -} -%typemap(argout) (double * dest, const size_t k, const gsl_vector * v) { - int i=0; - AV* tempav = newAV(); - - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (double * dest, const size_t k, const double * src, const size_t stride, const size_t n) { - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} -%typemap(argout) (size_t * p, const size_t k, const gsl_vector * v) -{ - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((double) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (size_t * p, const double * data, const size_t stride, const size_t n) -{ - int i=0; - AV* tempav = newAV(); - while( i < $4 ) { - av_push(tempav, newSVnv((size_t) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%typemap(argout) (size_t * p, const size_t k, const double * src, const size_t stride, const size_t n) -{ - int i=0; - AV* tempav = newAV(); - while( i < $2 ) { - av_push(tempav, newSVnv((size_t) $1[i])); - i++; - } - - $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); - argvi++; -} - -%apply double * { double *data, double *dest }; - -%{ - #include "gsl/gsl_nan.h" - #include "gsl/gsl_sort.h" - #include "gsl/gsl_sort_double.h" - #include "gsl/gsl_sort_int.h" - #include "gsl/gsl_sort_vector.h" - #include "gsl/gsl_sort_vector_double.h" - #include "gsl/gsl_sort_vector_int.h" - #include "gsl/gsl_permutation.h" -%} -%include "gsl/gsl_nan.h" -%include "gsl/gsl_sort.h" -%include "gsl/gsl_sort_double.h" -%include "gsl/gsl_sort_int.h" -%include "gsl/gsl_sort_vector.h" -%include "gsl/gsl_sort_vector_double.h" -%include "gsl/gsl_sort_vector_int.h" -%include "gsl/gsl_permutation.h" - - -%perlcode %{ -@EXPORT_plain = qw/ - gsl_sort gsl_sort_index - gsl_sort_smallest gsl_sort_smallest_index - gsl_sort_largest gsl_sort_largest_index - /; -@EXPORT_vector= qw/ - gsl_sort_vector gsl_sort_vector_index - gsl_sort_vector_smallest gsl_sort_vector_smallest_index - gsl_sort_vector_largest gsl_sort_vector_largest_index - /; -@EXPORT_OK = ( @EXPORT_plain, @EXPORT_vector ); -%EXPORT_TAGS = ( - all => [ @EXPORT_OK ], - plain => [ @EXPORT_plain ], - vector => [ @EXPORT_vector ], - ); -__END__ - -=head1 NAME - -Math::GSL::Sort - Functions for sorting data - -=head1 SYNOPSIS - - use Math::GSL::Sort qw/:all/; - my $x = [ 2**15, 1.67, 20e5, -17, 6900, 1/3 , 42e-10 ]; - my $sorted = gsl_sort($x, 1, $#$x+1 ); - my $numbers = [ map { rand(100) } (1..100) ]; - my ($status, $smallest10) = gsl_sort_smallest($array, 10, $x, 1, $#$x+1); - - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over - -=item * gsl_sort_vector($v) - - This function sorts the elements of the vector $v into ascending numerical order. - -=item * gsl_sort_vector_index($p, $v) - - This function indirectly sorts the elements of the vector $v into ascending - order, storing the resulting permutation in $p. The elements of $p give the - index of the vector element which would have been stored in that position if - the vector had been sorted in place. The first element of $p gives the index - of the least element in $v, and the last element of $p gives the index of the - greatest element in $v. The vector $v is not changed. - -=item * gsl_sort_vector_smallest($array, $k, $vector) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - $k smallest elements of the vector $v. $k must be less than or equal to the - length of the vector $v. - -=item * gsl_sort_vector_smallest_index($p, $k, $v) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - indices of the $k smallest elements of the vector $v. $p must be a prealocated - array reference. This should be removed in further versions. $k must be less - than or equal to the length of the vector $v. - -=item * gsl_sort_vector_largest($array, $k, $vector) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - $k largest elements of the vector $v. $k must be less than or equal to the - length of the vector $v. - -=item * gsl_sort_vector_largest_index($p, $k, $v) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - indices of the $k largest elements of the vector $v. $p must be a prealocated - array reference. This should be removed in further versions. $k must be less - than or equal to the length of the vector $v. - -=item * gsl_sort($data, $stride, $n) - - This function returns an array reference to the sorted $n elements of the - array $data with stride $stride into ascending numerical order. - -=item * gsl_sort_index($p, $data, $stride, $n) - - This function indirectly sorts the $n elements of the array $data with stride - $stride into ascending order, outputting the permutation in the foram of an - array. $p must be a prealocated array reference. This should be removed in - further versions. The array $data is not changed. - -=item * gsl_sort_smallest($array, $k, $data, $stride, $n) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - $k smallest elements of the array $data, of size $n and stride $stride, in - ascending numerical. The size $k of the subset must be less than or equal to - $n. The data $src is not modified by this operation. $array must be a - prealocated array reference. This should be removed in further versions. - -=item * gsl_sort_smallest_index($p, $k, $src, $stride, $n) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - indices of the $k smallest elements of the array $src, of size $n and stride - $stride. The indices are chosen so that the corresponding data is in ascending - numerical order. $k must be less than or equal to $n. The data $src is not - modified by this operation. $p must be a prealocated array reference. This - should be removed in further versions. - -=item * gsl_sort_largest($array, $k, $data, $stride, $n) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - $k largest elements of the array $data, of size $n and stride $stride, in - ascending numerical. The size $k of the subset must be less than or equal to - $n. The data $src is not modified by this operation. $array must be a - prealocated array reference. This should be removed in further versions. - -=item * gsl_sort_largest_index($p, $k, $src, $stride, $n) - - This function outputs 0 if the operation succeeded, 1 otherwise and then the - indices of the $k largest elements of the array $src, of size $n and stride - $stride. The indices are chosen so that the corresponding data is in ascending - numerical order. $k must be less than or equal to $n. The data $src is not - modified by this operation. $p must be a prealocated array reference. This - should be removed in further versions. - -=back - - Here is a complete list of all tags for this module : - -=over - -=item all - -=item plain - -=item vector - -=back - - For more informations on the functions, we refer you to the GSL offcial documentation: - L - - Tip : search on google: L - -=head1 PERFORMANCE - - In the source code of Math::GSL, the file "examples/benchmark/sort" compares - the performance of gsl_sort() to Perl's builtin sort() function. It's first - argument is the number of iterations and the second is the size of the array - of numbers to sort. For example, to see a benchmark of 1000 iterations for - arrays of size 50000 you would type - - ./examples/benchmark/sort 1000 50000 - - Initial benchmarks indicate just slightly above a 2x performance increase - over sort() for arrays of between 5000 and 50000 elements. This may mostly - be due to the fact that gsl_sort() takes and returns a reference while sort() - takes and returns a plain list. - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Sort" +/* Danger Will Robinson! */ + +%include "typemaps.i" +%include "gsl_typemaps.i" + +%typemap(argout) (double * data, const size_t stride, const size_t n) { + int i=0; + AV* tempav = newAV(); + + while( i < $3 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + //Perl_sv_dump($result); + argvi++; +} +%typemap(argout) (double * dest, const size_t k, const gsl_vector * v) { + int i=0; + AV* tempav = newAV(); + + while( i < $2 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%typemap(argout) (double * dest, const size_t k, const double * src, const size_t stride, const size_t n) { + int i=0; + AV* tempav = newAV(); + while( i < $2 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} +%typemap(argout) (size_t * p, const size_t k, const gsl_vector * v) +{ + int i=0; + AV* tempav = newAV(); + while( i < $2 ) { + av_push(tempav, newSVnv((double) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%typemap(argout) (size_t * p, const double * data, const size_t stride, const size_t n) +{ + int i=0; + AV* tempav = newAV(); + while( i < $4 ) { + av_push(tempav, newSVnv((size_t) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%typemap(argout) (size_t * p, const size_t k, const double * src, const size_t stride, const size_t n) +{ + int i=0; + AV* tempav = newAV(); + while( i < $2 ) { + av_push(tempav, newSVnv((size_t) $1[i])); + i++; + } + + $result = sv_2mortal( newRV_noinc( (SV*) tempav) ); + argvi++; +} + +%apply double * { double *data, double *dest }; + +%{ + #include "gsl/gsl_nan.h" + #include "gsl/gsl_sort.h" + #include "gsl/gsl_sort_double.h" + #include "gsl/gsl_sort_int.h" + #include "gsl/gsl_sort_vector.h" + #include "gsl/gsl_sort_vector_double.h" + #include "gsl/gsl_sort_vector_int.h" + #include "gsl/gsl_permutation.h" +%} +%include "gsl/gsl_nan.h" +%include "gsl/gsl_sort.h" +%include "gsl/gsl_sort_double.h" +%include "gsl/gsl_sort_int.h" +%include "gsl/gsl_sort_vector.h" +%include "gsl/gsl_sort_vector_double.h" +%include "gsl/gsl_sort_vector_int.h" +%include "gsl/gsl_permutation.h" + +%include "../pod/Sort.pod" diff --git a/swig/Spline.i b/swig/Spline.i dissimilarity index 91% index 27abd94..6aa939d 100644 --- a/swig/Spline.i +++ b/swig/Spline.i @@ -1,98 +1,13 @@ -%module "Math::GSL::Spline" - -%include "typemaps.i" -%include "gsl_typemaps.i" -%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; - -%{ - #include "gsl/gsl_spline.h" -%} - -%include "gsl/gsl_spline.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_spline_alloc - gsl_spline_init - gsl_spline_name - gsl_spline_min_size - gsl_spline_eval_e - gsl_spline_eval - gsl_spline_eval_deriv_e - gsl_spline_eval_deriv - gsl_spline_eval_deriv2_e - gsl_spline_eval_deriv2 - gsl_spline_eval_integ_e - gsl_spline_eval_integ - gsl_spline_free - /; -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -__END__ - -=head1 NAME - -Math::GSL::Spline - Higher-level Interface to Interp - -=head1 SYNOPSIS - -use Math::GSL::Spline qw /:all/; - -=head1 DESCRIPTION - -The functions described in the Interp module required the user to supply pointers to the x and y arrays on each call. The following functions are equivalent to the corresponding gsl_interp functions but maintain a copy of this data in the gsl_spline object. This removes the need to pass both xa and ya as arguments on each evaluation. - -Here is a list of all the functions in this module : - -=over - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - -%} +%module "Math::GSL::Spline" + +%include "typemaps.i" +%include "gsl_typemaps.i" +%apply double *OUTPUT { double * y, double * d, double * d2, double * result }; + +%{ + #include "gsl/gsl_spline.h" +%} + +%include "gsl/gsl_spline.h" + +%include "../pod/Spline.pod" diff --git a/swig/Statistics.i b/swig/Statistics.i dissimilarity index 98% index 2e3831e..e9a1bc8 100644 --- a/swig/Statistics.i +++ b/swig/Statistics.i @@ -1,433 +1,20 @@ -%module "Math::GSL::Statistics" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -%apply double *OUTPUT { double * min, double * max }; - -%apply int *OUTPUT { size_t * min_index, size_t * max_index }; - -%{ - #include "gsl/gsl_statistics_double.h" - #include "gsl/gsl_statistics_int.h" - #include "gsl/gsl_statistics_char.h" -%} - -%include "gsl/gsl_statistics_double.h" -%include "gsl/gsl_statistics_int.h" -%include "gsl/gsl_statistics_char.h" - - -%perlcode %{ -@EXPORT_OK = qw/ - gsl_stats_mean - gsl_stats_variance - gsl_stats_sd - gsl_stats_variance_with_fixed_mean - gsl_stats_sd_with_fixed_mean - gsl_stats_tss - gsl_stats_tss_m - gsl_stats_absdev - gsl_stats_skew - gsl_stats_kurtosis - gsl_stats_lag1_autocorrelation - gsl_stats_covariance - gsl_stats_correlation - gsl_stats_variance_m - gsl_stats_sd_m - gsl_stats_absdev_m - gsl_stats_skew_m_sd - gsl_stats_kurtosis_m_sd - gsl_stats_lag1_autocorrelation_m - gsl_stats_covariance_m - gsl_stats_wmean - gsl_stats_wvariance - gsl_stats_wsd - gsl_stats_wvariance_with_fixed_mean - gsl_stats_wsd_with_fixed_mean - gsl_stats_wtss - gsl_stats_wtss_m - gsl_stats_wabsdev - gsl_stats_wskew - gsl_stats_wkurtosis - gsl_stats_wvariance_m - gsl_stats_wsd_m - gsl_stats_wabsdev_m - gsl_stats_wskew_m_sd - gsl_stats_wkurtosis_m_sd - gsl_stats_pvariance - gsl_stats_ttest - gsl_stats_max - gsl_stats_min - gsl_stats_minmax - gsl_stats_max_index - gsl_stats_min_index - gsl_stats_minmax_index - gsl_stats_median_from_sorted_data - gsl_stats_quantile_from_sorted_data - /; -our @EXPORT_int = qw/ - gsl_stats_int_mean - gsl_stats_int_variance - gsl_stats_int_sd - gsl_stats_int_variance_with_fixed_mean - gsl_stats_int_sd_with_fixed_mean - gsl_stats_int_tss - gsl_stats_int_tss_m - gsl_stats_int_absdev - gsl_stats_int_skew - gsl_stats_int_kurtosis - gsl_stats_int_lag1_autocorrelation - gsl_stats_int_covariance - gsl_stats_int_correlation - gsl_stats_int_variance_m - gsl_stats_int_sd_m - gsl_stats_int_absdev_m - gsl_stats_int_skew_m_sd - gsl_stats_int_kurtosis_m_sd - gsl_stats_int_lag1_autocorrelation_m - gsl_stats_int_covariance_m - gsl_stats_int_pvariance - gsl_stats_int_ttest - gsl_stats_int_max - gsl_stats_int_min - gsl_stats_int_minmax - gsl_stats_int_max_index - gsl_stats_int_min_index - gsl_stats_int_minmax_index - gsl_stats_int_median_from_sorted_data - gsl_stats_int_quantile_from_sorted_data - /; -our @EXPORT_char = qw/ - gsl_stats_char_mean - gsl_stats_char_variance - gsl_stats_char_sd - gsl_stats_char_variance_with_fixed_mean - gsl_stats_char_sd_with_fixed_mean - gsl_stats_char_tss - gsl_stats_char_tss_m - gsl_stats_char_absdev - gsl_stats_char_skew - gsl_stats_char_kurtosis - gsl_stats_char_lag1_autocorrelation - gsl_stats_char_covariance - gsl_stats_char_correlation - gsl_stats_char_variance_m - gsl_stats_char_sd_m - gsl_stats_char_absdev_m - gsl_stats_char_skew_m_sd - gsl_stats_char_kurtosis_m_sd - gsl_stats_char_lag1_autocorrelation_m - gsl_stats_char_covariance_m - gsl_stats_char_pvariance - gsl_stats_char_ttest - gsl_stats_char_max - gsl_stats_char_min - gsl_stats_char_minmax - gsl_stats_char_max_index - gsl_stats_char_min_index - gsl_stats_char_minmax_index - gsl_stats_char_median_from_sorted_data - gsl_stats_char_quantile_from_sorted_data - /; -push @EXPORT_OK, @EXPORT_int, @EXPORT_char; -%EXPORT_TAGS = ( - all => \@EXPORT_OK, - int => \@EXPORT_int, - char => \@EXPORT_char - ); -__END__ - -=head1 NAME - -Math::GSL::Statistics - Statistical functions - -=head1 SYNOPSIS - - use Math::GSL::Statistics qw /:all/; - - my $data = [17.2, 18.1, 16.5, 18.3, 12.6]; - my $mean = gsl_stats_mean($data, 1, 5); - my $variance = gsl_stats_variance($data, 1, 5); - my $largest = gsl_stats_max($data, 1, 5); - my $smallest = gsl_stats_min($data, 1, 5); - print qq{ - Dataset : @$data - Sample mean $mean - Estimated variance $variance - Largest value $largest - Smallest value $smallest - }; - - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over 2 - -=item * C - This function returns the arithmetic mean of the array reference $data, a dataset of length $n with stride $stride. The arithmetic mean, or sample mean, is denoted by \Hat\mu and defined as, \Hat\mu = (1/N) \sum x_i where x_i are the elements of the dataset $data. For samples drawn from a gaussian distribution the variance of \Hat\mu is \sigma^2 / N. - -=item * C - This function returns the estimated, or sample, variance of data, an array reference of length $n with stride $stride. The estimated variance is denoted by \Hat\sigma^2 and is defined by, \Hat\sigma^2 = (1/(N-1)) \sum (x_i - \Hat\mu)^2 where x_i are the elements of the dataset data. Note that the normalization factor of 1/(N-1) results from the derivation of \Hat\sigma^2 as an unbiased estimator of the population variance \sigma^2. For samples drawn from a gaussian distribution the variance of \Hat\sigma^2 itself is 2 \sigma^4 / N. This function computes the mean via a call to gsl_stats_mean. If you have already computed the mean then you can pass it directly to gsl_stats_variance_m. - -=item * C - -=item * C - -The standard deviation is defined as the square root of the variance. These functions return the square root of the corresponding variance functions above. - -=item * C - This function calculates the standard deviation of the array reference $data for a fixed population mean $mean. The result is the square root of the corresponding variance function. - -=item * C - This function computes an unbiased estimate of the variance of data when the population mean $mean of the underlying distribution is known a priori. In this case the estimator for the variance uses the factor 1/N and the sample mean \Hat\mu is replaced by the known population mean \mu, \Hat\sigma^2 = (1/N) \sum (x_i - \mu)^2 - -=item * C - -=item * C - -These functions return the total sum of squares (TSS) of data about the mean. For gsl_stats_tss_m the user-supplied value of mean is used, and for gsl_stats_tss it is computed using gsl_stats_mean. TSS = \sum (x_i - mean)^2 - -=item * C - This function computes the absolute deviation from the mean of data, a dataset of length $n with stride $stride. The absolute deviation from the mean is defined as, absdev = (1/N) \sum |x_i - \Hat\mu| where x_i are the elements of the array reference $data. The absolute deviation from the mean provides a more robust measure of the width of a distribution than the variance. This function computes the mean of data via a call to gsl_stats_mean. - -=item * C - This function computes the skewness of $data, a dataset in the form of an array reference of length $n with stride $stride. The skewness is defined as, skew = (1/N) \sum ((x_i - \Hat\mu)/\Hat\sigma)^3 where x_i are the elements of the dataset $data. The skewness measures the asymmetry of the tails of a distribution. The function computes the mean and estimated standard deviation of data via calls to gsl_stats_mean and gsl_stats_sd. - -=item * C - This function computes the skewness of the array reference $data using the given values of the mean $mean and standard deviation $sd, skew = (1/N) \sum ((x_i - mean)/sd)^3. These functions are useful if you have already computed the mean and standard deviation of $data and want to avoid recomputing them. - -=item * C - This function computes the kurtosis of data, an array reference of length $n with stride $stride. The kurtosis is defined as, kurtosis = ((1/N) \sum ((x_i - \Hat\mu)/\Hat\sigma)^4) - 3. The kurtosis measures how sharply peaked a distribution is, relative to its width. The kurtosis is normalized to zero for a gaussian distribution. - -=item * C - This function computes the kurtosis of the array reference $data using the given values of the mean $mean and standard deviation $sd, kurtosis = ((1/N) \sum ((x_i - mean)/sd)^4) - 3. This function is useful if you have already computed the mean and standard deviation of data and want to avoid recomputing them. - -=item * C - This function computes the lag-1 autocorrelation of the array reference data. - a_1 = {\sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i-1} - \Hat\mu) - \over - \sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i} - \Hat\mu)} - -=item * C - This function computes the lag-1 autocorrelation of the array reference $data using the given value of the mean $mean. - -=item * C - This function computes the covariance of the array reference $data1 and $data2 which must both be of the same length $n. covar = (1/(n - 1)) \sum_{i = 1}^{n} (x_i - \Hat x) (y_i - \Hat y) - -=item * C - This function computes the covariance of the array reference $data1 and $data2 using the given values of the means, $mean1 and $mean2. This is useful if you have already computed the means of $data1 and $data2 and want to avoid recomputing them. - -=item * C - This function efficiently computes the Pearson correlation coefficient between the array reference $data1 and $data2 which must both be of the same length $n. - r = cov(x, y) / (\Hat\sigma_x \Hat\sigma_y) - = {1/(n-1) \sum (x_i - \Hat x) (y_i - \Hat y) - \over - \sqrt{1/(n-1) \sum (x_i - \Hat x)^2} \sqrt{1/(n-1) \sum (y_i - \Hat y)^2} - } - -=item * C - This function returns the sample variance of $data, an array reference, relative to the given value of $mean. The function is computed with \Hat\mu replaced by the value of mean that you supply, \Hat\sigma^2 = (1/(N-1)) \sum (x_i - mean)^2 - -=item * C - This function computes the absolute deviation of the dataset $data, an array refrence, relative to the given value of $mean, absdev = (1/N) \sum |x_i - mean|. This function is useful if you have already computed the mean of data (and want to avoid recomputing it), or wish to calculate the absolute deviation relative to another value (such as zero, or the median). - -=item * C - This function returns the weighted mean of the dataset $data array reference with stride $stride and length $n, using the set of weights $w, which is an array reference, with stride $wstride and length $n. The weighted mean is defined as, \Hat\mu = (\sum w_i x_i) / (\sum w_i) - -=item * C - This function returns the estimated variance of the dataset $data, which is the dataset, with stride $stride and length $n, using the set of weights $w (as an array reference) with stride $wstride and length $n. The estimated variance of a weighted dataset is defined as, \Hat\sigma^2 = ((\sum w_i)/((\sum w_i)^2 - \sum (w_i^2))) \sum w_i (x_i - \Hat\mu)^2. Note that this expression reduces to an unweighted variance with the familiar 1/(N-1) factor when there are N equal non-zero weights. - -=item * C - This function returns the estimated variance of the weighted dataset $data (which is an array reference) using the given weighted mean $wmean. - -=item * C - The standard deviation is defined as the square root of the variance. This function returns the square root of the corresponding variance function gsl_stats_wvariance above. - -=item * C - This function returns the square root of the corresponding variance function gsl_stats_wvariance_m above. - -=item * C - This function computes an unbiased estimate of the variance of weighted dataset $data (which is an array reference) when the population mean $mean of the underlying distribution is known a priori. In this case the estimator for the variance replaces the sample mean \Hat\mu by the known population mean \mu, \Hat\sigma^2 = (\sum w_i (x_i - \mu)^2) / (\sum w_i) - -=item * C - The standard deviation is defined as the square root of the variance. This function returns the square root of the corresponding variance function above. - -=item * C - -=item * C - These functions return the weighted total sum of squares (TSS) of data about the weighted mean. For gsl_stats_wtss_m the user-supplied value of $wmean is used, and for gsl_stats_wtss it is computed using gsl_stats_wmean. TSS = \sum w_i (x_i - wmean)^2 - -=item * C - This function computes the weighted absolute deviation from the weighted mean of $data, which is an array reference. The absolute deviation from the mean is defined as, absdev = (\sum w_i |x_i - \Hat\mu|) / (\sum w_i) - -=item * C - This function computes the absolute deviation of the weighted dataset $data (an array reference) about the given weighted mean $wmean. - -=item * C - This function computes the weighted skewness of the dataset $data, an array reference. skew = (\sum w_i ((x_i - xbar)/\sigma)^3) / (\sum w_i) - -=item * C - This function computes the weighted skewness of the dataset $data using the given values of the weighted mean and weighted standard deviation, $wmean and $wsd. - -=item * C - This function computes the weighted kurtosis of the dataset $data, an array reference. kurtosis = ((\sum w_i ((x_i - xbar)/sigma)^4) / (\sum w_i)) - 3 - -=item * C - This function computes the weighted kurtosis of the dataset $data, an array reference, using the given values of the weighted mean and weighted standard deviation, $wmean and $wsd. - -=item * C - -=item * C - -=item * C - This function returns the maximum value in the $data array reference, a dataset of length $n with stride $stride. The maximum value is defined as the value of the element x_i which satisfies x_i >= x_j for all j. If you want instead to find the element with the largest absolute magnitude you will need to apply fabs or abs to your data before calling this function. - -=item * C - This function returns the minimum value in $data (which is an array reference) a dataset of length $n with stride $stride. The minimum value is defined as the value of the element x_i which satisfies x_i <= x_j for all j. If you want instead to find the element with the smallest absolute magnitude you will need to apply fabs or abs to your data before calling this function. - -=item * C - This function finds both the minimum and maximum values in $data, which is an array reference, in a single pass and returns them in this order. - -=item * C - This function returns the index of the maximum value in $data array reference, a dataset of length $n with stride $stride. The maximum value is defined as the value of the element x_i which satisfies x_i >= x_j for all j. When there are several equal maximum elements then the first one is chosen. - -=item * C - This function returns the index of the minimum value in $data array reference, a dataset of length $n with stride $stride. The minimum value is defined as the value of the element x_i which satisfies x_i <= x_j for all j. When there are several equal minimum elements then the first one is chosen. - -=item * C - This function returns the indexes of the minimum and maximum values in $data, an array reference in a single pass. The value are returned in this order. - -=item * C - This function returns the median value of $sorted_data (which is an array reference), a dataset of length $n with stride $stride. The elements of the array must be in ascending numerical order. There are no checks to see whether the data are sorted, so the function gsl_sort should always be used first. This function can be found in the Math::GSL::Sort module. When the dataset has an odd number of elements the median is the value of element (n-1)/2. When the dataset has an even number of elements the median is the mean of the two nearest middle values, elements (n-1)/2 and n/2. Since the algorithm for computing the median involves interpolation this function always returns a floating-point number, even for integer data types. - -=item * C - This function returns a quantile value of $sorted_data, a double-precision array reference of length $n with stride $stride. The elements of the array must be in ascending numerical order. The quantile is determined by the f, a fraction between 0 and 1. For example, to compute the value of the 75th percentile f should have the value 0.75. There are no checks to see whether the data are sorted, so the function gsl_sort should always be used first. This function can be found in the Math::GSL::Sort module. The quantile is found by interpolation, using the formula quantile = (1 - \delta) x_i + \delta x_{i+1} where i is floor((n - 1)f) and \delta is (n-1)f - i. Thus the minimum value of the array (data[0*stride]) is given by f equal to zero, the maximum value (data[(n-1)*stride]) is given by f equal to one and the median value is given by f equal to 0.5. Since the algorithm for computing quantiles involves interpolation this function always returns a floating-point number, even for integer data types. - -=back - -The following function are simply variants for int and char of the last functions: - -=over 4 - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=back - -You have to add the functions you want to use inside the qw /put_funtion_here /. -You can also write use Math::GSL::Statistics qw/:all/; to use all avaible functions of the module. -Other tags are also avaible, here is a complete list of all tags for this module : - -=over - -=item all - -=item int - -=item char - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - - -%} +%module "Math::GSL::Statistics" + +%include "typemaps.i" +%include "gsl_typemaps.i" + +%apply double *OUTPUT { double * min, double * max }; + +%apply int *OUTPUT { size_t * min_index, size_t * max_index }; + +%{ + #include "gsl/gsl_statistics_double.h" + #include "gsl/gsl_statistics_int.h" + #include "gsl/gsl_statistics_char.h" +%} + +%include "gsl/gsl_statistics_double.h" +%include "gsl/gsl_statistics_int.h" +%include "gsl/gsl_statistics_char.h" + +%include "../pod/Statistics.pod" diff --git a/swig/Sys.i b/swig/Sys.i dissimilarity index 96% index 1520939..5d0abbf 100644 --- a/swig/Sys.i +++ b/swig/Sys.i @@ -1,113 +1,10 @@ -%module "Math::GSL::Sys" - -%include "typemaps.i" -%apply int *OUTPUT { int * e }; - -%{ - #include "gsl/gsl_sys.h" -%} -%include "gsl/gsl_sys.h" -%perlcode %{ -our @EXPORT = qw(); -our @EXPORT_OK = qw/ - gsl_log1p - gsl_expm1 - gsl_hypot - gsl_hypot3 - gsl_acosh - gsl_asinh - gsl_atanh - gsl_isnan - gsl_isinf - gsl_finite - gsl_posinf - gsl_neginf - gsl_fdiv - gsl_coerce_double - gsl_coerce_float - gsl_coerce_long_double - gsl_ldexp - gsl_frexp - gsl_fcmp - gsl_nan - gsl_isnan - gsl_inf - /; - -our %EXPORT_TAGS = ( all => \@EXPORT_OK ); - -__END__ - -=head1 NAME - -Math::GSL::Sys - - -=head1 SYNOPSIS - -use Math::GSL::Sys qw /:all/; - -=head1 DESCRIPTION - -Here is a list of all the functions in this module : - -=over - -=item * C - This function computes the value of \log(1+$x) in a way that is accurate for small $x. It provides an alternative to the BSD math function log1p(x). -=item * C - This function computes the value of \exp($x)-1 in a way that is accurate for small $x. It provides an alternative to the BSD math function expm1(x). - -=item * C - This function computes the value of \sqrt{$x^2 + $y^2} in a way that avoids overflow. It provides an alternative to the BSD math function hypot($x,$y). - -=item * C - This function computes the value of \sqrt{$x^2 + $y^2 + $z^2} in a way that avoids overflow. - -=item * C - This function computes the value of \arccosh($x). It provides an alternative to the standard math function acosh($x). - -=item * C - This function computes the value of \arcsinh($x). It provides an alternative to the standard math function asinh($x). - -=item * C - This function computes the value of \arctanh($x). It provides an alternative to the standard math function atanh($x). - -=item * C - This function returns 1 if $x is not-a-number. - -=item * C - This function returns +1 if $x is positive infinity, -1 if $x is negative infinity and 0 otherwise. - -=item * C - This function returns 1 if $x is a real number, and 0 if it is infinite or not-a-number. - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - -=item * C - This function computes the value of $x * 2**$e. It provides an alternative to the standard math function ldexp($x,$e). - -=item * C - This function splits the number $x into its normalized fraction f and exponent e, such that $x = f * 2^e and 0.5 <= f < 1. The function returns f and then the exponent in e. If $x is zero, both f and e are set to zero. This function provides an alternative to the standard math function frexp(x, e). - -=item * C - This function determines whether $x and $y are approximately equal to a relative accuracy $epsilon. The relative accuracy is measured using an interval of size 2 \delta, where \delta = 2^k \epsilon and k is the maximum base-2 exponent of $x and $y as computed by the function frexp. If $x and $y lie within this interval, they are considered approximately equal and the function returns 0. Otherwise if $x < $y, the function returns -1, or if $x > $y, the function returns +1. Note that $x and $y are compared to relative accuracy, so this function is not suitable for testing whether a value is approximately zero. The implementation is based on the package fcmp by T.C. Belding. - -=back - -For more informations on the functions, we refer you to the GSL offcial -documentation: L - - Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - -%} +%module "Math::GSL::Sys" + +%include "typemaps.i" +%apply int *OUTPUT { int * e }; + +%{ + #include "gsl/gsl_sys.h" +%} +%include "gsl/gsl_sys.h" +%include "../pod/Sys.pod" diff --git a/swig/Vector.i b/swig/Vector.i dissimilarity index 96% index 35d9455..0d3251c 100644 --- a/swig/Vector.i +++ b/swig/Vector.i @@ -1,477 +1,27 @@ -%module "Math::GSL::Vector" - -%include "typemaps.i" -%include "gsl_typemaps.i" - -FILE * fopen(char *, char *); -int fclose(FILE *); - -%{ - #include "gsl/gsl_nan.h" - #include "gsl/gsl_vector.h" - #include "gsl/gsl_vector_char.h" - #include "gsl/gsl_vector_complex.h" - #include "gsl/gsl_vector_complex_double.h" - #include "gsl/gsl_vector_double.h" - #include "gsl/gsl_vector_float.h" - #include "gsl/gsl_vector_int.h" -%} - -%include "gsl/gsl_nan.h" -%include "gsl/gsl_vector.h" -%include "gsl/gsl_vector_char.h" -%include "gsl/gsl_vector_complex.h" -%include "gsl/gsl_vector_complex_double.h" -%include "gsl/gsl_vector_double.h" -%include "gsl/gsl_vector_int.h" - - - -%perlcode %{ -use Scalar::Util 'blessed'; -use Data::Dumper; -use Carp qw/croak/; -use Math::GSL::Errno qw/:all/; -use Math::GSL::BLAS qw/gsl_blas_ddot/; -use overload - '*' => \&_multiplication, - '+' => \&_addition, - '-' => \&_subtract, - fallback => 1, -; - -@EXPORT_all = qw/fopen fclose - gsl_vector_alloc gsl_vector_calloc gsl_vector_alloc_from_block gsl_vector_alloc_from_vector - gsl_vector_free gsl_vector_view_array gsl_vector_const_view_array gsl_vector_view_array_with_stride - gsl_vector_const_view_array_with_stride gsl_vector_subvector gsl_vector_subvector_wi gsl_vector_subvector_with_stride - gsl_vector_const_subvec gsl_vector_const_subvec gsl_vector_get gsl_vector_set - gsl_vector_ptr gsl_vector_const_ptr gsl_vector_set_zero gsl_vector_set_all - gsl_vector_set_basis gsl_vector_fread gsl_vector_fwrite gsl_vector_fscanf - gsl_vector_fprintf gsl_vector_memcpy gsl_vector_reverse gsl_vector_swap - gsl_vector_swap_elements gsl_vector_max gsl_vector_min gsl_vector_minmax - gsl_vector_max_index gsl_vector_min_index gsl_vector_minmax_index - gsl_vector_add gsl_vector_sub gsl_vector_mul gsl_vector_div - gsl_vector_scale gsl_vector_add_constant gsl_vector_isnull - gsl_vector_ispos gsl_vector_isneg gsl_vector_isnonneg - gsl_vector_float_alloc gsl_vector_float_calloc gsl_vector_float_alloc_from_block - gsl_vector_float_alloc_from_vector gsl_vector_float_free gsl_vector_float_view_array - gsl_vector_float_view_array_with_stride gsl_vector_float_const_view_array gsl_vector_float_const_view_array_with_stride - gsl_vector_float_subvector gsl_vector_float_subvector_with_stride gsl_vector_float_const_subvector - gsl_vector_float_const_subvector_with_stride gsl_vector_float_get gsl_vector_float_set gsl_vector_float_ptr - gsl_vector_float_const_ptr gsl_vector_float_set_zero gsl_vector_float_set_all gsl_vector_float_set_basis - gsl_vector_float_fread gsl_vector_float_fwrite gsl_vector_float_fscanf gsl_vector_float_fprintf - gsl_vector_float_memcpy gsl_vector_float_reverse gsl_vector_float_swap gsl_vector_float_swap_elements - gsl_vector_float_max gsl_vector_float_min gsl_vector_float_minmax gsl_vector_float_max_index gsl_vector_float_min_index - gsl_vector_float_minmax_index gsl_vector_float_add gsl_vector_float_sub gsl_vector_float_mul gsl_vector_float_div gsl_vector_float_scale - gsl_vector_float_add_constant gsl_vector_float_isnull gsl_vector_float_ispos gsl_vector_float_isneg gsl_vector_float_isnonneg - gsl_vector_complex_alloc gsl_vector_complex_calloc gsl_vector_complex_alloc_from_block gsl_vector_complex_alloc_from_vector - gsl_vector_complex_free gsl_vector_complex_view_array gsl_vector_complex_view_array_with_stride gsl_vector_complex_const_view_array - gsl_vector_complex_const_view_array_with_stride gsl_vector_complex_subvector gsl_vector_complex_subvector_with_stride - gsl_vector_complex_const_subvector gsl_vector_complex_const_subvector_with_stride gsl_vector_complex_real gsl_vector_complex_imag - gsl_vector_complex_const_real gsl_vector_complex_const_imag gsl_vector_complex_get gsl_vector_complex_set - gsl_vector_complex_ptr gsl_vector_complex_const_ptr gsl_vector_complex_set_zero gsl_vector_complex_set_all - gsl_vector_complex_set_basis gsl_vector_complex_fread gsl_vector_complex_fwrite gsl_vector_complex_fscanf - gsl_vector_complex_fprintf gsl_vector_complex_memcpy gsl_vector_complex_reverse gsl_vector_complex_swap - gsl_vector_complex_swap_elements gsl_vector_complex_isnull gsl_vector_complex_ispos gsl_vector_complex_isneg -/; -@EXPORT_file =qw/ fopen fclose/; -@EXPORT_OK = (@EXPORT_all, @EXPORT_file); -%EXPORT_TAGS = ( file => \@EXPORT_file, all => \@EXPORT_all ); - -=head1 NAME - -Math::GSL::Vector - Functions concerning vectors - -=head1 SYNOPSIS - - use Math::GSL::Vector qw/:all/; - my $vec1 = Math::GSL::Vector->new([1, 7, 94, 15 ]); - my $vec2 = $vec1 * 5; - my $vec3 = Math::GSL::Vector>new(10); # 10 element zero vector - my $vec4 = $vec1 + $vec2; - - # set the element at index 1 to 9 - # and the element at index 3 to 8 - $vec3->set([ 1, 3 ], [ 9, 8 ]); - - my @vec = $vec2->as_list; # return elements as Perl list - - my $dot_product = $vec1 * $vec2; - my $length = $vec2->length; - my $first = $vec1->get(0); - - -=cut - -=head1 Objected Oriented Interface to GSL Math::GSL::Vector - -=head2 Math::GSL::Vector->new() - -Creates a new Vector of the given size. - - my $vector = Math::GSL::Matrix->new(3); - -You can also create and set directly the values of the vector like this : - - my $vector = Math::GSL::Vector->new([2,4,1]); - -=cut -sub new { - my ($class, $values) = @_; - my $length = $#$values; - my $this = {}; - my $vector; - if ( ref $values eq 'ARRAY' ){ - die __PACKAGE__.'::new($x) - $x must be a nonempty array reference' if $length == -1; - $vector = gsl_vector_alloc($length+1); - map { gsl_vector_set($vector, $_, $values->[$_] ) } (0 .. $length); - $this->{_length} = $length+1; - } elsif ( (int($values) == $values) && ($values > 0)) { - $vector = gsl_vector_alloc($values); - gsl_vector_set_zero($vector); - $this->{_length} = $values; - } else { - die __PACKAGE__.'::new($x) - $x must be an int or array reference'; - } - $this->{_vector} = $vector; - bless $this, $class; -} -=head2 raw() - -Get the underlying GSL vector object created by SWIG, useful for using gsl_vector_* functions which do not have an OO counterpart. - - my $vector = Math::GSL::Vector->new(3); - my $gsl_vector = $vector->raw; - my $stuff = gsl_vector_get($gsl_vector, 1); - -=cut - -sub raw { - my $self = shift; - return $self->{_vector}; -} - -=head2 min() - -Returns the minimum value contained in the vector. - - my $vector = Math::GSL::Vector->new([2,4,1]); - my $minimum = $vector->min; - -=cut - -sub min { - my $self=shift; - return gsl_vector_min($self->raw); -} - -=head2 max() - -Returns the minimum value contained in the vector. - - my $vector = Math::GSL::Vector->new([2,4,1]); - my $maximum = $vector->max; - -=cut - -sub max { - my $self=shift; - return gsl_vector_max($self->raw); -} - -=head2 length() - -Returns the number of elements contained in the vector. - - my $vector = Math::GSL::Vector->new([2,4,1]); - my $length = $vector->length; - -=cut - -sub length { my $self=shift; $self->{_length} } - -=head2 as_list() - -Gets the content of a Math::GSL::Vector object as a Perl list. - - my $vector = Math::GSL::Vector->new(3); - ... - my @values = $vector->as_list; -=cut - -sub as_list { - my $self=shift; - $self->get( [ 0 .. $self->length - 1 ] ); -} - -=head2 get() - -Gets the value of an of a Math::GSL::Vector object. - - my $vector = Math::GSL::Vector->new(3); - ... - my @values = $vector->get(2); - -You can also enter an array of indices to receive their corresponding values: - - my $vector = Math::GSL::Vector->new(3); - ... - my @values = $vector->get([0,2]); - -=cut - -sub get { - my ($self, $indices) = @_; - return map { gsl_vector_get($self->raw, $_ ) } @$indices ; -} - -=head2 set() - -Sets values of an of a Math::GSL::Vector object. - - my $vector = Math::GSL::Vector->new(3); - $vector->set([1,2], [8,23]); - -This sets the second and third value to 8 and 23. - -=cut - -sub set { - my ($self, $indices, $values) = @_; - die (__PACKAGE__.'::set($indices, $values) - $indices and $values must be array references of the same length') - unless ( ref $indices eq 'ARRAY' && ref $values eq 'ARRAY' && $#$indices == $#$values ); - eval { - map { gsl_vector_set($self->{_vector}, $indices->[$_], $values->[$_] ) } (0..$#$indices); - }; - return; -} - -=head2 copy() - -Returns a copy of the vector, which has the same length and values but resides at a different location in memory. - - my $vector = Math::GSL::Vector->new([10 .. 20]); - my $copy = $vector->copy; - -=cut - - -sub copy { - my $self = shift; - my $copy = Math::GSL::Vector->new( $self->length ); - if ( gsl_vector_memcpy($copy->raw, $self->raw) != $GSL_SUCCESS ) { - croak "Math::GSL - error copying memory, aborting"; - } - return $copy; -} - -sub _multiplication { - my ($left,$right) = @_; - my $lcopy = $left->copy; - - if ( blessed $right && $right->isa('Math::GSL::Vector') ) { - return $lcopy->dot_product($right); - } else { - gsl_vector_scale($lcopy->raw, $right); - } - return $lcopy; -} - -sub _subtract { - my ($left, $right, $flip) = @_; - - if ($flip) { - my $lcopy = $left->copy; - gsl_vector_scale($lcopy->raw, -1 ); - gsl_vector_add_constant($lcopy->raw, $right); - return $lcopy; - } else { - return _addition($left, -1.0*$right); - } -} - -sub _addition { - my ($left, $right, $flip) = @_; - - my $lcopy = $left->copy; - - if ( blessed $right && $right->isa('Math::GSL::Vector') && blessed $left && $left->isa('Math::GSL::Vector') ) { - if ( $left->length == $right->length ) { - gsl_vector_add($lcopy->raw, $right->raw); - } else { - croak "Math::GSL - addition of vectors must be called with two objects vectors and must have the same length"; - } - } else { - gsl_vector_add_constant($lcopy->raw, $right); - } - return $lcopy; -} - -sub dot_product_pp { - my ($left,$right) = @_; - my $sum=0; - if ( blessed $right && $right->isa('Math::GSL::Vector') && - $left->length == $right->length ) { - my @l = $left->as_list; - my @r = $right->as_list; - map { $sum += $l[$_] * $r[$_] } (0..$#l); - return $sum; - } else { - croak "dot_product() must be called with two vectors"; - } -} - -sub dot_product { - my ($left,$right) = @_; - - my ($status, $product) = gsl_blas_ddot($left->raw,$right->raw); - croak sprintf "Math::GSL::dot_product - %s", gsl_strerror($status) if ($status != $GSL_SUCCESS); - return $product; -} - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over 1 - -=item C - create a vector of size $x - -=item C - create a vector of size $x and initializes all the elements of the vector to zero - -=item C - -=item C - -=item C - free a previously allocated vector $v - -=item C - This function returns a vector view of an array reference $base. The start of the new vector is given by $base and has $n elements. Mathematically, the i-th element of the new vector v' is given by, v'(i) = $base->[i] where the index i runs from 0 to $n-1. The array containing the elements of v is not owned by the new vector view. When the view goes out of scope the original array will continue to exist. The original memory can only be deallocated by freeing the original pointer base. Of course, the original array should not be deallocated while the view is still in use. - -=item C - This function is equivalent to gsl_vector_view_array but can be used for arrays which are declared const. - -=item C - This function returns a vector view of an array reference $base with an additional $stride argument. The subvector is formed in the same way as for gsl_vector_view_array but the new vector has $n elements with a step-size of $stride from one element to the next in the original array. Mathematically, the i-th element of the new vector v' is given by, v'(i) = $base->[i*$stride] where the index i runs from 0 to $n-1. Note that the view gives direct access to the underlying elements of the original array. A vector view $view can be passed to any subroutine which takes a vector argument just as a directly allocated vector would be, using $view->{vector}. - -=item C - This function is equivalent to gsl_vector_view_array_with_stride but can be used for arrays which are declared const. - -=item C - return a vector_view type which contains a subvector of $v, with a size of $size, starting from the $offset position - -=item C - return a vector_view type which contains a subvector of $v, with a size of $size, starting from the $offset position and with a $stride step between each element of $v - -=item C - -=item C - return the $i-th element of a vector $v - -=item C - return the vector $v with his $i-th element set to $x - -=item C - -=item C - -=item C - set all the elements of $v to 0 - -=item C - set all the elements of $v to $x - -=item C - set all the elements of $v to 0 except for the $i-th element which is set to 1 and return 0 if the operation succeded, 1 otherwise. - -=item C - This function reads into the vector $v from the open stream $file opened with gsl_fopen function from the Math::GSL module in binary format. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many bytes to read. The return value is 0 for success and 1 if there was a problem reading from the file. - -=item C - This function writes the elements of the vector $v to the stream $file opened with gsl_fopen function from the Math::GSL module in binary format. The return value is 0 for success and 1 if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures. - -=item C This function reads formatted data from the stream $file opened with gsl_fopen function from the Math::GSL module into the vector $v. The vector $v must be preallocated with the correct length since the function uses the size of $v to determine how many numbers to read. The function returns 0 for success and 1 if there was a problem reading from the file. - -=item C -This function writes the elements of the vector $v line-by-line to the stream $file opened with gsl_fopen function from the Math::GSL module using the format specifier $format, which should be one of the "%g", "%e" or "%f" formats for floating point numbers and "%d" for integers. The function returns 0 for success and 1 if there was a problem writing to the file. - -=item C - This function copies the elements of the vector $src into the vector $dest and return 0 if the opertaion succeded, 1 otherwise. The two vectors must have the same length. - -=item C - reverse the order of the elements of the vector $v and return 0 if the opertaion succeded, 1 otherwise - -=item C - swap the values of the vectors $v and $v2 and return 0 if the opertaion succeded, 1 otherwise - -=item C - permute the elements at position $i and $j in the vector $v and return 0 if the operation succeded, 1 otherwise. - -=item C - return the maximum value in the vector $v - -=item C - return the minimum value in the vector $v - -=item C - return two values, the first is the minimum value in the vector $v and the second is the maximum value. - -=item C - return the position of the maximum value in the vector $v - -=item C - return the position of the minimum value in the vector $v - -=item C - return two values, the first is the position of the minimum value in the vector $v and the second is the position of the maximum value. - -=item C - add the elements of $v2 to the elements of $v, the two vectors must have the same lenght and return 0 if the operation succeded, 1 otherwise. - -=item C - substract the elements of $v2 from the elements of $v, the two vectors must have the same lenght and return 0 if the operation succeded, 1 otherwise. - -=item C - multiply the elements of $v by the elements of $v2, the two vectors must have the same lenght and return 0 if the operation succeded, 1 otherwise. - -=item C - divides the elements of $v by the elements of $v2, the two vectors must have the same lenght and return 0 if the operation succeded, 1 otherwise. - -=item C - multiplty the elements of the vector $v by a constant $x and return 0 if the operation succeded, 1 otherwise. - -=item C - add a constant $x to the elements of the vector $v and return 0 if the operation succeded, 1 otherwise. - -=item C - verify if all the elements of the vector $v are null, return 0 if it's the case, 1 otherwise. - -=item C - verify if all the elements of the vector $v are positive, return 0 if it's the case, 1 otherwise. - -=item C - verify if all the elements of the vector $v are negative, return 0 if it's the case, 1 otherwise. - -=item C - verify if all the elements the vector $v are not negative, return 0 if it's the case, 1 otherwise. - -=back - -You have to add the functions you want to use inside the qw /put_funtion_here / with spaces between each function. You can also write use Math::GSL::Complex qw/:all/ to use all avaible functions of the module. - - -Precision on the vector_view type : every modification you'll make on a vector_view will also modify the original vector. -For example, the following code will zero the even elements of the vector $v of length $size, while leaving the odd elements untouched : - -=over 1 - -=item C<$v_even= gsl_vector_subvector_with_stride ($v, 0, 2, $size/2);> - -=item C{vector});> - -=back - -For more informations on the functions, we refer you to the GSL offcial documentation: -L - -Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want - -=head1 EXAMPLES - -Here is an example using both interfaces. - - use Math::GSL::Vector qw/:all/; - - print "We'll create this vector : [0,1,4,9,16] \n"; - my $vector = Math::GSL::Vector->new([0,1,4,9,16]); - my ($min, $max) = gsl_vector_minmax_index($vector->raw); - - print "We then check the index value of the maximum and minimum values of the vector. \n"; - print "The index of the maximum should be 4 and we received $max \n"; - print "The index of the minimum should be 0 and we received $min \n"; - print "We'll then swap the first and the third elements of the vector \n"; - - gsl_vector_swap_elements($vector->raw, 0, 3); - my @got = $vector->as_list; - print "The vector should now be like this : [9,1,4,0,16] \n"; - print "and we received : [ @got ]\n"; - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::Vector" +%include "typemaps.i" +%include "gsl_typemaps.i" + +FILE * fopen(char *, char *); +int fclose(FILE *); + +%{ + #include "gsl/gsl_nan.h" + #include "gsl/gsl_vector.h" + #include "gsl/gsl_vector_char.h" + #include "gsl/gsl_vector_complex.h" + #include "gsl/gsl_vector_complex_double.h" + #include "gsl/gsl_vector_double.h" + #include "gsl/gsl_vector_float.h" + #include "gsl/gsl_vector_int.h" +%} + +%include "gsl/gsl_nan.h" +%include "gsl/gsl_vector.h" +%include "gsl/gsl_vector_char.h" +%include "gsl/gsl_vector_complex.h" +%include "gsl/gsl_vector_complex_double.h" +%include "gsl/gsl_vector_double.h" +%include "gsl/gsl_vector_int.h" + +%include "../pod/Vector.pod" diff --git a/swig/Wavelet.i b/swig/Wavelet.i dissimilarity index 94% index bf30e70..3077b29 100644 --- a/swig/Wavelet.i +++ b/swig/Wavelet.i @@ -1,127 +1,12 @@ -%module "Math::GSL::Wavelet" -%include "gsl_typemaps.i" -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_wavelet.h" -%} - -typedef int size_t; - -%include "gsl/gsl_types.h" -%include "gsl/gsl_wavelet.h" - -%include "typemaps.i" - - -%perlcode %{ - - -@EXPORT_OK = qw/ - gsl_wavelet_alloc - gsl_wavelet_free - gsl_wavelet_name - gsl_wavelet_workspace_alloc - gsl_wavelet_workspace_free - gsl_wavelet_transform - gsl_wavelet_transform_forward - gsl_wavelet_transform_inverse - $gsl_wavelet_daubechies - $gsl_wavelet_daubechies_centered - $gsl_wavelet_haar - $gsl_wavelet_haar_centered - $gsl_wavelet_bspline - $gsl_wavelet_bspline_centered -/; - - -%EXPORT_TAGS = ( all => [ @EXPORT_OK ], ); - -=head1 NAME - -Math::GSL::Wavelet - Wavelets (for 1-D real data) - -=head1 SYNOPSIS - - use Math::GSL::Wavelet qw/:all/; - -=cut - -=head1 DESCRIPTION - -Here is a list of all the functions included in this module : - -=over 1 - -=item C - This function allocates and initializes a wavelet object of type $T, where $T must be one of the constants below. The parameter $k selects the specific member of the wavelet family. - -=item C - This function frees the wavelet object $w. - -=item C - -=item C - This function allocates a workspace for the discrete wavelet transform. To perform a one-dimensional transform on $n elements, a workspace of size $n must be provided. For two-dimensional transforms of $n-by-$n matrices it is sufficient to allocate a workspace of size $n, since the transform operates on individual rows and columns. - -=item C - This function frees the allocated workspace work. - -=item C - -=item C - This functions compute in-place forward discrete wavelet transforms of length $n with stride $stride on the array $data. The length of the transform $n is restricted to powers of two. For the forward transform, the elements of the original array are replaced by the discrete wavelet transform f_i -> w_{j,k} in a packed triangular storage layout, where j is the index of the level j = 0 ... J-1 and k is the index of the coefficient within each level, k = 0 ... (2^j)-1. The total number of levels is J = \log_2(n). The output data has the following form, - -=over - -=item (s_{-1,0}, d_{0,0}, d_{1,0}, d_{1,1}, d_{2,0}, ..., - -=item d_{j,k}, ..., d_{J-1,2^{J-1}-1}) - -=back - -where the first element is the smoothing coefficient s_{-1,0}, followed by the detail coefficients d_{j,k} for each level j. The backward transform inverts these coefficients to obtain the original data. These functions return a status of $GSL_SUCCESS upon successful completion. $GSL_EINVAL is returned if $n is not an integer power of 2 or if insufficient workspace is provided. - -=item C - -=back - -This module also contains the following constants with their valid k value for the gsl_wavelet_alloc function : - -=over 1 - -=item $gsl_wavelet_daubechies - -=item $gsl_wavelet_daubechies_centered - -=back - -This is the Daubechies wavelet family of maximum phase with k/2 vanishing moments. The implemented wavelets are k=4, 6, ..., 20, with k even. - -=over 1 - -=item $gsl_wavelet_haar - -=item $gsl_wavelet_haar_centered - -=back - -This is the Haar wavelet. The only valid choice of k for the Haar wavelet is k=2. - -=over 1 - -=item $gsl_wavelet_bspline - -=item $gsl_wavelet_bspline_centered - -=back - -This is the biorthogonal B-spline wavelet family of order (i,j). The implemented values of k = 100*i + j are 103, 105, 202, 204, 206, 208, 301, 303, 305 307, 309. - -=head1 AUTHORS - -Jonathan Leto and Thierry Moisan - -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2008 Jonathan Leto and Thierry Moisan - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut -%} +%module "Math::GSL::Wavelet" +%include "typemaps.i" +%include "gsl_typemaps.i" +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_wavelet.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_wavelet.h" + +%include "../pod/Wavelet.pod" diff --git a/swig/Wavelet2D.i b/swig/Wavelet2D.i dissimilarity index 72% index ef730a8..a7a3a8e 100644 --- a/swig/Wavelet2D.i +++ b/swig/Wavelet2D.i @@ -1,33 +1,12 @@ -%module "Math::GSL::Wavelet2D" -%include "typemaps.i" -%include "gsl_typemaps.i" - -%{ - #include "gsl/gsl_types.h" - #include "gsl/gsl_wavelet2d.h" -%} - -%include "gsl/gsl_types.h" -%include "gsl/gsl_wavelet2d.h" - -%perlcode %{ - -@EXPORT_OK = qw/ - gsl_wavelet2d_transform - gsl_wavelet2d_transform_forward - gsl_wavelet2d_transform_inverse - gsl_wavelet2d_nstransform - gsl_wavelet2d_nstransform_forward - gsl_wavelet2d_nstransform_inverse - gsl_wavelet2d_transform_matrix - gsl_wavelet2d_transform_matrix_forward - gsl_wavelet2d_transform_matrix_inverse - gsl_wavelet2d_nstransform_matrix - gsl_wavelet2d_nstransform_matrix_forward - gsl_wavelet2d_nstransform_matrix_inverse - -/; - -%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); - -%} +%module "Math::GSL::Wavelet2D" +%include "typemaps.i" +%include "gsl_typemaps.i" + +%{ + #include "gsl/gsl_types.h" + #include "gsl/gsl_wavelet2d.h" +%} + +%include "gsl/gsl_types.h" +%include "gsl/gsl_wavelet2d.h" +%include "../pod/Wavelet2D.pod" diff --git a/swig/gsl_typemaps.i b/swig/gsl_typemaps.i index 79db1ed..30b235e 100644 --- a/swig/gsl_typemaps.i +++ b/swig/gsl_typemaps.i @@ -100,3 +100,5 @@ fprintf(stderr, 'FDF_FUNC'); } + +typedef int size_t; diff --git a/t/Heapsort.t b/t/Heapsort.t new file mode 100644 index 0000000..b7a3be5 --- /dev/null +++ b/t/Heapsort.t @@ -0,0 +1,23 @@ +package Math::GSL::Heapsort::Test; +use base q{Test::Class}; +use Test::More; +use Math::GSL qw/:all/; +use Math::GSL::Heapsort qw/:all/; +use Math::GSL::Test qw/:all/; +use Math::GSL::Errno qw/:all/; +use Data::Dumper; +use strict; + +BEGIN { gsl_set_error_handler_off(); } + +sub make_fixture : Test(setup) { +} + +sub teardown : Test(teardown) { +} + +sub GSL_HEAPSORT : Tests { + ok(1); +} + +Test::Class->runtests; diff --git a/t/IEEEUtils.t b/t/IEEEUtils.t new file mode 100644 index 0000000..b26cfe0 --- /dev/null +++ b/t/IEEEUtils.t @@ -0,0 +1,23 @@ +package Math::GSL::IEEEUtils::Test; +use base q{Test::Class}; +use Test::More; +use Math::GSL qw/:all/; +use Math::GSL::IEEEUtils qw/:all/; +use Math::GSL::Test qw/:all/; +use Math::GSL::Errno qw/:all/; +use Data::Dumper; +use strict; + +BEGIN { gsl_set_error_handler_off(); } + +sub make_fixture : Test(setup) { +} + +sub teardown : Test(teardown) { +} + +sub GSL_IEEEUTILS : Tests { + ok(1); +} + +Test::Class->runtests; diff --git a/t/Multimin.t b/t/Multimin.t new file mode 100644 index 0000000..679a105 --- /dev/null +++ b/t/Multimin.t @@ -0,0 +1,23 @@ +package Math::GSL::Multimin::Test; +use base q{Test::Class}; +use Test::More; +use Math::GSL qw/:all/; +use Math::GSL::Multimin qw/:all/; +use Math::GSL::Test qw/:all/; +use Math::GSL::Errno qw/:all/; +use Data::Dumper; +use strict; + +BEGIN { gsl_set_error_handler_off(); } + +sub make_fixture : Test(setup) { +} + +sub teardown : Test(teardown) { +} + +sub GSL_MULTIMIN : Tests { + ok(1); +} + +Test::Class->runtests; diff --git a/t/Siman.t b/t/Siman.t new file mode 100644 index 0000000..b7c8ae8 --- /dev/null +++ b/t/Siman.t @@ -0,0 +1,23 @@ +package Math::GSL::Siman::Test; +use base q{Test::Class}; +use Test::More; +use Math::GSL qw/:all/; +use Math::GSL::Siman qw/:all/; +use Math::GSL::Test qw/:all/; +use Math::GSL::Errno qw/:all/; +use Data::Dumper; +use strict; + +BEGIN { gsl_set_error_handler_off(); } + +sub make_fixture : Test(setup) { +} + +sub teardown : Test(teardown) { +} + +sub GSL_SIMAN : Tests { + ok(1); +} + +Test::Class->runtests; diff --git a/t/Wavelet2D.t b/t/Wavelet2D.t new file mode 100644 index 0000000..c0366a0 --- /dev/null +++ b/t/Wavelet2D.t @@ -0,0 +1,23 @@ +package Math::GSL::Wavelet2D::Test; +use base q{Test::Class}; +use Test::More; +use Math::GSL qw/:all/; +use Math::GSL::Wavelet2D qw/:all/; +use Math::GSL::Test qw/:all/; +use Math::GSL::Errno qw/:all/; +use Data::Dumper; +use strict; + +BEGIN { gsl_set_error_handler_off(); } + +sub make_fixture : Test(setup) { +} + +sub teardown : Test(teardown) { +} + +sub GSL_WAVELET2D : Tests { + ok(1); +} + +Test::Class->runtests; -- 2.11.4.GIT