Liking cljdoc? Tell your friends :D

fastmath.complex

Complex numbers operations.

Complex numbers are represented using the [[Vec2]] type defined in the fastmath.vector namespace. A complex number $z = a + bi$ corresponds to the vector (Vec2. a b).

To create a complex number, use complex, [[vec2]], or convert from sequences/arrays using functions like fastmath.vector/seq->vec2.

The implementation correctly handles floating-point special values such as ##Inf, ##NaN, and distinguishes between +0.0 and -0.0 where necessary.

This namespace provides standard complex number operations like arithmetic (+, -, *, /), exponentiation (pow, exp, log), trigonometric functions (sin, cos, tan, etc.), and their inverses, as well as utility functions like abs, arg, conjugate, etc.

Complex numbers operations.

Complex numbers are represented using the [[Vec2]] type defined in the `fastmath.vector` namespace.
A complex number $z = a + bi$ corresponds to the vector `(Vec2. a b)`.

To create a complex number, use [[complex]], [[vec2]], or convert from sequences/arrays using functions like [[fastmath.vector/seq->vec2]].

The implementation correctly handles floating-point special values such as `##Inf`, `##NaN`, and distinguishes between `+0.0` and `-0.0` where necessary.

This namespace provides standard complex number operations like arithmetic (+, -, *, /), exponentiation (pow, exp, log), trigonometric functions (sin, cos, tan, etc.), and their inverses, as well as utility functions like `abs`, `arg`, `conjugate`, etc.
raw docstring

-Iclj

z=0-i

z=0-i
sourceraw docstring

absclj

(abs z)

Calculates the magnitude (absolute value) of the complex number z.

Calculates the magnitude (absolute value) of the complex number `z`.
sourceraw docstring

acosclj

(acos z)

acos(z)

acos(z)
sourceraw docstring

acoshclj

(acosh z)

acosh(z)

acosh(z)
sourceraw docstring

acotclj

(acot z)

acot(z)

acot(z)
sourceraw docstring

acothclj

(acoth z)

acoth(z)

acoth(z)
sourceraw docstring

acscclj

(acsc z)

acsc(z)

acsc(z)
sourceraw docstring

acschclj

(acsch z)

acsch(z)

acsch(z)
sourceraw docstring

addclj

(add z1 z2)

Sum of two complex numbers.

Sum of two complex numbers.
sourceraw docstring

addsclj

(adds z v)

Add scalar to complex number.

Add scalar to complex number.
sourceraw docstring

argclj

(arg z)

Argument (angle) of the complex number.

Argument (angle) of the complex number.
sourceraw docstring

asecclj

(asec z)

asec(z)

asec(z)
sourceraw docstring

asechclj

(asech z)

asech(z)

asech(z)
sourceraw docstring

asinclj

(asin z)

asin(z)

asin(z)
sourceraw docstring

asinhclj

(asinh z)

asinh(z)

asinh(z)
sourceraw docstring

atanclj

(atan z)

atan(z)

atan(z)
sourceraw docstring

atanhclj

(atanh z)

atanh(z)

atanh(z)
sourceraw docstring

complexclj

(complex)
(complex a)
(complex a b)

Creates a complex number represented as a [[Vec2]]. Takes optional real and imaginary parts.

Examples:

(complex 1 2) ;; => #vec2 [1.0, 2.0] (complex 3) ;; => #vec2 [3.0, 0.0] (complex) ;; => #vec2 [0.0, 0.0]

Creates a complex number represented as a [[Vec2]].
Takes optional real and imaginary parts.

Examples:

(complex 1 2) ;; => #vec2 [1.0, 2.0]
(complex 3)   ;; => #vec2 [3.0, 0.0]
(complex)     ;; => #vec2 [0.0, 0.0]
sourceraw docstring

conjugateclj

(conjugate z)

Complex conjugate.

Complex conjugate.
sourceraw docstring

cosclj

(cos z)

cos(z)

cos(z)
sourceraw docstring

coshclj

(cosh z)

cosh(z)

cosh(z)
sourceraw docstring

cotclj

(cot z)

csc(z)

csc(z)
sourceraw docstring

cothclj

(coth z)

coth(z)

coth(z)
sourceraw docstring

cscclj

(csc z)

csc(z)

csc(z)
sourceraw docstring

cschclj

(csch z)

csch(z)

csch(z)
sourceraw docstring

csgnclj

(csgn z)
(csgn re im)

Complex signum function.

Returns 0.0 for the zero. For any other vector, returns the sign of the real part.

Complex signum function.

