Package cc.redberry.core.utils

Examples of cc.redberry.core.utils.BitArray


    public StructureOfIndices(byte type, int count, boolean... states) {
        typesCounts[type] = count;
        size = count;
        for (int i = 0; i < IndexType.TYPES_COUNT; ++i)
            if (!CC.isMetric((byte) i))
                this.states[i] = i == type ? new BitArray(states) : BitArray.EMPTY;
    }
View Full Code Here


    }

    private static BitArray createBBBA(int size) {
        if (size == 0)
            return BitArray.EMPTY;
        return new BitArray(size);
    }
View Full Code Here

        else
            newStabilizers = new ArrayList<>(BSGS.get(i + 2).stabilizerGenerators);


        //allowed points
        BitArray allowedPoints = new BitArray(effectiveDegree);
        allowedPoints.setAll(BSGS.get(i).orbitList, true);
        allowedPoints.set(ithBeta, false);
        allowedPoints.set(jthBeta, false);

        //we shall store the orbit of ithBeta under new stabilizers in BSGSCandidateElement
        BSGSCandidateElement newOrbitStabilizer =
                new BSGSCandidateElement(ithBeta, newStabilizers, effectiveDegree);

        //main loop
        main:
        while (newOrbitStabilizer.orbitSize() != s) {
            //this loop is redundant but helps to avoid unnecessary calculations of orbits in the main loop condition
            int nextBasePoint = -1;
            while ((nextBasePoint = allowedPoints.nextBit(++nextBasePoint)) != -1) {
                //transversal
                Permutation transversal = BSGS.get(i).getTransversalOf(nextBasePoint);
                int newIndexUnderInverse = transversal.newIndexOfUnderInverse(jthBeta);
                //check whether beta_{i+1}^(inverse transversal) belongs to orbit of G^{i+1}
                if (!BSGS.get(i + 1).belongsToOrbit(newIndexUnderInverse)) {
                    //then this transversal is bad and we can skip the orbit of this point under new stabilizers
                    IntArrayList toRemove = Permutations.getOrbitList(
                            newOrbitStabilizer.stabilizerGenerators, nextBasePoint, effectiveDegree);
                    allowedPoints.setAll(toRemove, false);
                } else {
                    //<-ok this transversal is good
                    //we need an element in G^(4) that beta_{i+1}^element = beta_{i+1}^{inverse transversal}
                    //so that beta_{i+1} is fixed under product of element * transversal
                    //todo unnecessary composition can be carried out!
                    Permutation newStabilizer =
                            BSGS.get(i + 1).getTransversalOf(newIndexUnderInverse).composition(transversal);
                    //if this element was not yet seen
                    if (!newOrbitStabilizer.belongsToOrbit(newStabilizer.newIndexOf(ithBeta))) {
                        newOrbitStabilizer.addStabilizer(newStabilizer);
                        IntArrayList toRemove = Permutations.getOrbitList(
                                newOrbitStabilizer.stabilizerGenerators, nextBasePoint, effectiveDegree);
                        allowedPoints.setAll(toRemove, false);
                        continue main;
                    }
                }
            }
        }
