Skip to main content

lattice_core/
basis.rs

1use crate::types::BasisMatrix;
2
3#[derive(Clone, Debug, PartialEq)]
4pub struct Basis {
5  basis: BasisMatrix,
6}
7
8impl Basis {
9  pub fn new(basis: BasisMatrix) -> Self {
10    assert_eq!(basis.nrows(), basis.ncols(), "basis dimension mismatch");
11    Self { basis }
12  }
13
14  pub fn simple(dim: usize) -> Self {
15    Self::new(BasisMatrix::identity(dim, dim))
16  }
17
18  pub fn dimension(&self) -> usize {
19    self.basis.nrows()
20  }
21
22  pub fn basis_vectors(&self) -> &BasisMatrix {
23    &self.basis
24  }
25
26  pub fn volume(&self) -> f64 {
27    self.basis.clone().determinant().abs()
28  }
29}