Search in sources :

Example 1 with Apfloat

use of org.apfloat.Apfloat in project symja_android_library by axkr.

the class ApfloatNum method valueOf.

public static ApfloatNum valueOf(final BigInteger numerator, final BigInteger denominator, long precision) {
    Apfloat n = new Apfloat(numerator, precision);
    Apfloat d = new Apfloat(denominator, precision);
    return new ApfloatNum(n.divide(d));
}
Also used : Apfloat(org.apfloat.Apfloat)

Example 2 with Apfloat

use of org.apfloat.Apfloat in project symja_android_library by axkr.

the class ComplexSym method apcomplexValue.

public Apcomplex apcomplexValue(long precision) {
    Apfloat real = new Apfloat(fReal.toBigNumerator(), precision).divide(new Apfloat(fReal.toBigDenominator(), precision));
    Apfloat imag = new Apfloat(fImaginary.toBigNumerator(), precision).divide(new Apfloat(fImaginary.toBigDenominator(), precision));
    return new Apcomplex(real, imag);
}
Also used : Apcomplex(org.apfloat.Apcomplex) Apfloat(org.apfloat.Apfloat)

Example 3 with Apfloat

use of org.apfloat.Apfloat in project symja_android_library by axkr.

the class AbstractFractionSym method apfloatValue.

@Override
public Apfloat apfloatValue() {
    long precision = EvalEngine.getApfloat().precision();
    Apfloat n = new Apfloat(toBigNumerator(), precision);
    Apfloat d = new Apfloat(toBigDenominator(), precision);
    return n.divide(d);
}
Also used : Apfloat(org.apfloat.Apfloat)

Example 4 with Apfloat

use of org.apfloat.Apfloat in project symja_android_library by axkr.

the class ApcomplexNum method integerPart.

/**
 * {@inheritDoc}
 */
@Override
public IComplex integerPart() {
    // isNegative() ? ceilFraction() : floorFraction();
    Apfloat re = fApcomplex.real();
    Apfloat im = fApcomplex.imag();
    IInteger reInt;
    IInteger imInt;
    if (re.signum() == -1) {
        // ceilFraction
        reInt = F.ZZ(ApfloatMath.ceil(re).toBigInteger());
    } else {
        // floorFraction
        reInt = F.ZZ(ApfloatMath.floor(re).toBigInteger());
    }
    if (im.signum() == -1) {
        // ceilFraction
        imInt = F.ZZ(ApfloatMath.ceil(im).toBigInteger());
    } else {
        // floorFraction
        imInt = F.ZZ(ApfloatMath.floor(im).toBigInteger());
    }
    return F.complex(reInt, imInt);
}
Also used : IInteger(org.matheclipse.core.interfaces.IInteger) Apfloat(org.apfloat.Apfloat)

Example 5 with Apfloat

use of org.apfloat.Apfloat in project symja_android_library by axkr.

the class ApcomplexNum method valueOf.

/**
 * Create a <code>ApcomplexNum</code> complex number from the real and imaginary <code>BigInteger
 * </code> parts.
 *
 * @param realNumerator the real numbers numerator part
 * @param realDenominator the real numbers denominator part
 * @param imagNumerator the imaginary numbers numerator part
 * @param imagDenominator the imaginary numbers denominator part
 * @return a new <code>ApcomplexNum</code> complex number object
 */
public static ApcomplexNum valueOf(final BigInteger realNumerator, final BigInteger realDenominator, final BigInteger imagNumerator, final BigInteger imagDenominator) {
    FixedPrecisionApfloatHelper h = EvalEngine.getApfloat();
    long prec = h.precision();
    Apfloat real = h.divide(new Apfloat(realNumerator, prec), new Apfloat(realDenominator, prec));
    Apfloat imag = h.divide(new Apfloat(imagNumerator, prec), new Apfloat(imagDenominator, prec));
    return new ApcomplexNum(real, imag);
}
Also used : FixedPrecisionApfloatHelper(org.apfloat.FixedPrecisionApfloatHelper) Apfloat(org.apfloat.Apfloat)

Aggregations

Apfloat (org.apfloat.Apfloat)29 IExpr (org.matheclipse.core.interfaces.IExpr)8 FixedPrecisionApfloatHelper (org.apfloat.FixedPrecisionApfloatHelper)7 Apcomplex (org.apfloat.Apcomplex)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 Apint (org.apfloat.Apint)3 IAST (org.matheclipse.core.interfaces.IAST)3 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)3 IComplexNum (org.matheclipse.core.interfaces.IComplexNum)3 IInteger (org.matheclipse.core.interfaces.IInteger)3 INum (org.matheclipse.core.interfaces.INum)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 BigIntegerNode (com.fasterxml.jackson.databind.node.BigIntegerNode)2 BooleanNode (com.fasterxml.jackson.databind.node.BooleanNode)2 DecimalNode (com.fasterxml.jackson.databind.node.DecimalNode)2 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)2 FloatNode (com.fasterxml.jackson.databind.node.FloatNode)2 IntNode (com.fasterxml.jackson.databind.node.IntNode)2 LongNode (com.fasterxml.jackson.databind.node.LongNode)2 NullNode (com.fasterxml.jackson.databind.node.NullNode)2