Packages

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()
Linear Supertypes
Serializable, ScalaNumericConversions, ScalaNumericAnyConversions, ScalaNumber, java.lang.Number, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Algebraic
  2. Serializable
  3. ScalaNumericConversions
  4. ScalaNumericAnyConversions
  5. ScalaNumber
  6. Number
  7. Serializable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def %(that: Algebraic): Algebraic

    An alias for mod.

  4. def *(that: Algebraic): Algebraic
  5. def +(that: Algebraic): Algebraic
  6. def -(that: Algebraic): Algebraic
  7. def /(that: Algebraic): Algebraic
  8. def /~(that: Algebraic): Algebraic

    An alias for quot.

  9. def <(that: Algebraic): Boolean
  10. def <=(that: Algebraic): Boolean
  11. def =!=(that: Algebraic): Boolean
  12. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def ===(that: Algebraic): Boolean
  14. def >(that: Algebraic): Boolean
  15. def >=(that: Algebraic): Boolean
  16. def abs: Algebraic

    Return a non-negative Algebraic with the same magnitude as this one.

  17. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  18. def byteValue(): Byte
    Definition Classes
    Number
  19. def cbrt: Algebraic

    Returns the cube root of this number.

  20. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. 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, if this < that, then the sign is negative, if this > that, then the sign is positive, otherwise this == that and this returns 0.

  22. def doubleValue(): Double

    Returns a Double that approximates this value.

    Returns a Double that approximates this value. If the exponent is too large to fit in a double, the Double.PositiveInfinity or Double.NegativeInfinity is returned.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions → Number
  23. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. def equals(that: Any): Boolean
    Definition Classes
    Algebraic → AnyRef → Any
  25. 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 Algebraic numbers 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.

  26. val expr: Expr
  27. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. def floatValue(): Float

    Returns a Float that approximates this value.

    Returns a Float that approximates this value. If the exponent is too large to fit in a float, the Float.PositiveInfinity or Float.NegativeInfinity is returned.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions → Number
  29. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  30. def hashCode(): Int
    Definition Classes
    Algebraic → AnyRef → Any
  31. def intValue(): Int

    Returns the nearest, valid Int value to this Algebraic, without going further away from 0 (eg.

    Returns the nearest, valid Int value to this Algebraic, without going further away from 0 (eg. truncation).

    If this Algebraic represented 1.2, then this would return 1. If this represented -3.3, then this would return -3. If this value is greater than Int.MaxValue, then Int.MaxValue is returned. If this value is less than Int.MinValue, then Int.MinValue is returned.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions → Number
  32. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  33. def isRational: Boolean

    Returns true iff this is a rational expression (ie contains no n-root expressions).

    Returns true iff this is a rational expression (ie contains no n-root expressions). Otherwise it is a radical expression and returns false.

  34. def isValidByte: Boolean
    Definition Classes
    ScalaNumericAnyConversions
  35. def isValidChar: Boolean
    Definition Classes
    ScalaNumericAnyConversions
  36. def isValidInt: Boolean

    Returns true if this Algebraic number is a whole number (no fractional part) and fits within the bounds of an Int.

    Returns true if this Algebraic number is a whole number (no fractional part) and fits within the bounds of an Int. That is, if x.isValidInt, then Algebraic(x.toInt) == x.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions
  37. def isValidLong: Boolean

    Returns true if this Algebraic number is a whole number (no fractional part) and fits within the bounds of an Long.

    Returns true if this Algebraic number is a whole number (no fractional part) and fits within the bounds of an Long. That is, if x.isValidLong, then Algebraic(x.toLong) == x.

  38. def isValidShort: Boolean
    Definition Classes
    ScalaNumericAnyConversions
  39. def isWhole(): Boolean

    Returns true iff this Algebraic exactly represents a valid BigInt.

    Returns true iff this Algebraic exactly represents a valid BigInt.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions → ScalaNumber
  40. def isZero: Boolean

    Returns true iff this Algebraic number is exactly 0.

  41. def longValue(): Long

    Returns the nearest, valid Long value to this Algebraic, without going further away from 0 (eg.

    Returns the nearest, valid Long value to this Algebraic, without going further away from 0 (eg. truncation).

    If this Algebraic represented 1.2, then this would return 1. If this represented -3.3, then this would return -3. If this value is greater than Long.MaxValue, then Long.MaxValue is returned. If this value is less than Long.MinValue, then Long.MinValue is returned.

    Definition Classes
    Algebraic → ScalaNumericAnyConversions → Number
  42. def mod(that: Algebraic): Algebraic

    Returns an Algebraic whose value is the difference between this and (this /~ that) * that -- the modulus.

  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. final def notify(): Unit
    Definition Classes
    AnyRef
  45. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  46. def nroot(k: Int): Algebraic

    Returns the k-th root of this number.

  47. def pow(k: Int): Algebraic

    Raise this number to the k-th power.

  48. def quot(that: Algebraic): Algebraic

    Returns an Algebraic whose value is just the integer part of this / that.

    Returns an Algebraic whose value is just the integer part of this / that. This operation is exact.

  49. def shortValue(): Short
    Definition Classes
    Number
  50. 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.

  51. def signum: Int

    Returns an Int with the same sign as this algebraic number.

    Returns an Int with the same sign as this algebraic number. Algebraic numbers support exact sign tests, so this is guaranteed to be accurate.

  52. def sqrt: Algebraic

    Returns the square root of this number.

  53. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  54. def toBigDecimal(mc: MathContext): BigDecimal

    Relative approximation to the precision specified in mc with the given rounding mode.

    Relative approximation to the precision specified in mc with the given rounding mode. Rounding is always exact. The sign is always correct; the sign of the returned BigDecimal matches the sign of the exact value this Algebraic represents.

    mc

    the precision and rounding mode of the final result

    returns

    an approximation to the value of this algebraic number

  55. def toBigDecimal(scale: Int, roundingMode: RoundingMode): BigDecimal

    Absolute approximation to scale decimal places with the given rounding mode.

    Absolute approximation to scale decimal places with the given rounding mode. Rounding is always exact.

  56. def toBigInt: BigInt

    Returns the nearest, valid BigInt value to this Algebraic, without going further away from 0 (eg.

    Returns the nearest, valid BigInt value to this Algebraic, without going further away from 0 (eg. truncation).

    If this Algebraic represented 1.2, then this would return 1. If this represented -3.3, then this would return -3.

  57. def toByte: Byte
    Definition Classes
    ScalaNumericAnyConversions
  58. def toChar: Char
    Definition Classes
    ScalaNumericAnyConversions
  59. def toDouble: Double
    Definition Classes
    ScalaNumericAnyConversions
  60. def toExprString: String
  61. def toFloat: Float
    Definition Classes
    ScalaNumericAnyConversions
  62. def toInt: Int
    Definition Classes
    ScalaNumericAnyConversions
  63. def toLong: Long
    Definition Classes
    ScalaNumericAnyConversions
  64. 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 None is returned.

  65. def toReal: Real

    Returns an exact Real representation of this number.

  66. def toShort: Short
    Definition Classes
    ScalaNumericAnyConversions
  67. def toString(): String
    Definition Classes
    Algebraic → AnyRef → Any
  68. def unary_-: Algebraic
  69. def underlying(): AnyRef
    Definition Classes
    Algebraic → ScalaNumericConversions → ScalaNumericAnyConversions → ScalaNumber
  70. def unifiedPrimitiveEquals(x: Any): Boolean
    Attributes
    protected
    Definition Classes
    ScalaNumericAnyConversions
  71. def unifiedPrimitiveHashcode(): Int
    Attributes
    protected
    Definition Classes
    ScalaNumericAnyConversions
  72. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  73. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  74. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from ScalaNumericConversions

Inherited from ScalaNumericAnyConversions

Inherited from ScalaNumber

Inherited from java.lang.Number

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped