From 1b6170fa5a96e50f5d737d9dd31d80987bb3e26c Mon Sep 17 00:00:00 2001 From: ferxades12 Date: Wed, 24 Jun 2026 14:58:38 +0200 Subject: [PATCH] feat: add shape method to MatrixTrait and implementations for ComplexMatrix and Matrix --- src/complex/matrix.rs | 4 ++++ src/structure/matrix.rs | 4 ++++ src/traits/matrix.rs | 1 + 3 files changed, 9 insertions(+) diff --git a/src/complex/matrix.rs b/src/complex/matrix.rs index a3ec647..7afa90a 100644 --- a/src/complex/matrix.rs +++ b/src/complex/matrix.rs @@ -706,6 +706,10 @@ impl MatrixTrait for ComplexMatrix { } } } + + fn shape(&self) -> (usize, usize) { + (self.row, self.col) + } } // ============================================================================= diff --git a/src/structure/matrix.rs b/src/structure/matrix.rs index aa3c01c..0795b28 100644 --- a/src/structure/matrix.rs +++ b/src/structure/matrix.rs @@ -1272,6 +1272,10 @@ impl MatrixTrait for Matrix { } } } + + fn shape(&self) -> (usize, usize) { + (self.row, self.col) + } } impl Matrix { diff --git a/src/traits/matrix.rs b/src/traits/matrix.rs index a2d14c4..10daabd 100644 --- a/src/traits/matrix.rs +++ b/src/traits/matrix.rs @@ -28,6 +28,7 @@ pub trait MatrixTrait: fn to_diag(&self) -> Self; fn submat(&self, start: (usize, usize), end: (usize, usize)) -> Self; fn subs_mat(&mut self, start: (usize, usize), end: (usize, usize), m: &Self); + fn shape(&self) -> (usize, usize); } // ┌─────────────────────────────────────────────────────────┐