Skip to content

Commit

Permalink
chirality should use booth
Browse files Browse the repository at this point in the history
  • Loading branch information
inthar-raven committed Aug 12, 2024
1 parent 7f89eb9 commit e9a083b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/equal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ pub fn ed_tunings_for_ternary(
(3..ed_bound)
.flat_map(|l| (2..l).flat_map(move |m| (1..m).map(move |s| vec![l, m, s])))
.filter(|edostep_counts| {
let ed: i32 =
edostep_counts[0] * step_sig[0] as i32
+ edostep_counts[1] * step_sig[1] as i32
+ edostep_counts[2] * step_sig[2] as i32;
let ed: i32 = edostep_counts[0] * step_sig[0] as i32
+ edostep_counts[1] * step_sig[1] as i32
+ edostep_counts[2] * step_sig[2] as i32;
let aber_size = steps_as_cents(edostep_counts[2], ed as f64, equave);
edostep_counts[0] * step_sig[0] as i32
+ edostep_counts[1] * step_sig[1] as i32
+ edostep_counts[2] * step_sig[2] as i32 <= ed_bound
edostep_counts[0] * step_sig[0] as i32
+ edostep_counts[1] * step_sig[1] as i32
+ edostep_counts[2] * step_sig[2] as i32
<= ed_bound
&& aber_lower <= aber_size
&& aber_size <= aber_upper
})
Expand Down
17 changes: 5 additions & 12 deletions src/words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,7 @@ where
+ (1..slice.len())
.map(|i| slice.iter().take(i).cycle())
.take_while(|iter| {
slice.to_vec()
!= iter
.clone()
.take(slice.len())
.cloned()
.collect::<Vec<T>>()
slice.to_vec() != iter.clone().take(slice.len()).cloned().collect::<Vec<T>>()
})
.collect::<Vec<_>>()
.len();
Expand All @@ -668,14 +663,12 @@ where

/// The chirality of a scale word.
pub fn chirality(word: &[Letter]) -> Chirality {
let mut modes = rotations(word);
modes.sort_unstable();
let mut least_mode = least_mode(word);

let word_rev: Vec<usize> = word.iter().cloned().rev().collect();
let mut modes_rev = rotations(&word_rev);
modes_rev.sort_unstable();

match modes[0].cmp(&modes_rev[0]) {
let least_mode_word_rev = least_mode(&word_rev);

match least_mode.cmp(&least_mode_word_rev) {
Ordering::Less => Chirality::Right,
Ordering::Equal => Chirality::Achiral,
Ordering::Greater => Chirality::Left,
Expand Down

0 comments on commit e9a083b

Please sign in to comment.