View Full Code Here

     */
    public static int parity(int[] permutation) {
        //we shall decompose this permutation into product of cycles and calculate l.c.m. of their sizes

        //to mark viewed points
        BitArray used = new BitArray(permutation.length);
        //lcm
        int start, pointer, currentSize, counter = 0;
        int numOfTranspositions = 0;
        //while not all points are seen
        //loop over cycles
        while (counter < permutation.length) {
            //get first point that was not already traversed
            start = pointer = used.nextZeroBit(0);
            currentSize = 0;
            //processing current cycle
            //loop over current cycle
            do {
                assert !used.get(pointer);
                used.set(pointer);
                pointer = permutation[pointer];
                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            numOfTranspositions += currentSize - 1;
View Full Code Here

     */
    public static int parity(short[] permutation) {
        //we shall decompose this permutation into product of cycles and calculate l.c.m. of their sizes

        //to mark viewed points
        BitArray used = new BitArray(permutation.length);
        //lcm
        int start, pointer, currentSize, counter = 0;
        int numOfTranspositions = 0;
        //while not all points are seen
        //loop over cycles
        while (counter < permutation.length) {
            //get first point that was not already traversed
            start = pointer = used.nextZeroBit(0);
            currentSize = 0;
            //processing current cycle
            //loop over current cycle
            do {
                assert !used.get(pointer);
                used.set(pointer);
                pointer = permutation[pointer];
                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            numOfTranspositions += currentSize - 1;
View Full Code Here

     */
    public static int parity(byte[] permutation) {
        //we shall decompose this permutation into product of cycles and calculate l.c.m. of their sizes

        //to mark viewed points
        BitArray used = new BitArray(permutation.length);
        //lcm
        int start, pointer, currentSize, counter = 0;
        int numOfTranspositions = 0;
        //while not all points are seen
        //loop over cycles
        while (counter < permutation.length) {
            //get first point that was not already traversed
            start = pointer = used.nextZeroBit(0);
            currentSize = 0;
            //processing current cycle
            //loop over current cycle
            do {
                assert !used.get(pointer);
                used.set(pointer);
                pointer = permutation[pointer];
                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            numOfTranspositions += currentSize - 1;
View Full Code Here

     * @return {@code true} if specified array satisfies the one-line notation for permutations and {@code false} if
     * not
     */
    public static boolean testPermutationCorrectness(int[] permutation) {
        int length = permutation.length;
        BitArray checked = new BitArray(length);
        for (int i = 0; i < length; ++i) {
            if (permutation[i] >= length || permutation[i] < 0)
                return false;
            if (checked.get(permutation[i]))
                return false;
            checked.set(permutation[i]);
        }
        return checked.isFull();
    }
View Full Code Here

     * @return {@code true} if specified array satisfies the one-line notation for permutations and {@code false} if
     * not
     */
    public static boolean testPermutationCorrectness(short[] permutation) {
        int length = permutation.length;
        BitArray checked = new BitArray(length);
        for (int i = 0; i < length; ++i) {
            if (permutation[i] >= length || permutation[i] < 0)
                return false;
            if (checked.get(permutation[i]))
                return false;
            checked.set(permutation[i]);
        }
        return checked.isFull();
    }
View Full Code Here

     * @return {@code true} if specified array satisfies the one-line notation for permutations and {@code false} if
     * not
     */
    public static boolean testPermutationCorrectness(byte[] permutation) {
        int length = permutation.length;
        BitArray checked = new BitArray(length);
        for (int i = 0; i < length; ++i) {
            if (permutation[i] >= length || permutation[i] < 0)
                return false;
            if (checked.get(permutation[i]))
                return false;
            checked.set(permutation[i]);
        }
        return checked.isFull();
    }
View Full Code Here

     */
    public static BigInteger orderOfPermutation(int[] permutation) {
        //we shall decompose this permutation into product of cycles and calculate l.c.m. of their sizes

        //to mark viewed points
        BitArray used = new BitArray(permutation.length);
        //lcm
        BigInteger lcm = BigInteger.ONE, temp;

        int start, pointer, currentSize, counter = 0;
        //while not all points are seen
        //loop over cycles
        while (counter < permutation.length) {
            //get first point that was not already traversed
            start = pointer = used.nextZeroBit(0);
            currentSize = 0;
            //processing current cycle
            //loop over current cycle
            do {
                assert !used.get(pointer);
                used.set(pointer);
                pointer = permutation[pointer];
                ++currentSize;
            } while (pointer != start);
            counter += currentSize;
            temp = BigInteger.valueOf(currentSize);
View Full Code Here

TOP

Related Classes of cc.redberry.core.utils.BitArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.