/** * @return the permutation vector <tt>(perm(0),perm(1),...,perm(n-1))</tt> */ public int[] getVector() { return IntUtils.clone(perm); }
/** * Check if the given object is equal to this vector. * * @param other vector * @return the result of the comparison */ public boolean equals(Object other) { if (!(other instanceof GF2Vector)) { return false; } GF2Vector otherVec = (GF2Vector)other; return (length == otherVec.length) && IntUtils.equals(v, otherVec.v); }
/** * Sort a subarray of a source array. The subarray is specified by its start * and end index. * * @param source the int array to be sorted * @param left the start index of the subarray * @param right the end index of the subarray */ public static void quicksort(int[] source, int left, int right) { if (right > left) { int index = partition(source, left, right, right); quicksort(source, left, index - 1); quicksort(source, index + 1, right); } }
/** * Sorts this array of integers according to the Quicksort algorithm. After * calling this method this array is sorted in ascending order with the * smallest integer taking position 0 in the array. * <p> * This implementation is based on the quicksort algorithm as described in * <code>Data Structures In Java</code> by Thomas A. Standish, Chapter 10, * ISBN 0-201-30564-X. * * @param source the array of integers that needs to be sorted. */ public static void quicksort(int[] source) { quicksort(source, 0, source.length - 1); }
public static void main( String[] args ) { System.out.println("ceil: [" + (15 >>> 5) + "]"); System.out.println("ceil: [" + (31 >>> 5) + "]"); System.out.println("ceil: [" + (32 >>> 5) + "]"); System.out.println("ceil: [" + (36 >>> 5) + "]"); System.out.println("ceil: [" + (63 >>> 5) + "]"); System.out.println("ceil: [" + (64 >>> 5) + "]"); System.out.println("ceil: [" + (66 >>> 5) + "]"); GF2Matrix m = new GF2Matrix(33, GF2Matrix.MATRIX_TYPE_RANDOM_REGULAR); System.out.println("Matrix: " + m.toString()); final int[][] a = m.getIntArray(); for(int i=0; i<m.getNumRows(); i++){ System.out.println("MatrixEnc["+i+"]: [" + Utils.toBinaryString(a[i])+ "]"); } System.out.println("MatrixEncLen: [" + m.getEncoded().length + "]"); System.out.println("MatrixEncHex: [" + IntUtils.toHexString(m.getRow(0)) + "]"); } }
/** * Sorts this array of integers according to the Quicksort algorithm. After * calling this method this array is sorted in ascending order with the * smallest integer taking position 0 in the array. * <p> * This implementation is based on the quicksort algorithm as described in * <code>Data Structures In Java</code> by Thomas A. Standish, Chapter 10, * ISBN 0-201-30564-X. * * @param source the array of integers that needs to be sorted. */ public static void quicksort(int[] source) { quicksort(source, 0, source.length - 1); }
/** * Copy constructor. * * @param other another {@link PolynomialGF2mSmallM} */ public PolynomialGF2mSmallM(PolynomialGF2mSmallM other) { // field needs not to be cloned since it is immutable field = other.field; degree = other.degree; coefficients = IntUtils.clone(other.coefficients); }
/** * Check if the given object is equal to this vector. * * @param other vector * @return the result of the comparison */ public boolean equals(Object other) { if (!(other instanceof GF2Vector)) { return false; } GF2Vector otherVec = (GF2Vector)other; return (length == otherVec.length) && IntUtils.equals(v, otherVec.v); }
/** * Sort a subarray of a source array. The subarray is specified by its start * and end index. * * @param source the int array to be sorted * @param left the start index of the subarray * @param right the end index of the subarray */ public static void quicksort(int[] source, int left, int right) { if (right > left) { int index = partition(source, left, right, right); quicksort(source, left, index - 1); quicksort(source, index + 1, right); } }
/** * @return int[] form of this vector */ public int[] getIntArrayForm() { return IntUtils.clone(vector); }
/** * checks if given object is equal to this permutation. * <p> * The method returns false whenever the given object is not permutation. * * @param other - * permutation * @return true or false */ public boolean equals(Object other) { if (!(other instanceof Permutation)) { return false; } Permutation otherPerm = (Permutation)other; return IntUtils.equals(perm, otherPerm.perm); }
/** * @return the permutation vector <tt>(perm(0),perm(1),...,perm(n-1))</tt> */ public int[] getVector() { return IntUtils.clone(perm); }
/** * checks if given object is equal to this permutation. * <p> * The method returns false whenever the given object is not permutation. * * @param other - * permutation * @return true or false */ public boolean equals(Object other) { if (!(other instanceof Permutation)) { return false; } Permutation otherPerm = (Permutation)other; return IntUtils.equals(perm, otherPerm.perm); }
/** * Creates a new GF2Polynomial by cloneing the given GF2Polynomial <i>b</i>. * * @param b the GF2Polynomial to clone */ public GF2Polynomial(GF2Polynomial b) { len = b.len; blocks = b.blocks; value = IntUtils.clone(b.value); }
/** * Compare this matrix with another object. * * @param other another object * @return the result of the comparison */ public boolean equals(Object other) { if (!(other instanceof GF2Matrix)) { return false; } GF2Matrix otherMatrix = (GF2Matrix)other; if ((numRows != otherMatrix.numRows) || (numColumns != otherMatrix.numColumns) || (length != otherMatrix.length)) { return false; } for (int i = 0; i < numRows; i++) { if (!IntUtils.equals(matrix[i], otherMatrix.matrix[i])) { return false; } } return true; }
/** * Creates a new GF2Polynomial by cloneing the given GF2Polynomial <i>b</i>. * * @param b the GF2Polynomial to clone */ public GF2Polynomial(GF2Polynomial b) { len = b.len; blocks = b.blocks; value = IntUtils.clone(b.value); }
/** * Compare this matrix with another object. * * @param other another object * @return the result of the comparison */ @Override public boolean equals(Object other) { if (!(other instanceof GF2MatrixEx)) { return false; } GF2MatrixEx otherMatrix = (GF2MatrixEx)other; if ((numRows != otherMatrix.numRows) || (numColumns != otherMatrix.numColumns) || (length != otherMatrix.length)) { return false; } for (int i = 0; i < numRows; i++) { if (!IntUtils.equals(matrix[i], otherMatrix.matrix[i])) { return false; } } return true; }
/** * @return int[] form of this vector */ public int[] getIntArrayForm() { return IntUtils.clone(vector); }
/** * Compare this matrix with another object. * * @param other another object * @return the result of the comparison */ public boolean equals(Object other) { if (!(other instanceof GF2Matrix)) { return false; } GF2Matrix otherMatrix = (GF2Matrix)other; if ((numRows != otherMatrix.numRows) || (numColumns != otherMatrix.numColumns) || (length != otherMatrix.length)) { return false; } for (int i = 0; i < numRows; i++) { if (!IntUtils.equals(matrix[i], otherMatrix.matrix[i])) { return false; } } return true; }
/** * Copy constructor. * * @param other another {@link GF2Vector} */ public GF2Vector(GF2Vector other) { this.length = other.length; this.v = IntUtils.clone(other.v); }