PINE LIBRARY

Complex

Library "Complex"
This library includes user-defined complex type, and functions to perform basic arithmetic operations on complex numbers.

real(radius, angle)
  Calculates the real part of a complex number based on its polar coordinates.
  Parameters:
    radius (float)
    angle (float)

imag(radius, angle)
  Calculates the imaginary part of a complex number based on its polar coordinates.
  Parameters:
    radius (float)
    angle (float)

rds(real, imag)
  Calculates the radius of a complex number based on its cartesian coordinates.
  Parameters:
    real (float)
    imag (float)

ang(real, imag)
  Calculates the angle of a complex number based on its cartesian coordinates.
  Parameters:
    real (float)
    imag (float)

method realP(c)
  Calculates the real part of a complex number represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.

method imagP(c)
  Calculates the imaginary part of a complex number represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.

method rdsC(c)
  Calculates the radius of a complex number represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.

method angC(c)
  Calculates the angle of a complex number represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.

method toCart(c)
  Converts a complex number from its polar representation to cartesian.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.

method toPolar(c)
  Converts a complex number from its cartesian representation to polar.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.

method addC(c, z)
  Calculates the addition of two complex numbers represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in cartesian coordinates.
    z (complex): Second complex number expressed in cartesian coordinates.

method addP(c, z)
  Calculates the addition of two complex numbers represented in polar coordinates. Performing addition and subtraction operations in cartesian form of complex numbers is more efficient.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in polar coordinates.
    z (complex): Second complex number expressed in polar coordinates.

method subC(c, z)
  Calculates the subtraction of two complex numbers represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in cartesian coordinates.
    z (complex): Second complex number expressed in cartesian coordinates.

method subP(c, z)
  Calculates the subtraction of two complex numbers represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in polar coordinates.
    z (complex): Second complex number expressed in polar coordinates.

method multC(c, z)
  Calculates the multiplication of two complex numbers represented in cartesian coordinates. Performing multiplication in polar form of complex numbers is more efficient.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in cartesian coordinates.
    z (complex): Second complex number expressed in cartesian coordinates.

method multP(c, z)
  Calculates the multiplication of two complex numbers represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex): First complex number expressed in polar coordinates.
    z (complex): Second complex number expressed in polar coordinates.

method powC(c, exp, shift)
  Exponentiates a complex number represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.
    exp (float): The exponent.
    shift (float): The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.

method powP(c, exp, shift)
  Exponentiates a complex number represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.
    exp (float): The exponent.
    shift (float): The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.

method invC(c)
  Calculates the multiplicative inverse of a complex number represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex)

method invP(c)
  Calculates the multiplicative inverse of a complex number represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex)

method negC(c)
  Negates a complex number represented in cartesian coordinates.
  Namespace types: complex
  Parameters:
    c (complex)

method negP(c)
  Negates a complex number represented in polar coordinates.
  Namespace types: complex
  Parameters:
    c (complex)

method con(c)
  Calculates the conjugate of a complex number in either forms.
  Namespace types: complex
  Parameters:
    c (complex)

method fAddC(c, d)
  Calculates the addition of a complex number represented in cartesian coordinates and a real number.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.
    d (float)
  Returns: The complex number resulted by the addition in cartesian form.

method fAddP(c, d)
  Calculates the addition of a complex number represented in polar coordinates and a real number.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.
    d (float)
  Returns: The complex number resulted by the addition in polar form.

method fMultC(c, d)
  Calculates the multiplication of a complex number represented in cartesian coordinates and a real number.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in cartesian coordinates.
    d (float)
  Returns: The complex number resulted by the multiplication in cartesian form.

method fMultP(c, d)
  Calculates the multiplication of a complex number represented in polar coordinates and a real number.
  Namespace types: complex
  Parameters:
    c (complex): A complex number expressed in polar coordinates.
    d (float)
  Returns: The complex number resulted by the multiplication in polar form.

complex
  Complex number expressed in polar or cartesian coordinates.
  Fields:
    R (series float): Real part or radius of the complex number.
    J (series float): Imaginary part or angle (phase) of the complex number.
    iP (series bool): This field is employed to keep track of the coordinates of the number. Note that the functions do not verify this field for the purpose of efficiency.
formattingMATH

Thư viện Pine

Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.

Thông báo miễn trừ trách nhiệm