Search in sources :

Example 1 with FixedPrecisionApfloatHelper

use of org.apfloat.FixedPrecisionApfloatHelper 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)

Example 2 with FixedPrecisionApfloatHelper

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

the class ComplexSym method apcomplexValue.

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

Example 3 with FixedPrecisionApfloatHelper

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

the class EvalEngine method copy.

/**
 * Copy this EvalEngine into a new EvalEngine. The copied engine is used in function <code>
 * TimeConstrained</code> to stop a thread after T seconds.
 *
 * @return
 */
public synchronized EvalEngine copy() {
    EvalEngine engine = new EvalEngine();
    // rememberASTCache;
    engine.rememberASTCache = null;
    engine.rememberMap = rememberMap;
    engine.fAnswer = fAnswer;
    engine.fAssumptions = fAssumptions;
    engine.fContextPath = fContextPath.copy();
    engine.fErrorPrintStream = fErrorPrintStream;
    engine.fEvalLHSMode = fEvalLHSMode;
    engine.fEvalRHSMode = fEvalRHSMode;
    engine.fFileSystemEnabled = fFileSystemEnabled;
    engine.fIterationLimit = fIterationLimit;
    engine.fModifiedVariablesList = fModifiedVariablesList;
    engine.fNumericMode = fNumericMode;
    // engine.fNumericPrecision = fNumericPrecision;
    engine.fApfloatHelper = new FixedPrecisionApfloatHelper(getNumericPrecision());
    engine.fSignificantFigures = fSignificantFigures;
    engine.fEvalHistory = fEvalHistory;
    engine.fOptionsStack = fOptionsStack;
    engine.fOutListDisabled = fOutListDisabled;
    engine.fOutPrintStream = fOutPrintStream;
    engine.fOnOffMap = fOnOffMap;
    engine.fOnOffMode = fOnOffMode;
    engine.fOnOffUnique = fOnOffUnique;
    engine.fOnOffUniqueMap = fOnOffUniqueMap;
    engine.fPackageMode = fPackageMode;
    engine.fQuietMode = fQuietMode;
    engine.fReapList = fReapList;
    engine.fRecursionCounter = 0;
    engine.fRecursionLimit = fRecursionLimit;
    engine.fRelaxedSyntax = fRelaxedSyntax;
    engine.fSeconds = fSeconds;
    engine.fSessionID = fSessionID;
    engine.fStopRequested = false;
    engine.fTogetherMode = fTogetherMode;
    engine.fTraceMode = fTraceMode;
    engine.fTraceStack = fTraceStack;
    engine.f$Input = f$Input;
    engine.f$InputFileName = f$InputFileName;
    fCopiedEngine = engine;
    return engine;
}
Also used : FixedPrecisionApfloatHelper(org.apfloat.FixedPrecisionApfloatHelper)

Example 4 with FixedPrecisionApfloatHelper

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

the class ApfloatJUnit method testApfloatDivide.

public void testApfloatDivide() {
    EvalEngine.setApfloat(new FixedPrecisionApfloatHelper(30));
    IComplexNum cnum1 = F.complexNum(new Apfloat(Long.MIN_VALUE), new Apfloat(Long.MAX_VALUE));
    INum cnum2 = F.num(new Apfloat(Long.MIN_VALUE));
    IExpr value = S.Divide.of(cnum2, cnum1);
    assertEquals(// 
    value.toString(), "(5.00000000000000000054210108624*10^-1, 4.99999999999999999999999999999*10^-1)");
}
Also used : FixedPrecisionApfloatHelper(org.apfloat.FixedPrecisionApfloatHelper) IComplexNum(org.matheclipse.core.interfaces.IComplexNum) IExpr(org.matheclipse.core.interfaces.IExpr) Apfloat(org.apfloat.Apfloat) INum(org.matheclipse.core.interfaces.INum)

Example 5 with FixedPrecisionApfloatHelper

use of org.apfloat.FixedPrecisionApfloatHelper 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);
}
Also used : FixedPrecisionApfloatHelper(org.apfloat.FixedPrecisionApfloatHelper) Apcomplex(org.apfloat.Apcomplex) Apfloat(org.apfloat.Apfloat)

Aggregations

FixedPrecisionApfloatHelper (org.apfloat.FixedPrecisionApfloatHelper)8 Apfloat (org.apfloat.Apfloat)7 Apcomplex (org.apfloat.Apcomplex)3 IComplexNum (org.matheclipse.core.interfaces.IComplexNum)1 IExpr (org.matheclipse.core.interfaces.IExpr)1 INum (org.matheclipse.core.interfaces.INum)1