Algosim documentation: ComplexNumber

ComplexNumber

Converts an object to a complex number.

Syntax

Description

If X is any number, then ComplexNumber(X) returns X as an object of type ComplexNumber.

If X is a vector, matrix, list, set, or structure – in each case containing only a single element which is a number – then this number is returned in the form of a complex number object.

If X is an real two-dimensional vector, the natural mapping between ℝ² and ℂ is used to map (x, y) into x + y⋅i.

If X is a string, an attempt is made to parse it as a complex number. If successful, the parsed number is returned.

In all other cases, ComplexNumber(X) returns an error.

Examples

'((n ≔ 687), (x ≔ ComplexNumber(n))) @ type
integer
complex number
ComplexNumber(❨❨5, 9, 3, 1❩❩ ⋅ ❨❨7❩, ❨2❩, ❨4❩, ❨i❩❩)
65 + i
'("7 + 3⋅i", "−5.2E−4 + 3.6j", "−.4 − .8⋅i", "i−2.5E3") @ ComplexNumber
7 + 3⋅i
−0.00052 + 3.6⋅i
−0.4 − 0.8⋅i
−2500 + i

See also