RawComplexTrait

Trait RawComplexTrait 

Source
pub trait RawComplexTrait:
    RawScalarTrait<ValidationErrors = ErrorsValidationRawComplex<ErrorsValidationRawReal<Self::RawReal>>>
    + Conjugate
    + for<'a> Mul<&'a Self::RawReal, Output = Self>
    + for<'a> MulAssign<&'a Self::RawReal> {
    type RawReal: RawRealTrait<RawComplex = Self>;

    // Required methods
    fn new_unchecked_raw_complex(
        real: Self::RawReal,
        imag: Self::RawReal,
    ) -> Self;
    fn unchecked_abs(self) -> Self::RawReal;
    fn raw_real_part(&self) -> &Self::RawReal;
    fn raw_imag_part(&self) -> &Self::RawReal;
    fn mut_raw_real_part(&mut self) -> &mut Self::RawReal;
    fn mut_raw_imag_part(&mut self) -> &mut Self::RawReal;
    fn unchecked_arg(self) -> Self::RawReal;
    fn unchecked_pow_exponent_real(self, exponent: &Self::RawReal) -> Self;
}
Expand description

A trait for raw complex scalar types, extending RawScalarTrait.

This trait is implemented by the underlying complex number types within a kernel, such as num::Complex<f64>. It builds upon RawScalarTrait by adding operations that are unique to complex numbers.

§Trait Bounds

  • RawScalarTrait<...>: Ensures the type is a raw scalar and fixes its validation error type to ErrorsValidationRawComplex, which in turn wraps the validation error of the associated real type. This establishes a consistent error structure.
  • Conjugate: Requires that the complex number can be conjugated.

§Associated Types

  • type RawReal: RawRealTrait<RawComplex = Self>: This is a critical part of the design. It links the complex type to its underlying real component type (e.g., f64 for num::Complex<f64>). This associated real type must itself implement RawRealTrait, creating a two-way link between the real and complex raw types.

§Methods

This trait provides methods for accessing components and performing complex-specific mathematical operations without validation checks.

Required Associated Types§

Source

type RawReal: RawRealTrait<RawComplex = Self>

The associated real type that makes up the components of this complex type.

Required Methods§

Source

fn new_unchecked_raw_complex(real: Self::RawReal, imag: Self::RawReal) -> Self

Source

fn unchecked_abs(self) -> Self::RawReal

Computes the absolute value (modulus or norm) of self without validation.

Contract: The caller must ensure the input is valid for this operation.

Source

fn raw_real_part(&self) -> &Self::RawReal

Returns a reference to the real part of the complex number.

Source

fn raw_imag_part(&self) -> &Self::RawReal

Returns a reference to the imaginary part of the complex number.

Source

fn mut_raw_real_part(&mut self) -> &mut Self::RawReal

Returns a mutable reference to the real part of the complex number.

Source

fn mut_raw_imag_part(&mut self) -> &mut Self::RawReal

Returns a mutable reference to the imaginary part of the complex number.

Source

fn unchecked_arg(self) -> Self::RawReal

Computes the argument (or phase) of self in radians, without validation.

Contract: The caller must ensure that self is not zero.

Source

fn unchecked_pow_exponent_real(self, exponent: &Self::RawReal) -> Self

Raises self to the power of a real exponent without validation.

Contract: The caller must ensure the inputs are valid for the power function.

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.

Implementations on Foreign Types§

Source§

impl RawComplexTrait for Complex<f64>

Source§

fn mut_raw_real_part(&mut self) -> &mut f64

Returns a mutable reference to the real part of the complex number.

Source§

fn mut_raw_imag_part(&mut self) -> &mut f64

Returns a mutable reference to the imaginary part of the complex number.

Source§

type RawReal = f64

Source§

fn new_unchecked_raw_complex(real: f64, imag: f64) -> Self

Source§

fn unchecked_abs(self) -> f64

Source§

fn raw_real_part(&self) -> &f64

Source§

fn raw_imag_part(&self) -> &f64

Source§

fn unchecked_arg(self) -> f64

Source§

fn unchecked_pow_exponent_real(self, exponent: &f64) -> Self

Source§

impl RawComplexTrait for Complex

Source§

fn mut_raw_real_part(&mut self) -> &mut Float

Returns a mutable reference to the real part of the complex number.

Source§

fn mut_raw_imag_part(&mut self) -> &mut Float

Returns a mutable reference to the imaginary part of the complex number.

Source§

type RawReal = Float

Source§

fn new_unchecked_raw_complex(real: Float, imag: Float) -> Self

Source§

fn unchecked_abs(self) -> Float

Source§

fn raw_real_part(&self) -> &Float

Source§

fn raw_imag_part(&self) -> &Float

Source§

fn unchecked_arg(self) -> Float

Source§

fn unchecked_pow_exponent_real(self, exponent: &Float) -> Self

Implementors§