mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-05-13 03:00:26 -04:00
Merge pull request #142 from chriseth/degree_computaton
Assert degree is large enough.
This commit is contained in:
@@ -127,12 +127,17 @@ impl ArrayExpression {
|
||||
impl ArrayExpression {
|
||||
/// solve for `*`
|
||||
pub fn solve(&self, degree: DegreeType) -> Option<DegreeType> {
|
||||
assert!(degree > 0, "Degree cannot be zero.");
|
||||
// the length of this expression is `a + b*x`
|
||||
let (a, b) = self.len();
|
||||
// it must match `degree`, and we solve for `x`
|
||||
if b == 0 {
|
||||
None
|
||||
} else {
|
||||
assert!(
|
||||
a <= degree,
|
||||
"Array literal is too large ({a}) for degree ({degree})."
|
||||
);
|
||||
assert_eq!((degree - a) % b, 0, "Cannot find a suitable value for `*`");
|
||||
Some((degree - a) / b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user