Packages

case class Complex(re: Double, im: Double = 0.0) extends Fractional[Complex] with Ordered[Complex] with Product with Serializable

The Complex class is used to represent and operate on complex numbers. Internally, a complex number is represented as two double precision floating point numbers (Double). Externally, two forms are supported:

a+bi = 2.1+3.2i via: Complex ("2.1+3.2i"), 'toString' (a, b) = (2.1, 3.2) via: create ("(2.1, 3.2)"), 'toString2'

Note: 'i * i = -1'. -------------------------------------------------------------------------

re

the real part (e.g., 2.1)

im

the imaginary part (e.g., 3.2)

Linear Supertypes
Product, Equals, Ordered[Complex], Comparable[Complex], Fractional[Complex], Numeric[Complex], Ordering[Complex], PartialOrdering[Complex], Equiv[Complex], Serializable, Serializable, Comparator[Complex], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Complex
  2. Product
  3. Equals
  4. Ordered
  5. Comparable
  6. Fractional
  7. Numeric
  8. Ordering
  9. PartialOrdering
  10. Equiv
  11. Serializable
  12. Serializable
  13. Comparator
  14. AnyRef
  15. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Complex(re: Double, im: Double = 0.0)

    re

    the real part (e.g., 2.1)

    im

    the imaginary part (e.g., 3.2)

Type Members

  1. class FractionalOps extends scala.math.Fractional.Ops
    Definition Classes
    Fractional
  2. class Ops extends AnyRef
    Definition Classes
    Numeric

