Adding GSL_MATRIX_SUBMATRIX test.
[Math-GSL.git] / RNG.i
blob4217547dfcd1e647314eab1596da92cc1b5bfa17
1 %module RNG
2 %{
3 #include "/usr/local/include/gsl/gsl_rng.h"
4 %}
5 %import "/usr/local/include/gsl/gsl_types.h"
7 %include "/usr/local/include/gsl/gsl_rng.h"
9 %perlcode %{
10 use Data::Dumper;
11 @EXPORT_OK = qw/ gsl_rng_alloc gsl_rng_set gsl_rng_get gsl_rng_free gsl_rng_memcpy
12 gsl_rng_fwrite gsl_rng_fread gsl_rng_clone gsl_rng_max gsl_rng_min
13 gsl_rng_name gsl_rng_size gsl_rng_state gsl_rng_print_state
14 $gsl_rng_default $$gsl_rng_knuthran $$gsl_rng_ran0 $gsl_rng_borosh13
15 $gsl_rng_coveyou $gsl_rng_cmrg $gsl_rng_fishman18 $gsl_rng_fishman20 $gsl_rng_fishman2x
16 $gsl_rng_gfsr4 $gsl_rng_knuthran $gsl_rng_knuthran2 $gsl_rng_knuthran2002 $gsl_rng_lecuyer21
17 $gsl_rng_minstd $gsl_rng_mrg $gsl_rng_mt19937 $gsl_rng_mt19937_1999 $gsl_rng_mt19937_1998
18 $gsl_rng_r250 $gsl_rng_ran0 $gsl_rng_ran1 $gsl_rng_ran2 $gsl_rng_ran3
19 $gsl_rng_rand $gsl_rng_rand48 $gsl_rng_random128_bsd $gsl_rng_random128_gli $gsl_rng_random128_lib
20 $gsl_rng_random256_bsd $gsl_rng_random256_gli $gsl_rng_random256_lib $gsl_rng_random32_bsd
21 $gsl_rng_random32_glib $gsl_rng_random32_libc $gsl_rng_random64_bsd $gsl_rng_random64_glib
22 $gsl_rng_random64_libc $gsl_rng_random8_bsd $gsl_rng_random8_glibc $gsl_rng_random8_libc5
23 $gsl_rng_random_bsd $gsl_rng_random_glibc2 $gsl_rng_random_libc5 $gsl_rng_randu
24 $gsl_rng_ranf $gsl_rng_ranlux $gsl_rng_ranlux389 $gsl_rng_ranlxd1 $gsl_rng_ranlxd2 $gsl_rng_ranlxs0
25 $gsl_rng_ranlxs1 $gsl_rng_ranlxs2 $gsl_rng_ranmar $gsl_rng_slatec $gsl_rng_taus $gsl_rng_taus2
26 $gsl_rng_taus113 $gsl_rng_transputer $gsl_rng_tt800 $gsl_rng_uni $gsl_rng_uni32 $gsl_rng_vax
27 $gsl_rng_waterman14 $gsl_rng_zuf
29 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
31 sub new {
32 my ($class, $type, $seed) = @_;
33 $type ||= $gsl_rng_default;
34 $seed ||= int 100*rand;
36 my $self = {};
37 my $rng = gsl_rng_alloc($type);
38 gsl_rng_set($rng, $seed);
40 $self->{_rng} = $rng;
41 bless $self, $class;
44 sub copy {
45 my ($self) = @_;
46 my $copy = Math::GSL::RNG->new;
47 $copy->{_rng} = gsl_rng_clone($self->{_rng});
49 return $copy;
52 sub free {
53 my ($self) = @_;
54 gsl_rng_free($self->{_rng});
56 sub name {
57 my ($self) = @_;
58 gsl_rng_name($self->{_rng});
60 sub get {
61 my ($self) = @_;
63 gsl_rng_get($self->{_rng});