aboutsummaryrefslogtreecommitdiff
path: root/libmu/src/maths
diff options
context:
space:
mode:
Diffstat (limited to 'libmu/src/maths')
-rw-r--r--libmu/src/maths/matrix.rs3
-rw-r--r--libmu/src/maths/vector.rs17
2 files changed, 10 insertions, 10 deletions
diff --git a/libmu/src/maths/matrix.rs b/libmu/src/maths/matrix.rs
index 9932895..388f858 100644
--- a/libmu/src/maths/matrix.rs
+++ b/libmu/src/maths/matrix.rs
@@ -24,6 +24,7 @@ macro_rules! matrix {
}};
}
+#[derive(Clone)]
pub struct Matrix<T: Float> {
pub data: Vec<T>,
pub rows: usize,
@@ -78,7 +79,7 @@ impl<T: Float> Matrix<T> {
for l in 0..other.cols {
let result_row = i * other.rows + k;
let result_col = j * other.cols + l;
- result.set(result_row, result_col, self_val * other.get(k, l))
+ result.set(result_row, result_col, self_val.clone() * other.get(k, l));
}
}
}
diff --git a/libmu/src/maths/vector.rs b/libmu/src/maths/vector.rs
index c97b415..0c13e4c 100644
--- a/libmu/src/maths/vector.rs
+++ b/libmu/src/maths/vector.rs
@@ -362,14 +362,13 @@ impl<T: Float + fmt::Display> fmt::Display for RowVector<T> {
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(", ")
- )
+ write!(f, "[")?;
+ for (i, x) in self.0.iter().enumerate() {
+ if i > 0 {
+ write!(f, ",\n ")?;
+ }
+ write!(f, "{}", x)?;
+ }
+ write!(f, "]")
}
}