1 %module
"Math::GSL::Sort"
2 /* Danger Will Robinson
! */
5 %include
"gsl_typemaps.i"
7 %typemap
(argout
) (double
* data
, const size_t stride
, const size_t n
) {
12 av_push
(tempav
, newSVnv
((double
) $
1[i
]));
16 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
17 //Perl_sv_dump
($result
);
20 %typemap
(argout
) (double
* dest
, const size_t k
, const gsl_vector
* v
) {
25 av_push
(tempav
, newSVnv
((double
) $
1[i
]));
29 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
33 %typemap
(argout
) (double
* dest
, const size_t k
, const double
* src
, const size_t stride
, const size_t n
) {
37 av_push
(tempav
, newSVnv
((double
) $
1[i
]));
41 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
44 %typemap
(argout
) (size_t
* p
, const size_t k
, const gsl_vector
* v
)
49 av_push
(tempav
, newSVnv
((double
) $
1[i
]));
53 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
57 %typemap
(argout
) (size_t
* p
, const double
* data
, const size_t stride
, const size_t n
)
62 av_push
(tempav
, newSVnv
((size_t
) $
1[i
]));
66 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
70 %typemap
(argout
) (size_t
* p
, const size_t k
, const double
* src
, const size_t stride
, const size_t n
)
75 av_push
(tempav
, newSVnv
((size_t
) $
1[i
]));
79 $result
= sv_2mortal
( newRV_noinc
( (SV
*) tempav
) );
83 %apply double
* { double
*data
, double
*dest
};
86 #include
"gsl/gsl_nan.h"
87 #include
"gsl/gsl_sort.h"
88 #include
"gsl/gsl_sort_double.h"
89 #include
"gsl/gsl_sort_int.h"
90 #include
"gsl/gsl_sort_vector.h"
91 #include
"gsl/gsl_sort_vector_double.h"
92 #include
"gsl/gsl_sort_vector_int.h"
93 #include
"gsl/gsl_permutation.h"
95 %include
"gsl/gsl_nan.h"
96 %include
"gsl/gsl_sort.h"
97 %include
"gsl/gsl_sort_double.h"
98 %include
"gsl/gsl_sort_int.h"
99 %include
"gsl/gsl_sort_vector.h"
100 %include
"gsl/gsl_sort_vector_double.h"
101 %include
"gsl/gsl_sort_vector_int.h"
102 %include
"gsl/gsl_permutation.h"
107 gsl_sort gsl_sort_index
108 gsl_sort_smallest gsl_sort_smallest_index
109 gsl_sort_largest gsl_sort_largest_index
112 gsl_sort_vector gsl_sort_vector_index
113 gsl_sort_vector_smallest gsl_sort_vector_smallest_index
114 gsl_sort_vector_largest gsl_sort_vector_largest_index
116 @EXPORT_OK
= ( @EXPORT_plain
, @EXPORT_vector
);
118 all
=> [ @EXPORT_OK
],
119 plain
=> [ @EXPORT_plain
],
120 vector
=> [ @EXPORT_vector
],
126 Math
::GSL
::Sort
- Functions for sorting data
130 use Math
::GSL
::Sort qw
/:all
/;
131 my $x
= [ 2**15, 1.67, 20e5
,
132 -17, 6900, 1/3 , 42e-10 ];
133 my $sorted
= gsl_sort
($x
, 1, $#$x
+1 );
138 Here is a list of all the functions included in this module
:
142 =item
* gsl_sort_vector
($v
) - This function sorts the elements of the vector $v into ascending numerical order.
144 =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.
146 =item
* gsl_sort_vector_smallest
148 =item
* gsl_sort_vector_smallest_index
150 =item
* gsl_sort_vector_largest
152 =item
* gsl_sort_vector_largest_index
154 =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.
156 =item
* gsl_sort_index
158 =item
* gsl_sort_smallest
160 =item
* gsl_sort_smallest_index
162 =item
* gsl_sort_largest
164 =item
* gsl_sort_largest_index
168 You have to add the functions you want to use inside the qw
/put_funtion_here
/.
169 You can also write use Math
::GSL
::Sort qw
/:all
/ to use all avaible functions of the module.
170 Other tags are also avaible
, here is a complete list of all tags for this module
:
182 For more informations on the functions
, we refer you to the GSL offcial documentation
:
183 L
<http
://www.gnu.org
/software
/gsl
/manual
/html_node
/>
185 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
189 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
191 =head1 COPYRIGHT
AND LICENSE
193 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
195 This program is free software
; you can redistribute it and
/or modify it
196 under the same terms as Perl itself.