Examples of IntPermutationsGenerator


Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

            }
        return true;
    }

    private boolean comparePermutationAlgorythm(TensorSortedContent arr1, TensorSortedContent arr2, int from, int size) {
        IntPermutationsGenerator enumerator = new IntPermutationsGenerator(size);
        int[] permutation;
        OUTFOR:
        while (enumerator.hasNext()) {
            permutation = enumerator.next();
            for (int i = 0; i < size; ++i)
                if (!compare(arr1.get(i + from), arr2.get(permutation[i] + from)))
                    continue OUTFOR;
            return true;
        }
View Full Code Here

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

    PermutatorProvider(final OutputPort<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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

                    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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

        Indices indices = IndicesFactory.create(tensor.getIndices().getFree());
        int[] indicesArray = indices.getAllIndices().copy();
        List<Permutation> symmetries = TensorUtils.getIndicesSymmetriesForIndicesWithSameStates(indicesArray, tensor);
        int lowerCount = indices.getLower().size(), upperCount = indices.getUpper().size();

        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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

        public StretchPairSource(final OutputPort<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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

    }
    private final List<Tensor> result = new ArrayList<>();

    private List<Tensor> get() {
        IntPermutationsGenerator lowIndicesPermutator, upperIndicesPermutator;

        if (upperCount != 0 && lowerCount != 0) {
            lowIndicesPermutator = new IntPermutationsGenerator(lowerCount);
            while (lowIndicesPermutator.hasNext()) {
                int[] lowerPermutation = lowIndicesPermutator.next().clone();
                for (int i = 0; i < lowerCount; ++i)
                    lowerPermutation[i] = lowerPermutation[i] + upperCount;
                upperIndicesPermutator = new IntPermutationsGenerator(upperCount);
                UPPER:
                while (upperIndicesPermutator.hasNext()) {
                    int[] upperPermutation = upperIndicesPermutator.next();
                    permute(upperPermutation, lowerPermutation);
                }
            }
        } else if (upperCount == 0) {
            lowIndicesPermutator = new IntPermutationsGenerator(lowerCount);
            while (lowIndicesPermutator.hasNext()) {
                int[] lowerPermutation = lowIndicesPermutator.next();
                permute(new int[0], lowerPermutation);
            }
        } else if (lowerCount == 0) {
            upperIndicesPermutator = new IntPermutationsGenerator(upperCount);
            while (upperIndicesPermutator.hasNext()) {
                int[] upperPermutation = upperIndicesPermutator.next();
                permute(upperPermutation, new int[0]);
            }
        }
View Full Code Here

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

                    return IndexMappingProvider.Util.EMPTY_PROVIDER;
        STRETCHES:
        for (Stretch stretch : stretches)
            if (stretch.length != 1) {
                PERMUTATIONS:
                for (int[] permutation : new IntPermutationsGenerator(stretch.length)) {
                    for (i = 0; i < stretch.length; ++i)
                        if (!IndexMappings.mappingExists(varsFrom[stretch.from + i], varsTo[stretch.from + permutation[i]], allowDiffStates))
                            continue PERMUTATIONS;
                    continue STRETCHES;
                }
View Full Code Here

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

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

Examples of cc.redberry.core.combinatorics.IntPermutationsGenerator

            if (stretch.length == 1)
                if (!mappingExists(from[stretch.from], to[stretch.from], allowDiffStates))
                    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
Copyright © 2018 www.massapi.com. 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.