Skip to content

Commit 4448160

Browse files
committed
rename Ideal.len to dimension
1 parent fd75b52 commit 4448160

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/downset.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl DownSet {
344344
continue;
345345
}
346346
processed.insert(flow.clone());
347-
if Self::is_safe(ideal, edges, safe, ideal.len(), maximal_finite_value) {
347+
if Self::is_safe(ideal, edges, safe, ideal.dimension(), maximal_finite_value) {
348348
//println!("...safe");
349349
result.insert(ideal);
350350
} else {
@@ -384,7 +384,7 @@ impl DownSet {
384384
}
385385
//println!("{} refined", candidate);
386386
let mut candidate_copy = candidate.clone();
387-
for i in 0..candidate.len() {
387+
for i in 0..candidate.dimension() {
388388
let ci = candidate.get(i);
389389
if ci == C0 || ci == OMEGA {
390390
continue;
@@ -486,7 +486,7 @@ impl DownSet {
486486
max_finite_value: coef,
487487
) -> DownSet {
488488
let mut downset = DownSet::new();
489-
let choices = (0..dom.len())
489+
let choices = (0..dom.dimension())
490490
.map(|index| get_choices(dim, dom.get(index), edges.get_successors(index)))
491491
.collect::<Vec<_>>();
492492
for im in choices

src/flow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl Flow {
343343
//debug!("domain\n{}", domain);
344344
//debug!("edges{}", edges);
345345

346-
let dim = domain.len();
346+
let dim = domain.dimension();
347347
if edges.iter().any(|f| f.0 >= dim || f.1 >= dim) {
348348
panic!("Edge out of domain");
349349
}
@@ -389,7 +389,7 @@ impl Flow {
389389
}
390390

391391
fn get_lines_vec(domain: &Ideal, edges: &Graph) -> Vec<Vec<Domain>> {
392-
let dim = domain.len();
392+
let dim = domain.dimension();
393393
domain
394394
.iter()
395395
.enumerate()

src/ideal.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Add for &Ideal {
2525
type Output = Ideal;
2626

2727
fn add(self, other: Self) -> Self::Output {
28-
debug_assert_eq!(self.len(), other.len());
28+
debug_assert_eq!(self.dimension(), other.dimension());
2929
Ideal(
3030
self.0
3131
.iter()
@@ -45,7 +45,7 @@ impl Add for Ideal {
4545

4646
impl AddAssign for Ideal {
4747
fn add_assign(&mut self, other: Self) {
48-
debug_assert_eq!(self.len(), other.len());
48+
debug_assert_eq!(self.dimension(), other.dimension());
4949
for (i, x) in self.0.iter_mut().enumerate() {
5050
*x += other.0[i];
5151
}
@@ -100,7 +100,9 @@ impl Ideal {
100100
self.0.iter().enumerate().all(|(i, &x)| x <= other.0[i])
101101
}
102102

103-
pub fn len(&self) -> usize {
103+
/// Returns the dimension of this ideal,
104+
/// which for us is the number of states in the NFA
105+
pub fn dimension(&self) -> usize {
104106
self.0.len()
105107
}
106108

@@ -113,7 +115,7 @@ impl Ideal {
113115
}
114116

115117
pub fn intersection(x: &Ideal, ideal: &Ideal) -> Ideal {
116-
debug_assert_eq!(x.len(), ideal.len());
118+
debug_assert_eq!(x.dimension(), ideal.dimension());
117119
Ideal(
118120
x.0.iter()
119121
.zip(ideal.0.iter())
@@ -184,8 +186,8 @@ impl Ideal {
184186

185187
//why AddAssign does not allow adding a reference !!??
186188
pub fn add_other(&mut self, x: &Ideal) {
187-
debug_assert_eq!(self.len(), x.len());
188-
for i in 0..self.len() {
189+
debug_assert_eq!(self.dimension(), x.dimension());
190+
for i in 0..self.dimension() {
189191
self.0[i] += x.0[i];
190192
}
191193
}

0 commit comments

Comments
 (0)