pub struct Perplex<T> {
pub t: T,
pub x: T,
}Expand description
The Perplex struct is a representation of hyperbolic numbers, also known as split-complex numbers, which consist of two components: a real part (t) and a hyperbolic part (x). These components correspond to the time and space coordinates in Minkowski space-time, respectively. See Sec. 4.1 Geometrical Representation of Hyperbolic Numbers in The Mathematics of Minkowski Space-Time.
The implementation is generic over a type T, which allows it to be used with different numeric types (i.e., f32 or f64).
Fields§
§t: TThe real part of the perplex number, representing time.
x: TThe hyperbolic part of the perplex number, representing space.
Implementations§
Source§impl<T: Copy + RealField> Perplex<T>
impl<T: Copy + RealField> Perplex<T>
Sourcepub fn as_matrix_form(&self) -> PerplexMatrixForm<T>
pub fn as_matrix_form(&self) -> PerplexMatrixForm<T>
Creates a matrix form from a perplex number, resulting in a symmetric matrix.
Source§impl<T: Copy + Num> Perplex<T>
impl<T: Copy + Num> Perplex<T>
Sourcepub fn hyperbolic(&self) -> T
pub fn hyperbolic(&self) -> T
Returns the space component.
Sourcepub fn squared_distance(&self) -> T
pub fn squared_distance(&self) -> T
Returns the squared distance D(z) in the hyperbolic plane.
Source§impl<T: Copy + Num + PartialOrd> Perplex<T>
impl<T: Copy + Num + PartialOrd> Perplex<T>
Sourcepub fn is_time_like(&self) -> bool
pub fn is_time_like(&self) -> bool
Checks if the perplex number is time-like, i.e., the squared distance is positive.
Sourcepub fn is_space_like(&self) -> bool
pub fn is_space_like(&self) -> bool
Checks if the perplex number is space-like, i.e., the squared distance is negative.
Sourcepub fn is_light_like(&self) -> bool
pub fn is_light_like(&self) -> bool
Checks if the perplex number is light-like, i.e., the squared distance is zero.
Source§impl<T: Copy + Num + Neg<Output = T>> Perplex<T>
impl<T: Copy + Num + Neg<Output = T>> Perplex<T>
Sourcepub fn try_inverse(&self) -> Option<Self>
pub fn try_inverse(&self) -> Option<Self>
Returns the multiplicative inverse 1/self, if it exists, or None if not.
Source§impl<T: Copy + Float> Perplex<T>
impl<T: Copy + Float> Perplex<T>
Sourcepub fn l1_norm(&self) -> T
pub fn l1_norm(&self) -> T
Returns the L1 norm |t| + |x| (Manhattan distance) from the origin in the cartesian coordinate plane, see Eq. 2.49 in New characterizations of the ring of the split-complex numbers and the field C of complex numbers and their comparative analyses.
Sourcepub fn l2_norm(&self) -> T
pub fn l2_norm(&self) -> T
Returns the L2 norm |t^2| + |x^2| (Euclidean distance) from the origin in the cartesian coordinate plane, see Eq. 2.50 in New characterizations of the ring of the split-complex numbers and the field C of complex numbers and their comparative analyses.
Sourcepub fn max_norm(&self) -> T
pub fn max_norm(&self) -> T
Returns the maximum norm ||z||_∞ = max(|t|, |x|) from the origin in the cartesian coordinate plane, see Eq. 2.51 in New characterizations of the ring of the split-complex numbers and the field C of complex numbers and their comparative analyses.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
Computes the hyperbolic exponential function for all sectors. Formula is extended to all sectors, see Sec 4.1.1 Hyperbolic Exponential Function and 7.4 The Elementary Functions of a Canonical Hyperbolic Variable in The Mathematics of Minkowski Space-Time.
Sourcepub fn ln(self) -> Option<Self>
pub fn ln(self) -> Option<Self>
Computes the inverse of the hyperbolic exponential function, i.e., the natural logarithm. Formula is extended to all sectors, see Sec. 7.4 The Elementary Functions of a Canonical Hyperbolic Variable in The Mathematics of Minkowski Space-Time.
Sourcepub fn log(self, base: T) -> Option<Self>
pub fn log(self, base: T) -> Option<Self>
Returns the logarithm of self with respect to an arbitrary base, if the natural logarithm of self exists, according to the formula ln(self) / ln(base).
Sourcepub fn sqrt(self) -> Option<Self>
pub fn sqrt(self) -> Option<Self>
Computes the square root of self if self lies in the right sector, or returns None if not. Formula is taken from Eq. 2.23 in New characterizations of the ring of the split-complex numbers and the field C of complex numbers and their comparative analyses.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
Computes the sinus (circular trigonometric) of self. Formula is taken from Eq. 7.4.6 in The Mathematics of Minkowski Space-Time.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
Computes the cosinus (circular trigonometric) of self. Formula is taken from Eq. 7.4.6 in The Mathematics of Minkowski Space-Time.
Sourcepub fn tan(self) -> Option<Self>
pub fn tan(self) -> Option<Self>
Computes the tangens (circular trigonometric) of self by the formula sin(self) / cos(self). Returns None if cos(self) is light-like.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
Computes the sinh (hyperbolic trigonometric) of self. Formula is taken from Eq. 7.4.5 in The Mathematics of Minkowski Space-Time.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
Computes the cosh (hyperbolic trigonometric) of self. Formula is taken from Eq. 7.4.5 in The Mathematics of Minkowski Space-Time.
Source§impl<T: FloatCore> Perplex<T>
impl<T: FloatCore> Perplex<T>
Sourcepub fn is_infinite(self) -> bool
pub fn is_infinite(self) -> bool
Checks if the given perplex number is infinite
Source§impl<T: Copy + Float> Perplex<T>
impl<T: Copy + Float> Perplex<T>
Sourcepub fn cis(theta: T) -> Self
pub fn cis(theta: T) -> Self
Creates a new Perplex number z with a given hyperbolic angle theta such that z= exp(h theta).
It is used to create a Perplex number with a given phase, using hyperbolic cosine and sine.
Sourcepub fn arg(self) -> T
pub fn arg(self) -> T
Calculates the hyperbolic argument of self.
The argument is the angle in the hyperbolic plane from the positive time axis to the line
connecting the origin to self. It is defined by a piecewise function, with special cases
for light-like perplex numbers, whereby lines x=t and x=-t are mapped to ∞ and -∞, respectively, according to Sec. 4.1 in New characterizations of the ring of the split-complex numbers and the field C of complex numbers and their comparative analyses.
The formula is taken from Eq. 4.1.6 in Sec 4.1.1 Hyperbolic Exponential Function and Hyperbolic Polar Transformation in The Mathematics of Minkowski Space-Time.
Sourcepub fn klein(self) -> Option<Self>
pub fn klein(self) -> Option<Self>
Calculate the Klein index of self for space- or time-like numbers. Returns None for light-like numbers.
The Klein index is determined by the sector of the hyperbolic plane in which self resides.
Formula is taken from Tab. 1 and Appendix B in Hyperbolic trigonometry in two-dimensional space-time geometry.
Sourcepub fn sector(&self) -> HyperbolicSector<T>
pub fn sector(&self) -> HyperbolicSector<T>
Retrieves the hyperbolic sector of the perplex number.
§Examples
use perplex_num::{Perplex, HyperbolicSector};
let perplex = Perplex::new(1.0, 0.5);
assert_eq!(perplex.sector(), HyperbolicSector::Right);Sourcepub fn polar(&self) -> HyperbolicPolar<T>
pub fn polar(&self) -> HyperbolicPolar<T>
Retrieves the hyperbolic polar form from a perplex number.
§Examples
use perplex_num::{Perplex, HyperbolicPolar};
let perplex = Perplex::new(1.0, 0.5);
let polar = perplex.polar();
assert_eq!(polar.rho, perplex.norm());
assert_eq!(polar.theta, perplex.arg());Trait Implementations§
Source§impl<T: AbsDiffEq> AbsDiffEq for Perplex<T>
impl<T: AbsDiffEq> AbsDiffEq for Perplex<T>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq.Source§impl<T: Copy + NumAssign> AddAssign<T> for Perplex<T>
impl<T: Copy + NumAssign> AddAssign<T> for Perplex<T>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
+= operation. Read moreSource§impl<T: Copy + NumAssign> AddAssign for Perplex<T>
impl<T: Copy + NumAssign> AddAssign for Perplex<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<T: Copy + NumAssign> DivAssign<T> for Perplex<T>
impl<T: Copy + NumAssign> DivAssign<T> for Perplex<T>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
/= operation. Read moreSource§impl<T: Copy + NumAssign> DivAssign for Perplex<T>
impl<T: Copy + NumAssign> DivAssign for Perplex<T>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Divides self by rhs in place. Division by a light-like number yields a Perplex number with NaN components.
Source§impl<T: Copy + Float> From<HyperbolicPolar<T>> for Perplex<T>
impl<T: Copy + Float> From<HyperbolicPolar<T>> for Perplex<T>
Source§fn from(polar: HyperbolicPolar<T>) -> Self
fn from(polar: HyperbolicPolar<T>) -> Self
Converts a hyperbolic polar representation back to a perplex number.
This method applies the inverse of the hyperbolic polar conversion, reconstructing the original perplex number from its modulus, argument, and sector.
Source§impl<T: Copy + RealField> From<Matrix<T, Const<2>, Const<2>, ArrayStorage<T, 2, 2>>> for Perplex<T>
impl<T: Copy + RealField> From<Matrix<T, Const<2>, Const<2>, ArrayStorage<T, 2, 2>>> for Perplex<T>
Source§fn from(m: PerplexMatrixForm<T>) -> Self
fn from(m: PerplexMatrixForm<T>) -> Self
Converts a matrix form to a perplex number, assuming a symmetric matrix.
Source§impl<T: Copy + NumAssign + MulAddAssign> MulAddAssign for Perplex<T>
impl<T: Copy + NumAssign + MulAddAssign> MulAddAssign for Perplex<T>
Source§fn mul_add_assign(&mut self, other: Self, add: Self)
fn mul_add_assign(&mut self, other: Self, add: Self)
*self = (*self * a) + bSource§impl<T: Copy + NumAssign> MulAssign<T> for Perplex<T>
impl<T: Copy + NumAssign> MulAssign<T> for Perplex<T>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
*= operation. Read moreSource§impl<T: Copy + NumAssign> MulAssign for Perplex<T>
impl<T: Copy + NumAssign> MulAssign for Perplex<T>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl<T: Ord> Ord for Perplex<T>
impl<T: Ord> Ord for Perplex<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd> PartialOrd for Perplex<T>
impl<T: PartialOrd> PartialOrd for Perplex<T>
Source§impl<T: Copy + Num + Neg<Output = T>> Pow<i32> for Perplex<T>
impl<T: Copy + Num + Neg<Output = T>> Pow<i32> for Perplex<T>
Source§fn pow(self, exp: i32) -> Self::Output
fn pow(self, exp: i32) -> Self::Output
Performs exponentiation for both positive and negative integer exponents. For negative exponents, it calculates the multiplicative inverse before exponentiation.
§Arguments
exp- The exponent to raise the perplex number to.
§Returns
An Option containing the result of raising the perplex number to the power of exp.
Returns None if the perplex number cannot be inverted (i.e., it is light-like).
Source§impl<T: Copy + Num> Pow<u32> for Perplex<T>
impl<T: Copy + Num> Pow<u32> for Perplex<T>
Source§fn pow(self, exp: u32) -> Self::Output
fn pow(self, exp: u32) -> Self::Output
Performs exponentiation by squaring, an efficient algorithm for raising numbers to a power. This method is an iterative implementation of the algorithm described at Exponentiation by Squaring.
§Arguments
exp- The exponent to raise the perplex number to.
§Returns
The result of raising the perplex number to the power of exp.
Source§impl<T: Copy + NumAssign> SubAssign<T> for Perplex<T>
impl<T: Copy + NumAssign> SubAssign<T> for Perplex<T>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
-= operation. Read moreSource§impl<T: Copy + NumAssign> SubAssign for Perplex<T>
impl<T: Copy + NumAssign> SubAssign for Perplex<T>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreimpl<T: Copy> Copy for Perplex<T>
impl<T: Eq> Eq for Perplex<T>
impl<T> StructuralPartialEq for Perplex<T>
Auto Trait Implementations§
impl<T> Freeze for Perplex<T>where
T: Freeze,
impl<T> RefUnwindSafe for Perplex<T>where
T: RefUnwindSafe,
impl<T> Send for Perplex<T>where
T: Send,
impl<T> Sync for Perplex<T>where
T: Sync,
impl<T> Unpin for Perplex<T>where
T: Unpin,
impl<T> UnwindSafe for Perplex<T>where
T: UnwindSafe,
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.