use_eigen/
multiplicity.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub struct EigenMultiplicity {
4 algebraic: usize,
5 geometric: usize,
6}
7
8impl EigenMultiplicity {
9 #[must_use]
11 pub const fn new(algebraic: usize, geometric: usize) -> Self {
12 Self {
13 algebraic,
14 geometric,
15 }
16 }
17
18 #[must_use]
20 pub const fn algebraic(self) -> usize {
21 self.algebraic
22 }
23
24 #[must_use]
26 pub const fn geometric(self) -> usize {
27 self.geometric
28 }
29
30 #[must_use]
32 pub const fn is_simple(self) -> bool {
33 self.algebraic == 1 && self.geometric == 1
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use super::EigenMultiplicity;
40
41 #[test]
42 fn exposes_algebraic_and_geometric_multiplicity() {
43 let multiplicity = EigenMultiplicity::new(3, 2);
44
45 assert_eq!(multiplicity.algebraic(), 3);
46 assert_eq!(multiplicity.geometric(), 2);
47 assert!(!multiplicity.is_simple());
48 assert!(EigenMultiplicity::new(1, 1).is_simple());
49 }
50}