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