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::Divide, 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_private(FunctionExpr::Negate)
}
}
impl Expr {
pub fn floor_div(self, rhs: Self) -> Self {
binary_expr(self, Operator::FloorDivide, rhs)
}
pub fn pow<E: Into<Expr>>(self, exponent: E) -> Self {
self.map_many_private(
FunctionExpr::Pow(PowFunction::Generic),
&[exponent.into()],
false,
false,
)
}
pub fn sqrt(self) -> Self {
self.map_private(FunctionExpr::Pow(PowFunction::Sqrt))
}
pub fn cbrt(self) -> Self {
self.map_private(FunctionExpr::Pow(PowFunction::Cbrt))
}
#[cfg(feature = "trigonometry")]
pub fn cos(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Cos))
}
#[cfg(feature = "trigonometry")]
pub fn cot(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Cot))
}
#[cfg(feature = "trigonometry")]
pub fn sin(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Sin))
}
#[cfg(feature = "trigonometry")]
pub fn tan(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Tan))
}
#[cfg(feature = "trigonometry")]
pub fn arccos(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcCos))
}
#[cfg(feature = "trigonometry")]
pub fn arcsin(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcSin))
}
#[cfg(feature = "trigonometry")]
pub fn arctan(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcTan))
}
#[cfg(feature = "trigonometry")]
pub fn arctan2(self, x: Self) -> Self {
self.map_many_private(FunctionExpr::Atan2, &[x], false, false)
}
#[cfg(feature = "trigonometry")]
pub fn cosh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Cosh))
}
#[cfg(feature = "trigonometry")]
pub fn sinh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Sinh))
}
#[cfg(feature = "trigonometry")]
pub fn tanh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Tanh))
}
#[cfg(feature = "trigonometry")]
pub fn arccosh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcCosh))
}
#[cfg(feature = "trigonometry")]
pub fn arcsinh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcSinh))
}
#[cfg(feature = "trigonometry")]
pub fn arctanh(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::ArcTanh))
}
#[cfg(feature = "trigonometry")]
pub fn degrees(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Degrees))
}
#[cfg(feature = "trigonometry")]
pub fn radians(self) -> Self {
self.map_private(FunctionExpr::Trigonometry(TrigonometricFunction::Radians))
}
#[cfg(feature = "sign")]
pub fn sign(self) -> Self {
self.map_private(FunctionExpr::Sign)
}
}