use of org.apfloat.Apfloat in project symja_android_library by axkr.
the class ApfloatOutput method main.
public static void main(String[] args) {
Apfloat value = new Apfloat("6.7", 25);
value = ApfloatMath.pow(value, -4L);
System.out.println(value.toString());
// Apfloat newValue = ApfloatMath.round(value, 20, RoundingMode.HALF_EVEN);
// System.out.println(newValue.toString());
Apfloat value2 = new Apfloat("6.7", 24);
value2 = ApfloatMath.pow(value2, -4L);
System.out.println(value2.toString());
// Apfloat newValue2 = ApfloatMath.round(value2, 20, RoundingMode.HALF_EVEN);
// System.out.println(newValue2.toString());
Apfloat valueD = new Apfloat(Math.pow(6.7, -4));
Apfloat newValueD = ApfloatMath.round(valueD, 6, RoundingMode.HALF_EVEN);
System.out.println(newValueD.toString());
Apfloat valueD2 = new Apfloat(Math.pow(6.7, -4));
Apfloat newValueD2 = ApfloatMath.round(valueD2, 7, RoundingMode.HALF_EVEN);
System.out.println(newValueD2.toString());
}
use of org.apfloat.Apfloat in project symja_android_library by axkr.
the class AbstractFractionSym method apcomplexValue.
@Override
public Apcomplex apcomplexValue() {
FixedPrecisionApfloatHelper h = EvalEngine.getApfloat();
Apfloat real = h.divide(new Apfloat(toBigNumerator(), h.precision()), new Apfloat(toBigDenominator(), h.precision()));
return new Apcomplex(real);
}
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) {
FixedPrecisionApfloatHelper h = EvalEngine.getApfloat();
Apfloat n = new Apfloat(numerator, h.precision());
Apfloat d = new Apfloat(denominator, h.precision());
return new ApfloatNum(h.divide(n, d));
}
use of org.apfloat.Apfloat in project symja_android_library by axkr.
the class ApcomplexNum method atan2.
@Override
public IExpr atan2(IExpr value) {
try {
if (value instanceof ApcomplexNum) {
Apcomplex th = fApcomplex;
Apcomplex x = ((ApcomplexNum) value).fApcomplex;
// compute r = sqrt(x^2+y^2)
FixedPrecisionApfloatHelper h = EvalEngine.getApfloat();
final Apcomplex r = h.sqrt(h.add(h.multiply(x, x), h.multiply(th, th)));
if (x.real().compareTo(Apfloat.ZERO) >= 0) {
// compute atan2(y, x) = 2 atan(y / (r + x))
return valueOf(h.multiply(h.atan(h.divide(th, h.add(r, x))), new Apfloat(2)));
} else {
// compute atan2(y, x) = +/- pi - 2 atan(y / (r - x))
return valueOf(h.add(h.multiply(h.atan(h.divide(th, h.subtract(r, x))), new Apfloat(-2)), h.pi()));
}
}
return IComplexNum.super.atan2(value);
} catch (ArithmeticException aex) {
// Indeterminate expression `1` encountered.
IOFunctions.printMessage(S.ArcTan, "indet", F.list(F.ArcTan(value, this)), EvalEngine.get());
return S.Indeterminate;
}
}
use of org.apfloat.Apfloat in project symja_android_library by axkr.
the class ApcomplexNum method copySign.
@Override
public IExpr copySign(double d) {
FixedPrecisionApfloatHelper h = EvalEngine.getApfloat();
Apfloat sign = new Apfloat(d);
return valueOf(//
h.copySign(fApcomplex.real(), sign), h.copySign(fApcomplex.imag(), sign));
}
Aggregations