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


        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

            return t;

        List<Tensor> toMultiply = new ArrayList<>(map.size());
        for (SortedMap.Entry<GenPolynomial<BigInteger>, Long> entry : map.entrySet())
            toMultiply.add(Tensors.pow(poly2Tensor(entry.getKey(), varsArray),
                    new Complex(entry.getValue())));
        if (!gcd.equals(java.math.BigInteger.ONE) || !lcm.equals(java.math.BigInteger.ONE))
            toMultiply.add(new Complex(new Rational(gcd, lcm)));

        return Tensors.multiply(toMultiply.toArray(new Tensor[toMultiply.size()]));
    }
View Full Code Here

        for (Monomial<BigInteger> monomial : poly) {
            coefficient = monomial.coefficient();
            exp = monomial.exponent();
            temp.clear();

            temp.add(new Complex(new Rational(coefficient.getVal())));
            for (int i = 0; i < exp.length(); ++i)
                if ((lExp = exp.getVal(i)) != 0)
                    temp.add(Tensors.pow(varsArray[i].simpleTensor, new Complex(lExp)));

            sum.add(Tensors.multiply(temp.toArray(new Tensor[temp.size()])));
        }
        return Tensors.sum(sum.toArray(new Tensor[sum.size()]));
    }
View Full Code Here

    @Override
    public Complex parse(String expression, NumberParser<Complex> parser) {
        if (expression.equals("I"))
            return Complex.IMAGE_ONE;
        try {
            return new Complex(new BigInteger(expression));
        } catch (NumberFormatException ignored) {
        }
        try {
            return new Complex(Double.parseDouble(expression));
        } catch (NumberFormatException exception) {
            return null;
        }
    }
View Full Code Here

    static Tensor power(Tensor argument, Tensor power) {
        //TODO improve Complex^Complex
        if (argument instanceof Complex && power instanceof Complex) {

            Complex a = (Complex) argument;
            Complex p = (Complex) power;
            Complex result = Exponentiation.exponentiateIfPossible(a, p);

            if (result != null)
                return result;
        }
        if (TensorUtils.isOne(power))
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

        return false;
    }

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

    abstract TensorBuilder getBuilder();

    static Split split(final Tensor tensor) {
        if (tensor.getIndices().size() == 0) {//case 2*a*b*c
            Complex complex;
            Tensor factor;
            if (tensor instanceof Product) {
                Product product = (Product) tensor;
                complex = product.factor;
                if (complex == Complex.ONE)//case a*b
 
View Full Code Here

            }

            pb.put(Tensors.simpleTensor(descriptor.getId(), IndicesFactory.createSimple(descriptor.getSymmetries(), factorIndices)));
        }
        if (random.nextBoolean())
            pb.put(new Complex(1 + nextInt(100)));
        return pb.build();
    }
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.