use std::ops::{Add, Div, Mul, Neg, Rem, Sub};
use super::*;
impl Add for Expr {
type Output = Expr;
fn add(self, rhs: Self) -> Self::Output {
binary_expr(self, Operator::Plus, rhs)
}
}
impl Sub for Expr {
type Output = Expr;
fn sub(self, rhs: Self) -> Self::Output {
binary_expr(self, Operator::Minus, rhs)
}
}
impl Div for Expr {
type Output = Expr;
fn div(self, rhs: Self) -> Self::Output {
binary_expr(self, Operator::RustDivide, rhs)
}
}
impl Mul for Expr {
type Output = Expr;
fn mul(self, rhs: Self) -> Self::Output {
binary_expr(self, Operator::Multiply, rhs)
}
}
impl Rem for Expr {
type Output = Expr;
fn rem(self, rhs: Self) -> Self::Output {
binary_expr(self, Operator::Modulus, rhs)
}
}
impl Neg for Expr {
type Output = Expr;
fn neg(self) -> Self::Output {
self.map_unary(FunctionExpr::Negate)
}
}
impl Expr {
pub fn floor_div(self, rhs: Self) -> Self {
binary_expr(self, Operator::FloorDivide, rhs)
}
pub fn true_div(self, rhs: Self) -> Self {
binary_expr(self, Operator::TrueDivide, rhs)
}
pub fn pow<E: Into<Expr>>(self, exponent: E) -> Self {
self.map_binary(PowFunction::Generic, exponent.into())
}
pub fn sqrt(self) -> Self {
self.map_unary(PowFunction::Sqrt)
}
pub fn cbrt(self) -> Self {
self.map_unary(PowFunction::Cbrt)
}
#[cfg(feature = "trigonometry")]
pub fn cos(self) -> Self {
self.map_unary(TrigonometricFunction::Cos)
}
#[cfg(feature = "trigonometry")]
pub fn cot(self) -> Self {
self.map_unary(TrigonometricFunction::Cot)
}
#[cfg(feature = "trigonometry")]
pub fn sin(self) -> Self {
self.map_unary(TrigonometricFunction::Sin)
}
#[cfg(feature = "trigonometry")]
pub fn tan(self) -> Self {
self.map_unary(TrigonometricFunction::Tan)
}
#[cfg(feature = "trigonometry")]
pub fn arccos(self) -> Self {
self.map_unary(TrigonometricFunction::ArcCos)
}
#[cfg(feature = "trigonometry")]
pub fn arcsin(self) -> Self {
self.map_unary(TrigonometricFunction::ArcSin)
}
#[cfg(feature = "trigonometry")]
pub fn arctan(self) -> Self {
self.map_unary(TrigonometricFunction::ArcTan)
}
#[cfg(feature = "trigonometry")]
pub fn arctan2(self, x: Self) -> Self {
self.map_binary(FunctionExpr::Atan2, x)
}
#[cfg(feature = "trigonometry")]
pub fn cosh(self) -> Self {
self.map_unary(TrigonometricFunction::Cosh)
}
#[cfg(feature = "trigonometry")]
pub fn sinh(self) -> Self {
self.map_unary(TrigonometricFunction::Sinh)
}
#[cfg(feature = "trigonometry")]
pub fn tanh(self) -> Self {
self.map_unary(TrigonometricFunction::Tanh)
}
#[cfg(feature = "trigonometry")]
pub fn arccosh(self) -> Self {
self.map_unary(TrigonometricFunction::ArcCosh)
}
#[cfg(feature = "trigonometry")]
pub fn arcsinh(self) -> Self {
self.map_unary(TrigonometricFunction::ArcSinh)
}
#[cfg(feature = "trigonometry")]
pub fn arctanh(self) -> Self {
self.map_unary(TrigonometricFunction::ArcTanh)
}
#[cfg(feature = "trigonometry")]
pub fn degrees(self) -> Self {
self.map_unary(TrigonometricFunction::Degrees)
}
#[cfg(feature = "trigonometry")]
pub fn radians(self) -> Self {
self.map_unary(TrigonometricFunction::Radians)
}
#[cfg(feature = "sign")]
pub fn sign(self) -> Self {
self.map_unary(FunctionExpr::Sign)
}
}