Graphite
Version 3
An experimental 3D geometry processing program
|
Utilities for manipulating permutations. More...
Functions | |
bool | is_valid (const vector< index_t > &permutation) |
Checks whether a vector is a valid permutation. More... | |
void | mark (vector< index_t > &permutation, index_t i) |
Marks a permutation element as visited. More... | |
bool | is_marked (const vector< index_t > &permutation, index_t i) |
Checks if a permutation element has been visited. More... | |
void | unmark (vector< index_t > &permutation, index_t i) |
Unmarks a permutation element. More... | |
void | apply (void *data, const vector< index_t > &permutation_in, index_t elemsize) |
Applies a permutation in-place. Permutes the first N elements of size elemsize in array data using permutation permutation where N is the number of elements in permutation . The result of the permutation is left in data . The array data must contain at least permutation.size() elements otherwise memory corruption will happen. More... | |
template<class T > | |
void | apply (vector< T > &data, const vector< index_t > &permutation_in) |
Applies a permutation in-place. Permutes the first N elements of vector data using permutation permutation where N is the number of elements in permutation . The result of the permutation is left in data . The array data must contain at least permutation.size() elements otherwise the function throws an out_of_range exception. More... | |
void | invert (vector< index_t > &permutation) |
Inverts a permutation in-place. More... | |
void | invert (const vector< index_t > &permutation, vector< index_t > &invert) |
Inverts a permutation. More... | |
Utilities for manipulating permutations.
|
inline |
Applies a permutation in-place. Permutes the first N
elements of vector data
using permutation permutation
where N
is the number of elements in permutation
. The result of the permutation is left in data
. The array data
must contain at least permutation.size()
elements otherwise the function throws an out_of_range exception.
Applying permutation permutation
is equivalent to:
[in,out] | data | the vector to permute |
[in] | permutation_in | the permutation. It is temporarily changed during execution of the function, but identical to the input on exit. |
Definition at line 211 of file permutation.h.
|
inline |
Applies a permutation in-place. Permutes the first N
elements of size elemsize
in array data
using permutation permutation
where N
is the number of elements in permutation
. The result of the permutation is left in data
. The array data
must contain at least permutation.size()
elements otherwise memory corruption will happen.
Applying permutation permutation
is equivalent to:
[in,out] | data | an array of permutation.size() elements to permute |
[in] | permutation_in | the permutation. It is temporarily changed during execution of the function, but identical to the input on exit. |
[in] | elemsize | size of the vector elements |
Definition at line 157 of file permutation.h.
|
inline |
Inverts a permutation.
Computes the inverse of a given permutation
and stores the result in another one.
[in] | permutation | the permutation to invert |
[out] | invert | the computed inverse of permutation |
Definition at line 285 of file permutation.h.
Inverts a permutation in-place.
Inverses the given permutation
in place, the result of the inversion is left in permutation
.
The inversion is equivalent to:
[in,out] | permutation | to inverse. |
Definition at line 253 of file permutation.h.
Checks if a permutation element has been visited.
[in] | permutation | a valid permutation |
[in] | i | the index of the element in permutation |
Definition at line 110 of file permutation.h.
Checks whether a vector is a valid permutation.
The vector permutation
is a valid permutation if there is a bijection between the range [0..N-1] and the range [permutation[0]..permutation[N-1]] where N is the number of elements in the vector. An empty vector is considered as a valid permutation.
[in] | permutation | a vector of integers |
true | if permutation is a valid permutation |
false | otherwise |
Definition at line 70 of file permutation.h.
Marks a permutation element as visited.
Sets a visited mark for element at index i
. in permutation
. The element must not have been already marked. The mark can be checked with is_marked() and removed with unmark().
[in,out] | permutation | a valid permutation |
[in] | i | the index of the element in permutation |
Definition at line 95 of file permutation.h.
Unmarks a permutation element.
This restores the initial value of element at index i
in permutation
[in,out] | permutation | a valid permutation |
[in] | i | the index of the element in permutation |
Definition at line 126 of file permutation.h.