Package cc.redberry.core.indices

Examples of cc.redberry.core.indices.Indices


            if (sp.getName() != var.getName())
                return null;
            if (sp.getIndices().size() == 0)
                return TensorNumber.createONE();
            Product kroneckers = new Product();
            Indices targetIndices = sp.getIndices();
            Indices varIndices = var.getIndices();
            for (int i = 0; i < sp.getIndices().size(); ++i)
                kroneckers.add(CC.createMetricOrKronecker(targetIndices.get(i), varIndices.get(i)));
            return kroneckers.equivalent();
        } else if (target.getClass() == TensorField.class) {
            TensorField field = (TensorField) target;
            Tensor[] args = field.getArgs();
            for (int i = 0; i < args.length; ++i)
View Full Code Here


                new SimpleTensorSubstitution[from.getArgs().length];
        Tensor argFrom, argCurrent;
        for (int i = 0; i < from.getArgs().length; ++i) {
            argFrom = from.getArgs()[i].clone();
            argCurrent = current.getArgs()[i];
            final Indices fromIndices = from.getArgIndices()[i];
            final Indices currentIndices = current.getArgIndices()[i];

            if (!allowDiffStates)
                for (int j = 0; j < fromIndices.size(); ++j)
                    if (IndicesUtils.getRawStateInt(fromIndices.get(j))
                            != IndicesUtils.getRawStateInt(currentIndices.get(j)))
                        return null;

            final IndexMappingDirect im = new IndexMappingDirect(fromIndices,
                    currentIndices);
            if (argFrom.getIndices().applyIndexMapping(im))
View Full Code Here

        return result.equivalent();
    }

    public Tensor renameIndicesAndBuidKroneckers(Tensor tensor) {
        if (tensor instanceof SimpleTensor || tensor instanceof Product) {
            Indices indices = tensor.getIndices();
            IndexMappingDirectAllowingUnmapped im = new IndexMappingDirectAllowingUnmapped();
            IndexMappingDirectAllowingUnmapped renameUsedIndices = null;
            IndexGenerator ig;
           
            ig = new IndexGenerator(TensorUtils.getAllIndicesBuilder(tensor).append(usedIndicesNames).asArray());
            for (int i = 0; i < indices.size(); ++i) {
                int index = indices.get(i);
                if (checked.contains(inverseIndexState(index)))
                    if (usedIndicesNames.length == 0 || Arrays.binarySearch(usedIndicesNames, getNameWithType(index)) < 0) {
//                        uncontracted.add(inverseIndexState(index));
                        int newIndex = getRawStateInt(index) | ig.generate(getType(index));
                        uncontracted.add(getNameWithType(index));
View Full Code Here

    }

    @Override
    public Tensor transform(Tensor tensor) {
        if (tensor instanceof SimpleTensor || tensor instanceof Product) {
            Indices indices = tensor.getIndices();
            checked.ensureCapacity(indices.size());
            int index;
            IndexMappingDirectAllowingUnmapped im = new IndexMappingDirectAllowingUnmapped();
            //TODO discover case to put allIndices in ig
            IndexGenerator ig = new IndexGenerator(new IndicesBuilderSorted().append(indices).append(usedNames).asArray());
            for (int i = 0; i < indices.size(); i++) {
                index = indices.get(i);
                if (checked.contains(getNameWithType(index))) {
                    if (Arrays.binarySearch(usedNames, getNameWithType(index)) >= 0) {
                        int newIndex = getRawStateInt(index) | ig.generate(getType(index));
                        im.add(index, newIndex);
                        im.add(inverseIndexState(index), inverseIndexState(newIndex));
View Full Code Here

        }
        return tensor;
    }

    public void transform(Tensor tensor1, Tensor tensor2) {
        Indices indices = new IndicesBuilderSorted().append(tensor1.getIndices()).append(tensor2.getIndices()).getIndices();
        checked.ensureCapacity(indices.size());
        int index;
        IndexMappingDirectAllowingUnmapped im = new IndexMappingDirectAllowingUnmapped();
        //TODO discover case to put allIndices in ig
        IndexGenerator ig = new IndexGenerator(new IndicesBuilderSorted().append(indices).append(usedNames).asArray());
        for (int i = 0; i < indices.size(); i++) {
            index = indices.get(i);
            if (checked.contains(getNameWithType(index))) {
                if (Arrays.binarySearch(usedNames, getNameWithType(index)) >= 0) {
                    int newIndex = getRawStateInt(index) | ig.generate(getType(index));
                    im.add(index, newIndex);
                    im.add(inverseIndexState(index), inverseIndexState(newIndex));
View Full Code Here

        return Integer.compare(indices[1], o.indices[1]);
    }

    boolean apply(SimpleTensor t) {
        IM im = new IM();
        Indices tIndices = t.getIndices();
        OUTER:
        for (int i = 0; i < tIndices.size(); ++i)
            for (int j = 0; j < 2; ++j)
                if ((tIndices.get(i) ^ indices[j])
                        == 0x80000000) {
                    im.add(tIndices.get(i),
                            indices[1 - j]);
                    break OUTER;
                }
        boolean b = tIndices.applyIndexMapping(im);
        if (b)
            //FIXME may be redundant invocation
            t.update();
        return b;
    }
View Full Code Here

    }

    @Override
    public Tensor renameIndicesAndBuidKroneckers(Tensor tensor) {
        if (tensor instanceof SimpleTensor || tensor instanceof Product) {
            Indices indices = tensor.getIndices();
            IndexMappingDirectAllowingUnmapped im = new IndexMappingDirectAllowingUnmapped();
            IndexGenerator ig = createIndexGenerator(tensor);
            for (int i = 0; i < indices.size(); ++i) {
                int index = indices.get(i);
                if (checked.contains(inverseIndexState(index))) {
                    int newIndex = getRawStateInt(index) | ig.generate(getType(index));
                    im.add(index, newIndex);
                } else
                    checked.add(index);
View Full Code Here

    }

    @Override
    public Tensor renameIndicesAndBuidKroneckers(Tensor tensor) {
        if (tensor instanceof SimpleTensor || tensor instanceof Product) {
            Indices indices = tensor.getIndices();
            IndexMappingDirectAllowingUnmapped im = new IndexMappingDirectAllowingUnmapped();
            IndexMappingDirectAllowingUnmapped renameUsedIndices = null;
            IndexGenerator ig = createIndexGenerator(tensor);
            for (int i = 0; i < indices.size(); ++i) {
                int index = indices.get(i);
                if (checked.contains(inverseIndexState(index)))
                    if (Arrays.binarySearch(indicesToRenameNames, getNameWithType(index)) < 0) {
//                        uncontracted.addAll(inverseIndexState(index));
                        int newIndex = getRawStateInt(index) | ig.generate(getType(index));
                        im.add(index, newIndex);
View Full Code Here

    private void testConsistent() {
        IndicesBuilderSorted ib = new IndicesBuilderSorted();
        ib.append(data[0].getIndices().getFreeIndices());
        for (int i = 1; i < data.length; ++i)
            ib.append(data[i].getIndices());
        Indices indices = ib.getIndices();
        if (indices.size() == 0)
            return;
        if (CC.getRegim() == Context.Regim.TESTING)
            return;
        try {
            indices.testConsistentWithException();
        } catch (InconsistentIndicesException ex) {
            //Adding information about source tensor
            throw new InconsistentIndicesException(ex, this);
        }
    }
View Full Code Here

    private void testConsistent() {
        boolean isSymbol = (indices instanceof EmptyIndices);
        boolean b = true;
        for (Tensor t : this) {
            Indices ind = t.getIndices().getFreeIndices();
            if (!indices.equalsIgnoreOrder(ind))
                b = false;
            // Take care if sum e.g. a+h^i_i that indices will not be EmptyIndices (sum is not symbol)
            if (isSymbol && !(ind instanceof EmptyIndices)) {
                isSymbol = false;
View Full Code Here

TOP

Related Classes of cc.redberry.core.indices.Indices

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.