Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.SumBuilder


                newTo = ApplyIndexMapping.applyIndexMapping(to, buffer, forbidden);
//                if (newTo != to)
                iterator.forbiddenIndices().addAll(TensorUtils.getAllIndicesNames(newTo));
            }

            SumBuilder builder = new SumBuilder();
            int[] bijection = bc.bijection;
            Arrays.sort(bijection);
            builder.put(newTo);
            for (int i = current.size() - 1; i >= 0; --i)
                if (Arrays.binarySearch(bijection, i) >= 0)
                    continue;
                else
                    builder.put(current.get(i));
            iterator.set(builder.build());
        }
        return iterator.result();
    }
View Full Code Here


            return currentNode;

        Mapping mapping = bc.mapping;
        Tensor newTo = applyIndexMappingToTo(currentNode, to, mapping, iterator);

        SumBuilder builder = new SumBuilder();
        int[] bijection = bc.bijection;
        Arrays.sort(bijection);
        builder.put(newTo);
        for (int i = currentNode.size() - 1; i >= 0; --i)
            if (Arrays.binarySearch(bijection, i) < 0) //todo may be improved
                builder.put(currentNode.get(i));
        return builder.build();
    }
View Full Code Here

        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);
            }
        }
        if (multiplyOnSymmetryFactor)
            return Tensors.multiply(new Complex(new Rational(1, generatedPermutations.size())), sumBuilder.build());
        else
            return sumBuilder.build();
    }
View Full Code Here

        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);
            }
        }
        if (multiplyOnSymmetryFactor)
            return Tensors.multiply(new Complex(new Rational(1, generatedPermutations.size())), sumBuilder.build());
        else
            return sumBuilder.build();
    }
View Full Code Here

                return current;

            Mapping mapping = bc.mapping;
            Tensor newTo = applyIndexMappingToTo(current, to, mapping, iterator);

            SumBuilder builder = new SumBuilder();
            int[] bijection = bc.bijection;
            builder.put(newTo);

            Arrays.sort(bijection);
            int pivot = 0;
            for (int i = 0, size = current.size(); i < size; ++i) {
                if (pivot >= bijection.length || i != bijection[pivot])
                    builder.put(current.get(i));
                else
                    ++pivot;
            }
            current = builder.build();
        }
        return current;
    }
View Full Code Here

        if (toIsSymbolic)
            newTo = mapping.getSign() ? Tensors.negate(to) : to;
        else
            newTo = ApplyIndexMapping.applyIndexMapping(to, mapping, iterator.getForbidden());

        SumBuilder builder = new SumBuilder();
        int[] bijection = bc.bijection;
        Arrays.sort(bijection);
        builder.put(newTo);
        for (int i = currentNode.size() - 1; i >= 0; --i)
            if (Arrays.binarySearch(bijection, i) < 0) //todo may be improved
                builder.put(currentNode.get(i));
        return builder.build();
    }
View Full Code Here

        if (toIsSymbolic)
            newTo = buffer.getSign() ? Tensors.negate(to) : to;
        else
            newTo = ApplyIndexMapping.applyIndexMapping(to, buffer, iterator.getForbidden());

        SumBuilder builder = new SumBuilder();
        int[] bijection = bc.bijection;
        Arrays.sort(bijection);
        builder.put(newTo);
        for (int i = currentNode.size() - 1; i >= 0; --i)
            if (Arrays.binarySearch(bijection, i) < 0) //todo may be improved
                builder.put(currentNode.get(i));
        return builder.build();
    }
View Full Code Here

        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);
            }
        }
        if (multiplyOnSymmetryFactor)
            return Tensors.multiply(new Complex(new Rational(1, generatedPermutations.size())), sumBuilder.build());
        else
            return sumBuilder.build();
    }
View Full Code Here

                newTo = ApplyIndexMapping.applyIndexMapping(temp, buffer, forbidden);
                if (temp != newTo)
                    iterator.forbiddenIndices().addAll(TensorUtils.getAllIndicesNames(newTo));
            }

            SumBuilder builder = new SumBuilder();
            int[] bijection = bc.bijection;
            Arrays.sort(bijection);
            builder.put(newTo);
            for (int i = current.size() - 1; i >= 0; --i)
                if (Arrays.binarySearch(bijection, i) >= 0)
                    continue;
                else
                    builder.put(current.get(i));
            iterator.set(builder.build());
        }
        return iterator.result();
    }
View Full Code Here

        List<Permutation> 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);
            }
        }
        if (multiplyOnSymmetryFactor)
            return Tensors.multiply(new Complex(new Rational(1, generatedPermutations.size())), sumBuilder.build());
        else
            return sumBuilder.build();
    }
View Full Code Here

TOP

Related Classes of cc.redberry.core.tensor.SumBuilder

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.