Enum lattice_qcd_rs::lattice::DirectionEnum
source · pub enum DirectionEnum {
XPos,
XNeg,
YPos,
YNeg,
ZPos,
ZNeg,
TPos,
TNeg,
}
Expand description
Represent a cardinal direction
Variants§
XPos
Positive x direction.
XNeg
Negative x direction.
YPos
Positive y direction.
YNeg
Negative y direction.
ZPos
Positive z direction.
ZNeg
Negative z direction.
TPos
Positive t direction.
TNeg
Negative t direction.
Implementations§
source§impl DirectionEnum
impl DirectionEnum
sourcepub const DIRECTIONS: [Self; 8] = _
pub const DIRECTIONS: [Self; 8] = _
List all directions.
sourcepub const DIRECTIONS_SPACE: [Self; 6] = _
pub const DIRECTIONS_SPACE: [Self; 6] = _
List all spatial directions.
sourcepub const POSITIVES_SPACE: [Self; 3] = _
pub const POSITIVES_SPACE: [Self; 3] = _
List spatial positive direction.
sourcepub const fn to_unit_vector(self) -> Vector4<Real>
pub const fn to_unit_vector(self) -> Vector4<Real>
Convert the direction into a vector of norm 1
;
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Get if the position is positive.
Example
assert_eq!(DirectionEnum::XPos.is_positive(), true);
assert_eq!(DirectionEnum::TPos.is_positive(), true);
assert_eq!(DirectionEnum::YNeg.is_positive(), false);
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Get if the position is Negative. see DirectionEnum::is_positive
sourcepub fn from_vector(v: &Vector4<Real>) -> Self
pub fn from_vector(v: &Vector4<Real>) -> Self
Find the direction the vector point the most.
For a zero vector return DirectionEnum::XPos
.
Example
assert_eq!(
DirectionEnum::from_vector(&nalgebra::Vector4::new(1_f64, 0_f64, 0_f64, 0_f64)),
DirectionEnum::XPos
);
assert_eq!(
DirectionEnum::from_vector(&nalgebra::Vector4::new(0_f64, -1_f64, 0_f64, 0_f64)),
DirectionEnum::YNeg
);
assert_eq!(
DirectionEnum::from_vector(&nalgebra::Vector4::new(0.5_f64, 1_f64, 0_f64, 2_f64)),
DirectionEnum::TPos
);
sourcepub const fn to_positive(self) -> Self
pub const fn to_positive(self) -> Self
Return the positive direction associated, for example -x
gives +x
and +x
gives +x
.
Example
assert_eq!(DirectionEnum::XNeg.to_positive(), DirectionEnum::XPos);
assert_eq!(DirectionEnum::YPos.to_positive(), DirectionEnum::YPos);
sourcepub const fn to_index(self) -> usize
pub const fn to_index(self) -> usize
Get a index associated to the direction.
Example
assert_eq!(DirectionEnum::XPos.to_index(), 0);
assert_eq!(DirectionEnum::XNeg.to_index(), 0);
assert_eq!(DirectionEnum::YPos.to_index(), 1);
assert_eq!(DirectionEnum::YNeg.to_index(), 1);
assert_eq!(DirectionEnum::ZPos.to_index(), 2);
assert_eq!(DirectionEnum::ZNeg.to_index(), 2);
assert_eq!(DirectionEnum::TPos.to_index(), 3);
assert_eq!(DirectionEnum::TNeg.to_index(), 3);
Trait Implementations§
source§impl Clone for DirectionEnum
impl Clone for DirectionEnum
source§fn clone(&self) -> DirectionEnum
fn clone(&self) -> DirectionEnum
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DirectionEnum
impl Debug for DirectionEnum
source§impl Default for DirectionEnum
impl Default for DirectionEnum
Return DirectionEnum::XPos
source§fn default() -> Self
fn default() -> Self
Return DirectionEnum::XPos
source§impl<'de> Deserialize<'de> for DirectionEnum
impl<'de> Deserialize<'de> for DirectionEnum
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl DirectionList for DirectionEnum
impl DirectionList for DirectionEnum
source§fn directions() -> &'static [Self]
fn directions() -> &'static [Self]
source§fn positive_directions() -> &'static [Self]
fn positive_directions() -> &'static [Self]
source§impl Display for DirectionEnum
impl Display for DirectionEnum
source§impl From<&DirectionEnum> for Direction<4>
impl From<&DirectionEnum> for Direction<4>
source§fn from(d: &DirectionEnum) -> Self
fn from(d: &DirectionEnum) -> Self
source§impl From<&DirectionEnum> for Vector4<Real>
impl From<&DirectionEnum> for Vector4<Real>
Return DirectionEnum::to_unit_vector
.
source§fn from(d: &DirectionEnum) -> Self
fn from(d: &DirectionEnum) -> Self
source§impl From<&DirectionEnum> for usize
impl From<&DirectionEnum> for usize
Return DirectionEnum::to_index
.
source§fn from(d: &DirectionEnum) -> Self
fn from(d: &DirectionEnum) -> Self
source§impl From<&Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for DirectionEnum
impl From<&Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for DirectionEnum
Return DirectionEnum::from_vector
.
source§impl From<DirectionEnum> for Direction<4>
impl From<DirectionEnum> for Direction<4>
source§fn from(d: DirectionEnum) -> Self
fn from(d: DirectionEnum) -> Self
source§impl From<DirectionEnum> for Vector4<Real>
impl From<DirectionEnum> for Vector4<Real>
Return DirectionEnum::to_unit_vector
.
source§fn from(d: DirectionEnum) -> Self
fn from(d: DirectionEnum) -> Self
source§impl From<DirectionEnum> for usize
impl From<DirectionEnum> for usize
Return DirectionEnum::to_index
.
source§fn from(d: DirectionEnum) -> Self
fn from(d: DirectionEnum) -> Self
source§impl From<Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for DirectionEnum
impl From<Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for DirectionEnum
Return DirectionEnum::from_vector
.
source§impl Hash for DirectionEnum
impl Hash for DirectionEnum
source§impl Neg for &DirectionEnum
impl Neg for &DirectionEnum
source§impl Neg for DirectionEnum
impl Neg for DirectionEnum
Return the negative of a direction
Example
assert_eq!(-DirectionEnum::XNeg, DirectionEnum::XPos);
assert_eq!(-DirectionEnum::YPos, DirectionEnum::YNeg);
source§impl PartialEq<DirectionEnum> for DirectionEnum
impl PartialEq<DirectionEnum> for DirectionEnum
source§fn eq(&self, other: &DirectionEnum) -> bool
fn eq(&self, other: &DirectionEnum) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<DirectionEnum> for DirectionEnum
impl PartialOrd<DirectionEnum> for DirectionEnum
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for DirectionEnum
impl Serialize for DirectionEnum
impl Copy for DirectionEnum
impl Eq for DirectionEnum
impl StructuralEq for DirectionEnum
impl StructuralPartialEq for DirectionEnum
Auto Trait Implementations§
impl RefUnwindSafe for DirectionEnum
impl Send for DirectionEnum
impl Sync for DirectionEnum
impl Unpin for DirectionEnum
impl UnwindSafe for DirectionEnum
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.