version bump
[Math-GSL.git] / Sort.i
blob7011acb907b2dd8e4b5dfd939617bfe7a2dac715
1 %module "Math::GSL::Sort"
2 /* Danger Will Robinson! */
4 %include "typemaps.i"
5 %include "gsl_typemaps.i"
7 %typemap(argout) (double * data, const size_t stride, const size_t n) {
8 int i=0;
9 AV* tempav = newAV();
11 while( i < $3 ) {
12 av_push(tempav, newSVnv((double) $1[i]));
13 i++;
16 $result = sv_2mortal( newRV_noinc( (SV*) tempav) );
17 //Perl_sv_dump($result);
18 argvi++;
20 %typemap(argout) (double * dest, const size_t k, const gsl_vector * v) {
21 int i=0;
22 AV* tempav = newAV();
24 while( i < $2 ) {
25 av_push(tempav, newSVnv((double) $1[i]));
26 i++;
29 $result = sv_2mortal( newRV_noinc( (SV*) tempav) );
30 argvi++;
34 %apply double * { double *data, double *dest };
37 #include "gsl/gsl_nan.h"
38 #include "gsl/gsl_sort.h"
39 #include "gsl/gsl_sort_double.h"
40 #include "gsl/gsl_sort_int.h"
41 #include "gsl/gsl_sort_vector.h"
42 #include "gsl/gsl_sort_vector_double.h"
43 #include "gsl/gsl_sort_vector_int.h"
44 #include "gsl/gsl_permutation.h"
46 %include "gsl/gsl_nan.h"
47 %include "gsl/gsl_sort.h"
48 %include "gsl/gsl_sort_double.h"
49 %include "gsl/gsl_sort_int.h"
50 %include "gsl/gsl_sort_vector.h"
51 %include "gsl/gsl_sort_vector_double.h"
52 %include "gsl/gsl_sort_vector_int.h"
53 %include "gsl/gsl_permutation.h"
56 %perlcode %{
57 @EXPORT_plain = qw/
58 gsl_sort gsl_sort_index
59 gsl_sort_smallest gsl_sort_smallest_index
60 gsl_sort_largest gsl_sort_largest_index
62 @EXPORT_vector= qw/
63 gsl_sort_vector gsl_sort_vector_index
64 gsl_sort_vector_smallest gsl_sort_vector_smallest_index
65 gsl_sort_vector_largest gsl_sort_vector_largest_index
67 @EXPORT_OK = ( @EXPORT_plain, @EXPORT_vector );
68 %EXPORT_TAGS = (
69 all => [ @EXPORT_OK ],
70 plain => [ @EXPORT_plain ],
71 vector => [ @EXPORT_vector ],
73 __END__
75 =head1 NAME
77 Math::GSL::Sort - Functions for sorting data
79 =head1 SYNOPSIS
81 use Math::GSL::Sort qw/:all/;
82 my $x = [ 2**15, 1.67, 20e5,
83 -17, 6900, 1/3 , 42e-10 ];
84 my $sorted = gsl_sort($x, 1, $#$x+1 );
87 =head1 DESCRIPTION
89 Here is a list of all the functions included in this module :
91 =over
93 =item * gsl_sort_vector($v) - This function sorts the elements of the vector $v into ascending numerical order.
95 =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.
97 =item * gsl_sort_vector_smallest
99 =item * gsl_sort_vector_smallest_index
101 =item * gsl_sort_vector_largest
103 =item * gsl_sort_vector_largest_index
105 =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.
107 =item * gsl_sort_index
109 =item * gsl_sort_smallest
111 =item * gsl_sort_smallest_index
113 =item * gsl_sort_largest
115 =item * gsl_sort_largest_index
117 =back
119 You have to add the functions you want to use inside the qw /put_funtion_here /.
120 You can also write use Math::GSL::Sort qw/:all/ to use all avaible functions of the module.
121 Other tags are also avaible, here is a complete list of all tags for this module :
123 =over
125 =item all
127 =item plain
129 =item vector
131 =back
133 For more informations on the functions, we refer you to the GSL offcial documentation:
134 L<http://www.gnu.org/software/gsl/manual/html_node/>
136 Tip : search on google: site:http://www.gnu.org/software/gsl/manual/html_node/ name_of_the_function_you_want
138 =head1 AUTHORS
140 Jonathan Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
142 =head1 COPYRIGHT AND LICENSE
144 Copyright (C) 2008 Jonathan Leto and Thierry Moisan
146 This program is free software; you can redistribute it and/or modify it
147 under the same terms as Perl itself.
149 =cut