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 toErrorsValidationRawComplex
, 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
fornum::Complex<f64>
). This associated real type must itself implementRawRealTrait
, 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§
Sourcetype RawReal: RawRealTrait<RawComplex = Self>
type RawReal: RawRealTrait<RawComplex = Self>
The associated real type that makes up the components of this complex type.
Required Methods§
fn new_unchecked_raw_complex(real: Self::RawReal, imag: Self::RawReal) -> Self
Sourcefn unchecked_abs(self) -> Self::RawReal
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.
Sourcefn raw_real_part(&self) -> &Self::RawReal
fn raw_real_part(&self) -> &Self::RawReal
Returns a reference to the real part of the complex number.
Sourcefn raw_imag_part(&self) -> &Self::RawReal
fn raw_imag_part(&self) -> &Self::RawReal
Returns a reference to the imaginary part of the complex number.
Sourcefn mut_raw_real_part(&mut self) -> &mut Self::RawReal
fn mut_raw_real_part(&mut self) -> &mut Self::RawReal
Returns a mutable reference to the real part of the complex number.
Sourcefn mut_raw_imag_part(&mut self) -> &mut Self::RawReal
fn mut_raw_imag_part(&mut self) -> &mut Self::RawReal
Returns a mutable reference to the imaginary part of the complex number.
Sourcefn unchecked_arg(self) -> Self::RawReal
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.
Sourcefn unchecked_pow_exponent_real(self, exponent: &Self::RawReal) -> Self
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>
impl RawComplexTrait for Complex<f64>
Source§fn mut_raw_real_part(&mut self) -> &mut f64
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
fn mut_raw_imag_part(&mut self) -> &mut f64
Returns a mutable reference to the imaginary part of the complex number.
type RawReal = f64
fn new_unchecked_raw_complex(real: f64, imag: f64) -> Self
fn unchecked_abs(self) -> f64
fn raw_real_part(&self) -> &f64
fn raw_imag_part(&self) -> &f64
fn unchecked_arg(self) -> f64
fn unchecked_pow_exponent_real(self, exponent: &f64) -> Self
Source§impl RawComplexTrait for Complex
impl RawComplexTrait for Complex
Source§fn mut_raw_real_part(&mut self) -> &mut Float
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
fn mut_raw_imag_part(&mut self) -> &mut Float
Returns a mutable reference to the imaginary part of the complex number.