From a3e3971bcf5cc938db1fcae1e24e1c72f5a10038 Mon Sep 17 00:00:00 2001 From: hachem Date: Mon, 16 Sep 2024 21:22:44 +0200 Subject: refactor and fix bugs --- libmu/src/maths/vector.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'libmu/src/maths/vector.rs') 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 ops::MulAssign<&Matrix> for ColumnVector { } } } + +impl fmt::Debug for RowVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "RowVector({:?})", self.0) + } +} + +impl fmt::Debug for ColumnVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ColumnVector({:?})", self.0) + } +} + +impl fmt::Display for RowVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "[{}]", + self.0 + .iter() + .map(|x| x.to_string()) + .collect::>() + .join(", ") + ) + } +} + +impl fmt::Display for ColumnVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "[{}]", + self.0 + .iter() + .map(|x| x.to_string()) + .collect::>() + .join(", ") + ) + } +} -- cgit v1.3