Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Complex

import { Complex } from "https://raw.githubusercontent.com/JOTSR/Denum/master/mod.ts";

⚠️ Complex is an unstable API, expect breaking changes ⚠️

@unstable
class Complex<T extends Frac | Exponential> extends AbstractValue<Complex<T>> {
constructor(re: T, im: T);
get re();
get im();
get value();
 
abs(): Exponential;
compare(_compared: Complex<T>): bigint;
conjugate(): Complex<T>;
invert(): Complex<T>;
isBetween(
min: Complex<T>,
max: Complex<T>,
includeBounds?,
): boolean;
isEqual(compared: Complex<T>): boolean;
isEven(): boolean;
isGreater(compared: Complex<T>, ifEqual?): boolean;
isImg(pure?): boolean;
isInt(): boolean;
isLesser(compared: Complex<T>, ifEqual?): boolean;
isReal(pure?): boolean;
opposite(): Complex<T>;
sign(): bigint;
simplify(): Complex<T>;
toFloat(_decimals: bigint): number;
toJSON(): string;
toLatex(): string;
toString(): string;
 
static fromFloat<T extends Frac | Exponential>(_float: number): Complex<T>;
static fromJSON<T extends Frac | Exponential>(json: string | Record<string, unknown>): Complex<T>;
static fromLatex<T extends Frac | Exponential>(latex: string): Complex<T>;
static fromString<T extends Frac | Exponential>(_str: string): Complex<T>;
}

§Decorators

§
@unstable
[src]

§Type Parameters

§Extends

§
AbstractValue<Complex<T>>
[src]

§Constructors

§
new Complex(re: T, im: T)
[src]

Allows to store and manipulate complex numbers Returns a new instance of Complex

@param re
  • Exponential | Frac
@param im
  • Exponential | Frac

§Properties

§
re readonly
[src]
§
im readonly
[src]
§
value readonly
[src]

§Methods

§

⚠️ real and imaginary part must be integer Exponential or Frac ⚠️ ⚠️ return an instance of Exponential ⚠️ It takes a complex number, and returns its modulus

@return

The return value is a new instance of the Exponential class.

§
compare(_compared: Complex<T>): bigint
[src]

⚠️ Complex can't be compared ⚠️ It compares two complex and returns 0 if they are equal, 1 if the first is greater than the second, and -1 if the first is less than the second.

@param _compared
  • The complex to compare to.
@return

The sign of the difference between the two complex.

§
conjugate(): Complex<T>
[src]

The conjugate of a complex number is the complex number with the same real part and an imaginary part with the opposite sign

@return

A new Complex object with the real part of the original object and the imaginary part of the original object with the opposite sign.

§
invert(): Complex<T>
[src]

It takes a complex number, and returns its inverse. ⚠️ Only works if Complex or Complex with re and im base ** exponent and exponent are integer ⚠️

@return

A new Complex object with the inverse of the original Complex object.

§
isBetween(min: Complex<T>, max: Complex<T>, includeBounds?): boolean
[src]

⚠️ Complex can't be compared ⚠️ It checks if the complex is between two other complex.

@param min
  • The minimum value to compare to.
@param max
  • The maximum value of the range.
@return

A boolean value

§
isEqual(compared: Complex<T>): boolean
[src]

⚠️ Complex can't be compared ⚠️ Returns true if the two complex are equal, false otherwise.

@param compared
  • The complex to compare to.
@return

A boolean value.

§
isEven(): boolean
[src]

If the real part is even and the imaginary part is even, then return true, otherwise return false.

@return

The return value is a boolean.

§
isGreater(compared: Complex<T>, ifEqual?): boolean
[src]

⚠️ Complex can't be compared ⚠️ Returns true if the current complex is greater than the compared complex, or if the compared complex is equal to the current complex and ifEqual is true.

@param compared
  • The complex to compare to.
@return

A boolean value.

§
isImg(pure?): boolean
[src]

Return true if the imaginary part is not null, if pure, return true if real part is null, otherwise return false

@return
§
isInt(): boolean
[src]

Returns true if the real and imaginary parts of the complex number are integers.

@return

The return value is a boolean.

§
isLesser(compared: Complex<T>, ifEqual?): boolean
[src]

⚠️ Complex can't be compared ⚠️ Returns true if the current complex is lesser than the compared complex, or if the compared complex is equal to the current complex and the ifEqual parameter is true.

@param compared
  • The complex to compare to.
@return

The return value is a boolean.

§
isReal(pure?): boolean
[src]

Return true if the real part is not null, if pure, return true if imaginary part is null, otherwise return false

@return
§
opposite(): Complex<T>
[src]

The opposite of a complex number is the complex number with the opposite real and imaginary parts

@return

A new Complex object with the opposite of the real and imaginary parts.

§
sign(): bigint
[src]

⚠️ Sign is not Complex is not relevant for a complex ⚠️ The function returns the sign of a number

§
simplify(): Complex<T>
[src]

The function simplify() returns a new Complex object with the real and imaginary parts simplified

@return

A new Complex object with the simplified real and imaginary parts.

§
toFloat(_decimals: bigint): number
[src]

⚠️ Complex is not convertible to float32 ⚠️ If you try to convert a complex number to a float, you'll get an error.

@param _decimals
  • bigint
§
toJSON(): string
[src]

The function returns a string that is a JSON representation of the object

@return

A string.

§
toLatex(): string
[src]

returns the LaTeX representation of the complex number

@return

The return value is a LaTeX string.

§
toString(): string
[src]

⚠️ Complex is not convertible to an evaluable js string ⚠️ If you try to convert a Complex object to a string, you'll get an error.

§Static Methods

§
fromFloat<T extends Frac | Exponential>(_float: number): Complex<T>
[src]

⚠️ float32 is not convertible to Complex ⚠️ If you try to convert a float to a complex you'll get an error.

@param _float
  • float32
§
fromJSON<T extends Frac | Exponential>(json: string | Record<string, unknown>): Complex<T>
[src]

It takes a string or an object with two properties, re and im, and returns a Complex object

@param json
  • string | Record<string, unknown>
@return

A new Complex object.

§
fromLatex<T extends Frac | Exponential>(latex: string): Complex<T>
[src]

It takes a LaTeX string in the form of a + ib and returns a Complex object with a and b as the real and imaginary parts respectively

@param latex
  • string
@return

A new Complex object with the real and imaginary parts being the Frac or Exponential objects.

§
fromString<T extends Frac | Exponential>(_str: string): Complex<T>
[src]

⚠️ Complex is not convertible to an evaluable js string ⚠️ If you try to parse a string to a Complex you'll get an error.