org.matheclipse.core.expression
Class Num
- java.lang.Object
-
- org.matheclipse.core.expression.ExprImpl
-
- org.matheclipse.core.expression.Num
-
- All Implemented Interfaces:
- AbelianGroupElem<IExpr>, Element<IExpr>, MonoidElem<IExpr>, RingElem<IExpr>, java.io.Serializable, java.lang.Comparable<IExpr>, IExpr, INum, INumber, ISignedNumber
public class Num extends ExprImpl implements INum
- 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 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 typeintINumadd(INum val)IIntegerceil()Returns the smallest (closest to negative infinity)IIntegervalue that is not less thanthisand is equal to a mathematical integer.intcompareTo(double that)intcompareTo(IExpr obj)Compares this expression with the specified expression for order.intcomplexSign()Gets the signum value of a complex numberdoubledivide(double that)ISignedNumberdivideBy(ISignedNumber that)Dividethissigned number bythatsigned number.doubledoubleValue()Numeabs()Get the absolute value for a given numberbooleanequals(java.lang.Object arg0)Test if this is equal to b.booleanequalsInt(int i)Is this number equal an integer number?doubleexp()IIntegerfloor()Returns the largest (closest to positive infinity)IIntegervalue that is not greater thanthisand is equal to a mathematical integer.ISignedNumbergetIm()Returns the imaginary part of a complex numberISignedNumbergetRe()Returns the real part of a complex numberdoublegetRealPart()inthashCode()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 expressionintintValue()Returns the value of this number as anint(by simply casting to typeint).ISignedNumberinverse()Returns the multiplicative inverse of this object.booleanisGreaterThan(ISignedNumber that)booleanisInfinite()booleanisLessThan(ISignedNumber that)booleanisMinusOne()Test if this expression equals-1in symbolic or numeric mode.booleanisNaN()booleanisNegative()Test if this object is a negative signed number.booleanisNumEqualInteger(IInteger ii)Check if this expression equals anIIntegervalue.booleanisNumIntValue()Check if this expression represents anintvalue.booleanisOne()Test if this expression equals1in symbolic or numeric mode.booleanisPositive()Test if this object is a positive signed number.booleanisSame(IExpr expression, double epsilon)Test if this expression equals the given expression.booleanisZero()Test if this expression equals0in symbolic or numeric mode.doublelog()longlongValue()doubleminus(double that)INummultiply(INum val)ISignedNumbernegate()Negate this.ISignedNumberopposite()doubleplus(double that)IExprplus(IExpr that)doublepow(double that)doublepow(int exp)INumpow(INum val)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).doublesqrt()ISignedNumbersubtractFrom(ISignedNumber that)Subtractthatsigned number fromthissigned numberdoubletimes(double that)IExprtimes(IExpr that)Returns the product of this object with the one specified.inttoInt()Converts this double value to anintvalue; unlikeINum.intValue()this method raisesArithmeticExceptionif this integer 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 NumvalueOf(double doubleValue)static doublevalueOf(java.lang.String chars)-
Methods inherited from class org.matheclipse.core.expression.ExprImpl
abs, and, apply, apply, asType, copy, divide, egcd, evaluate, factory, fullFormString, gcd, getAt, internalFormString, 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, isModule, isNegativeInfinity, isNot, isNumber, isNumeric, isNumericFunction, isONE, isOr, isOrderlessAST, isPattern, isPatternExpr, isPatternSequence, isPlus, isPower, isRational, isRealFunction, isRuleAST, 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, evaluate, fullFormString, getAt, internalFormString, 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, isModule, isNegativeInfinity, isNot, isNumber, isNumeric, isNumericFunction, isOr, isOrderlessAST, isPattern, isPatternExpr, isPatternSequence, isPlus, isPower, isRational, isRealFunction, isRuleAST, 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
-
hierarchy
public int hierarchy()
Description copied from interface:IExprA unique integer ID for the implementation of this expression
-
isNumEqualInteger
public boolean isNumEqualInteger(IInteger ii) throws java.lang.ArithmeticException
Check if this expression equals anIIntegervalue. The value of anINumor the value of anIIntegerobject can be anIIntegervalue.- Specified by:
isNumEqualIntegerin interfaceIExpr- Overrides:
isNumEqualIntegerin classExprImpl- Returns:
- Throws:
java.lang.ArithmeticException
-
isNumIntValue
public boolean isNumIntValue()
Check if this expression represents anintvalue. The value of anINumobject can be anintvalue.- Specified by:
isNumIntValuein interfaceIExpr- Specified by:
isNumIntValuein interfaceINum- Overrides:
isNumIntValuein classExprImpl- Returns:
-
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.
-
equalsInt
public boolean equalsInt(int i)
Description copied from interface:INumberIs this number equal an integer number?
-
valueOf
public static double valueOf(java.lang.String chars)
- Parameters:
chars-- Returns:
-
valueOf
public static Num valueOf(double doubleValue)
- Parameters:
doubleValue-- Returns:
-
eabs
public Num eabs()
Description copied from interface:INumberGet the absolute value for a given number
-
plus
public double plus(double that)
- Parameters:
that-- Returns:
-
divideBy
public ISignedNumber divideBy(ISignedNumber that)
Description copied from interface:ISignedNumberDividethissigned number bythatsigned number.- Specified by:
divideByin interfaceISignedNumber- Parameters:
that- a signed number- Returns:
-
subtractFrom
public ISignedNumber subtractFrom(ISignedNumber that)
Description copied from interface:ISignedNumberSubtractthatsigned number fromthissigned number- Specified by:
subtractFromin interfaceISignedNumber- Parameters:
that- a signed number- Returns:
-
compareTo
public int compareTo(double that)
- Parameters:
that-- Returns:
-
divide
public double divide(double that)
- Parameters:
that-- Returns:
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein interfaceISignedNumber- Returns:
-
equals
public boolean equals(java.lang.Object arg0)
Description copied from interface:ElementTest if this is equal to b.
-
isSame
public boolean isSame(IExpr expression, double epsilon)
Description copied from interface:IExprTest if this expression equals the given expression. If the compared expressions are of the same numeric type, they are equal to a given EPSILON
-
exp
public double exp()
-
hashCode
public final int hashCode()
Description copied from interface:ElementHashcode of this Element.
-
intValue
public int intValue()
Description copied from interface:INumReturns the value of this number as anint(by simply casting to typeint).
-
toInt
public int toInt() throws java.lang.ArithmeticExceptionConverts this double value to anintvalue; unlikeINum.intValue()this method raisesArithmeticExceptionif this integer cannot be represented by aninttype.- Specified by:
toIntin interfaceINum- 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.
-
isInfinite
public boolean isInfinite()
- Returns:
-
isNaN
public boolean isNaN()
- Returns:
-
log
public double log()
- Returns:
-
longValue
public long longValue()
- Returns:
-
times
public double times(double that)
- Parameters:
that-- Returns:
-
times
public IExpr times(IExpr that)
Description copied from interface:IExprReturns the product of this object with the one specified.
-
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()
-
pow
public double pow(double that)
- Parameters:
that-- Returns:
-
pow
public double pow(int exp)
- Parameters:
exp-- Returns:
-
inverse
public ISignedNumber inverse()
Description copied from interface:IExprReturns 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.
-
sqrt
public double sqrt()
- Returns:
-
minus
public double minus(double that)
- Parameters:
that-- Returns:
-
getRealPart
public double getRealPart()
- Specified by:
getRealPartin interfaceINum- Returns:
-
isZero
public boolean isZero()
Description copied from interface:IExprTest if this expression equals0in symbolic or numeric mode.
-
isOne
public boolean isOne()
Description copied from interface:IExprTest if this expression equals1in symbolic or numeric mode.
-
isMinusOne
public boolean isMinusOne()
Description copied from interface:IExprTest if this expression equals-1in symbolic or numeric mode.- Specified by:
isMinusOnein interfaceIExpr- Overrides:
isMinusOnein classExprImpl
-
round
public IInteger round()
Description copied from interface:ISignedNumberReturns 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.
-
sign
public int sign()
Description copied from interface:ISignedNumberReturns 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.
-
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 that)
- Specified by:
isLessThanin interfaceISignedNumber
-
isGreaterThan
public boolean isGreaterThan(ISignedNumber that)
- 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) ).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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