pub struct Vector8 { /* private fields */ }Expand description
8-dimensional vector with exact coordinates
Used for E₈ root system and Atlas coordinates. All coordinates are half-integers for exact arithmetic.
§Examples
use atlas_embeddings::arithmetic::{Vector8, HalfInteger};
let v = Vector8::new([
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
HalfInteger::new(1), // 1/2
]);
// Norm squared: 8 * (1/2)² = 8 * 1/4 = 2
assert_eq!(v.norm_squared(), num_rational::Ratio::new(2, 1));Implementations§
Source§impl Vector8
impl Vector8
Sourcepub const fn new(coords: [HalfInteger; 8]) -> Self
pub const fn new(coords: [HalfInteger; 8]) -> Self
Create a vector from 8 half-integer coordinates
Sourcepub const fn get(&self, index: usize) -> HalfInteger
pub const fn get(&self, index: usize) -> HalfInteger
Get coordinate at index
Sourcepub const fn coords(&self) -> &[HalfInteger; 8]
pub const fn coords(&self) -> &[HalfInteger; 8]
Get all coordinates as slice
Sourcepub fn inner_product(&self, other: &Self) -> Rational
pub fn inner_product(&self, other: &Self) -> Rational
Inner product (dot product) - exact rational result
⟨v, w⟩ = Σᵢ vᵢ·wᵢ
Sourcepub fn norm_squared(&self) -> Rational
pub fn norm_squared(&self) -> Rational
Norm squared: ‖v‖² = ⟨v, v⟩
Sourcepub fn scale_rational(&self, scalar: Rational) -> Self
pub fn scale_rational(&self, scalar: Rational) -> Self
Scalar multiplication by rational
Multiplies each coordinate by a rational scalar (exact arithmetic)
Trait Implementations§
impl Copy for Vector8
impl Eq for Vector8
impl StructuralPartialEq for Vector8
Auto Trait Implementations§
impl Freeze for Vector8
impl RefUnwindSafe for Vector8
impl Send for Vector8
impl Sync for Vector8
impl Unpin for Vector8
impl UnwindSafe for Vector8
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
Mutably borrows from an owned value. Read more