conspire/math/tensor/rank_0/list/
mod.rs

1#[cfg(test)]
2mod test;
3
4use crate::math::{Tensor, TensorRank0, tensor::list::TensorList};
5use std::ops::Mul;
6
7pub type TensorRank0List<const W: usize> = TensorList<TensorRank0, W>;
8
9impl<const W: usize> Mul for TensorRank0List<W> {
10    type Output = TensorRank0;
11    fn mul(self, tensor_rank_0_list: Self) -> Self::Output {
12        self.iter()
13            .zip(tensor_rank_0_list.iter())
14            .map(|(self_entry, entry)| self_entry * entry)
15            .sum()
16    }
17}
18
19impl<const W: usize> Mul<&Self> for TensorRank0List<W> {
20    type Output = TensorRank0;
21    fn mul(self, tensor_rank_0_list: &Self) -> Self::Output {
22        self.iter()
23            .zip(tensor_rank_0_list.iter())
24            .map(|(self_entry, entry)| self_entry * entry)
25            .sum()
26    }
27}
28
29impl<const W: usize> Mul<TensorRank0List<W>> for &TensorRank0List<W> {
30    type Output = TensorRank0;
31    fn mul(self, tensor_rank_0_list: TensorRank0List<W>) -> Self::Output {
32        self.iter()
33            .zip(tensor_rank_0_list.iter())
34            .map(|(self_entry, entry)| self_entry * entry)
35            .sum()
36    }
37}
38
39impl<const W: usize> Mul for &TensorRank0List<W> {
40    type Output = TensorRank0;
41    fn mul(self, tensor_rank_0_list: Self) -> Self::Output {
42        self.iter()
43            .zip(tensor_rank_0_list.iter())
44            .map(|(self_entry, entry)| self_entry * entry)
45            .sum()
46    }
47}