pub struct Absurd<T>{
pub complex: Complex<T>,
pub absurd: Complex<T>,
}Expand description
An Absurd Number representing a + bz where a, b are complex numbers
and z = 1/0 is the absurd unit.
§Type Parameters
T- The underlying numeric type (must implementFloat + Clone + Debug)
§Mathematical Foundation
Absurd numbers extend complex numbers by introducing the absurd unit z = 1/0.
This allows division by zero to be defined consistently within the algebraic structure.
§Representation
An absurd number has the form: (a + bi) + (c + di)z
where:
a, b, c, d ∈ ℝ(real numbers)iis the imaginary unit (i² = -1)zis the absurd unit (z = 1/0)
§Examples
use num_absurd::*;
// Create absurd numbers
let a1: Absurd<f64> = ab!(co!(1.0, 2.0), co!(3.0, 0.0)); // (1+2i) + 3z
let a2: Absurd<f32> = ab!(2.0, 1.0); // 2 + z
// Arithmetic operations
let sum = a1 + a1;
let difference = a1 - a2;Fields§
§complex: Complex<T>The complex part (coefficient of 1)
absurd: Complex<T>The absurd part (coefficient of z)
Implementations§
Source§impl<T> Absurd<T>
impl<T> Absurd<T>
Sourcepub fn from_reals(complex_re: T, absurd_re: T) -> Self
pub fn from_reals(complex_re: T, absurd_re: T) -> Self
Sourcepub fn from_complex(complex: Complex<T>) -> Self
pub fn from_complex(complex: Complex<T>) -> Self
Sourcepub fn from_absurd(absurd: Complex<T>) -> Self
pub fn from_absurd(absurd: Complex<T>) -> Self
Sourcepub fn z() -> Self
pub fn z() -> Self
Get the absurd unit z = 1/0
§Examples
use num_absurd::*;
let z: Absurd<f64> = Absurd::z(); // 0 + 1zSourcepub fn is_complex(&self) -> bool
pub fn is_complex(&self) -> bool
Check if this is a pure complex number (absurd part is zero)
§Examples
use num_absurd::*;
let a1 = ab!(co!(1.0, 2.0), co!(0.0, 0.0));
let a2 = ab!(co!(1.0, 2.0), co!(1.0, 0.0));
assert!(a1.is_complex());
assert!(!a2.is_complex());Sourcepub fn is_pure_absurd(&self) -> bool
pub fn is_pure_absurd(&self) -> bool
Check if this is a pure absurd number (complex part is zero)
§Examples
use num_absurd::*;
let a1 = ab!(co!(0.0, 0.0), co!(1.0, 2.0));
let a2 = ab!(co!(1.0, 0.0), co!(1.0, 2.0));
assert!(a1.is_pure_absurd());
assert!(!a2.is_pure_absurd());Sourcepub fn to_complex(&self) -> Option<Complex<T>>
pub fn to_complex(&self) -> Option<Complex<T>>
Attempt to convert to a complex number if absurd part is zero
§Returns
Some(complex) if absurd part is zero, None otherwise
§Examples
use num_absurd::*;
let a1 = ab!(co!(1.0, 2.0), co!(0.0, 0.0));
let a2 = ab!(co!(1.0, 2.0), co!(1.0, 0.0));
assert!(a1.to_complex().is_some());
assert!(a2.to_complex().is_none());Sourcepub fn multiply_by_z(&self) -> Self
pub fn multiply_by_z(&self) -> Self
Multiply by the absurd unit (equivalent to dividing by zero)
For any absurd number a + bz, multiplying by z gives:
(a + bz) * z = az + b
This effectively “shifts” the complex part to the absurd part and reduces the absurd part by one power of z.
§Examples
use num_absurd::*;
let a = ab!(co!(1.0, 2.0), co!(3.0, 0.0)); // (1+2i) + 3z
let result = a.multiply_by_z(); // (1+2i)z + 3Sourcepub fn divide_by_zero(&self) -> Self
pub fn divide_by_zero(&self) -> Self
Divide by zero (equivalent to multiplying by the absurd unit)
This is an alias for multiply_by_z() that makes the operation
more explicit in terms of division by zero.
§Examples
use num_absurd::*;
let a = ab!(co!(2.0, 0.0), co!(0.0, 0.0)); // 2 + 0z
let result = a.divide_by_zero(); // 0 + 2z (which is 2z)Sourcepub fn complex_conjugate(&self) -> Self
pub fn complex_conjugate(&self) -> Self
Get the complex conjugate of the absurd number
For an absurd number (a + bi) + (c + di)z, the complex conjugate is:
(a - bi) + (c - di)z
§Examples
use num_absurd::*;
let a = ab!(co!(1.0, 2.0), co!(3.0, 4.0));
let conj = a.complex_conjugate();
// conj = (1-2i) + (3-4i)zSourcepub fn absurd_conjugate(&self) -> Self
pub fn absurd_conjugate(&self) -> Self
Get the absurd conjugate of the absurd number
For an absurd number a + bz, the absurd conjugate is: a - bz
§Examples
use num_absurd::*;
let a = ab!(co!(1.0, 2.0), co!(3.0, 4.0));
let conj = a.absurd_conjugate();
// conj = (1+2i) - (3+4i)zSourcepub fn norm_squared(&self) -> T
pub fn norm_squared(&self) -> T
Calculate the norm squared of the absurd number
For a + bz, this returns |a|² + |b|²
§Examples
use num_absurd::*;
let a = ab!(co!(3.0, 4.0), co!(1.0, 2.0));
let norm_sq = a.norm_squared();
// |3+4i|² + |1+2i|² = 25 + 5 = 30