final class Algebraic extends ScalaNumber with ScalaNumericConversions with Serializable
Algebraic provides an exact number type for algebraic numbers. Algebraic
numbers are roots of polynomials with rational coefficients. With it, we can
represent expressions involving addition, multiplication, division, n-roots
(eg. sqrt or cbrt), and roots of rational polynomials. So, it is similar
Rational, but adds roots as a valid, exact operation. The cost is that
this will not be as fast as Rational for many operations.
In general, you can assume all operations on this number type are exact,
except for those that explicitly construct approximations to an Algebraic
number, such as toBigDecimal.
For an overview of the ideas, algorithms, and proofs of this number type, you can read the following papers:
- "On Guaranteed Accuracy Computation." C. K. Yap.
- "Recent Progress in Exact Geometric Computation." C. Li, S. Pion, and C. K. Yap.
- "A New Constructive Root Bound for Algebraic Expressions" by C. Li & C. K. Yap.
- "A Separation Bound for Real Algebraic Expressions." C. Burnikel, et al.
- Annotations
- @SerialVersionUID()
- Alphabetic
- By Inheritance
- Algebraic
- Serializable
- ScalaNumericConversions
- ScalaNumericAnyConversions
- ScalaNumber
- Number
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
%(that: Algebraic): Algebraic
An alias for mod.
- def *(that: Algebraic): Algebraic
- def +(that: Algebraic): Algebraic
- def -(that: Algebraic): Algebraic
- def /(that: Algebraic): Algebraic
-
def
/~(that: Algebraic): Algebraic
An alias for quot.
- def <(that: Algebraic): Boolean
- def <=(that: Algebraic): Boolean
- def =!=(that: Algebraic): Boolean
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ===(that: Algebraic): Boolean
- def >(that: Algebraic): Boolean
- def >=(that: Algebraic): Boolean
-
def
abs: Algebraic
Return a non-negative
Algebraicwith the same magnitude as this one. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
byteValue(): Byte
- Definition Classes
- Number
-
def
cbrt: Algebraic
Returns the cube root of this number.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
compare(that: Algebraic): Int
Returns an integer with the same sign as
this - that.Returns an integer with the same sign as
this - that. Specifically, ifthis < that, then the sign is negative, ifthis > that, then the sign is positive, otherwisethis == thatand this returns 0. -
def
doubleValue(): Double
Returns a
Doublethat approximates this value.Returns a
Doublethat approximates this value. If the exponent is too large to fit in a double, theDouble.PositiveInfinityorDouble.NegativeInfinityis returned.- Definition Classes
- Algebraic → ScalaNumericAnyConversions → Number
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
- Definition Classes
- Algebraic → AnyRef → Any
-
def
evaluateWith[A](implicit arg0: Field[A], arg1: NRoot[A], arg2: RootFinder[A], arg3: Eq[A], arg4: ClassTag[A], conv: ConvertableTo[A]): A
Evaluates this algebraic expression with a different number type.
Evaluates this algebraic expression with a different number type. All
Algebraicnumbers store the entire expression tree, so we can use this to *replay* the stored expression using a different type. This will accumulate errors as if the number type had been used from the beginning and is only really suitable for more exact number types, like Real.TODO: Eq/ClassTag come from poly.map - would love to get rid of them.
- val expr: Expr
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
floatValue(): Float
Returns a
Floatthat approximates this value.Returns a
Floatthat approximates this value. If the exponent is too large to fit in a float, theFloat.PositiveInfinityorFloat.NegativeInfinityis returned.- Definition Classes
- Algebraic → ScalaNumericAnyConversions → Number
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- Algebraic → AnyRef → Any
-
def
intValue(): Int
Returns the nearest, valid
Intvalue to this Algebraic, without going further away from 0 (eg.Returns the nearest, valid
Intvalue to this Algebraic, without going further away from 0 (eg. truncation).If this
Algebraicrepresented 1.2, then this would return 1. If this represented -3.3, then this would return -3. If this value is greater thanInt.MaxValue, thenInt.MaxValueis returned. If this value is less thanInt.MinValue, thenInt.MinValueis returned.- Definition Classes
- Algebraic → ScalaNumericAnyConversions → Number
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isRational: Boolean
Returns
trueiff this is a rational expression (ie contains no n-root expressions).Returns
trueiff this is a rational expression (ie contains no n-root expressions). Otherwise it is a radical expression and returns false. -
def
isValidByte: Boolean
- Definition Classes
- ScalaNumericAnyConversions
-
def
isValidChar: Boolean
- Definition Classes
- ScalaNumericAnyConversions
-
def
isValidInt: Boolean
Returns
trueif this Algebraic number is a whole number (no fractional part) and fits within the bounds of anInt.Returns
trueif this Algebraic number is a whole number (no fractional part) and fits within the bounds of anInt. That is, ifx.isValidInt, thenAlgebraic(x.toInt) == x.- Definition Classes
- Algebraic → ScalaNumericAnyConversions
-
def
isValidLong: Boolean
Returns
trueif this Algebraic number is a whole number (no fractional part) and fits within the bounds of anLong.Returns
trueif this Algebraic number is a whole number (no fractional part) and fits within the bounds of anLong. That is, ifx.isValidLong, thenAlgebraic(x.toLong) == x. -
def
isValidShort: Boolean
- Definition Classes
- ScalaNumericAnyConversions
-
def
isWhole(): Boolean
Returns
trueiff this Algebraic exactly represents a validBigInt.Returns
trueiff this Algebraic exactly represents a validBigInt.- Definition Classes
- Algebraic → ScalaNumericAnyConversions → ScalaNumber
-
def
isZero: Boolean
Returns
trueiff this Algebraic number is exactly 0. -
def
longValue(): Long
Returns the nearest, valid
Longvalue to this Algebraic, without going further away from 0 (eg.Returns the nearest, valid
Longvalue to this Algebraic, without going further away from 0 (eg. truncation).If this
Algebraicrepresented 1.2, then this would return 1. If this represented -3.3, then this would return -3. If this value is greater thanLong.MaxValue, thenLong.MaxValueis returned. If this value is less thanLong.MinValue, thenLong.MinValueis returned.- Definition Classes
- Algebraic → ScalaNumericAnyConversions → Number
-
def
mod(that: Algebraic): Algebraic
Returns an
Algebraicwhose value is the difference betweenthisand(this /~ that) * that-- the modulus. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
nroot(k: Int): Algebraic
Returns the
k-th root of this number. -
def
pow(k: Int): Algebraic
Raise this number to the
k-th power. -
def
quot(that: Algebraic): Algebraic
Returns an
Algebraicwhose value is just the integer part ofthis / that.Returns an
Algebraicwhose value is just the integer part ofthis / that. This operation is exact. -
def
shortValue(): Short
- Definition Classes
- Number
-
def
sign: Sign
Returns the sign of this Algebraic number.
Returns the sign of this Algebraic number. Algebraic numbers support exact sign tests, so this is guaranteed to be accurate.
-
def
signum: Int
Returns an
Intwith the same sign as this algebraic number.Returns an
Intwith the same sign as this algebraic number. Algebraic numbers support exact sign tests, so this is guaranteed to be accurate. -
def
sqrt: Algebraic
Returns the square root of this number.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toBigDecimal(mc: MathContext): BigDecimal
Relative approximation to the precision specified in
mcwith the given rounding mode.Relative approximation to the precision specified in
mcwith the given rounding mode. Rounding is always exact. The sign is always correct; the sign of the returnedBigDecimalmatches the sign of the exact value thisAlgebraicrepresents.- mc
the precision and rounding mode of the final result
- returns
an approximation to the value of this algebraic number
-
def
toBigDecimal(scale: Int, roundingMode: RoundingMode): BigDecimal
Absolute approximation to
scaledecimal places with the given rounding mode.Absolute approximation to
scaledecimal places with the given rounding mode. Rounding is always exact. -
def
toBigInt: BigInt
Returns the nearest, valid
BigIntvalue to this Algebraic, without going further away from 0 (eg.Returns the nearest, valid
BigIntvalue to this Algebraic, without going further away from 0 (eg. truncation).If this
Algebraicrepresented 1.2, then this would return 1. If this represented -3.3, then this would return -3. -
def
toByte: Byte
- Definition Classes
- ScalaNumericAnyConversions
-
def
toChar: Char
- Definition Classes
- ScalaNumericAnyConversions
-
def
toDouble: Double
- Definition Classes
- ScalaNumericAnyConversions
- def toExprString: String
-
def
toFloat: Float
- Definition Classes
- ScalaNumericAnyConversions
-
def
toInt: Int
- Definition Classes
- ScalaNumericAnyConversions
-
def
toLong: Long
- Definition Classes
- ScalaNumericAnyConversions
-
def
toRational: Option[Rational]
If this is a rational expressions, then it returns the exact value as a Rational.
If this is a rational expressions, then it returns the exact value as a Rational. Otherwise, this is a radical expression and
Noneis returned. -
def
toReal: Real
Returns an exact Real representation of this number.
-
def
toShort: Short
- Definition Classes
- ScalaNumericAnyConversions
-
def
toString(): String
- Definition Classes
- Algebraic → AnyRef → Any
- def unary_-: Algebraic
-
def
underlying(): AnyRef
- Definition Classes
- Algebraic → ScalaNumericConversions → ScalaNumericAnyConversions → ScalaNumber
-
def
unifiedPrimitiveEquals(x: Any): Boolean
- Attributes
- protected
- Definition Classes
- ScalaNumericAnyConversions
-
def
unifiedPrimitiveHashcode(): Int
- Attributes
- protected
- Definition Classes
- ScalaNumericAnyConversions
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )