First working typemaps are in Poly subsystem. Still fighting with Randist...
[Math-GSL.git] / Randist.i
blob31591d8cf30f20368369afd50d0f79923e91ca9e
1 %module Randist
2 %include "typemaps.i"
4 %typemap(in) void * {
5 AV *tempav;
6 I32 len;
7 int i,x;
8 SV **tv;
10 if (!SvROK($input))
11 croak("Argument $argnum is not a reference.");
12 if (SvTYPE(SvRV($input)) != SVt_PVAV)
13 croak("Argument $argnum is not an array.");
15 tempav = (AV*)SvRV($input);
16 len = av_len(tempav);
17 $1 = (int **) malloc((len+2)*sizeof(int *));
18 for (i = 0; i <= len; i++) {
19 tv = av_fetch(tempav, i, 0);
20 x = SvIV(*tv);
21 memset((int*)($1+i), x , 1);
22 //printf("curr = %d\n", (int)($1+i) );
25 %typemap(freearg) void * {
26 free($1);
30 #include "/usr/local/include/gsl/gsl_randist.h"
32 %include "/usr/local/include/gsl/gsl_randist.h"
35 %perlcode %{
37 our @EXPORT_OK = qw/gsl_ran_bernoulli gsl_ran_bernoulli_pdf gsl_ran_beta
38 gsl_ran_beta_pdf gsl_ran_binomial gsl_ran_binomial_knuth
39 gsl_ran_binomial_tpe gsl_ran_binomial_pdf gsl_ran_exponential
40 gsl_ran_exponential_pdf gsl_ran_exppow gsl_ran_exppow_pdf
41 gsl_ran_cauchy gsl_ran_cauchy_pdf gsl_ran_chisq
42 gsl_ran_chisq_pdf gsl_ran_dirichlet gsl_ran_dirichlet_pdf
43 gsl_ran_dirichlet_lnpdf gsl_ran_erlang gsl_ran_erlang_pdf
44 gsl_ran_fdist gsl_ran_fdist_pdf gsl_ran_flat
45 gsl_ran_flat_pdf gsl_ran_gamma gsl_ran_gamma_int
46 gsl_ran_gamma_pdf gsl_ran_gamma_mt gsl_ran_gamma_knuth
47 gsl_ran_gaussian gsl_ran_gaussian_ratio_method gsl_ran_gaussian_ziggurat
48 gsl_ran_gaussian_pdf gsl_ran_ugaussian gsl_ran_ugaussian_ratio_method
49 gsl_ran_ugaussian_pdf gsl_ran_gaussian_tail gsl_ran_gaussian_tail_pdf
50 gsl_ran_ugaussian_tail gsl_ran_ugaussian_tail_pdf gsl_ran_bivariate_gaussian
51 gsl_ran_bivariate_gaussian_pdf gsl_ran_landau gsl_ran_landau_pdf
52 gsl_ran_geometric gsl_ran_geometric_pdf gsl_ran_hypergeometric
53 gsl_ran_hypergeometric_pdf gsl_ran_gumbel1 gsl_ran_gumbel1_pdf
54 gsl_ran_gumbel2 gsl_ran_gumbel2_pdf gsl_ran_logistic
55 gsl_ran_logistic_pdf gsl_ran_lognormal gsl_ran_lognormal_pdf
56 gsl_ran_logarithmic gsl_ran_logarithmic_pdf gsl_ran_multinomial
57 gsl_ran_multinomial_pdf gsl_ran_multinomial_lnpdf
58 gsl_ran_negative_binomial gsl_ran_negative_binomial_pdf gsl_ran_pascal
59 gsl_ran_pascal_pdf gsl_ran_pareto gsl_ran_pareto_pdf
60 gsl_ran_poisson gsl_ran_poisson_array
61 gsl_ran_poisson_pdf gsl_ran_rayleigh gsl_ran_rayleigh_pdf
62 gsl_ran_rayleigh_tail gsl_ran_rayleigh_tail_pdf gsl_ran_tdist
63 gsl_ran_tdist_pdf gsl_ran_laplace gsl_ran_laplace_pdf
64 gsl_ran_levy gsl_ran_levy_skew gsl_ran_weibull
65 gsl_ran_weibull_pdf gsl_ran_dir_2d gsl_ran_dir_2d_trig_method
66 gsl_ran_dir_3d gsl_ran_dir_nd gsl_ran_shuffle
67 gsl_ran_choose gsl_ran_sample
68 gsl_ran_discrete_t gsl_ran_discrete_free
69 gsl_ran_discrete gsl_ran_discrete_pdf
72 our %EXPORT_TAGS = (
73 all => [ @EXPORT_OK ],
74 logarithmic => [ gsl_ran_logarithmic , gsl_ran_logarithmic_pdf ],
75 choose => [ gsl_ran_choose ],
76 exponential => [ gsl_ran_exponential , gsl_ran_exponential_pdf ],
77 gumbel1 => [ gsl_ran_gumbel1 , gsl_ran_gumbel1_pdf ],
78 exppow => [ gsl_ran_exppow , gsl_ran_exppow_pdf ],
79 sample => [ gsl_ran_sample ],
80 logistic => [ gsl_ran_logistic , gsl_ran_logistic_pdf ],
81 gaussian => [
82 gsl_ran_gaussian , gsl_ran_gaussian_ratio_method , gsl_ran_gaussian_ziggurat,
83 gsl_ran_gaussian_pdf , gsl_ran_gaussian_tail , gsl_ran_gaussian_tail_pdf
85 poisson => [ gsl_ran_poisson , gsl_ran_poisson_array , gsl_ran_poisson_pdf ],
86 binomial => [ gsl_ran_binomial , gsl_ran_binomial_knuth , gsl_ran_binomial_tpe ,
87 gsl_ran_binomial_pdf ],
88 fdist => [ gsl_ran_fdist , gsl_ran_fdist_pdf ],
89 chisq => [ gsl_ran_chisq , gsl_ran_chisq_pdf ],
90 gamma => [ gsl_ran_gamma , gsl_ran_gamma_int , gsl_ran_gamma_pdf , gsl_ran_gamma_mt , gsl_ran_gamma_knuth ],
91 hypergeometric => [ gsl_ran_hypergeometric , gsl_ran_hypergeometric_pdf ],
92 dirichlet => [ gsl_ran_dirichlet , gsl_ran_dirichlet_pdf , gsl_ran_dirichlet_lnpdf ],
93 negative => [ gsl_ran_negative_binomial , gsl_ran_negative_binomial_pdf ],
94 flat => [ gsl_ran_flat , gsl_ran_flat_pdf ],
95 geometric => [ gsl_ran_geometric , gsl_ran_geometric_pdf ],
96 discrete => [ gsl_ran_discrete , gsl_ran_discrete_pdf],
97 tdist => [ gsl_ran_tdist , gsl_ran_tdist_pdf ],
98 ugaussian => [ gsl_ran_ugaussian , gsl_ran_ugaussian_ratio_method , gsl_ran_ugaussian_pdf ,
99 gsl_ran_ugaussian_tail , gsl_ran_ugaussian_tail_pdf ],
100 rayleigh => [ gsl_ran_rayleigh , gsl_ran_rayleigh_pdf , gsl_ran_rayleigh_tail ,
101 gsl_ran_rayleigh_tail_pdf ],
102 dir => [ gsl_ran_dir_2d , gsl_ran_dir_2d_trig_method , gsl_ran_dir_3d , gsl_ran_dir_nd ],
103 pascal => [ gsl_ran_pascal , gsl_ran_pascal_pdf ],
104 gumbel2 => [ gsl_ran_gumbel2 , gsl_ran_gumbel2_pdf ],
105 shuffle => [ gsl_ran_shuffle ],
106 landau => [ gsl_ran_landau , gsl_ran_landau_pdf ],
107 bernoulli => [ gsl_ran_bernoulli , gsl_ran_bernoulli_pdf ],
108 weibull => [ gsl_ran_weibull , gsl_ran_weibull_pdf ],
109 multinomial => [ gsl_ran_multinomial , gsl_ran_multinomial_pdf , gsl_ran_multinomial_lnpdf ],
110 beta => [ gsl_ran_beta , gsl_ran_beta_pdf ],
111 lognormal => [ gsl_ran_lognormal , gsl_ran_lognormal_pdf ],
112 laplace => [ gsl_ran_laplace , gsl_ran_laplace_pdf ],
113 erlang => [ gsl_ran_erlang , gsl_ran_erlang_pdf ],
114 cauchy => [ gsl_ran_cauchy , gsl_ran_cauchy_pdf ],
115 levy => [ gsl_ran_levy , gsl_ran_levy_skew ],
116 bivariate => [ gsl_ran_bivariate_gaussian , gsl_ran_bivariate_gaussian_pdf ],
117 pareto => [ gsl_ran_pareto , gsl_ran_pareto_pdf ]
120 __END__
122 =head1 NAME
124 Math::GSL::Randist - Probability Distributions
126 =head1 SYPNOPSIS
128 use Math::GSL::Randist qw/put_functions_here/;
130 =head1 DESCRIPTION
132 Here is a list of all the functions included in this module :
134 gsl_ran_bernoulli gsl_ran_bernoulli_pdf gsl_ran_beta
135 gsl_ran_beta_pdf gsl_ran_binomial gsl_ran_binomial_knuth
136 gsl_ran_binomial_tpe gsl_ran_binomial_pdf gsl_ran_exponential
137 gsl_ran_exponential_pdf gsl_ran_exppow gsl_ran_exppow_pdf
138 gsl_ran_cauchy gsl_ran_cauchy_pdf gsl_ran_chisq
139 gsl_ran_chisq_pdf gsl_ran_dirichlet gsl_ran_dirichlet_pdf
140 gsl_ran_dirichlet_lnpdf gsl_ran_erlang gsl_ran_erlang_pdf
141 gsl_ran_fdist gsl_ran_fdist_pdf gsl_ran_flat
142 gsl_ran_flat_pdf gsl_ran_gamma gsl_ran_gamma_int
143 gsl_ran_gamma_pdf gsl_ran_gamma_mt gsl_ran_gamma_knuth
144 gsl_ran_gaussian gsl_ran_gaussian_ratio_method gsl_ran_gaussian_ziggurat
145 gsl_ran_gaussian_pdf gsl_ran_ugaussian gsl_ran_ugaussian_ratio_method
146 gsl_ran_ugaussian_pdf gsl_ran_gaussian_tail gsl_ran_gaussian_tail_pdf
147 gsl_ran_ugaussian_tail gsl_ran_ugaussian_tail_pdf gsl_ran_bivariate_gaussian
148 gsl_ran_bivariate_gaussian_pdf gsl_ran_landau gsl_ran_landau_pdf
149 gsl_ran_geometric gsl_ran_geometric_pdf gsl_ran_hypergeometric
150 gsl_ran_hypergeometric_pdf gsl_ran_gumbel1 gsl_ran_gumbel1_pdf
151 gsl_ran_gumbel2 gsl_ran_gumbel2_pdf gsl_ran_logistic
152 gsl_ran_logistic_pdf gsl_ran_lognormal gsl_ran_lognormal_pdf
153 gsl_ran_logarithmic gsl_ran_logarithmic_pdf gsl_ran_multinomial
154 gsl_ran_multinomial_pdf gsl_ran_multinomial_lnpdf
155 gsl_ran_negative_binomial gsl_ran_negative_binomial_pdf gsl_ran_pascal
156 gsl_ran_pascal_pdf gsl_ran_pareto gsl_ran_pareto_pdf
157 gsl_ran_poisson gsl_ran_poisson_array
158 gsl_ran_poisson_pdf gsl_ran_rayleigh gsl_ran_rayleigh_pdf
159 gsl_ran_rayleigh_tail gsl_ran_rayleigh_tail_pdf gsl_ran_tdist
160 gsl_ran_tdist_pdf gsl_ran_laplace gsl_ran_laplace_pdf
161 gsl_ran_levy gsl_ran_levy_skew gsl_ran_weibull
162 gsl_ran_weibull_pdf gsl_ran_dir_2d gsl_ran_dir_2d_trig_method
163 gsl_ran_dir_3d gsl_ran_dir_nd gsl_ran_shuffle
164 gsl_ran_choose gsl_ran_sample
165 gsl_ran_discrete gsl_ran_discrete_pdf
167 You have to add the functions you want to use inside the qw /put_funtion_here /. You can also write
169 use Math::GSL::Randist qw/:name_of_tag/
171 to use all avaible functions of the module. Other tags are also avaible, here is a complete list of all tags for this module :
173 logarithmic
174 choose
175 exponential
176 gumbel1
177 exppow
178 sample
179 logistic
180 gaussian
181 poisson
182 binomial
183 fdist
184 chisq
185 gamma
186 hypergeometric
187 dirichlet
188 negative
189 flat
190 geometric
191 discrete
192 tdist
193 ugaussian
194 rayleigh
196 pascal
197 gumbel2
198 shuffle
199 landau
200 bernoulli
201 weibull
202 multinomial
203 beta
204 lognormal
205 laplace
206 erlang
207 cauchy
208 levy
209 bivariate
210 pareto
212 For example the beta tag contains theses functions : gsl_ran_beta, gsl_ran_beta_pdf.
214 For more informations on the functions, we refer you to the GSL offcial documentation: http://www.gnu.org/software/gsl/manual/html_node/
215 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
217 You might also want to write
219 use Math::GSL::RNG qw/:all/;
221 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.
223 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.
226 =head1 EXAMPLES
228 use Math::GSL::Randist qw/:all/;
229 print gsl_ran_exponential_pdf(5,2) . "\n";
231 use Math::GSL::Randist qw/:all/;
232 $x= Math::GSL::gsl_ran_discrete_t::new;
235 =head1 AUTHOR
237 Jonathan Leto <jaleto@gmail.com> and Thierry Moisan <thierry.moisan@gmail.com>
239 =head1 COPYRIGHT AND LICENSE
241 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
243 This program is free software; you can redistribute it and/or modify it
244 under the same terms as Perl itself.
246 =cut