@@ -94,15 +94,16 @@ pub struct DerivedVariable<T, V> {
9494pub enum ComputationMethod < T , E > {
9595 /// A constant value.
9696 Constant ( T ) ,
97- /// The field inverse of an expression if it exists or zero otherwise.
98- InverseOrZero ( E ) ,
97+ /// The quotiont (using inversion in the field) of the first argument
98+ /// by the second argument, or zero if the latter is zero.
99+ QuotientOrZero ( E , E ) ,
99100}
100101
101102impl < T : Display , E : Display > Display for ComputationMethod < T , E > {
102103 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
103104 match self {
104105 ComputationMethod :: Constant ( c) => write ! ( f, "{c}" ) ,
105- ComputationMethod :: InverseOrZero ( e ) => write ! ( f, "InverseOrZero({e })" ) ,
106+ ComputationMethod :: QuotientOrZero ( e1 , e2 ) => write ! ( f, "QuotientOrZero({e1}, {e2 })" ) ,
106107 }
107108 }
108109}
@@ -112,7 +113,10 @@ impl<T, F> ComputationMethod<T, GroupedExpression<T, F>> {
112113 pub fn referenced_unknown_variables ( & self ) -> Box < dyn Iterator < Item = & F > + ' _ > {
113114 match self {
114115 ComputationMethod :: Constant ( _) => Box :: new ( std:: iter:: empty ( ) ) ,
115- ComputationMethod :: InverseOrZero ( e) => e. referenced_unknown_variables ( ) ,
116+ ComputationMethod :: QuotientOrZero ( e1, e2) => Box :: new (
117+ e1. referenced_unknown_variables ( )
118+ . chain ( e2. referenced_unknown_variables ( ) ) ,
119+ ) ,
116120 }
117121 }
118122}
@@ -125,8 +129,9 @@ impl<T: RuntimeConstant + Substitutable<V>, V: Ord + Clone + Eq>
125129 pub fn substitute_by_known ( & mut self , variable : & V , substitution : & T ) {
126130 match self {
127131 ComputationMethod :: Constant ( _) => { }
128- ComputationMethod :: InverseOrZero ( e) => {
129- e. substitute_by_known ( variable, substitution) ;
132+ ComputationMethod :: QuotientOrZero ( e1, e2) => {
133+ e1. substitute_by_known ( variable, substitution) ;
134+ e2. substitute_by_known ( variable, substitution) ;
130135 }
131136 }
132137 }
@@ -138,8 +143,9 @@ impl<T: RuntimeConstant + Substitutable<V>, V: Ord + Clone + Eq>
138143 pub fn substitute_by_unknown ( & mut self , variable : & V , substitution : & GroupedExpression < T , V > ) {
139144 match self {
140145 ComputationMethod :: Constant ( _) => { }
141- ComputationMethod :: InverseOrZero ( e) => {
142- e. substitute_by_unknown ( variable, substitution) ;
146+ ComputationMethod :: QuotientOrZero ( e1, e2) => {
147+ e1. substitute_by_unknown ( variable, substitution) ;
148+ e2. substitute_by_unknown ( variable, substitution) ;
143149 }
144150 }
145151 }
0 commit comments