use crate::tensor::TensorBase;
use ndarray::{ArrayBase, Data, Dimension, RawData, RawDataClone};
impl<A, S, D> TensorBase<S, D>
where
D: Dimension,
S: RawData<Elem = A>,
{
}
impl<A, S, D> Clone for TensorBase<S, D>
where
A: Clone,
S: RawDataClone<Elem = A>,
D: Dimension,
{
fn clone(&self) -> Self {
TensorBase {
store: self.store().clone(),
}
}
}
impl<A, S, D> Copy for TensorBase<S, D>
where
A: Copy,
S: RawDataClone<Elem = A> + Copy,
D: Dimension + Copy,
{
}
impl<A, S, D> core::fmt::Debug for TensorBase<S, D>
where
A: core::fmt::Debug,
S: Data<Elem = A>,
D: Dimension,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("TensorBase")
.field("store", &self.store())
.finish()
}
}
impl<A, S, D> core::fmt::Display for TensorBase<S, D>
where
A: core::fmt::Display,
S: Data<Elem = A>,
D: Dimension,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.store())
}
}
impl<A, S, D> PartialEq for TensorBase<S, D>
where
A: PartialEq,
S: Data<Elem = A>,
D: Dimension,
{
fn eq(&self, other: &Self) -> bool {
self.store() == other.store()
}
}
impl<A, S, D> PartialEq<ArrayBase<S, D>> for TensorBase<S, D>
where
A: PartialEq,
S: Data<Elem = A>,
D: Dimension,
{
fn eq(&self, other: &ArrayBase<S, D>) -> bool {
self.store() == other
}
}
impl<A, S, D> PartialEq<&ArrayBase<S, D>> for TensorBase<S, D>
where
A: PartialEq,
S: Data<Elem = A>,
D: Dimension,
{
fn eq(&self, other: &&ArrayBase<S, D>) -> bool {
self.store() == *other
}
}
impl<A, S, D> PartialEq<&mut ArrayBase<S, D>> for TensorBase<S, D>
where
A: PartialEq,
S: Data<Elem = A>,
D: Dimension,
{
fn eq(&self, other: &&mut ArrayBase<S, D>) -> bool {
self.store() == *other
}
}