Alex Mikhalev
6 years ago
3 changed files with 202 additions and 27 deletions
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
use std::ops; |
||||
|
||||
use super::eqn::{Expr, Unknown}; |
||||
use super::Scalar; |
||||
|
||||
impl From<Scalar> for Expr { |
||||
fn from(c: Scalar) -> Expr { |
||||
Expr::Const(c) |
||||
} |
||||
} |
||||
|
||||
impl From<Unknown> for Expr { |
||||
fn from(u: Unknown) -> Expr { |
||||
Expr::Unkn(u) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Expr> for Expr { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Expr) -> Expr { |
||||
Expr::new_sum(self, rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Scalar> for Expr { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Scalar) -> Expr { |
||||
Expr::new_sum(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Unknown> for Expr { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Unknown) -> Expr { |
||||
Expr::new_sum(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Expr> for Expr { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Expr) -> Expr { |
||||
Expr::new_minus(self, rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Scalar> for Expr { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Scalar) -> Expr { |
||||
Expr::new_minus(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Unknown> for Expr { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Unknown) -> Expr { |
||||
Expr::new_minus(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Expr> for Expr { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Expr) -> Expr { |
||||
Expr::new_product(self, rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Scalar> for Expr { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Scalar) -> Expr { |
||||
Expr::new_product(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Unknown> for Expr { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Unknown) -> Expr { |
||||
Expr::new_product(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Expr> for Expr { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Expr) -> Expr { |
||||
Expr::new_div(self, rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Scalar> for Expr { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Scalar) -> Expr { |
||||
Expr::new_div(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Unknown> for Expr { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Unknown) -> Expr { |
||||
Expr::new_div(self, rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Expr> for Unknown { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Expr) -> Expr { |
||||
Expr::new_sum(self.into(), rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Scalar> for Unknown { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Scalar) -> Expr { |
||||
Expr::new_sum(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Add<Unknown> for Unknown { |
||||
type Output = Expr; |
||||
fn add(self, rhs: Unknown) -> Expr { |
||||
Expr::new_sum(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Expr> for Unknown { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Expr) -> Expr { |
||||
Expr::new_minus(self.into(), rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Scalar> for Unknown { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Scalar) -> Expr { |
||||
Expr::new_minus(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Sub<Unknown> for Unknown { |
||||
type Output = Expr; |
||||
fn sub(self, rhs: Unknown) -> Expr { |
||||
Expr::new_minus(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Expr> for Unknown { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Expr) -> Expr { |
||||
Expr::new_product(self.into(), rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Scalar> for Unknown { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Scalar) -> Expr { |
||||
Expr::new_product(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Mul<Unknown> for Unknown { |
||||
type Output = Expr; |
||||
fn mul(self, rhs: Unknown) -> Expr { |
||||
Expr::new_product(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Expr> for Unknown { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Expr) -> Expr { |
||||
Expr::new_div(self.into(), rhs) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Scalar> for Unknown { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Scalar) -> Expr { |
||||
Expr::new_div(self.into(), rhs.into()) |
||||
} |
||||
} |
||||
|
||||
impl ops::Div<Unknown> for Unknown { |
||||
type Output = Expr; |
||||
fn div(self, rhs: Unknown) -> Expr { |
||||
Expr::new_div(self.into(), rhs.into()) |
||||
} |
||||
} |
Loading…
Reference in new issue