From d3e783906dfd8959ff0d1c75fa63b099d14da2f3 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 22 Sep 2024 22:35:48 +0200 Subject: Fix DisplayFmt --- libpsi/src/maths/matrix.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libpsi/src/maths') diff --git a/libpsi/src/maths/matrix.rs b/libpsi/src/maths/matrix.rs index 795b37f..975c92d 100644 --- a/libpsi/src/maths/matrix.rs +++ b/libpsi/src/maths/matrix.rs @@ -1,5 +1,3 @@ -// TODO(Hachem): Refactor - use super::Float; use core::{fmt, ops}; @@ -175,10 +173,17 @@ impl fmt::Debug for Matrix { impl fmt::Display for Matrix { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for i in 0..self.rows { + write!(f, "[")?; for j in 0..self.cols { - write!(f, "{:>8} ", self.get(i, j))?; + write!(f, "{}", self.get(i, j))?; + if j != self.cols - 1 { + write!(f, " ")?; + } + } + write!(f, "]")?; + if i != self.rows - 1 { + write!(f, "\n")?; } - writeln!(f)?; } Ok(()) } -- cgit v1.3