use crate::Tensor;
use crate::ops::broadcast::apply_binary;
use std::ops::{Add, Div, Mul, Sub};
impl Add for &Tensor {
type Output = Tensor;
fn add(self, rhs: &Tensor) -> Tensor {
apply_binary(self, rhs, "add", |a, b| a + b)
}
}
impl Sub for &Tensor {
type Output = Tensor;
fn sub(self, rhs: &Tensor) -> Tensor {
apply_binary(self, rhs, "sub", |a, b| a - b)
}
}
impl Mul for &Tensor {
type Output = Tensor;
fn mul(self, rhs: &Tensor) -> Tensor {
apply_binary(self, rhs, "mul", |a, b| a * b)
}
}
impl Div for &Tensor {
type Output = Tensor;
fn div(self, rhs: &Tensor) -> Tensor {
apply_binary(self, rhs, "div", |a, b| a / b)
}
}