aboutsummaryrefslogtreecommitdiff
path: root/libmu/src/maths/vector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libmu/src/maths/vector.rs')
-rw-r--r--libmu/src/maths/vector.rs45
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(", ")
+ )
+ }
+}