Perplex

Struct Perplex 

Source
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: T

The real part of the perplex number, representing time.

§x: T

The hyperbolic part of the perplex number, representing space.

Implementations§

Source§

impl<T: Copy + RealField> Perplex<T>

Source

pub fn as_matrix_form(&self) -> PerplexMatrixForm<T>

Creates a matrix form from a perplex number, resulting in a symmetric matrix.

Source§

impl<T> Perplex<T>

Source

pub fn new(t: T, x: T) -> Self

Create a new Perplex number

Source§

impl<T: Copy + Num> Perplex<T>

Source

pub fn h() -> Self

Returns hyperbolic unit.

Source

pub fn real(&self) -> T

Returns the time component.

Source

pub fn hyperbolic(&self) -> T

Returns the space component.

Source

pub fn squared_distance(&self) -> T

Returns the squared distance D(z) in the hyperbolic plane.

Source

pub fn scale(&self, factor: T) -> Self

Multiplies self by the scalar factor.

Source§

impl<T: Copy + Num + PartialOrd> Perplex<T>

Source

pub fn is_time_like(&self) -> bool

Checks if the perplex number is time-like, i.e., the squared distance is positive.

Source

pub fn is_space_like(&self) -> bool

Checks if the perplex number is space-like, i.e., the squared distance is negative.

Source

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>

Source

pub fn conj(&self) -> Self

Returns the hyperbolic conjugate.

Source

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>

Source

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.

Source

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.

Source

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.

Source

pub fn modulus(self) -> T

Returns the modulus of self.

Source

pub fn norm(self) -> T

Returns the norm (modulus) of self.

Source

pub fn magnitude(self) -> T

Returns the magnitude (modulus) of self.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

pub fn tanh(self) -> Option<Self>

Computes the tanh (hyperbolic trigonometric) of self by the formula sinh(self) / cosh(self). Returns None if cosh(self) is light-like.

Source§

impl<T: FloatCore> Perplex<T>

Source

pub fn is_nan(self) -> bool

Checks if the given perplex number is NaN

Source

pub fn is_infinite(self) -> bool

Checks if the given perplex number is infinite

Source

pub fn is_finite(self) -> bool

Checks if the given perplex number is finite

Source

pub fn is_normal(self) -> bool

Checks if the given perplex number is normal

Source§

impl<T: Copy + Float> Perplex<T>

Source

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.

Source

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.

Source

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.

Source

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);
Source

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());
Source§

impl<T: Copy + Num + Neg<Output = T>> Perplex<T>

Source

pub fn powu(&self, exp: u32) -> Self

Raises self to an unsigned integer power.

Source

pub fn powi(&self, exp: i32) -> Option<Self>

Raises self to a signed integer power.

Trait Implementations§

Source§

impl<T: AbsDiffEq> AbsDiffEq for Perplex<T>
where T::Epsilon: Copy,

Source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T: Copy + Num> Add<T> for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the + operator.
Source§

fn add(self, other: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Copy + Num> Add for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Copy + NumAssign> AddAssign<T> for Perplex<T>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<T: Copy + NumAssign> AddAssign for Perplex<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Perplex<T>

Source§

fn clone(&self) -> Perplex<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Perplex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy + Num> Default for Perplex<T>

Source§

fn default() -> Self

Defaults to the neutral element of multiplication.

Source§

impl<T: Copy + Neg<Output = T> + PartialOrd + Num + Display> Display for Perplex<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy + Num> Div<T> for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Copy + Num> Div for Perplex<T>

Source§

fn div(self, rhs: Self) -> Self::Output

Divides self by rhs. Division by a light-like number yields None, otherwise Some(self / rhs).

Source§

type Output = Option<Perplex<T>>

The resulting type after applying the / operator.
Source§

impl<T: Copy + NumAssign> DivAssign<T> for Perplex<T>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<T: Copy + NumAssign> DivAssign for Perplex<T>

Source§

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>

Source§

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>

Source§

fn from(m: PerplexMatrixForm<T>) -> Self

Converts a matrix form to a perplex number, assuming a symmetric matrix.

Source§

impl<T: Copy + Float> From<Perplex<T>> for HyperbolicPolar<T>

Source§

fn from(z: Perplex<T>) -> Self

Converts a perplex number to hyperbolic polar form.

The conversion takes into account the sector of the hyperbolic plane the number is in and uses the appropriate hyperbolic trigonometric functions.

Source§

impl<T: Copy + Float> From<Perplex<T>> for HyperbolicSector<T>

Source§

fn from(z: Perplex<T>) -> Self

Converts a perplex number into its corresponding hyperbolic sector.

Light-like numbers are converted to the Diagonal variant, while others are categorized based on the magnitude and sign of their time and space components.

Source§

impl<T: Copy + RealField> From<Perplex<T>> for PerplexMatrixForm<T>

Source§

fn from(z: Perplex<T>) -> Self

Returns the matrix form of the perplex number.

Source§

impl<T: Copy + Num> From<T> for Perplex<T>

Source§

fn from(t: T) -> Self

Conversion of a number t into a Perplex yields time-component t with zero space component.

Source§

impl<T: Hash> Hash for Perplex<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Copy + Num + Neg<Output = T>> Inv for Perplex<T>

Source§

type Output = Option<Perplex<T>>

The result after applying the operator.
Source§

fn inv(self) -> Self::Output

Returns the multiplicative inverse of self. Read more
Source§

impl<T: Copy + Num> Mul<T> for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Copy + Num> Mul for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Copy + Num + MulAdd<Output = T>> MulAdd for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the fused multiply-add.
Source§

fn mul_add(self, other: Perplex<T>, add: Perplex<T>) -> Self

Performs the fused multiply-add operation (self * a) + b
Source§

impl<T: Copy + NumAssign + MulAddAssign> MulAddAssign for Perplex<T>

Source§

fn mul_add_assign(&mut self, other: Self, add: Self)

Performs the fused multiply-add assignment operation *self = (*self * a) + b
Source§

impl<T: Copy + NumAssign> MulAssign<T> for Perplex<T>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<T: Copy + NumAssign> MulAssign for Perplex<T>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T: Copy + Num + Neg<Output = T>> Neg for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: Copy + Num> One for Perplex<T>

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl<T: Ord> Ord for Perplex<T>

Source§

fn cmp(&self, other: &Perplex<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Perplex<T>

Source§

fn eq(&self, other: &Perplex<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for Perplex<T>

Source§

fn partial_cmp(&self, other: &Perplex<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy + Num + Neg<Output = T>> Pow<i32> for Perplex<T>

Source§

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§

type Output = Option<Perplex<T>>

The result after applying the operator.
Source§

impl<T: Copy + Num> Pow<u32> for Perplex<T>

Source§

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§

type Output = Perplex<T>

The result after applying the operator.
Source§

impl<T: Copy + Num> Sub<T> for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Copy + Num> Sub for Perplex<T>

Source§

type Output = Perplex<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Copy + NumAssign> SubAssign<T> for Perplex<T>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<T: Copy + NumAssign> SubAssign for Perplex<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T: Copy + Num> Zero for Perplex<T>

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy> Copy for Perplex<T>

Source§

impl<T: Eq> Eq for Perplex<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

Source§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,