Package org.matheclipse.core.interfaces
Interface IRational
-
- All Superinterfaces:
edu.jas.structure.AbelianGroupElem<IExpr>
,org.hipparchus.CalculusFieldElement<IExpr>
,Comparable<IExpr>
,edu.jas.structure.Element<IExpr>
,org.hipparchus.FieldElement<IExpr>
,edu.jas.structure.GcdRingElem<IExpr>
,IBigNumber
,IExpr
,INumber
,IReal
,edu.jas.structure.MonoidElem<IExpr>
,edu.jas.structure.RingElem<IExpr>
,Serializable
- All Known Implementing Classes:
AbstractFractionSym
,AbstractIntegerSym
,BigFractionSym
,BigIntegerSym
,FractionSym
,IntegerSym
public interface IRational extends IReal, IBigNumber
Interface for "rational" numbers (i.e. numbers implementing IInteger or IFraction)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.matheclipse.core.interfaces.IExpr
IExpr.COMPARE_TERNARY
-
-
Field Summary
-
Fields inherited from interface org.matheclipse.core.interfaces.IExpr
ASTID, BDDEXPRID, BIOSEQUENCEID, BLANKID, BYTEARRAYID, COMPILEFUNCTONID, COMPLEXID, DATAID, DATASETID, DATEOBJECTEXPRID, DISPATCHID, DOUBLECOMPLEXID, DOUBLEID, FILEEXPRID, FITTEDMODELID, FRACTIONID, GEOPOSITIONID, GRAPHEXPRID, IMAGEID, INPUTSTREAMEXPRID, INTEGERID, INTERPOLATEDFUNCTONID, JAVACLASSEXPRID, JAVAOBJECTEXPRID, LINEARSOLVEUNCTONID, METHODSYMBOLID, NUMERICARRAYID, OUTPUTSTREAMEXPRID, PATTERNID, QUANTITYID, SERIESID, SPARSEARRAYID, STRINGID, SYMBOLID, TESTREPORTOBJECT, TESTRESULTOBJECT, TIMEOBJECTEXPRID
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description IRational
abs()
Get the absolute value for a given numberIRational
add(IRational parm1)
IInteger
ceil()
void
checkBitLength()
int
compareInt(int value)
IRational
dec()
Returns anIExpr
whose value is(this - 1)
.IInteger
denominator()
Returns the denominator of this fraction.IRational
divideBy(IRational parm1)
boolean
equalsFraction(int numerator, int denominator)
Check if this number equals the given fractionnumerator/denominator
number.IASTAppendable
factorInteger()
Return the prime factors paired with their exponents for integer and fractional numbers.IAST
factorSmallPrimes(int numerator, int root)
Factor into small factors below 1021 if possible and determine the root.IInteger
floor()
IRational
fractionalPart()
Return the fractional part of this fractionIRational
gcd(IRational that)
Compute the gcd of two rationals.default IInteger
getDenominator()
Deprecated.usedenominator()
default org.hipparchus.fraction.BigFraction
getFraction()
Deprecated.usetoBigFraction()
default IInteger
getNumerator()
Deprecated.usenumerator()
default IRational
imRational()
Get the imaginary part as rational numberIRational
inc()
Returns anIExpr
whose value is(this + 1)
.IRational
inverse()
Returns the multiplicative inverse of this object.default IRational
mod(IRational m)
Returnsthis mod m
, a non-negative value less than m.IRational
multiply(int n)
IRational
multiply(IRational parm1)
IRational
negate()
Returns (-1) * thisIRational
normalize()
Return the normalized form of this number (i.e.IInteger
numerator()
Returns the numerator of this fraction.IRational
powerRational(long exp)
Returns this number raised at the specified exponent.default IRational
reRational()
Get the real part as rational numberIRational
roundClosest(IReal factor)
Roundthis
number to the closestIReal
multiple of thefactor
.IRational
subtract(IRational parm1)
BigInteger
toBigDenominator()
Returns the denominator of this fraction.org.hipparchus.fraction.BigFraction
toBigFraction()
Returns this number asBigRational
number.BigInteger
toBigNumerator()
Returns the numerator of this fraction.edu.jas.arith.BigRational
toBigRational()
Returns this number asBigRational
number.default IInteger
trunc()
Truncates the integer part in the "direction to 0" asisNegative() ? ceil() : floor()
..-
Methods inherited from interface org.hipparchus.CalculusFieldElement
getExponent, isFinite, isInfinite, isNaN, norm, round
-
Methods inherited from interface org.matheclipse.core.interfaces.IBigNumber
numericNumber
-
Methods inherited from interface org.matheclipse.core.interfaces.IExpr
$div, $minus, $plus, $times, $up, accept, accept, accept, accept, acos, acosh, add, add, addEvalFlags, and, apply, apply, argSize, asBaseExp, asCoeffAdd, asCoeffAdd, asCoeffExponent, asCoeffmul, asCoeffmul, asCoeffmul, asCoeffMul, asin, asinh, asLeadingTerm, asLeadingTerm, asLeadingTerm, asLeadingTerm, asNumerDenom, asPowersDict, asType, atan, atan2, atanh, base, cancel, cbrt, compareTo, compareToNumerical, constantArray, copySign, copySign, copySign, cos, cosh, depth, determinePrecision, divide, divide, egcd, equalsArgs, equalsArgs, equalsAt, equalTernary, equalTo, erf, erfc, eval, eval, evalAsLeadingTerm, evalBinary64, evalComplex, evalDouble, evalf, evalfc, evalNIL, evalNumber, evalReal, evaluate, evaluateHead, evaluateOrElse, exists, exp, expm1, exponent, factory, first, forAll, fresnelC, fresnelS, fullFormString, gaussianIntegers, gcd, getArg, getAt, getField, getOptionalValue, getPi, greater, greaterEqual, greaterEqualThan, greaterEqualThan, greaterThan, greaterThan, has, has, has, has, hasComplexNumber, hasFree, head, headID, hierarchy, hypergeometric0F1, hypergeometric1F1, hypergeometric2F1, hypot, ifPresent, indexOf, indexOf, indexOf, internalFormString, internalJavaString, internalScalaString, intSlot, isAbs, isAllExpanded, isAlternatives, isAnd, isArcCos, isArcCosh, isArcSin, isArcSinh, isArcTan, isArcTanh, isAssociation, isAST, isAST, isAST, isAST, isAST, isAST, isAST, isAST0, isAST1, isAST2, isAST3, isASTOrAssociation, isASTSizeGE, isAtom, isBlank, isBooleanFormula, isBooleanFormulaSymbol, isBooleanFunction, isBooleanResult, isBuiltInSymbol, isBuiltInSymbolID, isComparatorFunction, isComparatorFunctionSymbol, isComplex, isComplexInfinity, isComplexNumeric, isCondition, isConditionalExpression, isConjugate, isConstantAttribute, isContinuousDistribution, isCoreFunctionSymbol, isCos, isCosh, isDataset, isDefer, isDerivative, isDerivativeAST1, isDirectedInfinity, isDirectedInfinity, isDiscreteDistribution, isDistribution, isE, isEdge, isEmpty, isEmptyIntervalData, isEmptyList, isEqual, isEvalFlagOff, isEvalFlagOn, isEvenResult, isExactNumber, isExcept, isExp, isExpanded, isFactorSqrtExpr, isFalse, isFlatAST, isFraction, isFree, isFree, isFree, isFree, isFreeAST, isFreeAST, isFreeOfPatterns, isFunction, isFunctionID, isGEOrdered, isGTOrdered, isHoldAllCompleteAST, isHoldOrHoldFormOrDefer, isHoldPatternOrLiteral, isHyperbolicFunction, isImaginaryUnit, isIndeterminate, isInexactNumber, isInexactVector, isInfinity, isInteger, isIntegerResult, isInterval, isInterval1, isIntervalData, isInvalid, isLEOrdered, isList, isList, isList, isList1, isList2, isList3, isList4, isListableAST, isListOfEdges, isListOfLists, isListOfMatrices, isListOfPoints, isListOfRules, isListOfRules, isListOfRulesOrAssociation, isListOfStrings, isListOrAssociation, isLog, isLTOrdered, isMachineNumber, isMathematicalIntegerNegative, isMathematicalIntegerNonNegative, isMatrix, isMatrix, isMatrixIgnore, isMember, isMember, isMinusOne, isModule, isModuleOrWithCondition, isNegativeImaginaryUnit, isNegativeInfinity, isNegativeSigned, isNIL, isNonEmptyList, isNonZeroComplexResult, isNonZeroRealResult, isNot, isNotDefined, isNotEmpty, isNumberOrInfinity, isNumEqualInteger, isNumEqualRational, isNumeric, isNumericArgument, isNumericArgument, isNumericArray, isNumericAST, isNumericFunction, isNumericFunction, isNumericFunction, isNumericFunction, isNumericMode, isNumIntValue, isOne, isONE, isOneIdentityAST1, isOptional, isOptionsPattern, isOr, isOrderlessAST, isPattern, isPatternDefault, isPatternExpr, isPatternMatchingFunction, isPatternOptional, isPatternSequence, isPatternTest, isPi, isPiecewise, isPlus, isPlus2, isPlus3, isPlusTimesPower, isPolynomial, isPolynomial, isPolynomialOfMaxDegree, isPolynomialStruct, isPossibleZero, isPower, isPowerReciprocal, isPredicateFunctionSymbol, isPresent, isPureFunction, isQuantity, isRational, isRationalResult, isRationalValue, isReal, isRealConstant, isRealMatrix, isRealNumber, isRealResult, isRealVector, isReNegativeResult, isRepeated, isRePositiveResult, isRGBColor, isRule, isRuleAST, isRuleDelayed, isSame, isSame, isSameHeadSizeGE, isSequence, isSin, isSinh, isSlot, isSlotSequence, isSpan, isSparseArray, isSqrt, isSqrtExpr, isString, isString, isStringIgnoreCase, isSubscript, isSymbol, isSymbolOrPattern, isTan, isTanh, isTimes, isTimes2, isTimes3, isTrigFunction, isTrue, isUndefined, isUnequalResult, isUnevaluated, isUnit, isValue, isVariable, isVariable, isVector, isWith, isZERO, isZeroResult, last, leadTerm, leadTerm, leafCount, leafCountSimplify, less, lessEqual, lessEqualThan, lessEqualThan, lessThan, lessThan, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, linearCombination, log, log10, log1p, makeAST, makeList, mapExpr, mapMatrixColumns, mapThread, minus, mod, most, multiply, multiply, multiplyDistributed, negative, newInstance, normal, optional, or, orElse, orElseGet, orElseThrow, partition, partitionPlus, partitionTimes, plus, pow, pow, pow, power, power, reciprocal, remainder, remainder, replaceAll, replaceAll, replaceAll, replacePart, replaceRepeated, replaceRepeated, replaceRepeated, rest, rewrite, rint, rootN, scalb, second, sign, signum, sin, sinCos, sinh, sinhCosh, size, sqr, sqrt, subs, subtract, subtract, sum, tan, tanh, times, timesDistributed, toBooleanMatrix, toBooleanVector, toBooleValueVector, toByteMatrix, toComplexMatrix, toComplexVector, toDegrees, toDoubleDefault, toDoubleDefault, toDoubleMatrix, toDoubleMatrixIgnore, toDoubleVector, toDoubleVectorIgnore, together, toIntDefault, toIntDefault, toIntMatrix, toIntVector, toLongDefault, toLongDefault, toMMA, toNumber, toNumber, topHead, toRadians, toRealMatrix, toRealMatrixIgnore, toRealVector, toScript, toScriptFactory, toWolframString, trigsimp, ulp, unequalTo, variables2Slots
-
Methods inherited from interface org.matheclipse.core.interfaces.INumber
apcomplexNumValue, apcomplexValue, asCoeffAdd, asCoeffmul, asCoeffMul, compareAbsValueToOne, complexNumValue, divide, eabs, equalsInt, evaluatePrecision, getImaginary, getReal, im, imDoubleValue, isNumber, isNumericFunction, isZero, linear, linearPower, plus, rationalFactor, re, reDoubleValue, subtract, times
-
Methods inherited from interface org.matheclipse.core.interfaces.IReal
add, apfloatNumValue, apfloatValue, binary64, ceilFraction, complexArg, complexSign, conjugate, divideBy, doubleValue, evalf, evalfc, floorFraction, integerPart, isGE, isGreaterThan, isGT, isLE, isLessThan, isLT, isNegative, isNegativeResult, isNonNegativeResult, isPositive, isPositiveResult, isRange, isRangeExclExcl, isRangeExclIncl, isRangeInclExcl, isZero, lower, max, min, multiply, numValue, one, opposite, roundExpr, subtractFrom, toInt, toLong, toPolarCoordinates, unitStep, upper, zero
-
-
-
-
Method Detail
-
abs
IRational abs()
Get the absolute value for a given number
-
ceil
IInteger ceil()
-
checkBitLength
void checkBitLength()
-
compareInt
int compareInt(int value)
-
dec
IRational dec()
Description copied from interface:IExpr
Returns anIExpr
whose value is(this - 1)
. CalculatesF.eval(F.Subtract(this, C1))
in the common case and uses a specialized implementation for derived number classes.
-
denominator
IInteger denominator()
Returns the denominator of this fraction.- Returns:
- denominator
-
equalsFraction
boolean equalsFraction(int numerator, int denominator)
Check if this number equals the given fractionnumerator/denominator
number.GCD(numerator, /denominator)
should be 1;- Parameters:
numerator
- the numeratordenominator
- the denominator- Returns:
-
factorInteger
IASTAppendable factorInteger()
Return the prime factors paired with their exponents for integer and fractional numbers. For factors of the denominator part of fractional numbers the exponents are negative.factorInteger(-4) ==> {{-1,1},{2,2}}
- Returns:
- the list of prime factors paired with their exponents
-
factorSmallPrimes
IAST factorSmallPrimes(int numerator, int root)
Factor into small factors below 1021 if possible and determine the root.- Parameters:
numerator
-root
- theroot > 1
which should be determined- Returns:
- the rest of the factorization
-
floor
IInteger floor()
-
fractionalPart
IRational fractionalPart()
Return the fractional part of this fraction- Specified by:
fractionalPart
in interfaceINumber
- Specified by:
fractionalPart
in interfaceIReal
- Returns:
-
gcd
IRational gcd(IRational that)
Compute the gcd of two rationals. The gcd is the rational number, such that dividing this and other with the gcd will yield two co-prime integers.- Parameters:
that
- the second rational argument.- Returns:
- the gcd of this and other.
-
getDenominator
@Deprecated default IInteger getDenominator()
Deprecated.usedenominator()
Returns the denominator of this fraction.- Returns:
- denominator
-
getFraction
@Deprecated default org.hipparchus.fraction.BigFraction getFraction()
Deprecated.usetoBigFraction()
Returns this number asBigFraction
number.- Returns:
this
number s big fraction.
-
getNumerator
@Deprecated default IInteger getNumerator()
Deprecated.usenumerator()
Returns the numerator of this fraction.- Returns:
-
imRational
default IRational imRational()
Description copied from interface:IBigNumber
Get the imaginary part as rational number- Specified by:
imRational
in interfaceIBigNumber
- Returns:
-
inc
IRational inc()
Description copied from interface:IExpr
Returns anIExpr
whose value is(this + 1)
. CalculatesF.eval(F.Plus(this, C1))
in the common case and uses a specialized implementation for derived number classes.
-
inverse
IRational inverse()
Returns the multiplicative inverse of this object. It is the object such asthis.times(this.inverse()) == ONE
, withONE
being the multiplicative identity. CalculatesF.eval(F.Power(this, F.CN1))
in the common case and uses a specialized implmentation for derived number classes.
-
mod
default IRational mod(IRational m)
Returnsthis mod m
, a non-negative value less than m. This differs fromthis % m
, which might be negative. For example:mod(7, 4) == 3 mod(-7, 4) == 1 mod(-1, 4) == 3 mod(-8, 4) == 0 mod(8, 4) == 0
- Parameters:
m
-- Returns:
- Throws:
ArithmeticException
- - if m <= 0
-
multiply
IRational multiply(int n)
-
normalize
IRational normalize()
Return the normalized form of this number (i.e. if the denominator part equals one, return the numerator part as an integer number).- Returns:
-
numerator
IInteger numerator()
Returns the numerator of this fraction.- Returns:
- numerator
-
powerRational
IRational powerRational(long exp) throws ArithmeticException
Returns this number raised at the specified exponent. See Wikipedia - Exponentiation by squaring- Parameters:
exp
- the exponent.- Returns:
thisexp
- Throws:
ArithmeticException
- if0^0
is given.
-
reRational
default IRational reRational()
Description copied from interface:IBigNumber
Get the real part as rational number- Specified by:
reRational
in interfaceIBigNumber
- Returns:
-
roundClosest
IRational roundClosest(IReal factor)
Description copied from interface:IReal
Roundthis
number to the closestIReal
multiple of thefactor
.- Specified by:
roundClosest
in interfaceIReal
- Returns:
- the closest integer to the argument.
-
toBigDenominator
BigInteger toBigDenominator()
Returns the denominator of this fraction.- Returns:
- denominator
-
toBigFraction
org.hipparchus.fraction.BigFraction toBigFraction()
Returns this number asBigRational
number.- Returns:
this
number s big fraction.
-
toBigRational
edu.jas.arith.BigRational toBigRational()
Returns this number asBigRational
number.- Returns:
this
number s big fraction.
-
toBigNumerator
BigInteger toBigNumerator()
Returns the numerator of this fraction.- Returns:
- denominator
-
trunc
default IInteger trunc()
Truncates the integer part in the "direction to 0" asisNegative() ? ceil() : floor()
..- Returns:
-
-