Package cc.redberry.core.number

Examples of cc.redberry.core.number.Rational


    }

    @Override
    public Real parse(String expression, NumberParser<Real> parser) {
        try {
            return new Rational(new BigInteger(expression));
        } catch (NumberFormatException exception) {
        }
        try {
            return new Numeric(Double.parseDouble(expression));
        } catch (NumberFormatException exception) {
View Full Code Here


        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()])));
View Full Code Here

        }

        t = sb.build();

        if (multiplyBySymmetryFactor) {
            Complex frac = new Complex(new Rational(BigInteger.ONE, factor));
            if (t instanceof Sum)
                return FastTensors.multiplySumElementsOnFactor((Sum) t, frac);
            return Tensors.multiply(frac, t);
        } else
            return sb.build();
View Full Code Here

                if (summand != null)
                    sumBuilder.put(summand);
            }
        }
        if (multiplyOnSymmetryFactor)
            return Tensors.multiply(new Complex(new Rational(1, generatedPermutations.size())), sumBuilder.build());
        else
            return sumBuilder.build();
    }
View Full Code Here

    }

    @Override
    public Real parse(String expression, NumberParser<Real> parser) {
        try {
            return new Rational(new BigInteger(expression));
        } catch (NumberFormatException exception) {
        }
        try {
            return new Numeric(Double.parseDouble(expression));
        } catch (NumberFormatException exception) {
View Full Code Here

                if (withCoefficients) {
                    coefficient = CC.generateNewSymbol();
                    coefficients.add((SimpleTensor) coefficient);
                } else coefficient = Complex.ONE;

                term = Tensors.multiply(coefficient, term, term instanceof Sum ? new Complex(new Rational(1, term.size())) : Complex.ONE);
            } else if (withCoefficients)
                term = FastTensors.multiplySumElementsOnFactors((Sum) term);
            result.put(term);
        }
        this.result = indices.getSymmetries().isTrivial() ? result.build() : symmetrize(result.build());
View Full Code Here

                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

                }

            //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

            int[] newIndicesNames = permutation.permute(freeIndicesNames);
            generatedTensors.add(ApplyIndexMapping.applyIndexMapping(tensor, new Mapping(freeIndicesNames, newIndicesNames), new int[0]));
        }
        Tensor[] summands = generatedTensors.toArray(new Tensor[generatedTensors.size()]);
        if (multiplyFactorial)
            return Tensors.multiply(new Complex(new Rational(1, generatedTensors.size())), Tensors.sum(summands));
        else
            return Tensors.sum(summands);
    }
View Full Code Here

TOP

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

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.