diff options
| author | hachem <im@hachem.wtf> | 2024-09-16 21:22:44 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2024-09-16 21:22:44 +0200 |
| commit | a3e3971bcf5cc938db1fcae1e24e1c72f5a10038 (patch) | |
| tree | dcc73c9514bdb69cccb76b53e8cff4cd53a35b8a /libmu/src/maths/vector.rs | |
| parent | 5abda23c3ed21db3c0a4541b85b6e2e916ce569e (diff) | |
refactor and fix bugs
Diffstat (limited to 'libmu/src/maths/vector.rs')
| -rw-r--r-- | libmu/src/maths/vector.rs | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/libmu/src/maths/vector.rs b/libmu/src/maths/vector.rs index 682907e..c97b415 100644 --- a/libmu/src/maths/vector.rs +++ b/libmu/src/maths/vector.rs @@ -1,5 +1,8 @@ +// TODO(Hachem): Operators Matrix/Vector don't work +// TODO(Hachem): Refactor + use super::{Float, Matrix}; -use core::ops; +use core::{fmt, ops}; #[macro_export] macro_rules! row_vector { @@ -330,3 +333,43 @@ impl<T: Float> ops::MulAssign<&Matrix<T>> for ColumnVector<T> { } } } + +impl<T: Float + fmt::Debug> fmt::Debug for RowVector<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "RowVector({:?})", self.0) + } +} + +impl<T: Float + fmt::Debug> fmt::Debug for ColumnVector<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ColumnVector({:?})", self.0) + } +} + +impl<T: Float + fmt::Display> fmt::Display for RowVector<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "[{}]", + self.0 + .iter() + .map(|x| x.to_string()) + .collect::<Vec<String>>() + .join(", ") + ) + } +} + +impl<T: Float + fmt::Display> fmt::Display for ColumnVector<T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "[{}]", + self.0 + .iter() + .map(|x| x.to_string()) + .collect::<Vec<String>>() + .join(", ") + ) + } +} |
