public abstract class AbstractFractionSym extends ExprImpl implements IFraction
FractionSym
,
BigFractionSym
,
Serialized FormModifier and Type | Field and Description |
---|---|
static FractionSym |
MONE |
static FractionSym |
ONE |
static FractionSym |
ZERO |
ASTID, BLANKID, COMPLEXID, DOUBLECOMPLEXID, DOUBLEID, FRACTIONID, INTEGERID, METHODSYMBOLID, PATTERNID, STRINGID, SYMBOLID
Constructor and Description |
---|
AbstractFractionSym() |
Modifier and Type | Method and Description |
---|---|
abstract IFraction |
abs()
Compute the absolute of this rational.
|
<T> T |
accept(IVisitor<T> visitor)
Accept a visitor with return type T
|
boolean |
accept(IVisitorBoolean visitor)
Accept a visitor with return type
boolean |
int |
accept(IVisitorInt visitor)
Accept a visitor with return type
int |
long |
accept(IVisitorLong visitor)
Accept a visitor with return type
long |
abstract IFraction |
add(IFraction other) |
IFraction |
addmul(IFraction fac1,
IFraction fac2)
Returns
this+(fac1*fac2) . |
ApcomplexNum |
apcomplexNumValue(long precision)
Get a
Apcomplex number wrapped into an
ApcomplexNum object. |
org.apfloat.Apcomplex |
apcomplexValue(long precision) |
ApfloatNum |
apfloatNumValue(long precision)
Get a
Apfloat number wrapped into an ApfloatNum object. |
abstract IFraction |
ceilFraction()
Returns the smallest (closest to negative infinity)
IInteger
value that is not less than this and is equal to a
mathematical integer. |
int |
complexSign()
Gets the signum value of a complex number
|
IRational |
divideBy(IRational that) |
ISignedNumber |
divideBy(ISignedNumber that)
Divide
this signed number by that signed number. |
IExpr |
eabs()
Get the absolute value for a given number
|
boolean |
equalsInt(int i)
Check if this number equals the given
int number? |
IExpr |
evaluate(EvalEngine engine)
Evaluate an expression
|
IAST |
factorInteger()
Return the factors paired with their exponents for integer and fractional
numbers.
|
abstract IFraction |
floorFraction()
Returns the largest (closest to positive infinity)
IInteger
value that is not greater than this and is equal to a
mathematical integer. |
static java.math.BigInteger |
gcd(java.math.BigInteger i1,
java.math.BigInteger i2) |
IInteger |
getDenominator()
Returns the denominator of this fraction.
|
ISignedNumber |
getIm()
Returns the imaginary part of a complex number
|
double |
getImaginary()
Returns the imaginary part of a complex number
|
IInteger |
getNumerator()
Returns the numerator of this fraction.
|
ISignedNumber |
getRe()
Returns the real part of a complex number
|
double |
getReal()
Returns the real part of a complex number
|
ISymbol |
head()
If this object is an instance of
IAST get the first element
(offset 0) of the IAST list (i.e. get(0) ). |
int |
hierarchy()
A unique integer ID for the implementation of this expression
|
abstract IFraction |
inverse()
Returns the multiplicative inverse of this object.
|
boolean |
isGreaterThan(ISignedNumber obj)
Test if
this signed number is greater than that signed number.. |
abstract boolean |
isIntegral()
Check whether this rational represents an integral value (i.e. the
denominator equals 1).
|
boolean |
isLessThan(ISignedNumber obj)
Test if
this signed number is less than that signed number.. |
boolean |
isNumEqualRational(IRational value)
Check if this expression equals an
IRational value. |
boolean |
isRationalValue(IRational value)
Test if this expression equals
value in symbolic or numeric
mode. |
IFraction |
mul(IFraction other)
Return a new rational representing
this * other . |
IFraction |
multiply(IFraction parm1) |
abstract IFraction |
negate()
Negate this.
|
INumber |
numericNumber()
Create a numeric number from this exact "symbolic" number.
|
Num |
numValue()
Get a Java double number wrapped into a
Num object. |
ISignedNumber |
opposite()
Returns an
IExpr whose value is (-1) * this . |
IExpr |
plus(IExpr that)
Returns an
IExpr whose value is (this + that) . |
IFraction |
pow(long n)
Returns this number raised at the specified exponent.
|
int |
sign()
Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive).
|
IFraction |
sub(IFraction other)
Return a new rational representing
this - other . |
IFraction |
subdiv(IFraction s,
FractionSym d)
Returns
(this-s)/d . |
IRational |
subtract(IRational that) |
ISignedNumber |
subtractFrom(ISignedNumber that)
Subtract
that signed number from this signed number |
IExpr |
times(IExpr that)
Returns an
IExpr whose value is (this * that) . |
static IFraction |
valueOf(org.apache.commons.math4.fraction.BigFraction fraction) |
static IFraction |
valueOf(java.math.BigInteger num) |
static IFraction |
valueOf(java.math.BigInteger num,
java.math.BigInteger den)
Construct a rational from two BigIntegers.
|
static IFraction |
valueOf(double value) |
static IFraction |
valueOf(IInteger numerator) |
static IFraction |
valueOf(IInteger numerator,
IInteger denominator) |
static IFraction |
valueOf(long newnum,
long newdenom)
Construct a rational from two longs.
|
$div, $minus, $plus, $times, $up, and, apply, apply, asType, compareTo, conjugate, copy, dec, divide, egcd, evalComplex, evalDouble, evalNumber, evalSignedNumber, factory, fullFormString, gcd, getAt, inc, internalFormString, internalJavaString, internalScalaString, leafCount, leaves, minus, mod, multiply, negative, optional, or, power, power, remainder, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceRepeated, replaceSlots, signum, subtract, sum, topHead, toScript, toScriptFactory, variables2Slots
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
div, divideAndRemainder, getBigDenominator, getBigNumerator, getRational, normalize
add, ceil, compareInt, equalsFraction, floor, getFraction, multiply
doubleValue, isNegative, isPositive, isZero, round, toInt, toLong
compareAbsValueToOne, complexNumValue, conjugate
$div, $minus, $plus, $times, $up, and, apply, apply, asType, compareTo, dec, divide, evalComplex, evalDouble, evalNumber, evalSignedNumber, evaluateHead, fullFormString, getAt, getField, ifPresent, inc, internalFormString, internalJavaString, internalScalaString, isAllExpanded, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isBlank, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConstant, isCos, isCosh, isDerivative, isDirectedInfinity, isE, isExpanded, isFalse, isFlatAST, isFraction, isFree, isFree, isFree, isFreeAST, isFreeAST, isFreeOfPatterns, isFunction, isGEOrdered, isGTOrdered, isIndeterminate, isInfinity, isInteger, isIntegerResult, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegativeInfinity, isNegativeResult, isNonNegativeResult, isNot, isNumber, isNumEqualInteger, isNumeric, isNumericFunction, isNumericMode, isNumIntValue, isOne, isONE, isOr, isOrderlessAST, isPattern, isPatternDefault, isPatternExpr, isPatternSequence, isPi, isPlus, isPlusTimesPower, isPolynomial, isPolynomial, isPolynomialOfMaxDegree, isPositiveResult, isPower, isPresent, isRational, isRationalResult, isRealResult, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSymbol, isTan, isTanh, isTimes, isTrue, isUnit, isValue, isVariable, isVector, isZERO, leafCount, leaves, minus, mod, multiply, multiply, negative, ofNullable, optional, or, orElse, orElseGet, orElseThrow, power, power, reciprocal, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceSlots, signum, subtract, sum, timesDistributed, topHead, variables2Slots
public static final FractionSym ZERO
public static final FractionSym ONE
public static final FractionSym MONE
public static java.math.BigInteger gcd(java.math.BigInteger i1, java.math.BigInteger i2)
public static IFraction valueOf(org.apache.commons.math4.fraction.BigFraction fraction)
public static IFraction valueOf(java.math.BigInteger num)
public static IFraction valueOf(java.math.BigInteger num, java.math.BigInteger den)
num
- Numeratorden
- Denominatorpublic static IFraction valueOf(double value)
public static IFraction valueOf(long newnum, long newdenom)
newnum
- Numerator.newdenom
- Denominator.public abstract IFraction abs()
public <T> T accept(IVisitor<T> visitor)
public boolean accept(IVisitorBoolean visitor)
boolean
public int accept(IVisitorInt visitor)
int
public long accept(IVisitorLong visitor)
long
public ApcomplexNum apcomplexNumValue(long precision)
INumber
Apcomplex
number wrapped into an
ApcomplexNum
object.apcomplexNumValue
in interface INumber
precision
- set the precision of the resulting ApcomplexNumpublic org.apfloat.Apcomplex apcomplexValue(long precision)
public ApfloatNum apfloatNumValue(long precision)
ISignedNumber
Apfloat
number wrapped into an ApfloatNum
object.apfloatNumValue
in interface ISignedNumber
precision
- set the precision of the resulting ApfloatNumpublic abstract IFraction ceilFraction()
INumber
IInteger
value that is not less than this
and is equal to a
mathematical integer. This method raises ArithmeticException
if a
numeric value cannot be represented by an long
type.ceilFraction
in interface INumber
IInteger
value that is not less than this
and is equal to a
mathematical integer.public int complexSign()
complexSign
in interface INumber
this == 0
; +1 for
real(this) > 0
or
( real(this)==0 && imaginary(this) > 0 )
;
-1 for real(this) < 0 || ( real(this) == 0 &&
imaginary(this) < 0 )
public ISignedNumber divideBy(ISignedNumber that)
this
signed number by that
signed number.divideBy
in interface ISignedNumber
that
- a signed numberpublic IExpr eabs()
INumber
public boolean equalsInt(int i)
INumber
int
number?public IExpr evaluate(EvalEngine engine)
public IAST factorInteger()
IRational
factorInteger(-4) ==> {{-1,1},{2,2}}
factorInteger
in interface IRational
public abstract IFraction floorFraction()
INumber
IInteger
value that is not greater than this
and is equal to a
mathematical integer. ArithmeticException
if a numeric value cannot
be represented by an long
type.floorFraction
in interface INumber
IInteger
value that is not greater than this
and is equal to
a mathematical integer.public IInteger getDenominator()
getDenominator
in interface IRational
public ISignedNumber getIm()
INumber
public IInteger getNumerator()
getNumerator
in interface IRational
public ISignedNumber getRe()
INumber
public ISymbol head()
ExprImpl
IAST
get the first element
(offset 0) of the IAST
list (i.e. get(0) ).public int hierarchy()
IExpr
public abstract IFraction inverse()
ExprImpl
this.times(this.inverse()) == ONE
, with ONE
being the multiplicative identity. Calculates
F.eval(F.Power(this, F.CN1))
in the common case and uses a
specialized implmentation for derived number classes.public boolean isGreaterThan(ISignedNumber obj)
ISignedNumber
this
signed number is greater than
that signed number..isGreaterThan
in interface ISignedNumber
this > that
public abstract boolean isIntegral()
true
iff value is integral.public boolean isLessThan(ISignedNumber obj)
ISignedNumber
this
signed number is less than
that signed number..isLessThan
in interface ISignedNumber
this < that
public boolean isNumEqualRational(IRational value) throws java.lang.ArithmeticException
IRational
value. The
value of an IInteger
, IFraction
or the value of
an INum
object can be equal to value
.isNumEqualRational
in interface IExpr
java.lang.ArithmeticException
IExpr.isRational()
public boolean isRationalValue(IRational value)
value
in symbolic or numeric
mode.isRationalValue
in interface IExpr
public abstract IFraction negate()
ExprImpl
negate
in interface edu.jas.structure.AbelianGroupElem<IExpr>
negate
in interface org.apache.commons.math4.FieldElement<IExpr>
negate
in interface IFraction
negate
in interface IRational
negate
in interface ISignedNumber
negate
in class ExprImpl
public INumber numericNumber()
IBigNumber
numericNumber
in interface IBigNumber
public Num numValue()
ISignedNumber
Num
object.numValue
in interface ISignedNumber
public ISignedNumber opposite()
ExprImpl
IExpr
whose value is (-1) * this
.
Calculates F.eval(F.Times(F.CN1, this))
in the common case
and uses a specialized implementation for derived number classes.opposite
in interface IExpr
opposite
in interface INumber
opposite
in interface ISignedNumber
opposite
in class ExprImpl
IExpr.negative()
public IExpr plus(IExpr that)
ExprImpl
IExpr
whose value is (this + that)
.
Calculates F.eval(F.Plus(this, that))
in the common case and
uses a specialized implementation for derived number classes.public final IFraction pow(long n) throws java.lang.ArithmeticException
public int sign()
sign
in interface ISignedNumber
public IFraction subdiv(IFraction s, FractionSym d)
(this-s)/d
.public ISignedNumber subtractFrom(ISignedNumber that)
that
signed number from this
signed numbersubtractFrom
in interface ISignedNumber
that
- a signed numberpublic IExpr times(IExpr that)
IExpr
whose value is (this * that)
.
Calculates F.eval(F.Times(this, that))
in the common case
and uses a specialized implementation for derived number classes.public double getImaginary()
INumber
getImaginary
in interface INumber