Value Members

  1. def !=~(c: Complex): Boolean

    Return whether two complex numbers are not nearly equal.

    Return whether two complex numbers are not nearly equal.

    c

    compare this with c

  2. def *(c: Complex): Complex

    Multiply two complex numbers.

    Multiply two complex numbers.

    c

    multiply 'this' times c

  3. def +(c: Complex): Complex

    Add two complex numbers.

    Add two complex numbers.

    c

    add complex c to this

  4. def -(c: Complex): Complex

    Subtract two complex numbers.

    Subtract two complex numbers.

    c

    subtract c from this

  5. def /(c: Complex): Complex

    Divide two complex numbers.

    Divide two complex numbers.

    c

    divide this by c

  6. def <(that: Complex): Boolean
    Definition Classes
    Ordered
  7. def <=(that: Complex): Boolean
    Definition Classes
    Ordered
  8. def =~(c: Complex): Boolean

    Return whether two complex numbers are nearly equal.

    Return whether two complex numbers are nearly equal.

    c

    compare this with c

  9. def >(that: Complex): Boolean
    Definition Classes
    Ordered
  10. def >=(that: Complex): Boolean
    Definition Classes
    Ordered
  11. def abs: Complex

    Return the absolute value of 'this' complex number.

  12. def abs(x: Complex): Complex
    Definition Classes
    Numeric
  13. def angle: Double

    Return the angle of the complex number as a vector in the 're'-'im' plane.

  14. def bar: Complex

    Return the complex conjugate: if z = (a + bi) then z.bar = (a - bi).

  15. def compare(d: Complex): Int

    Compare 'this' complex number with that complex number 'd'.

    Compare 'this' complex number with that complex number 'd'.

    d

    that complex number

    Definition Classes
    Complex → Ordered
  16. def compare(c: Complex, d: Complex): Int

    Compare two complex numbers (negative for <, zero for ==, positive for >).

    Compare two complex numbers (negative for <, zero for ==, positive for >).

    c

    the first complex number to compare

    d

    the second complex number to compare

    Definition Classes
    Complex → Ordering → Comparator
  17. def compareTo(that: Complex): Int
    Definition Classes
    Ordered → Comparable
  18. def div(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Fractional
  19. def equals(c: Any): Boolean

    Override equals to determine whether 'this' complex number equals complex 'c'.

    Override equals to determine whether 'this' complex number equals complex 'c'.

    c

    the complex number to compare with this

    Definition Classes
    Complex → Equals → Comparator → AnyRef → Any
  20. def equiv(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering → Equiv
  21. def fromInt(n: Int): Complex

    Create a complex number from an Int.

    Create a complex number from an Int.

    n

    the integer used to create the complex number

    Definition Classes
    Complex → Numeric
  22. def fromLong(n: Long): Complex

    Create a complex number from a Long.

    Create a complex number from a Long.

    n

    the long used to create the complex number

  23. def gt(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  24. def gteq(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  25. def hashCode(): Int

    Must also override hashCode to be be compatible with equals.

    Must also override hashCode to be be compatible with equals.

    Definition Classes
    Complex → AnyRef → Any
  26. val im: Double
  27. def in(set: Set[Complex]): Boolean

    Determine whether 'this' is in the given set.

  28. def in(lim: (Complex, Complex)): Boolean

    Determine whether 'this' is within the given bounds

    Determine whether 'this' is within the given bounds

    lim

    the given (lower, upper) bounds

  29. def isIm: Boolean

    Determine whether 'this' complex number is purely imaginary (no real part).

  30. def isInfinity: Boolean

    Determine whether 'this' number "is Infinite".

  31. def isNaN: Boolean

    Determine whether 'this' number "is Not a Number".

  32. def isRe: Boolean

    Determine whether 'this' complex number is real (no imaginary part).

  33. def lt(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  34. def lteq(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  35. def max(c: Complex): Complex

    Return the maximum of 'this' and 'c' complex numbers.

    Return the maximum of 'this' and 'c' complex numbers.

    c

    that complex number to compare with this

  36. def max(x: Complex, y: Complex): Complex
    Definition Classes
    Ordering
  37. def min(c: Complex): Complex

    Return the minimum of 'this' and 'c' complex numbers.

    Return the minimum of 'this' and 'c' complex numbers.

    c

    that complex number to compare with this

  38. def min(x: Complex, y: Complex): Complex
    Definition Classes
    Ordering
  39. def minus(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  40. implicit def mkNumericOps(lhs: Complex): FractionalOps
    Definition Classes
    Fractional → Numeric
  41. implicit def mkOrderingOps(lhs: Complex): Complex.Ops
    Definition Classes
    Ordering
  42. def near_eq(c: Complex, d: Complex): Boolean
  43. def negate(c: Complex): Complex
    Definition Classes
    Complex → Numeric
  44. def not_in(set: Set[Complex]): Boolean

    Determine whether 'this' is not in the given set.

  45. def not_in(lim: (Complex, Complex)): Boolean

    Determine whether 'this' is not within the given bounds

    Determine whether 'this' is not within the given bounds

    lim

    the given (lower, upper) bounds

  46. def on[U](f: (U) ⇒ Complex): Ordering[U]
    Definition Classes
    Ordering
  47. def one: Complex
    Definition Classes
    Numeric
  48. def plus(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  49. def polar: (Double, Double)

    Return the complex number in polar coordinates (radius, angle).

  50. def pow(c: Complex, r: Double): Complex
  51. def radius: Double

    Return the radius of the complex number as a vector in the 're'-'im' plane.

  52. val re: Double
  53. def reverse: Ordering[Complex]
    Definition Classes
    Ordering → PartialOrdering
  54. def reversed(): Comparator[Complex]
    Definition Classes
    Comparator
  55. def setFormat(newFormat: String): Unit

    Set the format to the 'newFormat'.

    Set the format to the 'newFormat'.

    newFormat

    the new format String

  56. def signum(x: Complex): Int
    Definition Classes
    Numeric
  57. def thenComparing[U <: Comparable[_ >: U]](arg0: Function[_ >: Complex, _ <: U]): Comparator[Complex]
    Definition Classes
    Comparator
  58. def thenComparing[U](arg0: Function[_ >: Complex, _ <: U], arg1: Comparator[_ >: U]): Comparator[Complex]
    Definition Classes
    Comparator
  59. def thenComparing(arg0: Comparator[_ >: Complex]): Comparator[Complex]
    Definition Classes
    Comparator
  60. def thenComparingDouble(arg0: ToDoubleFunction[_ >: Complex]): Comparator[Complex]
    Definition Classes
    Comparator
  61. def thenComparingInt(arg0: ToIntFunction[_ >: Complex]): Comparator[Complex]
    Definition Classes
    Comparator
  62. def thenComparingLong(arg0: ToLongFunction[_ >: Complex]): Comparator[Complex]
    Definition Classes
    Comparator
  63. def times(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  64. def toComplex: Complex
  65. def toComplex(c: Complex): Complex

    Convert 'this' complex number to a Complex.

    Convert 'this' complex number to a Complex.

    c

    that complex number to convert

  66. def toDouble: Double
  67. def toDouble(c: Complex): Double

    Convert 'this' complex number to a Double.

    Convert 'this' complex number to a Double.

    c

    that complex number to convert

    Definition Classes
    Complex → Numeric
  68. def toFloat: Float
  69. def toFloat(c: Complex): Float

    Convert 'this' complex number to a Float.

    Convert 'this' complex number to a Float.

    c

    that complex number to convert

    Definition Classes
    Complex → Numeric
  70. def toInt: Int
  71. def toInt(c: Complex): Int

    Convert 'this' complex number to an Int.

    Convert 'this' complex number to an Int.

    c

    that complex number to convert

    Definition Classes
    Complex → Numeric
  72. def toLong: Long
  73. def toLong(c: Complex): Long

    Convert 'this' complex number to a Long.

    Convert 'this' complex number to a Long.

    c

    that complex number to convert

    Definition Classes
    Complex → Numeric
  74. def toString(): String

    Convert 'this' complex number to a String of the form "a+bi".

    Convert 'this' complex number to a String of the form "a+bi".

    Definition Classes
    Complex → AnyRef → Any
  75. def toString2: String

    Convert 'this' complex number to a String of the form "(a, b)".

  76. def tryCompare(x: Complex, y: Complex): Some[Int]
    Definition Classes
    Ordering → PartialOrdering
  77. def unary_-(): Complex

    Compute the unary minus (-).

  78. val val1: Double

    General alias for the parts of a complex number

  79. val val2: Double

    General alias for the parts of a complex number

  80. def zero: Complex
    Definition Classes
    Numeric
  81. def ~^(r: Double): Complex

    Raise a complex to the 'r'-th power (a double) using polar coordinates.

    Raise a complex to the 'r'-th power (a double) using polar coordinates.

    r

    the power/exponent

  82. def (r: Double): Complex
  83. def (set: Set[Complex]): Boolean
  84. def (lim: (Complex, Complex)): Boolean
  85. def (set: Set[Complex]): Boolean
  86. def (lim: (Complex, Complex)): Boolean
  87. def (c: Complex): Boolean
  88. def (c: Complex): Boolean
  89. def (d: Complex): Boolean

    Compare 'this' complex number with that complex number 'd' for inequality.

    Compare 'this' complex number with that complex number 'd' for inequality.

    d

    that complex number

  90. def (d: Complex): Boolean

    Compare 'this' complex number with that complex number 'd' for less than or equal to.

    Compare 'this' complex number with that complex number 'd' for less than or equal to.

    d

    that complex number

  91. def (d: Complex): Boolean

    Compare 'this' complex number with that complex number 'd' for greater than or equal to.

    Compare 'this' complex number with that complex number 'd' for greater than or equal to.

    d

    that complex number