Class Permutation
java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.Permutation
This class implements permutations of the set {0,1,...,n-1} for some given n
> 0, i.e., ordered sequences containing each number m (0 <=
m < n)
once and only once.
-
Constructor Summary
ConstructorsConstructorDescriptionPermutation
(byte[] enc) Create a permutation from an encoded permutation.Permutation
(int n) Create the identity permutation of the given size.Permutation
(int[] perm) Create a permutation using the given permutation vector.Permutation
(int n, SecureRandom sr) Create a random permutation of the given size. -
Method Summary
-
Constructor Details
-
Permutation
public Permutation(int n) Create the identity permutation of the given size.- Parameters:
n
- the size of the permutation
-
Permutation
public Permutation(int[] perm) Create a permutation using the given permutation vector.- Parameters:
perm
- the permutation vector
-
Permutation
public Permutation(byte[] enc) Create a permutation from an encoded permutation.- Parameters:
enc
- the encoded permutation
-
Permutation
Create a random permutation of the given size.- Parameters:
n
- the size of the permutationsr
- the source of randomness
-
-
Method Details
-
getEncoded
public byte[] getEncoded()Encode this permutation as byte array.- Returns:
- the encoded permutation
-
getVector
public int[] getVector()- Returns:
- the permutation vector (perm(0),perm(1),...,perm(n-1))
-
computeInverse
Compute the inverse permutation P-1.- Returns:
- this-1
-
rightMultiply
Compute the product of this permutation and another permutation.- Parameters:
p
- the other permutation- Returns:
- this * p
-
equals
checks if given object is equal to this permutation.The method returns false whenever the given object is not permutation.
-
toString
-
hashCode
public int hashCode()
-