Examples of TensorLastTreeIterator


Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

    private AdjustParent() {
    }

    @Override
    public Tensor transform(Tensor tensor) {
        TensorLastTreeIterator iterator = new TensorLastTreeIterator(tensor, SetParent.INSTANCE);
        while (iterator.hasNext())
            iterator.next();
        return tensor;
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

    public Tensor transform(Tensor tensor) {
        //TODO review
        Tensor parent = tensor.getParent();
        TensorWrapper wrapper = new TensorWrapper(tensor);

        TensorLastTreeIterator iterator = new TensorLastTreeIterator(wrapper, new Guide(), EquivalentTransformation.INSTANCE);

        Tensor current;
        OUT_FOR:
        while (iterator.hasNext()) {
            current = iterator.next();
            if (current instanceof Sum && ((Sum) current).isEmpty()) {
                subsZero(iterator);
                continue;
            }
            if (current.getClass() != getFromClasss())
                continue;
            T _current = (T) current;
            if (_current.getName() != from.getName())
                continue;
            if (IndexMappings.createPortForSimpleTensor(from, _current, allowDiffStates).take() == null)
                continue;
            if (!canMatch(from, _current))
                continue;

            if (iterator.isUnderIterator(Derivative.onTargetIndicator, Integer.MAX_VALUE)) {
                for (Tensor[] vars : derivativesVars) {
                    int i;
                    if ((i = Arrays.binarySearch(vars, current)) >= 0) {
                        if (!allowDiffStates) {
                            //TODO discover all possibiliyies
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

public abstract class TensorTreeIndicator implements Indicator<Tensor> {
    //FIXME add iteration guide
    @Override
    public boolean is(Tensor tensor) {
        //TODO add iteration guide
        TensorTreeIterator iterator = new TensorLastTreeIterator(tensor);
        while (iterator.hasNext())
            if (_is(iterator.next()))
                return true;
        return false;
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

    private TensorUtils() {
    }

    public static IndicesBuilderSorted getAllIndicesBuilder(final Tensor tensor) {
        final IndicesBuilderSorted ib = new IndicesBuilderSorted();
        TensorLastTreeIterator iterator = new TensorLastTreeIterator(tensor, IterationGuide.EXCEPT_DENOMINATOR_TENSORFIELD_ARGUMENTS);
        Tensor current;
        while (iterator.hasNext()) {
            current = iterator.next();
            if (!(current instanceof SimpleTensor))
                continue;
            if (Derivative.onVarsIndicator.is(iterator))
                ib.append(current.getIndices().getInverseIndices());
            else
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

            return ((Derivative) t).getDerivativeOrder() + 1;
        return 1;
    }

    public static boolean testParentConsistent(final Tensor tensor) {
        TensorTreeIterator iterator = new TensorLastTreeIterator(tensor);
        Tensor current;
        while (iterator.hasNext()) {
            current = iterator.next();
            for (Tensor t : current)
                if (t.getParent() != current)
                    return false;
        }
        return true;
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

     * @param target target tensor to find whether it contains one of the keys
     * @param keys simple tensors array
     * @return true if target tensor contains one of the keys and false if not
     */
    public static boolean contains(final Tensor target, final SimpleTensor... keys) {
        final TensorTreeIterator iterator = new TensorLastTreeIterator(target);
        Tensor c;
        SimpleTensor s;
        while (iterator.hasNext()) {
            c = iterator.next();
            if (!(c instanceof SimpleTensor))
                continue;
            s = (SimpleTensor) c;
            for (SimpleTensor k : keys)
                if (k.getName() == s.getName())
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

     * @param target target tensor
     * @return list of simple tensors, which are occurs in target tensor
     */
    public static Collection<SimpleTensor> getSimpleTensorContent(Tensor target) {
        final List<SimpleTensor> result = new LinkedList<>();
        final TensorTreeIterator iterator = new TensorLastTreeIterator(target);
        Tensor c;
        while (iterator.hasNext()) {
            c = iterator.next();
            if (c instanceof SimpleTensor)
                result.add((SimpleTensor) c);
        }
        return result;
    }
View Full Code Here

Examples of cc.redberry.core.tensor.iterators.TensorLastTreeIterator

     * @return list of simple tensors, which are occurs in target tensor and
     * have different names.
     */
    public static Collection<SimpleTensor> getDiffSimpleTensorContent(Tensor target) {
        final Map<Integer, SimpleTensor> map = new HashMap<>();
        final TensorTreeIterator iterator = new TensorLastTreeIterator(target);
        Tensor c;
        while (iterator.hasNext()) {
            c = iterator.next();
            if (c instanceof SimpleTensor) {
                SimpleTensor st = (SimpleTensor) c;
                if (map.containsKey(st.getName()))
                    continue;
                map.put(st.getName(), st);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.