pub struct Complex { /* private fields */ }Expand description
Dataset container for double-precision (f64) examples.
Same shape and semantics as Data, but stores features and labels
with f64 precision for algorithms or tests that require higher
numeric fidelity.
A complex number represented by real and imaginary components
This is a lightweight, copy-friendly type suitable for use in tensors and GPU computations. It implements all standard complex arithmetic operations and integrates seamlessly with the tensor framework.
§Properties
- Copy: Can be freely copied without performance penalty
- DeviceCopy: Compatible with CUDA memory transfers
- Comparable: Implements PartialEq for complex comparison
§Example
use iron_learn::Complex;
let z1 = Complex::new(3.0, 4.0); // 3 + 4i
let z2 = Complex::new(1.0, 2.0); // 1 + 2i
let sum = z1 + z2; // 4 + 6i
let product = z1 * z2; // -5 + 10iImplementations§
Trait Implementations§
Source§impl Add for Complex
impl Add for Complex
Source§fn add(self, rhs: Self) -> Self
fn add(self, rhs: Self) -> Self
Adds two complex numbers
Implements complex addition: (a + bi) + (c + di) = (a + c) + (b + d)i
§Arguments
rhs- The complex number to add
§Returns
The sum of the two complex numbers
§Example
use iron_learn::Complex;
let a = Complex::new(1.0, 2.0);
let b = Complex::new(3.0, 4.0);
let sum = a + b;
assert_eq!(sum, Complex::new(4.0, 6.0));Source§impl Div for Complex
impl Div for Complex
Source§fn div(self, rhs: Self) -> Self
fn div(self, rhs: Self) -> Self
Divides one complex number by another
Implements complex division using conjugate multiplication: (a + bi)/(c + di) = ((ac + bd) + (bc - ad)i) / (c² + d²)
§Arguments
rhs- The complex number to divide by
§Returns
The quotient of the two complex numbers
§Panics
Does not panic on division by zero; returns NaN/Inf values
§Example
use iron_learn::Complex;
let a = Complex::new(1.0, 2.0);
let b = Complex::new(3.0, 4.0);
let quotient = a / b;
assert_eq!(quotient, Complex::new(0.44, 0.08));Source§impl Mul for Complex
impl Mul for Complex
Source§fn mul(self, rhs: Self) -> Self
fn mul(self, rhs: Self) -> Self
Multiplies two complex numbers
Implements complex multiplication using the distributive property: (a + bi)(c + di) = (ac - bd) + (ad + bc)i
§Arguments
rhs- The complex number to multiply by
§Returns
The product of the two complex numbers
§Example
use iron_learn::Complex;
let a = Complex::new(1.0, 2.0);
let b = Complex::new(3.0, 4.0);
let product = a * b;
assert_eq!(product, Complex::new(-5.0, 10.0));Source§impl Numeric for Complex
Implementation of Numeric for the Complex type from the complex module.
impl Numeric for Complex
Implementation of Numeric for the Complex type from the complex module.
Source§impl PartialOrd for Complex
impl PartialOrd for Complex
Source§impl Sub for Complex
impl Sub for Complex
Source§fn sub(self, rhs: Self) -> Self
fn sub(self, rhs: Self) -> Self
Subtracts one complex number from another
Implements complex subtraction: (a + bi) - (c + di) = (a - c) + (b - d)i
§Arguments
rhs- The complex number to subtract
§Returns
The difference of the two complex numbers
§Example
use iron_learn::Complex;
let a = Complex::new(1.0, 2.0);
let b = Complex::new(3.0, 4.0);
let diff = a - b;
assert_eq!(diff, Complex::new(-2.0, -2.0));impl Copy for Complex
impl SignedNumeric for Complex
impl StructuralPartialEq for Complex
Auto Trait Implementations§
impl Freeze for Complex
impl RefUnwindSafe for Complex
impl Send for Complex
impl Sync for Complex
impl Unpin for Complex
impl UnwindSafe for Complex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more