3 #include
"/usr/local/include/gsl/gsl_permutation.h"
6 %include
"/usr/local/include/gsl/gsl_permutation.h"
11 gsl_permutation_calloc
14 gsl_permutation_memcpy
16 gsl_permutation_fwrite
17 gsl_permutation_fscanf
18 gsl_permutation_fprintf
24 gsl_permutation_reverse
25 gsl_permutation_inverse
29 gsl_permutation_linear_to_canonical
30 gsl_permutation_canonical_to_linear
31 gsl_permutation_inversions
32 gsl_permutation_linear_cycles
33 gsl_permutation_canonical_cycles
35 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
37 ### wrapper interface ###
39 my
($class
, $value
) = @_
;
41 $this-
>{_permutation
} = gsl_permutation_alloc
($value
);
49 Math
::GSL
::Permutation
- functions for creating and manipulating permutations
53 use Math
::GSL
::Permutation qw
/:all
/;
57 Here is a list of all the functions included in this module
:
59 gsl_permutation_alloc
($n
) - return a newly allocated permutation of size $n
60 gsl_permutation_calloc
($n
) - return a newly allocated permutation of size $n which is initialized to the identity
61 gsl_permutation_init
($p
) - initialize the permutation $p to the identity i.e.
(0,1,2, ...
, n-1
)
62 gsl_permutation_free
($p
) - free all the memory use by the permutaion $p
63 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
65 gsl_permutation_fwrite
66 gsl_permutation_fscanf
67 gsl_permutation_fprintf
68 gsl_permutation_size
($p
) - return the size of the permutation $p
70 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
71 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
72 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
73 gsl_permutation_reverse
($p
) - reverse the elements of the permutation $p
74 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
75 gsl_permutation_next
($p
) - advance the permutation $p to the next permutation in lexicographic order and return
0 if the operation succeeded
, 1 otherwise
76 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
77 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
78 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
79 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
80 gsl_permutation_inversions
($p
) - return the number of inversions in the permutation $p
81 gsl_permutation_linear_cycles
($p
) - return the number of cycles in the permutation $p
, given a linear form
82 gsl_permutation_canonical_cycles
($p
) - return the number of cycles in the permutation $p
, given a canonical form
84 You have to add the functions you want to use inside the qw
/put_funtion_here
/ with spaces between each function.
85 You can also write use Math
::GSL
::CDF qw
/:all
/ to use all avaible functions of the module.
86 Other tags are also avaible
, here is a complete list of all tags for this module.
87 For more informations on the functions
, we refer you to the GSL offcial documentation
: http
://www.gnu.org
/software
/gsl
/manual
/html_node
/
88 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
92 use Math
::GSL
::Permutation qw
/:all
/;
93 $p-
>{permutation
} = gsl_permutation_calloc
(5);
94 print
"The permutation contains [";
95 map
{ print gsl_permutation_get
($p-
>{permutation
}, $_
) .
", " } (0.
.3);
96 print gsl_permutation_get
($p-
>{permutation
}, 4);
98 print
"We'll then swap the first and last elements of the permutation...\n";
99 gsl_permutation_swap
($p-
>{permutation
}, 0, 4);
100 print
"The permutation now contains [";
101 map
{ print gsl_permutation_get
($p-
>{permutation
},$_
) .
", " } (0.
.3);
102 print gsl_permutation_get
($p-
>{permutation
}, 4);
108 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
110 =head1 COPYRIGHT
AND LICENSE
112 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
114 This program is free software
; you can redistribute it and
/or modify it
115 under the same terms as Perl itself.