3 FILE * fopen
(char
*, char
*);
7 #include
"/usr/local/include/gsl/gsl_permute.h"
8 #include
"/usr/local/include/gsl/gsl_permute_double.h"
9 #include
"/usr/local/include/gsl/gsl_permute_int.h"
10 #include
"/usr/local/include/gsl/gsl_permute_vector.h"
11 #include
"/usr/local/include/gsl/gsl_permute_vector_double.h"
12 #include
"/usr/local/include/gsl/gsl_permute_vector_int.h"
13 #include
"/usr/local/include/gsl/gsl_permutation.h"
15 %include
"/usr/local/include/gsl/gsl_permute.h"
16 %include
"/usr/local/include/gsl/gsl_permute_double.h"
17 %include
"/usr/local/include/gsl/gsl_permute_int.h"
18 %include
"/usr/local/include/gsl/gsl_permute_vector.h"
19 %include
"/usr/local/include/gsl/gsl_permute_vector_double.h"
20 %include
"/usr/local/include/gsl/gsl_permute_vector_int.h"
21 %include
"/usr/local/include/gsl/gsl_permutation.h"
24 @EXPORT_OK
= qw
/fopen fclose
26 gsl_permutation_calloc
29 gsl_permutation_memcpy
31 gsl_permutation_fwrite
32 gsl_permutation_fscanf
33 gsl_permutation_fprintf
39 gsl_permutation_reverse
40 gsl_permutation_inverse
44 gsl_permutation_linear_to_canonical
45 gsl_permutation_canonical_to_linear
46 gsl_permutation_inversions
47 gsl_permutation_linear_cycles
48 gsl_permutation_canonical_cycles
52 gsl_permute_int_inverse
54 gsl_permute_vector_inverse
55 gsl_permute_vector_int
56 gsl_permute_vector_int_inverse
58 %EXPORT_TAGS
= ( all
=> [ @EXPORT_OK
] );
60 ### wrapper interface ###
62 my
($class
, $value
) = @_
;
64 $this-
>{_permutation
} = gsl_permutation_alloc
($value
);
72 Math
::GSL
::Permutation
- functions for creating and manipulating permutations
76 use Math
::GSL
::Permutation qw
/:all
/;
80 Here is a list of all the functions included in this module
:
82 gsl_permutation_alloc
($n
) - return a newly allocated permutation of size $n
83 gsl_permutation_calloc
($n
) - return a newly allocated permutation of size $n which is initialized to the identity
84 gsl_permutation_init
($p
) - initialize the permutation $p to the identity i.e.
(0,1,2, ...
, n-1
)
85 gsl_permutation_free
($p
) - free all the memory use by the permutaion $p
86 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
88 gsl_permutation_fwrite
89 gsl_permutation_fscanf
90 gsl_permutation_fprintf
91 gsl_permutation_size
($p
) - return the size of the permutation $p
93 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
94 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
95 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
96 gsl_permutation_reverse
($p
) - reverse the elements of the permutation $p
97 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
98 gsl_permutation_next
($p
) - advance the permutation $p to the next permutation in lexicographic order and return
0 if the operation succeeded
, 1 otherwise
99 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
100 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
101 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
102 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
103 gsl_permutation_inversions
($p
) - return the number of inversions in the permutation $p
104 gsl_permutation_linear_cycles
($p
) - return the number of cycles in the permutation $p
, given a linear form
105 gsl_permute_vector_int_inversegsl_permutation_canonical_cycles
($p
) - return the number of cycles in the permutation $p
, given a canonical form
109 gsl_permute_int_inverse
111 gsl_permute_vector_inverse
112 gsl_permute_vector_int
114 You have to add the functions you want to use inside the qw
/put_funtion_here
/ with spaces between each function.
115 You can also write use Math
::GSL
::CDF qw
/:all
/ to use all avaible functions of the module.
116 Other tags are also avaible
, here is a complete list of all tags for this module.
117 For more informations on the functions
, we refer you to the GSL offcial documentation
: http
://www.gnu.org
/software
/gsl
/manual
/html_node
/
118 Tip
: search on google
: site
:http
://www.gnu.org
/software
/gsl
/manual
/html_node
/ name_of_the_function_you_want
122 use Math
::GSL
::Permutation qw
/:all
/;
123 $p-
>{permutation
} = gsl_permutation_calloc
(5);
124 print
"The permutation contains [";
125 map
{ print gsl_permutation_get
($p-
>{permutation
}, $_
) .
", " } (0.
.3);
126 print gsl_permutation_get
($p-
>{permutation
}, 4);
128 print
"We'll then swap the first and last elements of the permutation...\n";
129 gsl_permutation_swap
($p-
>{permutation
}, 0, 4);
130 print
"The permutation now contains [";
131 map
{ print gsl_permutation_get
($p-
>{permutation
},$_
) .
", " } (0.
.3);
132 print gsl_permutation_get
($p-
>{permutation
}, 4);
136 use Math
::GSL
::Permutation qw
/:all
/;
137 use Math
::GSL
::Vector qw
/:all
/;
138 my $p-
>{permutation
} = gsl_permutation_calloc
(6);
139 gsl_permutation_init
($p-
>{permutation
});
140 gsl_permutation_swap
($p-
>{permutation
}, 0, 1);
141 print
"The permutation has his first and second elements swapped : [";
142 map
{ print gsl_permutation_get
($p-
>{permutation
}, $_
) .
"," } (0.
.4);
143 print gsl_permutation_get
($p-
>{permutation
}, 5) .
"] \n";
144 my $vec-
>{vector
} = gsl_vector_alloc
(6);
145 map
{ gsl_vector_set
($vec-
>{vector
}, $_
, $_
) } (0.
.5);
147 print
"We will now apply the permutation to this vector : [";
148 map
{ print gsl_vector_get
($vec-
>{vector
}, $_
) .
"," } (0.
.4);
149 print gsl_vector_get
($vec-
>{vector
}, 5) .
"] \n";
150 gsl_permute_vector
($p-
>{permutation
}, $vec-
>{vector
});
151 print
"The vector is now : [";
152 map
{ print gsl_vector_get
($vec-
>{vector
}, $_
) .
"," } (0.
.4);
153 print gsl_vector_get
($vec-
>{vector
}, 5) .
"] \n";
158 Jonathan Leto
<jonathan@leto.net
> and Thierry Moisan
<thierry.moisan@gmail.com
>
160 =head1 COPYRIGHT
AND LICENSE
162 Copyright
(C
) 2008 Jonathan Leto and Thierry Moisan
164 This program is free software
; you can redistribute it and
/or modify it
165 under the same terms as Perl itself.