ComplexScalar

Trait ComplexScalar 

Source
pub trait ComplexScalar:
    Clone
    + Copy
    + Sync
    + Send
    + Sized
    + Any
    + Debug
    + Display
    + Sum
    + Product
    + NumAssign
    + NumAssignRef
    + NumOps<Self::R>
    + NumAssignOps<Self::R>
    + Default
    + 'static
    + ConstOne
    + ConstZero
    + ComplexField<Real = Self::R>
    + ComplexFloat<Real = Self::R>
    + Memorable
    + BitWidthConvertible<Width32 = c32, Width64 = c64> {
    type R: RealScalar<C = Self>;

    // Required methods
    fn new(real: impl RealScalar, imag: impl RealScalar) -> Self;
    fn from_real(real: impl RealScalar) -> Self;
    fn real(&self) -> Self::R;
    fn imag(&self) -> Self::R;
    fn standard_random() -> Self;
    fn uniform_random(
        real_min: Self::R,
        real_max: Self::R,
        imag_min: Self::R,
        imag_max: Self::R,
    ) -> Self;

    // Provided method
    fn norm_squared(self) -> Self::R { ... }
}
Expand description

A generic complex number within the OpenQudit library.

Required Associated Types§

Source

type R: RealScalar<C = Self>

The real number type associated with this complex number.

Required Methods§

Source

fn new(real: impl RealScalar, imag: impl RealScalar) -> Self

Create a complex number from real and imaginary parts

Source

fn from_real(real: impl RealScalar) -> Self

Create a complex number from just the real part (imaginary = 0)

Source

fn real(&self) -> Self::R

The real component of the complex number.

Source

fn imag(&self) -> Self::R

The imaginary component of the complex number.

Source

fn standard_random() -> Self

Generate a random complex number with both real and imaginary parts from standard normal

Source

fn uniform_random( real_min: Self::R, real_max: Self::R, imag_min: Self::R, imag_max: Self::R, ) -> Self

Generate a random complex number with both parts uniform in given ranges

Provided Methods§

Source

fn norm_squared(self) -> Self::R

Calculate the squared norm (|z|²) of the complex number

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§