Package cc.redberry.core.combinatorics

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator


    PermutatorProvider(final MappingsPort opu,
                       final Tensor[] from, final Tensor[] to) {
        super(opu);
        this.from = from;
        this.to = to;
        generator = new IntPermutationsGenerator(from.length);
    }
View Full Code Here


                    return false;
        OUTER:
        for (Stretch stretch : precalculatedStretches)
            if (stretch.length > 1) {
                SEMIOUTER:
                for (int[] permutation : new IntPermutationsGenerator(stretch.length)) {
                    for (i = 0; i < stretch.length; ++i)
                        if (!mappingExists(from[stretch.from + i], to[stretch.from + permutation[i]]))
                            continue SEMIOUTER; // This permutation is bad
                    continue OUTER; //Good permutation has been found
                }
View Full Code Here

        public StretchPairSource(final MappingsPort opu,
                                 final Tensor[] from, final Tensor[] to) {
            super(opu);
            this.from = from;
            this.to = to;
            this.permutationGenerator = new IntPermutationsGenerator(from.length);
        }
View Full Code Here

    PermutatorProvider(final MappingsPort opu,
            final Tensor[] from, final Tensor[] to) {
        super(opu);
        this.from = from;
        this.to = to;
        generator = new IntPermutationsGenerator(from.length);
    }
View Full Code Here

                    return false;
        OUTER:
        for (Stretch stretch : precalculatedStretches)
            if (stretch.length > 1) {
                SEMIOUTER:
                for (int[] permutation : new IntPermutationsGenerator(stretch.length)) {
                    for (i = 0; i < stretch.length; ++i)
                        if (!mappingExists(from[stretch.from + i], to[stretch.from + permutation[i]]))
                            continue SEMIOUTER; // This permutation is bad
                    continue OUTER; //Good permutation has been found
                }
View Full Code Here

        Indices indices = IndicesFactory.create(tensor.getIndices().getFree());
        int[] indicesArray = indices.getAllIndices().copy();
        Symmetries symmetries = TensorUtils.getIndicesSymmetriesForIndicesWithSameStates(indicesArray, tensor);
        int lowerCount = indices.getLower().length(), upperCount = indices.getUpper().length();

        IntPermutationsGenerator lowIndicesPermutationsGenerator,
                upperIndicesPermutationGenerator;
        SumBuilder sumBuilder = new SumBuilder();
        Tensor summand;
        List<int[]> generatedPermutations = new ArrayList<>();
        if (upperCount != 0 && lowerCount != 0) {
            lowIndicesPermutationsGenerator = new IntPermutationsGenerator(lowerCount);
            while (lowIndicesPermutationsGenerator.hasNext()) {
                int[] lowerPermutation = lowIndicesPermutationsGenerator.next().clone();
                for (int i = 0; i < lowerCount; ++i)
                    lowerPermutation[i] = lowerPermutation[i] + upperCount;
                upperIndicesPermutationGenerator = new IntPermutationsGenerator(upperCount);
                UPPER:
                while (upperIndicesPermutationGenerator.hasNext()) {
                    int[] upperPermutation = upperIndicesPermutationGenerator.next();
                    summand = permute(tensor, indicesArray, upperPermutation, lowerPermutation, generatedPermutations, symmetries);
                    if (summand != null)
                        sumBuilder.put(summand);
                }
            }
        } else if (upperCount == 0) {
            lowIndicesPermutationsGenerator = new IntPermutationsGenerator(lowerCount);
            while (lowIndicesPermutationsGenerator.hasNext()) {
                int[] lowerPermutation = lowIndicesPermutationsGenerator.next();
                summand = permute(tensor, indicesArray, new int[0], lowerPermutation, generatedPermutations, symmetries);
                if (summand != null)
                    sumBuilder.put(summand);
            }
        } else if (lowerCount == 0) {
            upperIndicesPermutationGenerator = new IntPermutationsGenerator(upperCount);
            while (upperIndicesPermutationGenerator.hasNext()) {
                int[] upperPermutation = upperIndicesPermutationGenerator.next();
                summand = permute(tensor, indicesArray, upperPermutation, new int[0], generatedPermutations, symmetries);
                if (summand != null)
                    sumBuilder.put(summand);
View Full Code Here

    PermutatorProvider(final OutputPortUnsafe<IndexMappingBuffer> opu,
                       final Tensor[] from, final Tensor[] to) {
        super(opu);
        this.from = from;
        this.to = to;
        generator = new IntPermutationsGenerator(from.length);
    }
View Full Code Here

                    return false;
        OUTER:
        for (Stretch stretch : precalculatedStretches)
            if (stretch.length > 1) {
                SEMIOUTER:
                for (int[] permutation : new IntPermutationsGenerator(stretch.length)) {
                    for (i = 0; i < stretch.length; ++i)
                        if (!mappingExists(from[stretch.from + i], to[stretch.from + permutation[i]]))
                            continue SEMIOUTER; // This permutation is bad
                    continue OUTER; //Good permutation has been found
                }
View Full Code Here

        public StretchPairSource(final OutputPortUnsafe<IndexMappingBuffer> opu,
                                 final Tensor[] from, final Tensor[] to) {
            super(opu);
            this.from = from;
            this.to = to;
            this.permutationGenerator = new IntPermutationsGenerator(from.length);
        }
View Full Code Here

                    return false;
        OUTER:
        for (Stretch stretch : precalculatedStretches)
            if (stretch.length > 1) {
                SEMIOUTER:
                for (int[] permutation : new IntPermutationsGenerator(stretch.length)) {
                    for (i = 0; i < stretch.length; ++i)
                        if (!mappingExists(from[stretch.from + i], to[stretch.from + permutation[i]], allowDiffStates))
                            continue SEMIOUTER; // This permutation is bad
                    continue OUTER; //Good permutation has been found
                }
View Full Code Here

TOP

Related Classes of cc.redberry.core.combinatorics.IntPermutationsGenerator

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.