Returns `0.0` for the zero. For any other vector, returns the sign of the real part.
sourceraw docstring

delta-eqclj

(delta-eq q1 q2)
(delta-eq q1 q2 accuracy)

Compare complex numbers with given accuracy (10e-6 by default)

Compare complex numbers with given accuracy (10e-6 by default)
sourceraw docstring

divclj

(div z1 z2)

Division of two complex numbers.

Division of two complex numbers.
sourceraw docstring

ensure-complexclj

(ensure-complex v)

Convert possible number to complex or return input.

Convert possible number to complex or return input.
sourceraw docstring

expclj

(exp z)

exp(z)

exp(z)
sourceraw docstring

flipclj

(flip z)

Exchange imaginary and real parts

Exchange imaginary and real parts
sourceraw docstring

Iclj

z=0+i

z=0+i
sourceraw docstring

I-clj

z=0-i

z=0-i
sourceraw docstring

imclj

(im z)

Imaginary part

Imaginary part
sourceraw docstring

imaginary?clj

(imaginary? z)

Is z is a pure imaginary number?

Is z is a pure imaginary number?
sourceraw docstring

inf?clj

(inf? z)

Is infinite?

Is infinite?
sourceraw docstring

invalid?clj

(invalid? z)

Is NaN or Inf?

Is NaN or Inf?
sourceraw docstring

logclj

(log z)

log(z), principal value

log(z), principal value
sourceraw docstring

logbclj

(logb z b)

log with base b

log with base b
sourceraw docstring

muladdclj

(muladd x y z)

(+ z (* x y))

(+ z (* x y))
sourceraw docstring

multclj

(mult z1 z2)

Multiplication of two complex numbers.

Multiplication of two complex numbers.
sourceraw docstring

mult-Iclj

(mult-I z)

Multiplication by 0+i.

Multiplication by 0+i.
sourceraw docstring

mult-I-clj

(mult-I- z)

Multiplication by 0-i.

Multiplication by 0-i.
sourceraw docstring

nan?clj

(nan? z)

Is NaN?

Is NaN?
sourceraw docstring

negclj

(neg z)

Negation of the complex number, -z.

Negation of the complex number, -z.
sourceraw docstring

normclj

(norm z)

Calculates the squared magnitude (norm) of the complex number z.

Also known as the squared modulus or squared Euclidean norm.

Calculates the squared magnitude (norm) of the complex number `z`.

Also known as the squared modulus or squared Euclidean norm.
sourceraw docstring

normalizeclj

(normalize z)

Normalize complex number to make abs(z) = 1

Normalize complex number to make abs(z) = 1
sourceraw docstring

ONEclj

z=1+0i

z=1+0i
sourceraw docstring

PIclj

z=pi+0i

z=pi+0i
sourceraw docstring

powclj

(pow z1 z2)

Complex power, z^z

Complex power, z^z
sourceraw docstring

reclj

(re z)

Real part

Real part
sourceraw docstring

real?clj

(real? z)

Is z is a real number?

Is z is a real number?
sourceraw docstring

reciprocalclj

(reciprocal z)

Reciprocal, 1/z.

Reciprocal, 1/z.
sourceraw docstring

scaleclj

(scale z v)

Multiplication by real number

Multiplication by real number
sourceraw docstring

secclj

(sec z)

sec(z)

sec(z)
sourceraw docstring

sechclj

(sech z)

sech(z)

sech(z)
sourceraw docstring

sinclj

(sin z)

sin(z)

sin(z)
sourceraw docstring

sinhclj

(sinh z)

sinh(z)

sinh(z)
sourceraw docstring

sqclj

(sq z)

Square of the complex number.

Square of the complex number.
sourceraw docstring

sqrtclj

(sqrt z)

Sqrt of the complex number, sqrt(z)

Sqrt of the complex number, sqrt(z)
sourceraw docstring

sqrt1zclj

(sqrt1z z)

sqrt(1-z^2)

sqrt(1-z^2)
sourceraw docstring

subclj

(sub z1 z2)

Difference of two complex numbers.

Difference of two complex numbers.
sourceraw docstring

tanclj

(tan z)

tan(z)

tan(z)
sourceraw docstring

tanhclj

(tanh z)

tanh(z)

tanh(z)
sourceraw docstring

TWOclj

z=2+0i

z=2+0i
sourceraw docstring

valid?clj

(valid? z)

Is valid complex (not NaN or Inf)?

Is valid complex (not NaN or Inf)?
sourceraw docstring

ZEROclj

z=0+0i

z=0+0i
sourceraw docstring

zero?clj

(zero? z)

Is zero?

Is zero?
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close