org.matheclipse.core.expression
Class IntegerSym
- java.lang.Object
-
- org.matheclipse.core.expression.ExprImpl
-
- org.matheclipse.core.expression.IntegerSym
-
- All Implemented Interfaces:
- AbelianGroupElem<IExpr>, Element<IExpr>, MonoidElem<IExpr>, RingElem<IExpr>, java.io.Serializable, java.lang.Comparable<IExpr>, IBigNumber, IExpr, IInteger, INumber, IRational, ISignedNumber
public class IntegerSym extends ExprImpl implements IInteger
IInteger implementation which simply delegates most of the methods to the BigInteger methods- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static java.math.BigIntegerBI_MINUS_ONEThe BigInteger constant minus one.-
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 typeintIIntegeradd(IInteger val)IntegerSymadd(IntegerSym that)intbitLength()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.intcompareTo(IntegerSym that)intcomplexSign()Gets the signum value of a complex numberjava.math.BigIntegerdivide(java.math.BigInteger that)java.math.BigIntegerdivide(long val)IntegerSym[]divideAndRemainder(IntegerSym that)ISignedNumberdivideBy(ISignedNumber that)Dividethissigned number bythatsigned number.doubledoubleValue()IntegerSymeabs()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?IIntegereulerPhi()IExprevaluate(EvalEngine engine)Evaluate an expressionIASTfactorInteger()java.util.List<IInteger>factorize()Get the factors of this integerIIntegerfloor()Returns the largest (closest to positive infinity)IIntegervalue that is not greater thanthisand is equal to a mathematical integer.IIntegergcd(IInteger that)Returns the greatest common divisor of this large integer and the one specified.IntegerSymgcd(IntegerSym that)Returns the greatest common divisor of this large integer and the one specified.java.math.BigIntegergetBigNumerator()Returns the numerator of this Rational.IIntegergetDenominator()Returns the denominator of this fraction.BigFractiongetFraction()Returns this number asBigFractionnumber.ISignedNumbergetIm()Returns the imaginary part of a complex numberIIntegergetNumerator()Returns the numerator of this fraction.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.intintValue()Converts this large integer toint; unlikeISignedNumber.toInt()this method raises no exception, if this integer cannot be represented by aninttype.ISignedNumberinverse()Returns the multiplicative inverse of this object.booleanisEven()booleanisGreaterThan(ISignedNumber obj)booleanisLargerThan(java.math.BigInteger that)booleanisLessThan(ISignedNumber obj)booleanisMinusOne()Test if this expression equals-1in symbolic or numeric mode.booleanisNegative()Test if this object is a negative signed number.booleanisNumEqualInteger(IInteger ii)Check if this expression equals anIIntegervalue.booleanisOdd()booleanisOne()Test if this expression equals1in symbolic or numeric mode.booleanisPositive()Test if this object is a positive signed number.booleanisZero()Test if this expression equals0in symbolic or numeric mode.IntegerSymjacobiSymbol(IntegerSym b)IIntegerlcm(IInteger that)Returns the least common multiple of this large integer and the one specified.IntegerSymlcm(IntegerSym that)Returns the least common multiple of this large integer and the one specified.longlongValue()IntegerSymmod(IntegerSym that)IntegerSymmodInverse(IntegerSym m)IntegerSymmodPow(IntegerSym exp, IntegerSym m)IntegerSymmoebiusMu()IIntegermultiply(IInteger val)Multiply this integer with valueIntegerSymmultiply(IntegerSym that)java.math.BigIntegermultiply(long val)ISignedNumbernegate()Negate this.IIntegernthRoot(int n)Returns the nth-root of this integer.IInteger[]nthRootSplit(int n)Split this integer into the nth-root (with prime factors less equal 1021) and the "rest-factor", so thatthis== (nth-root)^n + restINumbernumericNumber()Create a numeric number from this exact "symbolic" number.ISignedNumberopposite()IExprplus(IExpr that)IntegerSympow(int exp)IInteger[]primitiveRoots()The primitive roots of this integer numberIntegerSymquotient(IntegerSym that)IIntegerround()Returns the closestIIntegerto the argument.java.math.BigIntegershiftLeft(int n)java.math.BigIntegershiftRight(int n)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).IIntegersqrt()Returns the integer square root of this integer.java.math.BigIntegersubtract(java.math.BigInteger that)IIntegersubtract(IInteger that)ISignedNumbersubtractFrom(ISignedNumber that)Subtractthatsigned number fromthissigned numberIExprtimes(IExpr that)Returns the product of this object with the one specified.byte[]toByteArray()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 IntegerSymvalueOf(java.math.BigInteger bigInteger)static IntegerSymvalueOf(long value)static IntegerSymvalueOf(java.lang.String integerString, int radix)Returns the IntegerImpl for the specified character sequence stated in the specified radix.-
Methods inherited from class org.matheclipse.core.expression.ExprImpl
abs, and, apply, apply, asType, copy, divide, egcd, factory, fullFormString, 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, isModule, isNegativeInfinity, isNot, isNumber, 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, 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, fullFormString, 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, isModule, isNegativeInfinity, isNot, isNumber, isNumeric, isNumericFunction, isNumIntValue, 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
-
-
-
-
Field Detail
-
BI_MINUS_ONE
public static final java.math.BigInteger BI_MINUS_ONE
The BigInteger constant minus one.
-
-
Method Detail
-
valueOf
public static IntegerSym valueOf(long value)
-
valueOf
public static IntegerSym valueOf(java.lang.String integerString, int radix)
Returns the IntegerImpl for the specified character sequence stated in the specified radix. The characters must all be digits of the specified radix, except the first character which may be a plus sign'+'or a minus sign'-'.- Parameters:
chars- the character sequence to parse.radix- the radix to be used while parsing.- Returns:
- the corresponding large integer.
- Throws:
java.lang.NumberFormatException- if the specified character sequence does not contain a parsable large integer.
-
equalsInt
public boolean equalsInt(int i)
Description copied from interface:INumberIs this number equal an integer number?
-
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:
-
hierarchy
public int hierarchy()
Description copied from interface:IExprA unique integer ID for the implementation of this expression
-
multiply
public IInteger multiply(IInteger val)
Description copied from interface:IIntegerMultiply this integer with value
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:ElementTest if this is equal to b.
-
valueOf
public static IntegerSym valueOf(java.math.BigInteger bigInteger)
- Parameters:
bigInteger-- Returns:
-
eabs
public IntegerSym eabs()
Description copied from interface:INumberGet the absolute value for a given number
-
add
public IntegerSym add(IntegerSym that)
- Parameters:
that-- Returns:
-
bitLength
public int bitLength()
- Returns:
-
divide
public java.math.BigInteger divide(long val)
- Parameters:
val-- Returns:
-
divide
public java.math.BigInteger divide(java.math.BigInteger that)
- Parameters:
that-- Returns:
-
quotient
public IntegerSym quotient(IntegerSym that)
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein interfaceISignedNumber- Returns:
-
gcd
public IntegerSym gcd(IntegerSym that)
Returns the greatest common divisor of this large integer and the one specified.
-
gcd
public IInteger gcd(IInteger that)
Returns the greatest common divisor of this large integer and the one specified.
-
lcm
public IntegerSym lcm(IntegerSym that)
Returns the least common multiple of this large integer and the one specified.
-
lcm
public IInteger lcm(IInteger that)
Returns the least common multiple of this large integer and the one specified.
-
hashCode
public final int hashCode()
Hashcode of this Element.
-
isLargerThan
public boolean isLargerThan(java.math.BigInteger that)
- Parameters:
that-- 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.
-
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
-
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.
-
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
-
intValue
public int intValue()
Description copied from interface:IIntegerConverts this large integer toint; unlikeISignedNumber.toInt()this method raises no exception, if this integer cannot be represented by aninttype.
-
mod
public IntegerSym mod(IntegerSym that)
-
multiply
public IntegerSym multiply(IntegerSym that)
- Parameters:
that-- Returns:
-
multiply
public java.math.BigInteger multiply(long val)
- Parameters:
val-- 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)
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:
-
pow
public IntegerSym pow(int exp)
-
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:
-
shiftLeft
public java.math.BigInteger shiftLeft(int n)
- Parameters:
n-- Returns:
-
shiftRight
public java.math.BigInteger shiftRight(int n)
- Parameters:
n-- Returns:
-
subtract
public java.math.BigInteger subtract(java.math.BigInteger that)
- Parameters:
that-- Returns:
-
times
public IExpr times(IExpr that)
Description copied from interface:IExprReturns the product of this object with the one specified.
-
toByteArray
public byte[] toByteArray()
-
getBigNumerator
public java.math.BigInteger getBigNumerator()
Returns the numerator of this Rational.- Specified by:
getBigNumeratorin interfaceIInteger- Returns:
- numerator
-
getNumerator
public IInteger getNumerator()
Returns the numerator of this fraction.- Specified by:
getNumeratorin interfaceIRational- Returns:
- denominator
-
getDenominator
public IInteger getDenominator()
Returns the denominator of this fraction.- Specified by:
getDenominatorin interfaceIRational- Returns:
- denominator
-
getFraction
public BigFraction getFraction()
Returns this number asBigFractionnumber.- Specified by:
getFractionin interfaceIRational- Returns:
thisnumber s big fraction.
-
factorize
public java.util.List<IInteger> factorize()
Get the factors of this integer- Returns:
-
factorInteger
public IAST factorInteger()
-
eulerPhi
public IInteger eulerPhi() throws java.lang.ArithmeticException
- Throws:
java.lang.ArithmeticException
-
moebiusMu
public IntegerSym moebiusMu()
-
jacobiSymbol
public IntegerSym jacobiSymbol(IntegerSym b)
-
primitiveRoots
public IInteger[] primitiveRoots() throws java.lang.ArithmeticException
The primitive roots of this integer number- Returns:
- the primitive roots
- Throws:
java.lang.ArithmeticException
-
compareTo
public int compareTo(IntegerSym that)
-
divideAndRemainder
public IntegerSym[] divideAndRemainder(IntegerSym that)
-
modInverse
public IntegerSym modInverse(IntegerSym m)
-
modPow
public IntegerSym modPow(IntegerSym exp, IntegerSym m)
-
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.
-
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;
-
sqrt
public IInteger sqrt() throws java.lang.ArithmeticException
Returns the integer square root of this integer.- Returns:
ksuch ask^2 <= this < (k + 1)^2- Throws:
java.lang.ArithmeticException- if this integer is negative.
-
nthRoot
public IInteger nthRoot(int n) throws java.lang.ArithmeticException
Returns the nth-root of this integer.
-
nthRootSplit
public IInteger[] nthRootSplit(int n) throws java.lang.ArithmeticException
Split this integer into the nth-root (with prime factors less equal 1021) and the "rest-factor", so thatthis== (nth-root)^n + rest- Specified by:
nthRootSplitin interfaceIInteger- Returns:
{nth-root, rest}- Throws:
java.lang.ArithmeticException
-
complexSign
public int complexSign()
Description copied from interface:INumberGets 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()
Description copied from interface:ISignedNumberReturns 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()
Description copied from interface:ISignedNumberReturns 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()
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.
-
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) ).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
internalFormString
public java.lang.String internalFormString(boolean symbolsAsFactoryMethod, int depth)Description copied from interface:IExprReturn 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".
-
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