org.matheclipse.core.expression
Class FractionSym
- java.lang.Object
-
- org.matheclipse.core.expression.ExprImpl
-
- org.matheclipse.core.expression.FractionSym
-
- All Implemented Interfaces:
- AbelianGroupElem<IExpr>, Element<IExpr>, MonoidElem<IExpr>, RingElem<IExpr>, java.io.Serializable, java.lang.Comparable<IExpr>, IBigNumber, IExpr, IFraction, INumber, IRational, ISignedNumber
public class FractionSym extends ExprImpl implements IFraction
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.matheclipse.core.interfaces.IExpr
ASTID, COMPLEXID, DOUBLECOMPLEXID, DOUBLEID, FRACTIONID, INTEGERID, METHODSYMBOLID, PATTERNID, STRINGID, SYMBOLID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description <T> Taccept(IVisitor<T> visitor)Accept a visitor with return type Tbooleanaccept(IVisitorBoolean visitor)Accept a visitor with return typebooleanintaccept(IVisitorInt visitor)Accept a visitor with return typeintBigFractionadd(BigFraction that)IFractionadd(IFraction parm1)IIntegerceil()Returns the smallest (closest to negative infinity)IIntegervalue that is not less thanthisand is equal to a mathematical integer.intcompareTo(IExpr obj)Compares this expression with the specified expression for order.intcomplexSign()Gets the signum value of a complex numberBigFractiondivide(BigFraction that)ISignedNumberdivideBy(ISignedNumber that)Dividethissigned number bythatsigned number.doubledoubleValue()FractionSymeabs()Get the absolute value for a given numberbooleanequals(java.lang.Object obj)Test if this is equal to b.booleanequalsInt(int i)Is this number equal an integer number?IExprevaluate(EvalEngine engine)Evaluate an expressionIIntegerfloor()Returns the largest (closest to positive infinity)IIntegervalue that is not greater thanthisand is equal to a mathematical integer.java.lang.StringfullFormString()Return the FullForm of this expressionjava.math.BigIntegergetBigDenominator()Returns the denominator of this fraction.java.math.BigIntegergetBigNumerator()Returns the numerator of this fraction.IIntegergetDenominator()Returns the denominator of this fraction.java.math.BigIntegergetDividend()java.math.BigIntegergetDivisor()BigFractiongetFraction()Returns this number asBigFractionnumber.ISignedNumbergetIm()Returns the imaginary part of a complex numberIIntegergetNumerator()Returns the numerator of this Rational.BigFractiongetRational()ISignedNumbergetRe()Returns the real part of a complex numberinthashCode()Hashcode of this Element.ISymbolhead()If this object is an instance ofIASTget the first element (offset 0) of theIASTlist (i.e.inthierarchy()A unique integer ID for the implementation of this expressionjava.lang.StringinternalFormString(boolean symbolsAsFactoryMethod, int depth)Return the internal Java form of this expression.ISignedNumberinverse()Returns the multiplicative inverse of this object.booleanisGreaterThan(ISignedNumber obj)booleanisLessThan(ISignedNumber obj)booleanisNegative()Test if this object is a negative signed number.booleanisPositive()Test if this object is a positive signed number.booleanisZero()Test if this expression equals0in symbolic or numeric mode.longlongValue()BigFractionmultiply(BigFraction that)IFractionmultiply(IFraction parm1)ISignedNumbernegate()Negate this.INumbernormalize()Return the normalized form of this number (i.e.INumbernumericNumber()Create a numeric number from this exact "symbolic" number.ISignedNumberopposite()IExprplus(IExpr that)IFractionpow(int exp)Returns this number raised at the specified positive exponent.IIntegerround()Returns the closestIIntegerto the argument.intsign()Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive).BigFractionsubtract(BigFraction that)ISignedNumbersubtractFrom(ISignedNumber that)Subtractthatsigned number fromthissigned numberIExprtimes(IExpr that)Returns the product of this object with the one specified.inttoInt()Converts this number toint; unlike#intValuethis method raisesArithmeticExceptionif this number cannot be represented by aninttype.longtoLong()Converts this number tolong; unlike#longValuethis method raisesArithmeticExceptionif this number cannot be represented by anlongtype.java.lang.StringtoString()static FractionSymvalueOf(BigFraction rat)Deprecated.static FractionSymvalueOf(java.math.BigInteger numerator)static FractionSymvalueOf(java.math.BigInteger numerator, java.math.BigInteger denominator)static FractionSymvalueOf(double value)static FractionSymvalueOf(IInteger numerator, IInteger denominator)static FractionSymvalueOf(long numerator, long denominator)-
Methods inherited from class org.matheclipse.core.expression.ExprImpl
abs, and, apply, apply, asType, copy, divide, egcd, factory, gcd, getAt, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConstant, isCos, isCosh, isDirectedInfinity, isFalse, isFlatAST, isFraction, isFree, isFree, isFunction, isGEOrdered, isGTOrdered, isInfinity, isInteger, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegativeInfinity, isNot, isNumber, isNumEqualInteger, isNumeric, isNumericFunction, isNumIntValue, isOne, isONE, isOr, isOrderlessAST, isPattern, isPatternExpr, isPatternSequence, isPlus, isPower, isRational, isRealFunction, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSymbol, isTan, isTanh, isTimes, isTrue, isUnit, isValue, isVector, isZERO, leaves, minus, mod, multiply, negative, or, power, power, remainder, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceRepeated, replaceSlots, signum, subtract, sum, topHead, toScript, toScriptFactory, variables2Slots
-
Methods inherited from interface org.matheclipse.core.interfaces.IExpr
and, apply, apply, asType, getAt, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAST, isAST, isAST, isAST, isAST, isAST, isASTSizeGE, isAtom, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConstant, isCos, isCosh, isDirectedInfinity, isFalse, isFlatAST, isFraction, isFree, isFree, isFunction, isGEOrdered, isGTOrdered, isInfinity, isInteger, isLEOrdered, isList, isListOfLists, isLog, isLTOrdered, isMatrix, isMember, isMember, isMinusOne, isModule, isNegativeInfinity, isNot, isNumber, isNumEqualInteger, isNumeric, isNumericFunction, isNumIntValue, isOne, isOr, isOrderlessAST, isPattern, isPatternExpr, isPatternSequence, isPlus, isPower, isRational, isRealFunction, isRuleAST, isSame, isSame, isSequence, isSignedNumber, isSin, isSinh, isSlot, isSlotSequence, isSymbol, isTan, isTanh, isTimes, isTrue, isValue, isVector, leaves, minus, mod, multiply, negative, or, power, power, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceSlots, signum, topHead, variables2Slots
-
Methods inherited from interface edu.jas.structure.AbelianGroupElem
abs, isZERO, subtract, sum
-
Methods inherited from interface edu.jas.structure.MonoidElem
divide, isONE, isUnit, remainder
-
Methods inherited from interface edu.jas.structure.Element
copy, factory, toScript, toScriptFactory
-
-
-
-
Method Detail
-
valueOf
public static FractionSym valueOf(java.math.BigInteger numerator)
-
valueOf
@Deprecated public static FractionSym valueOf(BigFraction rat)
Deprecated.- Parameters:
rat-- Returns:
-
valueOf
public static FractionSym valueOf(java.math.BigInteger numerator, java.math.BigInteger denominator)
-
valueOf
public static FractionSym valueOf(IInteger numerator, IInteger denominator)
-
valueOf
public static FractionSym valueOf(long numerator, long denominator)
-
valueOf
public static FractionSym valueOf(double value)
-
isZero
public boolean isZero()
Test if this expression equals0in symbolic or numeric mode.
-
equalsInt
public boolean equalsInt(int i)
Is this number equal an integer number?
-
getBigDenominator
public java.math.BigInteger getBigDenominator()
Returns the denominator of this fraction.- Specified by:
getBigDenominatorin interfaceIFraction- Returns:
- denominator
-
getBigNumerator
public java.math.BigInteger getBigNumerator()
Returns the numerator of this fraction.- Specified by:
getBigNumeratorin interfaceIFraction- Returns:
- denominator
-
getFraction
public BigFraction getFraction()
Returns this number asBigFractionnumber.- Specified by:
getFractionin interfaceIRational- Returns:
thisnumber s big fraction.
-
getDenominator
public IInteger getDenominator()
Returns the denominator of this fraction.- Specified by:
getDenominatorin interfaceIRational- Returns:
- denominator
-
getNumerator
public IInteger getNumerator()
Returns the numerator of this Rational.- Specified by:
getNumeratorin interfaceIRational- Returns:
- numerator
-
hierarchy
public int hierarchy()
A unique integer ID for the implementation of this expression
-
isNegative
public boolean isNegative()
Test if this object is a negative signed number.- Specified by:
isNegativein interfaceIExpr- Specified by:
isNegativein interfaceISignedNumber- Overrides:
isNegativein classExprImpl- Returns:
true, ifthis < 0;falsein all other case.
-
isPositive
public boolean isPositive()
Test if this object is a positive signed number.- Specified by:
isPositivein interfaceIExpr- Specified by:
isPositivein interfaceISignedNumber- Overrides:
isPositivein classExprImpl- Returns:
true, ifthis > 0;falsein all other case.
-
eabs
public FractionSym eabs()
Get the absolute value for a given number
-
add
public BigFraction add(BigFraction that)
- Parameters:
that-- Returns:
-
divide
public BigFraction divide(BigFraction that)
- Parameters:
that-- Returns:
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein interfaceISignedNumber- Returns:
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:ElementTest if this is equal to b.
-
evaluate
public IExpr evaluate(EvalEngine engine)
Evaluate an expression
-
numericNumber
public final INumber numericNumber()
Description copied from interface:IBigNumberCreate a numeric number from this exact "symbolic" number.- Specified by:
numericNumberin interfaceIBigNumber- Returns:
-
normalize
public INumber normalize()
Description copied from interface:IFractionReturn the normalized form of this number (i.e. if the denominator part equals one, return the numerator part as an integer number).
-
getDividend
public java.math.BigInteger getDividend()
- Returns:
-
getDivisor
public java.math.BigInteger getDivisor()
- Returns:
-
hashCode
public int hashCode()
Description copied from interface:ElementHashcode of this Element.
-
longValue
public long longValue()
- Returns:
-
multiply
public BigFraction multiply(BigFraction that)
- Parameters:
that-- Returns:
-
negate
public ISignedNumber negate()
Description copied from interface:AbelianGroupElemNegate this.- Specified by:
negatein interfaceAbelianGroupElem<IExpr>- Specified by:
negatein interfaceISignedNumber- Overrides:
negatein classExprImpl- Returns:
-
opposite
public ISignedNumber opposite()
-
divideBy
public ISignedNumber divideBy(ISignedNumber that)
Dividethissigned number bythatsigned number.- Specified by:
divideByin interfaceISignedNumber- Parameters:
that- a signed number- Returns:
-
subtractFrom
public ISignedNumber subtractFrom(ISignedNumber that)
Subtractthatsigned number fromthissigned number- Specified by:
subtractFromin interfaceISignedNumber- Parameters:
that- a signed number- Returns:
-
pow
public IFraction pow(int exp)
Returns this number raised at the specified positive exponent.
-
inverse
public ISignedNumber inverse()
Returns the multiplicative inverse of this object. It is the object such asthis.times(this.inverse()) == ONE, withONEbeing the multiplicative identity.- Specified by:
inversein interfaceMonoidElem<IExpr>- Specified by:
inversein interfaceIExpr- Specified by:
inversein interfaceISignedNumber- Overrides:
inversein classExprImpl- Returns:
ONE / this.
-
subtract
public BigFraction subtract(BigFraction that)
- Parameters:
that-- Returns:
-
internalFormString
public java.lang.String internalFormString(boolean symbolsAsFactoryMethod, int depth)Return the internal Java form of this expression.- Specified by:
internalFormStringin interfaceIExpr- Overrides:
internalFormStringin classExprImpl- Parameters:
symbolsAsFactoryMethod- iftrueuse theF.symbol()method, otherwise print the symbol name.depth- the recursion depth of this call.0indicates "recurse without a limit".
-
toInt
public int toInt() throws java.lang.ArithmeticExceptionConverts this number toint; unlike#intValuethis method raisesArithmeticExceptionif this number cannot be represented by aninttype.- Specified by:
toIntin interfaceISignedNumber- Returns:
- the numeric value represented by this integer after conversion to type
int. - Throws:
java.lang.ArithmeticException- if conversion tointis not possible.
-
toLong
public long toLong() throws java.lang.ArithmeticExceptionConverts this number tolong; unlike#longValuethis method raisesArithmeticExceptionif this number cannot be represented by anlongtype.- Specified by:
toLongin interfaceISignedNumber- Returns:
- the numeric value represented by this integer after conversion to type
long. - Throws:
java.lang.ArithmeticException- if conversion tointis not possible.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fullFormString
public java.lang.String fullFormString()
Description copied from interface:IExprReturn the FullForm of this expression- Specified by:
fullFormStringin interfaceIExpr- Overrides:
fullFormStringin classExprImpl
-
getRational
public BigFraction getRational()
- Specified by:
getRationalin interfaceIFraction
-
sign
public 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).- Specified by:
signin interfaceISignedNumber- Returns:
- -1 if this is a negative number;
0 if this is a zero;
-1 if this is a negative number;
-
complexSign
public int complexSign()
Gets the signum value of a complex number- Specified by:
complexSignin interfaceINumber- Returns:
- 0 for
this == 0; +1 forreal(this) > 0or( real(this)==0 && imaginary(this) > 0 ); -1 forreal(this) < 0 || ( real(this) == 0 && imaginary(this) < 0 )
-
ceil
public IInteger ceil()
Returns the smallest (closest to negative infinity)IIntegervalue that is not less thanthisand is equal to a mathematical integer. This method raisesArithmeticExceptionif a numeric value cannot be represented by anlongtype.- Specified by:
ceilin interfaceISignedNumber- Returns:
- the smallest (closest to negative infinity)
IIntegervalue that is not less thanthisand is equal to a mathematical integer.
-
floor
public IInteger floor()
Returns the largest (closest to positive infinity)IIntegervalue that is not greater thanthisand is equal to a mathematical integer.
This method raisesArithmeticExceptionif a numeric value cannot be represented by anlongtype.- Specified by:
floorin interfaceISignedNumber- Returns:
- the largest (closest to positive infinity)
IIntegervalue that is not greater thanthisand is equal to a mathematical integer.
-
round
public IInteger round()
Returns the closestIIntegerto the argument. The result is rounded to an integer by adding 1/2 and taking the floor of the result.
This method raisesArithmeticExceptionif a numeric value cannot be represented by anlongtype.- Specified by:
roundin interfaceISignedNumber- Returns:
- the closest integer to the argument.
-
compareTo
public int compareTo(IExpr obj)
Compares this expression with the specified expression for order. Returns a negative integer, zero, or a positive integer as this expression is canonical less than, equal to, or greater than the specified expression.
-
isLessThan
public boolean isLessThan(ISignedNumber obj)
- Specified by:
isLessThanin interfaceISignedNumber
-
isGreaterThan
public boolean isGreaterThan(ISignedNumber obj)
- Specified by:
isGreaterThanin interfaceISignedNumber
-
head
public ISymbol head()
Description copied from interface:IExprIf this object is an instance ofIASTget the first element (offset 0) of theIASTlist (i.e. get(0) ).
-
accept
public <T> T accept(IVisitor<T> visitor)
Accept a visitor with return type T
-
accept
public boolean accept(IVisitorBoolean visitor)
Accept a visitor with return typeboolean
-
accept
public int accept(IVisitorInt visitor)
Accept a visitor with return typeint
-
getIm
public ISignedNumber getIm()
Returns the imaginary part of a complex number
-
getRe
public ISignedNumber getRe()
Returns the real part of a complex number
-
-
DMelt 3.0 © DataMelt by jWork.ORG