Implement Vector/Scalar multiplication

This commit is contained in:
Hanno Braun 2024-12-17 20:39:25 +01:00
parent b01ebd326a
commit a6b1bbfdcb

View File

@ -39,3 +39,22 @@ where
Self { components }
}
}
impl<S, const D: usize> ops::Mul<S> for Vector<D>
where
S: Into<Scalar>,
{
type Output = Self;
fn mul(self, scalar: S) -> Self::Output {
let scalar = scalar.into();
let components = self
.components
.into_iter_fixed()
.map(|v| v * scalar)
.collect();
Self { components }
}
}