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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations