aoc_framework_utils/math/algebra/
vector.rs

1/// Linear algebra Vector over T of size D
2pub struct Vector<T, const R: usize> {
3  raw: [T; R]
4}
5
6impl <T, const R: usize> Vector<T, R> {
7  pub fn new(components: [T; R]) -> Self {
8    Vector {
9      raw: components
10    }
11  }
12
13  pub fn get(&self, index: usize) -> Option<&T> {
14    self.raw.get(index)
15  }
16}
17
18/// Vector in LL^3 components
19impl <T> Vector<T, 3> {
20  pub fn x(&self) -> &T {
21    &self.raw[0]
22  }
23  pub fn y(&self) -> &T {
24    &self.raw[1]
25  }
26  pub fn z(&self) -> &T {
27    &self.raw[2]
28  }
29}
30
31/// Vector of vectors as a matrix
32impl <T, const R: usize, const S: usize> Vector<Vector<T, R>, S> {
33  
34}