Package cc.redberry.core.utils

Examples of cc.redberry.core.utils.BitArray


    }

    @Override
    public int[][] cycles() {
        ArrayList<int[]> cycles = new ArrayList<>();
        BitArray seen = new BitArray(degree());
        int counter = 0;
        while (counter < degree()) {
            int start = seen.nextZeroBit(0);
            if (newIndexOf(start) == start) {
                ++counter;
                seen.set(start);
                continue;
            }
            IntArrayList cycle = new IntArrayList();
            while (!seen.get(start)) {
                seen.set(start);
                ++counter;
                cycle.add(start);
                start = newIndexOf(start);
            }
            cycles.add(cycle.toArray());
View Full Code Here


            int omittedIndicesCount = structure.getTypeData(omittedIndexType.getType()).length;
            if ((omittedIndicesCount % 2) == 1)
                throw new IllegalArgumentException("The number of omitted indices for metric types should be even.");
            omittedIndicesCount /= 2;

            BitArray omittedIndices = structure.getTypeData(omittedIndexType.getType()).states;

            for (int i = 0, size = omittedIndices.size(); i < size; ++i) {
                if (i < omittedIndicesCount && !omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
                if (i >= omittedIndicesCount && omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
            }
        }
        mappedRules = null;
        InsertionRule rule = initialRules.get(originalStructureAndName);
View Full Code Here

            //this.insertionRule = insertionRule;
            StructureOfIndices originalStructure = insertionRule.originalStructureAndName.getStructure()[0];
            StructureOfIndices currentStructure = node.getIndicesTypeStructureAndName().getStructure()[0];
            for (IndexType type : insertionRule.indicesAllowedToOmit)
                if (currentStructure.getStates(type).size() == 0) {
                    BitArray originalStates = originalStructure.getStates(type);
                    if (originalStates != null) {
                        outerIndices.upper[type.getType()] = originalStates.bitCount();
                        outerIndices.lower[type.getType()] = originalStates.size() - outerIndices.upper[type.getType()];
                    } else {
                        outerIndices.upper[type.getType()] = outerIndices.lower[type.getType()]
                                = originalStructure.typeCount(type.getType()) / 2;
                    }
                } else if (currentStructure.typeCount(type.getType()) !=
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

    private 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

            //this.insertionRule = insertionRule;
            StructureOfIndices originalStructure = insertionRule.originalStructureAndName.getStructure()[0];
            StructureOfIndices currentStructure = node.getIndicesTypeStructureAndName().getStructure()[0];
            for (IndexType type : insertionRule.indicesAllowedToOmit)
                if (currentStructure.getStates(type).size() == 0) {
                    BitArray originalStates = originalStructure.getStates(type);
                    if (originalStates != null) {
                        outerIndices.upper[type.getType()] = originalStates.bitCount();
                        outerIndices.lower[type.getType()] = originalStates.size() - outerIndices.upper[type.getType()];
                    } else {
                        outerIndices.upper[type.getType()] = outerIndices.lower[type.getType()]
                                = originalStructure.typeCount(type.getType()) / 2;
                    }
                } else if (currentStructure.typeCount(type.getType()) !=
View Full Code Here

            int i;

            //Allocating origins arrays
            usedArrays = new BitArray[allDummyIndices.length];
            for (i = allDummyIndices.length - 1; i >= 0; --i)
                usedArrays[i] = new BitArray(size);

            //Full-filling origins array
            for (i = size - 1; i >= 0; --i) {
                dummy = TensorUtils.getAllDummyIndicesT(tensor.get(i));
                TIntIterator iterator = dummy.iterator();
View Full Code Here

            int omittedIndicesCount = structure.getTypeData(omittedIndexType.getType()).length;
            if ((omittedIndicesCount % 2) == 1)
                throw new IllegalArgumentException("The number of omitted indices for metric types should be even.");
            omittedIndicesCount /= 2;

            BitArray omittedIndices = structure.getTypeData(omittedIndexType.getType()).states;

            for (int i = 0, size = omittedIndices.size(); i < size; ++i) {
                if (i < omittedIndicesCount && !omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
                if (i >= omittedIndicesCount && omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
            }
        }
        mappedRules = null;
        InsertionRule rule = initialRules.get(originalStructureAndName);
View Full Code Here

            int omittedIndicesCount = structure.getTypeData(omittedIndexType.getType()).length;
            if ((omittedIndicesCount % 2) == 1)
                throw new IllegalArgumentException("The number of omitted indices for metric types should be even.");
            omittedIndicesCount /= 2;

            BitArray omittedIndices = structure.getTypeData(omittedIndexType.getType()).states;

            for (int i = 0, size = omittedIndices.size(); i < size; ++i) {
                if (i < omittedIndicesCount && !omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
                if (i >= omittedIndicesCount && omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
            }
        }
        mappedRules = null;
        InsertionRule rule = initialRules.get(originalStructureAndName);
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.