Class Permutation
- java.lang.Object
-
- org.bouncycastle.pqc.math.linearalgebra.Permutation
-
public class Permutation extends java.lang.Object
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
Constructors Constructor Description Permutation(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, java.security.SecureRandom sr)
Create a random permutation of the given size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Permutation
computeInverse()
Compute the inverse permutation P-1.boolean
equals(java.lang.Object other)
checks if given object is equal to this permutation.byte[]
getEncoded()
Encode this permutation as byte array.int[]
getVector()
int
hashCode()
Permutation
rightMultiply(Permutation p)
Compute the product of this permutation and another permutation.java.lang.String
toString()
-
-
-
Constructor Detail
-
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
public Permutation(int n, java.security.SecureRandom sr)
Create a random permutation of the given size.- Parameters:
n
- the size of the permutationsr
- the source of randomness
-
-
Method Detail
-
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
public Permutation computeInverse()
Compute the inverse permutation P-1.- Returns:
- this-1
-
rightMultiply
public Permutation rightMultiply(Permutation p)
Compute the product of this permutation and another permutation.- Parameters:
p
- the other permutation- Returns:
- this * p
-
equals
public boolean equals(java.lang.Object other)
checks if given object is equal to this permutation.The method returns false whenever the given object is not permutation.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- - permutation- Returns:
- true or false
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a human readable form of the permutation
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code of this permutation
-
-