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§
Sourcetype R: RealScalar<C = Self>
type R: RealScalar<C = Self>
The real number type associated with this complex number.
Required Methods§
Sourcefn new(real: impl RealScalar, imag: impl RealScalar) -> Self
fn new(real: impl RealScalar, imag: impl RealScalar) -> Self
Create a complex number from real and imaginary parts
Sourcefn from_real(real: impl RealScalar) -> Self
fn from_real(real: impl RealScalar) -> Self
Create a complex number from just the real part (imaginary = 0)
Sourcefn standard_random() -> Self
fn standard_random() -> Self
Generate a random complex number with both real and imaginary parts from standard normal
Provided Methods§
Sourcefn norm_squared(self) -> Self::R
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.