symforce.geo.complex module#

class Complex(real, imag)[source]#

Bases: Group

A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i is a solution of the equation x**2 = -1. Because no real number satisfies this equation, i is called an imaginary number. For the complex number a + bi, a is called the real part, and b is called the imaginary part. Despite the historical nomenclature “imaginary”, complex numbers are regarded in the mathematical sciences as just as “real” as the real numbers, and are fundamental in many aspects of the scientific description of the natural world.

A complex number is also a convenient way to store a two-dimensional rotation.

References

https://en.wikipedia.org/wiki/Complex_number

Parameters:
  • real (T.Scalar) –

  • imag (T.Scalar) –

classmethod storage_dim()[source]#

Dimension of underlying storage

Return type:

int

to_storage()[source]#

Flat list representation of the underlying storage, length of storage_dim(). This is used purely for plumbing, it is NOT like a tangent space.

Return type:

List[float]

classmethod from_storage(vec)[source]#

Construct from a flat list representation. Opposite of to_storage().

Parameters:

vec (Sequence[float]) –

Return type:

Complex

classmethod symbolic(name, **kwargs)[source]#

Construct a symbolic element with the given name prefix. Kwargs are forwarded to sf.Symbol (for example, sympy assumptions).

Parameters:
  • name (str) –

  • kwargs (Any) –

Return type:

Complex

classmethod identity()[source]#

Identity element such that compose(a, identity) = a.

Return type:

Complex

compose(other)[source]#

Apply the group operation with other.

Parameters:

other (Complex) –

Return type:

Complex

inverse()[source]#

Group inverse, such that compose(a, inverse(a)) = identity.

Return type:

Complex

classmethod zero()[source]#

Zero value.

Returns:

Complex

Return type:

Complex

conj()[source]#

Complex conjugate (real, -imag).

Returns:

Complex

Return type:

Complex

squared_norm()[source]#

Squared norm of the two-vector.

Returns:

Scalar – real**2 + imag**2

Return type:

float

__mul__(right)[source]#

Complex multiplication (composition).

Parameters:

right (Complex) –

Returns:

Complex

Return type:

Complex

__add__(right)[source]#

Element-wise addition.

Parameters:

right (Complex) –

Returns:

Complex

Return type:

Complex

__neg__()[source]#

Element-wise negation.

Returns:

Complex

Return type:

Complex

__div__(scalar)[source]#

Scalar element-wise division.

Parameters:

scalar (Scalar) –

Returns:

Complex

Return type:

Complex

__truediv__(scalar)#

Scalar element-wise division.

Parameters:

scalar (Scalar) –

Returns:

Complex

Return type:

Complex

classmethod random_uniform(low, high)[source]#

Generate a random complex number with real and imaginary parts between the given bounds

Parameters:
Return type:

Complex

classmethod unit_random()[source]#

Generate a unit-norm random complex number

Return type:

Complex

classmethod unit_random_from_uniform_sample(u1, pi=pi)[source]#

Generate a unit-norm random Complex number from a variable sampled uniformly on [0, 1]

Parameters:
Return type:

Complex