pub struct RealVec4 {
pub e: f64,
pub px: f64,
pub py: f64,
pub pz: f64,
}Expand description
A four-vector (Lorentz vector) stored in (E, p_x, p_y, p_z) order.
§Examples
use laddu_physics::vectors::{RealVec3, RealVec4};
let momentum = RealVec3::new(1.0, 0.0, 0.0);
let four_vector = momentum.with_mass(2.0);
assert!((four_vector.m2() - 4.0).abs() < 1e-12);Fields§
§e: f64Energy component.
px: f64Momentum in the x direction.
py: f64Momentum in the y direction.
pz: f64Momentum in the z direction.
Implementations§
Source§impl RealVec4
impl RealVec4
Sourcepub fn new(e: f64, px: f64, py: f64, pz: f64) -> RealVec4
pub fn new(e: f64, px: f64, py: f64, pz: f64) -> RealVec4
Create a four-vector in metric order (E, p_x, p_y, p_z).
Sourcepub fn gamma(&self) -> Result<f64, LadduPhysicsError>
pub fn gamma(&self) -> Result<f64, LadduPhysicsError>
The $\gamma$ factor $\frac{1}{\sqrt{1 - \beta^2}}$.
§Errors
Returns LadduPhysicsError when the energy is not positive or the
resulting velocity is not subluminal.
Sourcepub fn beta(&self) -> Result<RealVec3, LadduPhysicsError>
pub fn beta(&self) -> Result<RealVec3, LadduPhysicsError>
The $\vec{\beta}$ vector $\frac{\vec{p}}{E}$.
§Errors
Returns LadduPhysicsError when the four-momentum energy is not
positive.
Sourcepub fn m(&self) -> Result<f64, LadduPhysicsError>
pub fn m(&self) -> Result<f64, LadduPhysicsError>
The invariant mass corresponding to this 4-momentum
§Errors
Returns LadduPhysicsError when the invariant mass squared is
non-finite or negative.
Sourcepub fn m_unchecked(&self) -> f64
pub fn m_unchecked(&self) -> f64
Return the invariant mass without checking for a spacelike vector.
Sourcepub fn signed_m(&self) -> Result<f64, LadduPhysicsError>
pub fn signed_m(&self) -> Result<f64, LadduPhysicsError>
Return the signed invariant mass.
§Errors
Returns LadduPhysicsError when the invariant mass squared is
non-finite.
Sourcepub fn signed_m_unchecked(&self) -> f64
pub fn signed_m_unchecked(&self) -> f64
Return the signed invariant mass without checking for finite components.
Sourcepub fn dot(&self, other: &RealVec4) -> f64
pub fn dot(&self, other: &RealVec4) -> f64
Compute the Lorentz inner product with another four-vector.
Sourcepub fn to_p4_string(&self) -> String
pub fn to_p4_string(&self) -> String
Pretty-prints the four-momentum.
Sourcepub fn mag(&self) -> Result<f64, LadduPhysicsError>
pub fn mag(&self) -> Result<f64, LadduPhysicsError>
Alias for Self::m using the $+---$ metric.
§Errors
Returns LadduPhysicsError for non-finite or spacelike four-vectors,
where m2 < 0.
Sourcepub fn signed_mag(&self) -> Result<f64, LadduPhysicsError>
pub fn signed_mag(&self) -> Result<f64, LadduPhysicsError>
Signed invariant mass useful for diagnostics:
sqrt(mag2)for timelike/null vectors-sqrt(-mag2)for spacelike vectors
§Errors
Returns LadduPhysicsError when the invariant magnitude squared is
non-finite.
Sourcepub fn signed_mag_unchecked(&self) -> f64
pub fn signed_mag_unchecked(&self) -> f64
Return the signed magnitude without checking for finite components.
Trait Implementations§
Source§impl AbsDiffEq for RealVec4
impl AbsDiffEq for RealVec4
Source§fn default_epsilon() -> <RealVec4 as AbsDiffEq>::Epsilon
fn default_epsilon() -> <RealVec4 as AbsDiffEq>::Epsilon
Source§fn abs_diff_eq(
&self,
other: &RealVec4,
epsilon: <RealVec4 as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &RealVec4, epsilon: <RealVec4 as AbsDiffEq>::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.impl Copy for RealVec4
Source§impl<'de> Deserialize<'de> for RealVec4
impl<'de> Deserialize<'de> for RealVec4
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RealVec4, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RealVec4, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl RelativeEq for RealVec4
impl RelativeEq for RealVec4
Source§fn default_max_relative() -> <RealVec4 as AbsDiffEq>::Epsilon
fn default_max_relative() -> <RealVec4 as AbsDiffEq>::Epsilon
Source§fn relative_eq(
&self,
other: &RealVec4,
epsilon: <RealVec4 as AbsDiffEq>::Epsilon,
max_relative: <RealVec4 as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &RealVec4, epsilon: <RealVec4 as AbsDiffEq>::Epsilon, max_relative: <RealVec4 as AbsDiffEq>::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq.Source§impl Serialize for RealVec4
impl Serialize for RealVec4
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for RealVec4
Auto Trait Implementations§
impl Freeze for RealVec4
impl RefUnwindSafe for RealVec4
impl Send for RealVec4
impl Sync for RealVec4
impl Unpin for RealVec4
impl UnsafeUnpin for RealVec4
impl UnwindSafe for RealVec4
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ClosedNeg for Twhere
T: Neg<Output = T>,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
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.