Package cc.redberry.core.combinatorics

Examples of cc.redberry.core.combinatorics.Symmetry


        for (int j = 0; j < data.length; ++j, ++i)
            s[i] = symmetry.newIndexOf(j) + data.from;
        for (; i < indicesTypeStructure.size(); ++i)
            s[i] = i;
        try {
            if (symmetries.add(new Symmetry(s, symmetry.isAntiSymmetry()))) {
                diffIds = null;
                return true;
            }
            return false;
        } catch (InconsistentGeneratorsException exception) {
View Full Code Here


        SimpleTensor st = (SimpleTensor) parse(tensor);
        addSymmetry(st, type, sign, permutation);
    }

    public void addSymmetry(SimpleTensor st, IndexType type, boolean sign, int... permutation) {
        addSymmetry(st, type, new Symmetry(permutation, sign));
    }
View Full Code Here

                        || descriptor.getIndexTypeStructure().size() != 2)
                    return;
                if (descriptor.getIndexTypeStructure().get(0) != descriptor.getIndexTypeStructure().get(1))
                    throw new IllegalArgumentException("Wrong metric.");
                descriptor.addSymmetry(
                        type, new Symmetry(new int[]{1, 0}, false));
                if (metricNames == null)
                    metricNames = new int[]{descriptor.getId()};
                else {
                    metricNames = Arrays.copyOf(metricNames, metricNames.length + 1);
                    metricNames[metricNames.length - 1] = descriptor.getId();
                    Arrays.sort(metricNames);
                }
            } else if (descriptor.getName().equals(kroneckerName)) {
                if (descriptor.getIndexTypeStructure().size() != 2
                        || (type = descriptor.getIndexTypeStructure().get(0)) != descriptor.getIndexTypeStructure().get(1))
                    return;
                if (descriptor.getIndexTypeStructure().get(0) != descriptor.getIndexTypeStructure().get(1))
                    throw new IllegalArgumentException("Wrong kronecker.");
                descriptor.addSymmetry(type, new Symmetry(new int[]{1, 0}, false));
                if (kroneckerNames == null)
                    kroneckerNames = new int[]{descriptor.getId()};
                else {
                    kroneckerNames = Arrays.copyOf(kroneckerNames, kroneckerNames.length + 1);
                    kroneckerNames[kroneckerNames.length - 1] = descriptor.getId();
View Full Code Here

            Map<IntArray, Boolean> symmetries = getEpsilonSymmetries(indices.length);

            //symmetries of product, which is contracted with Levi-Civita
            MappingsPort port = IndexMappings.createPort(temp, temp);
            Mapping mapping;
            Symmetry sym;

            //check for two symmetric indices of product contracted with two antisymmetric indices of eps
            while ((mapping = port.take()) != null) {
                //symmetry of product indices
                sym = TensorUtils.getSymmetryFromMapping(indices, mapping);
                //if symmetry mixes indices of product, which are not contracted with eps
                if (!checkNonPermutingPositions(sym, nonPermutableArray))
                    continue;
                //bingo!
                if (sym.isAntiSymmetry() != symmetries.get(sym.getPermutation()))
                    return Complex.ZERO;
            }

        }
View Full Code Here

        Map<IntArray, Boolean> symmetries = cachedLeviCivitaSymmetries.get(indicesSize);
        if (symmetries != null)
            return symmetries;
        symmetries = new HashMap<>();
        Symmetries ss = SymmetriesFactory.createSymmetries(indicesSize);
        ss.addUnsafe(new Symmetry(Combinatorics.createTransposition(indicesSize, 0, 1), true));
        if (indicesSize % 2 == 0)
            ss.addUnsafe(new Symmetry(Combinatorics.createCycle(indicesSize), true));
        else
            ss.addUnsafe(new Symmetry(Combinatorics.createCycle(indicesSize), false));
        for (Symmetry symmetry : ss)
            symmetries.put(symmetry.getPermutation(), symmetry.isAntiSymmetry());
        cachedLeviCivitaSymmetries.put(indicesSize, symmetries);
        return symmetries;
    }
View Full Code Here

        int i;
        for (i = 0; i < dimension; ++i) {
            int fromIndex = indicesNames[i];
            IndexMappingBufferRecord record = indexMappingBuffer.getMap().get(fromIndex);
            if (record == null) {
                return new Symmetry(dimension);
                //todo discuss with Dima
                //throw new IllegalArgumentException("Index " + IndicesUtils.toString(fromIndex) + " does not contains in specified IndexMappingBuffer.");
            }
            int newPosition = -1;
            //TODO refactor with sort and binary search
            for (int j = 0; j < dimension; ++j)
                if (indicesNames[j] == record.getIndexName()) {
                    newPosition = j;
                    break;
                }
            if (newPosition < 0) {
                return new Symmetry(dimension);
                //todo discuss with Dima
                //throw new IllegalArgumentException("Index " + IndicesUtils.toString(record.getIndexName()) + " does not contains in specified indices array.");
            }
            permutation[i] = newPosition;
        }
        for (i = 0; i < dimension; ++i)
            if (permutation[i] == -1)
                permutation[i] = i;
        return new Symmetry(permutation, indexMappingBuffer.getSign());
    }
View Full Code Here

        int dimension = tensor.getIndices().size(type);
        boolean symmetriesAreEmpty = tensor.getIndices().getSymmetries().isEmpty();
        addSymmetry(tensor, type, true, Combinatorics.createTransposition(dimension));
        if (dimension > 2)
            if (symmetriesAreEmpty)
                tensor.getIndices().getSymmetries().addUnsafe(type.getType(), new Symmetry(Combinatorics.createCycle(dimension), dimension % 2 == 0 ? true : false));
            else
                tensor.getIndices().getSymmetries().add(type.getType(), new Symmetry(Combinatorics.createCycle(dimension), dimension % 2 == 0 ? true : false));
    }
View Full Code Here

    public static void setSymmetric(SimpleTensor tensor, IndexType type) {
        int dimension = tensor.getIndices().size(type);
        boolean symmetriesAreEmpty = tensor.getIndices().getSymmetries().isEmpty();
        tensor.getIndices().getSymmetries().addSymmetry(type, Combinatorics.createCycle(dimension));
        if (symmetriesAreEmpty)
            tensor.getIndices().getSymmetries().addUnsafe(type.getType(), new Symmetry(Combinatorics.createTransposition(dimension), false));
        else
            tensor.getIndices().getSymmetries().addSymmetry(type, Combinatorics.createTransposition(dimension));
    }
View Full Code Here

                    IndicesUtils.getNameWithType(_toIndices.get(positionInFrom)));

            if (positionInIndices < 0)
//                 throw new IllegalArgumentException();
//                todo review
                return new Symmetry(dimension);

            permutation[_sortPermutation[i]] = _sortPermutation[positionInIndices];
        }
        for (i = 0; i < dimension; ++i)
            if (permutation[i] == -1)
                permutation[i] = i;

        return new Symmetry(permutation, mapping.getSign()); //this is inverse permutation
    }
View Full Code Here

        for (int j = 0; j < data.length; ++j, ++i)
            s[i] = symmetry.newIndexOf(j) + data.from;
        for (; i < indicesTypeStructure.size(); ++i)
            s[i] = i;
        try {
            if (symmetries.add(new Symmetry(s, symmetry.isAntiSymmetry()))) {
                diffIds = null;
                return true;
            }
            return false;
        } catch (InconsistentGeneratorsException exception) {
View Full Code Here

TOP

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

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.