use crate::ArgminDiv;
use faer::{
mat::AsMatRef,
reborrow::{IntoConst, Reborrow, ReborrowMut},
unzipped, zipped_rw, Conjugate, Entity, Mat, MatMut, MatRef, SimpleEntity,
};
use std::ops::{Div, DivAssign};
impl<E> ArgminDiv<E, Mat<E>> for MatRef<'_, E>
where
E: Entity + Div<E, Output = E>,
{
#[inline]
fn div(&self, other: &E) -> Mat<E> {
zipped_rw!(self).map(|unzipped!(this)| this.read() / *other)
}
}
impl<E> ArgminDiv<E, Mat<E>> for Mat<E>
where
E: Entity + Div<E, Output = E>,
{
#[inline]
fn div(&self, other: &E) -> Mat<E> {
<_ as ArgminDiv<_, _>>::div(&self.as_mat_ref(), other)
}
}
impl<'a, E> ArgminDiv<MatRef<'a, E>, Mat<E>> for E
where
E: Entity + Div<E, Output = E>,
{
#[inline]
fn div(&self, other: &MatRef<'a, E>) -> Mat<E> {
zipped_rw!(other).map(|unzipped!(other_elem)| *self / other_elem.read())
}
}
impl<E> ArgminDiv<Mat<E>, Mat<E>> for E
where
E: Entity + Div<E, Output = E>,
{
#[inline]
fn div(&self, other: &Mat<E>) -> Mat<E> {
<_ as ArgminDiv<_, _>>::div(self, &other.as_mat_ref())
}
}
impl<'a, E: Entity + Div<E, Output = E>> ArgminDiv<MatRef<'a, E>, Mat<E>> for MatRef<'_, E> {
#[inline]
fn div(&self, other: &MatRef<'a, E>) -> Mat<E> {
zipped_rw!(self, other).map(|unzipped!(this, other)| this.read() / other.read())
}
}
impl<'a, E: Entity + Div<E, Output = E>> ArgminDiv<MatRef<'a, E>, Mat<E>> for Mat<E> {
#[inline]
fn div(&self, other: &MatRef<'a, E>) -> Mat<E> {
<_ as ArgminDiv<_, _>>::div(&self.as_mat_ref(), other)
}
}
impl<E: Entity + Div<E, Output = E>> ArgminDiv<Mat<E>, Mat<E>> for MatRef<'_, E> {
#[inline]
fn div(&self, other: &Mat<E>) -> Mat<E> {
<_ as ArgminDiv<_, _>>::div(self, &other.as_mat_ref())
}
}
impl<E: Entity + Div<E, Output = E>> ArgminDiv<Mat<E>, Mat<E>> for Mat<E> {
#[inline]
fn div(&self, other: &Mat<E>) -> Mat<E> {
<_ as ArgminDiv<_, _>>::div(&self.as_mat_ref(), &other.as_mat_ref())
}
}