|
|
|
@ -3,6 +3,7 @@ use std::fmt;
@@ -3,6 +3,7 @@ use std::fmt;
|
|
|
|
|
use super::expr::Expr; |
|
|
|
|
use super::unknown::*; |
|
|
|
|
use super::Scalar; |
|
|
|
|
use crate::math::expr::Expr::*; |
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)] |
|
|
|
|
pub struct Eqn(pub Expr, pub Expr); |
|
|
|
@ -47,17 +48,18 @@ impl Eqn {
@@ -47,17 +48,18 @@ impl Eqn {
|
|
|
|
|
if !self.has_unknown(for_u) { |
|
|
|
|
return None; |
|
|
|
|
} |
|
|
|
|
trace!("solve: {}", self); |
|
|
|
|
let (l, r) = ( |
|
|
|
|
self.0 |
|
|
|
|
.clone() /*.distribute()*/ |
|
|
|
|
.clone().distribute() |
|
|
|
|
.simplify(), |
|
|
|
|
self.1 |
|
|
|
|
.clone() /*.distribute()*/ |
|
|
|
|
.clone().distribute() |
|
|
|
|
.simplify(), |
|
|
|
|
); |
|
|
|
|
let (mut l, mut r) = ord_by_unkn(l, r, for_u)?; |
|
|
|
|
loop { |
|
|
|
|
trace!("solve: {} == {}", l, r); |
|
|
|
|
trace!("solve iter: {} == {}", l, r); |
|
|
|
|
let (new_l, new_r): (Expr, Expr) = match l { |
|
|
|
|
Unkn(u) => return if u == for_u { Some(r.simplify()) } else { None }, |
|
|
|
|
Sum(es) => { |
|
|
|
|