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, 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. Comparator
  13. AnyRef
  14. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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.NumericOps
    Definition Classes
    Fractional
  2. class NumericOps extends AnyRef
    Definition Classes
    Numeric
  3. class OrderingOps extends AnyRef
    Definition Classes
    Ordering

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. 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

  3. final def ##: Int
    Definition Classes
    AnyRef → Any
  4. def *(c: Complex): Complex

    Multiply two complex numbers.

    Multiply two complex numbers.

    c

    multiply 'this' times c

  5. def +(c: Complex): Complex

    Add two complex numbers.

    Add two complex numbers.

    c

    add complex c to this

  6. def -(c: Complex): Complex

    Subtract two complex numbers.

    Subtract two complex numbers.

    c

    subtract c from this

  7. def /(c: Complex): Complex

    Divide two complex numbers.

    Divide two complex numbers.

    c

    divide this by c

  8. def <(that: Complex): Boolean
    Definition Classes
    Ordered
  9. def <=(that: Complex): Boolean
    Definition Classes
    Ordered
  10. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. 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

  12. def >(that: Complex): Boolean
    Definition Classes
    Ordered
  13. def >=(that: Complex): Boolean
    Definition Classes
    Ordered
  14. def abs: Complex

    Return the absolute value of 'this' complex number.

  15. def abs(x: Complex): Complex
    Definition Classes
    Numeric
  16. def angle: Double

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

  17. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  18. def bar: Complex

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

  19. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  20. 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
  21. 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
  22. def compareTo(that: Complex): Int
    Definition Classes
    Ordered → Comparable
  23. def div(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Fractional
  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. 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
  26. def equiv(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering → Equiv
  27. 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
  28. 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

  29. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  30. def gt(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  31. def gteq(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  32. 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
  33. val im: Double
  34. def in(set: Set[Complex]): Boolean

    Determine whether 'this' is in the given set.

  35. 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

  36. def isIm: Boolean

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

  37. def isInfinity: Boolean

    Determine whether 'this' number "is Infinite".

  38. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  39. def isNaN: Boolean

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

  40. def isRe: Boolean

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

  41. def isReverseOf(other: Ordering[_]): Boolean
    Definition Classes
    Ordering
  42. def lt(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  43. def lteq(x: Complex, y: Complex): Boolean
    Definition Classes
    Ordering → PartialOrdering
  44. 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

  45. def max[U <: Complex](x: U, y: U): U
    Definition Classes
    Ordering
  46. 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

  47. def min[U <: Complex](x: U, y: U): U
    Definition Classes
    Ordering
  48. def minus(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  49. implicit def mkNumericOps(lhs: Complex): FractionalOps
    Definition Classes
    Fractional → Numeric
  50. implicit def mkOrderingOps(lhs: Complex): OrderingOps
    Definition Classes
    Ordering
  51. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  52. def near_eq(c: Complex, d: Complex): Boolean
  53. def negate(c: Complex): Complex
    Definition Classes
    Complex → Numeric
  54. def not_in(set: Set[Complex]): Boolean

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

  55. 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

  56. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  57. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  58. def on[U](f: (U) => Complex): Ordering[U]
    Definition Classes
    Ordering
  59. def one: Complex
    Definition Classes
    Numeric
  60. def orElse(other: Ordering[Complex]): Ordering[Complex]
    Definition Classes
    Ordering
  61. def orElseBy[S](f: (Complex) => S)(implicit ord: Ordering[S]): Ordering[Complex]
    Definition Classes
    Ordering
  62. def parseString(str: String): Option[Complex]

    Parse the string to create a complex number.

    Parse the string to create a complex number.

    Definition Classes
    Complex → Numeric
  63. def plus(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  64. def polar: (Double, Double)

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

  65. def pow(c: Complex, r: Double): Complex
  66. def productElementNames: Iterator[String]
    Definition Classes
    Product
  67. def radius: Double

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

  68. val re: Double
  69. def reverse: Ordering[Complex]
    Definition Classes
    Ordering → PartialOrdering
  70. def reversed(): Comparator[Complex]
    Definition Classes
    Comparator
  71. def setFormat(newFormat: String): Unit

    Set the format to the 'newFormat'.

    Set the format to the 'newFormat'.

    newFormat

    the new format String

  72. def sign(x: Complex): Complex
    Definition Classes
    Numeric
  73. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  74. def thenComparing[U <: Comparable[_ >: U <: AnyRef]](arg0: Function[_ >: Complex <: AnyRef, _ <: U]): Comparator[Complex]
    Definition Classes
    Comparator
  75. def thenComparing[U <: AnyRef](arg0: Function[_ >: Complex <: AnyRef, _ <: U], arg1: Comparator[_ >: U <: AnyRef]): Comparator[Complex]
    Definition Classes
    Comparator
  76. def thenComparing(arg0: Comparator[_ >: Complex <: AnyRef]): Comparator[Complex]
    Definition Classes
    Comparator
  77. def thenComparingDouble(arg0: ToDoubleFunction[_ >: Complex <: AnyRef]): Comparator[Complex]
    Definition Classes
    Comparator
  78. def thenComparingInt(arg0: ToIntFunction[_ >: Complex <: AnyRef]): Comparator[Complex]
    Definition Classes
    Comparator
  79. def thenComparingLong(arg0: ToLongFunction[_ >: Complex <: AnyRef]): Comparator[Complex]
    Definition Classes
    Comparator
  80. def times(c: Complex, d: Complex): Complex
    Definition Classes
    Complex → Numeric
  81. def toComplex: Complex
  82. 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

  83. def toDouble: Double
  84. 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
  85. def toFloat: Float
  86. 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
  87. def toInt: Int
  88. 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
  89. def toLong: Long
  90. 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
  91. 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
  92. def toString2: String

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

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

    Compute the unary minus (-).

  95. val val1: Double

    General alias for the parts of a complex number

  96. val val2: Double

    General alias for the parts of a complex number

  97. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  98. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  99. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  100. def zero: Complex
    Definition Classes
    Numeric
  101. 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

  102. def (r: Double): Complex
  103. def (set: Set[Complex]): Boolean
  104. def (lim: (Complex, Complex)): Boolean
  105. def (set: Set[Complex]): Boolean
  106. def (lim: (Complex, Complex)): Boolean
  107. def (c: Complex): Boolean
  108. def (c: Complex): Boolean
  109. 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

  110. 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

  111. 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

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated
  2. def signum(x: Complex): Int
    Definition Classes
    Numeric
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) use sign method instead

Inherited from Product

Inherited from Equals

Inherited from Ordered[Complex]

Inherited from Comparable[Complex]

Inherited from Fractional[Complex]

Inherited from Numeric[Complex]

Inherited from Ordering[Complex]

Inherited from PartialOrdering[Complex]

Inherited from Equiv[Complex]

Inherited from Serializable

Inherited from Comparator[Complex]

Inherited from AnyRef

Inherited from Any

Ungrouped