本文整理汇总了Java中org.bouncycastle.pqc.math.linearalgebra.Permutation.getVector方法的典型用法代码示例。如果您正苦于以下问题:Java Permutation.getVector方法的具体用法?Java Permutation.getVector怎么用?Java Permutation.getVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.pqc.math.linearalgebra.Permutation
的用法示例。
在下文中一共展示了Permutation.getVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignRandomRegularMatrix
import org.bouncycastle.pqc.math.linearalgebra.Permutation; //导入方法依赖的package包/类
/**
* Create an nxn random regular matrix.
*
* @param n number of rows (and columns)
* @param sr source of randomness
*/
public void assignRandomRegularMatrix(int n, SecureRandom sr)
{
numRows = n;
numColumns = n;
length = (n + (INTSIZE-1)) >>> BLOCKEXP;
matrix = new int[numRows][length];
GF2MatrixEx lm = new GF2MatrixEx(n, Matrix.MATRIX_TYPE_RANDOM_LT, sr);
GF2MatrixEx um = new GF2MatrixEx(n, Matrix.MATRIX_TYPE_RANDOM_UT, sr);
GF2MatrixEx rm = (GF2MatrixEx)lm.rightMultiply(um);
Permutation perm = new Permutation(n, sr);
int[] p = perm.getVector();
for (int i = 0; i < n; i++)
{
System.arraycopy(rm.getIntArray()[i], 0, matrix[p[i]], 0, length);
}
}
示例2: leftMultiply
import org.bouncycastle.pqc.math.linearalgebra.Permutation; //导入方法依赖的package包/类
/**
* Compute the product of a permutation matrix (which is generated from an
* n-permutation) and this matrix.
*
* @param p the permutation
* @return {@link GF2MatrixEx} <tt>P*this</tt>
*/
public Matrix leftMultiply(Permutation p)
{
int[] pVec = p.getVector();
if (pVec.length != numRows)
{
throw new ArithmeticException("length mismatch");
}
int[][] result = new int[numRows][];
for (int i = numRows - 1; i >= 0; i--)
{
result[i] = IntUtils.clone(matrix[pVec[i]]);
}
return new GF2MatrixEx(numRows, result);
}
示例3: rightMultiply
import org.bouncycastle.pqc.math.linearalgebra.Permutation; //导入方法依赖的package包/类
/**
* Compute the product of this matrix and a permutation matrix which is
* generated from an n-permutation.
*
* @param p the permutation
* @return {@link GF2MatrixEx} <tt>this*P</tt>
*/
public Matrix rightMultiply(Permutation p)
{
int[] pVec = p.getVector();
if (pVec.length != numColumns)
{
throw new ArithmeticException("length mismatch");
}
GF2MatrixEx result = new GF2MatrixEx(numRows, numColumns);
for (int i = numColumns - 1; i >= 0; i--)
{
int q = i >>> BLOCKEXP;
int r = i & 0x1f;
int pq = pVec[i] >>> BLOCKEXP;
int pr = pVec[i] & 0x1f;
for (int j = numRows - 1; j >= 0; j--)
{
result.matrix[j][q] |= ((matrix[j][pq] >>> pr) & 1) << r;
}
}
return result;
}