pub trait ComplexScalarGetParts: ComplexScalarConstructors {
// Required methods
fn real_part(&self) -> Self::RealType;
fn imag_part(&self) -> Self::RealType;
fn raw_real_part(&self) -> &<Self::RealType as RealScalar>::RawReal;
fn raw_imag_part(&self) -> &<Self::RealType as RealScalar>::RawReal;
// Provided methods
fn is_pure_real(&self) -> bool { ... }
fn is_pure_imaginary(&self) -> bool { ... }
}Expand description
Trait for accessing the real and imaginary components of a complex scalar.
This trait provides methods to extract and query the components of a complex number.
§Examples
use num_valid::ComplexNative64StrictFinite;
use num_valid::functions::{ComplexScalarConstructors, ComplexScalarGetParts};
let z = ComplexNative64StrictFinite::try_new_complex(3.0, 4.0).unwrap();
// Access components
assert_eq!(*z.raw_real_part(), 3.0);
assert_eq!(*z.raw_imag_part(), 4.0);
// Check if purely real or imaginary
assert!(!z.is_pure_real());
assert!(!z.is_pure_imaginary());
let real_only = ComplexNative64StrictFinite::try_new_pure_real(5.0).unwrap();
assert!(real_only.is_pure_real());Required Methods§
Sourcefn raw_real_part(&self) -> &<Self::RealType as RealScalar>::RawReal
fn raw_real_part(&self) -> &<Self::RealType as RealScalar>::RawReal
Returns a reference to the raw real part of the complex number.
Sourcefn raw_imag_part(&self) -> &<Self::RealType as RealScalar>::RawReal
fn raw_imag_part(&self) -> &<Self::RealType as RealScalar>::RawReal
Returns a reference to the raw imaginary part of the complex number.
Provided Methods§
Sourcefn is_pure_real(&self) -> bool
fn is_pure_real(&self) -> bool
Returns true if the complex number is purely real (i.e., has no imaginary part).
Note: the complex number zero is considered purely real.
Sourcefn is_pure_imaginary(&self) -> bool
fn is_pure_imaginary(&self) -> bool
Returns true if the complex number is purely imaginary (i.e., has zero real part and non-zero imaginary part).
Note: the complex number zero is considered purely real.
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 ComplexScalarGetParts for Complex<f64>
Implement the ComplexScalarGetParts trait for the Complex<f64> type.
impl ComplexScalarGetParts for Complex<f64>
Implement the ComplexScalarGetParts trait for the Complex<f64> type.
Source§fn raw_real_part(&self) -> &f64
fn raw_real_part(&self) -> &f64
Returns a reference to the raw real part of the complex number.
Source§fn raw_imag_part(&self) -> &f64
fn raw_imag_part(&self) -> &f64
Returns a reference to the raw imaginary part of the complex number.
Implementors§
impl<K: NumKernel> ComplexScalarGetParts for ComplexValidated<K>
Implement the ComplexScalarGetParts trait for the ComplexValidated type.