Package cc.redberry.core.tensor

Examples of cc.redberry.core.tensor.Product


            currentValues[i] = sumPorts[i].take();
    }

    @Override
    public Tensor take() {
        Product result = productBody.clone();
        int pointer = sumPorts.length - 1;
        boolean increment = false;
        Tensor element = sumPorts[pointer].take();
        if (element == null) {
            sumPorts[pointer].reset();
            element = sumPorts[pointer].take();
            increment = true;
        }
        result.add(element.clone());
        while (--pointer >= 0) {
            if (increment) {
                increment = false;
                element = sumPorts[pointer].take();
                if (element == null) {
                    sumPorts[pointer].reset();
                    element = sumPorts[pointer].take();
                    increment = true;
                }
                currentValues[pointer] = element;
            }
            result.add(currentValues[pointer].clone());
        }
        if (increment)
            return null;
        return result;
    }
View Full Code Here


    private static OutputPortUnsafe<Tensor> createOP(Tensor tensor, Indicator<Tensor> except) {
        if (!(tensor instanceof Product))
            return null;
        List<Sum> sums = new ArrayList<>();
        Product body = new Product();
        for (Tensor t : tensor)
            if ((t instanceof Sum) && !except.is(t))
                sums.add((Sum) t);
            else
                body.add(t);
        if (sums.isEmpty())
            return null;
        return new ExpandBracketsOutput(body, sums.toArray(new Sum[sums.size()]), except);
    }
View Full Code Here

                return tensor;
            if (syms.size() == 1) {
                ((Product) tensor).addFirst(syms.get(0));
                return tensor;
            }
            ((Product) tensor).addFirst(ExpandAndCollectTransformation.EXPAND_AND_COLLECT_SCALARS.transform(new Product(syms)));
            return tensor;
        }
        return tensor;
    }
View Full Code Here

        super(argument, parent);
    }

    @Override
    public Tensor derivative() {
        return new Fraction(TensorNumber.createONE(), new Product(new Cos(innerTensor.clone()), new Cos(innerTensor.clone())));
    }
View Full Code Here

        super(argument, parent);
    }

    @Override
    public Tensor derivative() {
        return new Product(TensorNumber.createMINUSONE(),new Sin(innerTensor.clone()));
    }
View Full Code Here

    @Override
    protected Tensor compile(List<Tensor> tensors) {
        if (tensors.isEmpty())
            throw new ParserException("Product parser get zero size array in complile(List<Tensor> tensors).");
        Tensor result = new Product(tensors);
        //consistent check
        result.getIndices();
        return result;
    }
View Full Code Here

        return result;
    }

    @Override
    protected void inverseOperation(Tensor tensor, List<Tensor> subTensors) {
        subTensors.add(new Product(TensorNumber.createMINUSONE(), tensor));
    }
View Full Code Here

        }
        if (metrics.isEmpty())
            return null;
        if (metrics.size() == 1)
            return metrics.get(0);
        return new Product(metrics);
    }
View Full Code Here

            System.arraycopy(freeIndices[b], 0, indicesSpace[b], diff * 2, freeIndices[b].length);
            shuffle(indicesSpace[b]);
        }

        //Creating resulting product
        Product product = new Product();
        for (NameDescriptor descriptor : descriptors) {
            IndicesTypeStructure its = descriptor.getIndicesTypeStructure();
            int[] factorIndices = new int[its.size()];
            int position = 0;
            for (byte b : TYPES) {
                IndicesTypeStructure.TypeData typeData = its.getTypeDatas(b);
                if (typeData == null)
                    continue;
                for (i = 0; i < typeData.length; ++i)
                    factorIndices[position++] = indicesSpace[b][--totalIndicesCounts[b]];
            }

            product.add(new SimpleTensor(descriptor.getId(), IndicesFactory.createSimple(factorIndices)));
        }
        return product;
    }
View Full Code Here

        super(argument, parent);
    }

    @Override
    public Tensor derivative() {
        return new Fraction(TensorNumber.createMINUSONE(), new Product(new Sin(innerTensor.clone()), new Sin(innerTensor.clone())));
    }
View Full Code Here

TOP

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

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.