Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.Integral


    @Override
    public Tensor transform(final Tensor tensor) {
        if (!(tensor instanceof Integral))
            return tensor;
        final Integral integral = (Integral) tensor;
        final Tensor target = integral.target();
        final SimpleTensor[] vars = integral.vars();
        if (!(target instanceof Sum))
            return tensor;
        Sum result = new Sum();
        for (Tensor summand : target)
            result.add(new Integral(summand.clone(), clone(vars)));
        return result;
    }
View Full Code Here


                for (SimpleTensor st : tempVars)
                    if (map.containsKey(st.getName()))
                        continue out_for;

                //current can be placed under current integral
                final Integral integral = integrals.get(i);
                integrals.set(i, new Integral(new Product(current, integral.target()), integral.vars()));
                iterator.remove();
            }
        }

        Product result = new Product();
View Full Code Here

            var = tensors.get(i);
            if (!(var instanceof SimpleTensor))
                return null;
            vars[i - 1] = (SimpleTensor) var;
        }
        return new Integral(tensors.get(0), vars);
    }
View Full Code Here

    private ProviderIntegralFactory() {
    }

    @Override
    public IndexMappingProvider create(IndexMappingProvider opu, Tensor from, Tensor to, boolean allowDiffStates) {
        final Integral intFrom = (Integral) from, intTo = (Integral) to;
        final SimpleTensor[] varsFrom = intFrom.vars(), varsTo = intTo.vars();
        if (varsFrom.length != varsTo.length)
            return IndexMappingProvider.Util.EMPTY_PROVIDER;
        Arrays.sort(varsFrom); //TODO change to quick Sort
        Arrays.sort(varsTo); //TODO change to quick Sort
        int i;
        int[] hashes = new int[varsFrom.length];
        for (i = 0; i < varsFrom.length; ++i)
            if ((hashes[i] = varsFrom[i].hashCode()) != varsTo[i].hashCode())
                return IndexMappingProvider.Util.EMPTY_PROVIDER;
        PrecalculatedStretches stretches = new PrecalculatedStretches(hashes);
        for (Stretch stretch : stretches)
            if (stretch.length == 1)
                if (!IndexMappings.mappingExists(varsFrom[stretch.from], varsTo[stretch.from], allowDiffStates))
                    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;
                }
                return IndexMappingProvider.Util.EMPTY_PROVIDER;
            }
        return IndexMappings.createPort(opu, intFrom.target(), intTo.target(), allowDiffStates);
    }
View Full Code Here

TOP

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

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.