Package cc.redberry.core.indexmapping

Examples of cc.redberry.core.indexmapping.IndexMappingBuffer


    @Override
    public BijectionContainer take() {
        if (finished)
            return null;
        List<int[]> bijections = new ArrayList<>();
        IndexMappingBuffer buffer;
        int i, b[];
        final int mappersSize = mappers.size();
        OUT:
        while (true) {
            buffer = source.take();
View Full Code Here


            return mapping;
        }

        @Override
        public IndexMappingBuffer take() {
            IndexMappingBuffer buf;
            while (true) {
                if (currentSource != null && (buf = currentSource.take()) != null)
                    return buf;
                if (!permutationGenerator.hasNext())
                    return null;
View Full Code Here

            BijectionContainer bc = new SumBijectionPort(from, current).take();
            if (bc == null)
                continue;

            IndexMappingBuffer buffer = bc.buffer;
            Tensor newTo;
            if (symbolic)
                newTo = to;
            else {
                int[] forbidden = new int[iterator.forbiddenIndices().size()];
View Full Code Here

        while ((current = iterator.next()) != null) {
            if (!(current instanceof Product))
                continue;
            Product cp = (Product) current;
            while (true) {
                IndexMappingBuffer buffer = null;

                final Tensor[] currentIndexless = cp.getIndexless();
                int[] indexlessBijection;
                IndexlessBijectionsPort indexlessPort = new IndexlessBijectionsPort(fromIndexless, currentIndexless);
                while ((indexlessBijection = indexlessPort.take()) != null) {
                    buffer = IndexMappings.createBijectiveProductPort(fromIndexless, extract(currentIndexless, indexlessBijection)).take();
                    if (buffer != null)
                        break;
                }
                if (buffer == null)
                    break;

                boolean sign = buffer.getSignum();
                buffer = null;
                ProductContent currentContent = cp.getContent();
                final Tensor[] currentData = currentContent.getDataCopy();
                int[] dataBijection;
                ProductsBijectionsPort dataPort = new ProductsBijectionsPort(fromContent, currentContent);
                while ((dataBijection = dataPort.take()) != null) {
                    buffer = IndexMappings.createBijectiveProductPort(fromData, extract(currentData, dataBijection)).take();
                    if (buffer != null)
                        break;
                }
                if (buffer == null)
                    break;

                buffer.addSignum(sign);
                Tensor newTo;
                if (symbolic)
                    newTo = to;
                else {
                    int[] forbidden = new int[iterator.forbiddenIndices().size()];
View Full Code Here

    @Override
    public Tensor transform(Tensor tensor) {
        SubstitutionIterator iterator = new SubstitutionIterator(tensor);
        Tensor current;
        while ((current = iterator.next()) != null) {
            IndexMappingBuffer buffer =
                    IndexMappings.getFirst(from, current);
            if (buffer == null)
                continue;
            Tensor newTo;
            if (symbolic)
View Full Code Here

        OUT:
        while ((current = iterator.next()) != null) {
            if (!(current instanceof TensorField))
                continue;
            TensorField currentField = (TensorField) current;
            IndexMappingBuffer buffer = IndexMappings.simpleTensorsPort(from, currentField).take();
            if (buffer == null)
                continue;


            Indices[] fromIndices = from.getArgIndices(), currentIndices = currentField.getArgIndices();
View Full Code Here

        Tensor current;
        while ((state = iterator.next()) != null) {
            if (state != TraverseState.Leaving)
                continue;
            current = iterator.current();
            IndexMappingBuffer buffer = IndexMappings.getFirst(from, current);
            if (buffer != null) {
                Tensor newFrom = ApplyIndexMapping.applyIndexMapping(to, buffer);
                iterator.set(newFrom);
            }
        }
View Full Code Here

    public static boolean compare(Tensor u, Tensor v) {
        Indices freeIndices = u.getIndices().getFreeIndices();
        if (!freeIndices.equalsRegardlessOrder(v.getIndices().getFreeIndices()))
            return false;
        int[] free = freeIndices.getAllIndices().copy();
        IndexMappingBuffer tester = new IndexMappingBufferTester(free, false);
        MappingsPort mp = IndexMappings.createPort(tester, u, v);
        IndexMappingBuffer buffer;

        while ((buffer = mp.take()) != null)
            if (buffer.getSignum() == false)
                return true;

        return false;
    }
View Full Code Here

    public static Boolean compare1(Tensor u, Tensor v) {
        Indices freeIndices = u.getIndices().getFreeIndices();
        if (!freeIndices.equalsRegardlessOrder(v.getIndices().getFreeIndices()))
            return false;
        int[] free = freeIndices.getAllIndices().copy();
        IndexMappingBuffer tester = new IndexMappingBufferTester(free, false);
        IndexMappingBuffer buffer = IndexMappings.createPort(tester, u, v).take();
        if (buffer == null)
            return null;
        return buffer.getSignum();
    }
View Full Code Here

                factorNodes.add(new FactorNode(split.factor, split.getBuilder()));
        }
    }

    static Boolean compareFactors(Tensor u, Tensor v) {
        IndexMappingBuffer buffer;
        if (u.getIndices().size() == 0)
            buffer = IndexMappings.createPort(u, v).take();
        else {
            int[] fromIndices = u.getIndices().getFreeIndices().getAllIndices().copy();
            for (int i = 0; i < fromIndices.length; ++i)
                fromIndices[i] = IndicesUtils.getNameWithType(fromIndices[i]);
//            long start = System.currentTimeMillis();
            buffer = IndexMappings.createPort(new IndexMappingBufferTester(fromIndices, false), u, v).take();
//            long stop = System.currentTimeMillis();
//            if (stop - start > 300) {
//                System.out.println("time " + (stop - start));
//
//                System.out.println(u);
//                System.out.println(v);
//            }
        }
        if (buffer == null)
            return null;
        assert buffer.isEmpty();
        return buffer.getSignum();
    }
View Full Code Here

TOP

Related Classes of cc.redberry.core.indexmapping.IndexMappingBuffer

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.