Package cc.redberry.core.number

Examples of cc.redberry.core.number.Complex


        if (t instanceof Power) {
            if (!isSymbolic(t.get(0)))
                return false;
            if (!TensorUtils.isInteger(t.get(1)))
                return false;
            Complex e = (Complex) t.get(1);
            if (!e.isReal() || e.isNumeric())
                return false;
            return true;
        }
        for (Tensor tt : t)
            if (!isSymbolic(tt))
View Full Code Here


//    }

    @Override
    Tensor newTo_(Tensor currentNode, SubstitutionIterator iterator) {
        Product product = (Product) currentNode;
        Complex factor = product.getFactor();
        PContent content = new PContent(product.getIndexless(), product.getDataSubProduct());

        //TODO getForbidden only if necessary!!!!!!!!!!!!!!!!!
        TIntHashSet forbidden = new TIntHashSet(iterator.getForbidden());
        SubsResult subsResult = atomicSubstitute(content, forbidden);
        if (subsResult == null)
            return currentNode;

        List<Tensor> newTos = new ArrayList<>();
        while (true) {
            if (subsResult == null)
                break;
            factor = factor.divide(fromFactor);
            newTos.add(subsResult.newTo);
            content = subsResult.remainder;
            subsResult = atomicSubstitute(content, forbidden);
        }
        Tensor[] result = new Tensor[newTos.size() + content.indexless.length + 2];
View Full Code Here

        Tensor toTensor() {
            BigInteger exponent = this.exponent;
            if (minExponent != null && minExponent.value != null) {
                exponent = exponent.subtract(minExponent.value);
                if (diffSigns && minExponent.value.testBit(0))
                    return Tensors.negate(Tensors.pow(tensor, new Complex(exponent)));
            }
            return Tensors.pow(tensor, new Complex(exponent));
        }
View Full Code Here

     * @param power    power
     * @return result of argument exponentiation
     * @throws IllegalArgumentException if argument is not scalar
     */
    public static Tensor pow(Tensor argument, int power) {
        return pow(argument, new Complex(power));
    }
View Full Code Here

            builder.put(temp);
        }
        temp = builder.build();
        if (temp instanceof Sum) {
            //retrieving factor
            Complex factor = null, tempF;
            for (int i = temp.size() - 1; i >= 0; --i) {
                if (temp.get(i) instanceof Product) {
                    tempF = ((Product) temp.get(i)).getFactor();
                    assert tempF.isInteger();
                    tempF = tempF.abs();
                } else
                    tempF = Complex.ONE;
                if (factor == null)
                    factor = tempF;
                assert factor.equals(tempF);
            }

            if (!factor.isOne())
                temp = FastTensors.multiplySumElementsOnFactor((Sum) temp, factor.reciprocal());
            return multiply(new Complex(new Rational(1, temp.size())), temp);
        }
        return temp;
    }
View Full Code Here

        Boolean compare = TensorUtils.compare1(old, tensor);
        if (compare == null)
            return super.set(i, tensor);

        Complex newFactor = factor;
        if (compare) {
            tensor = Tensors.negate(tensor);
            newFactor = factor.negate();
            newFactor = getDefaultReference(newFactor);
        }
View Full Code Here

    }

    @Override
    protected Tensor select1(int[] positions) {
        int add = factor == Complex.ONE ? 0 : 1;
        Complex newFactor = Complex.ONE;
        List<Tensor> newIndexless = new ArrayList<>(), newData = new ArrayList<>();
        for (int position : positions) {
            position -= add;
            if (position == -1)
                newFactor = factor;
View Full Code Here

        StringBuilder sb = new StringBuilder();
        char operatorChar = mode == OutputFormat.LaTeX ? ' ' : '*';

        if (factor.isReal() && factor.getReal().signum() < 0) {
            sb.append('-');
            Complex f = factor.abs();
            if (!f.isOne())
                sb.append(((Tensor) f).toString(mode, Product.class)).append(operatorChar);
        } else if (factor != Complex.ONE)
            sb.append(((Tensor) factor).toString(mode, Product.class)).append(operatorChar);

        int i = 0, size = factor == Complex.ONE ? size() : size() - 1;
View Full Code Here

                }

            //creating term & processing combinatorics           
            Tensor term = SymmetrizeUpperLowerIndicesTransformation.symmetrizeUpperLowerIndices(Tensors.multiplyAndRenameConflictingDummies(tCombination.toArray(new Tensor[tCombination.size()])));
            if (symmetricForm || !(term instanceof Sum))
                term = Tensors.multiply(coefficientsGenerator.take(), term, term instanceof Sum ? new Complex(new Rational(1, term.size())) : Complex.ONE);
            else
                term = FastTensors.multiplySumElementsOnFactors((Sum) term, coefficientsGenerator);
            result.put(term);
        }
    }
View Full Code Here

        return tensor instanceof Complex && ((Complex) tensor).isNegativeInteger();
    }

    public static boolean isRealPositiveNumber(Tensor tensor) {
        if (tensor instanceof Complex) {
            Complex complex = (Complex) tensor;
            return complex.isReal() && complex.getReal().signum() > 0;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of cc.redberry.core.number.Complex

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.