Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Complex

Represents a complex mnumber as a Vector on a plane.

Hierarchy

Index

Constructors

  • new Complex(...components: (number | number[])[]): Complex

Properties

components: number[]

Contains all the components of the Vector.

Accessors

  • get x(): number
  • set x(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

  • get y(): number
  • set y(value: number): void
  • Returns number

  • Parameters

    • value: number

    Returns void

Methods

  • Im(): number
  • Returns number

    The immaginary part of the number.

  • Re(): number
  • Returns number

    The real part of the number.

  • Sums all entries of this Vector with those of the passed one.

    remarks

    This method creates new components and returns an Array with them. If inPlace is set as true, the method modifies this array.

    Parameters

    • v: Vector

      The Vector with the addends.

    • inPlace: boolean = false

      Set as true to save the results in this Vector.

    Returns Vector

    A Vector containing the results.

  • Create a new Vector with all entries from this Vector and the passed one.

    Parameters

    • v: Vector

      Vector to be combined.

    Returns Vector

    The new Vector.

  • Returns the cross products between two vectors.

    Parameters

    Returns number

    The scalar number result of the cross product.

  • Returns the dot product of two Vectors.

    Parameters

    Returns number

    The dot product.

  • Returns true if the Vectors are equal.

    remarks

    This method takes in consideration the safe number precision of doubles.

    beta
    experimental

    Parameters

    Returns boolean

    A boolean.

  • Return true if the Vectors are normal (a.k.a. perpendicular) to each other.

    Parameters

    Returns boolean

    A boolean.

  • Multiplies this number for another complex.

    Parameters

    Returns Complex

    A new Complex.

  • norm(l?: number): number
  • Return the required norm. By default return the length of the Vector.

    remarks

    If l = 1, return the l1-norm (a.k.a. the Manhattan norm). If l = 2, return the l2-norm (a.k.a. the Euclidian norm). If you have no idea what these are you probably just want the default value for the distance between two points.

    Parameters

    • l: number = 2

      The type of norm.

    Returns number

    The value of the required norm.

  • normalize(inPlace?: boolean): Vector
  • Scales this Vector so that its lenght is equal to one.

    Parameters

    • inPlace: boolean = false

      Set as true to save the results in this Vector.

    Returns Vector

    The normalized Vector.

  • opposite(inPlace?: boolean): Vector
  • Sets all entries with opposite sign of this Vector's.

    remarks

    This method creates new components and returns an Array with them. If inPlace is set as true, the method modifies this array.

    Parameters

    • inPlace: boolean = false

      Set as true to save the results in this Vector.

    Returns Vector

    A Vector that has all entries opposite to this' ones.

  • Computes the roots of a Complex number.

    remarks

    Calculates all the possible roots of this Complex for a given number. The results are listed in an Array

    beta
    experimental

    Parameters

    • n: number

      Root exponent (e.g. set as 2 for sqrt).

    Returns Complex[]

    An Array of n Complex roots.

  • scalar(n: number, inPlace?: boolean): Vector
  • Scalar multiplication, scales this Vector by the given number.

    Parameters

    • n: number

      Scalar number

    • inPlace: boolean = false

      Set as true to save the results in this Vector.

    Returns Vector

    A scaled Vector.

  • set(id: number, value: number): void
  • Sets a single entry of the vector to a new value.

    Parameters

    • id: number
    • value: number

    Returns void

  • setComponents(newcomps: number[]): void
  • size(): number
  • Subtracts all entries of this Vector with those of the passed one.

    remarks

    This method creates new components and returns an Array with them. If inPlace is set as true, the method modifies this array.

    Parameters

    • v: Vector

      The Vector with the minuends.

    • inPlace: boolean = false

      Set as true to save the results in this Vector.

    Returns Vector

    A Vector containing the differences.

  • toArray(): number[]
  • Create an Array containing the components.

    Returns number[]

    An Array containing the components.

  • toObject(): object
  • toString(): string
  • Create a string describing the Vector.

    beta
    experimental

    Returns string

    A string describing the vector.

  • Create a new vector of size n with all entries set as zero.

    Parameters

    • n: number

      Size of the new vector of ones.

    Returns Vector

    The new Vector created.

  • Create a new vector of size n with all entries set as zero.

    Parameters

    • n: number

      Size of the new vector of zeros.

    Returns Vector

    The new Vector created.

Generated using TypeDoc