From 0c84d188508f8f7b7905ca074db99e72b04e6a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 17 Apr 2016 19:47:56 +0200 Subject: [PATCH] Substitute: diag -> diagonal. --- src/structs/dmatrix_macros.rs | 6 +++--- src/structs/matrix_macros.rs | 6 +++--- src/structs/rotation_macros.rs | 4 ++-- src/traits/structure.rs | 4 ++-- tests/mat.rs | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/structs/dmatrix_macros.rs b/src/structs/dmatrix_macros.rs index ab830ae5..f254474f 100644 --- a/src/structs/dmatrix_macros.rs +++ b/src/structs/dmatrix_macros.rs @@ -838,10 +838,10 @@ macro_rules! dmat_impl( impl Diagonal<$dvector> for $dmatrix { #[inline] - fn from_diag(diagonal: &$dvector) -> $dmatrix { + fn from_diagonal(diagonal: &$dvector) -> $dmatrix { let mut res = $dmatrix::new_zeros(diagonal.len(), diagonal.len()); - res.set_diag(diagonal); + res.set_diagonal(diagonal); res } @@ -862,7 +862,7 @@ macro_rules! dmat_impl( impl DiagMut<$dvector> for $dmatrix { #[inline] - fn set_diag(&mut self, diagonal: &$dvector) { + fn set_diagonal(&mut self, diagonal: &$dvector) { let smallest_dim = cmp::min(self.nrows, self.ncols); assert!(diagonal.len() == smallest_dim); diff --git a/src/structs/matrix_macros.rs b/src/structs/matrix_macros.rs index 504f1397..f736398f 100644 --- a/src/structs/matrix_macros.rs +++ b/src/structs/matrix_macros.rs @@ -499,10 +499,10 @@ macro_rules! diag_impl( ($t: ident, $tv: ident, $dimension: expr) => ( impl Diagonal<$tv> for $t { #[inline] - fn from_diag(diagonal: &$tv) -> $t { + fn from_diagonal(diagonal: &$tv) -> $t { let mut res: $t = ::zero(); - res.set_diag(diagonal); + res.set_diagonal(diagonal); res } @@ -521,7 +521,7 @@ macro_rules! diag_impl( impl DiagMut<$tv> for $t { #[inline] - fn set_diag(&mut self, diagonal: &$tv) { + fn set_diagonal(&mut self, diagonal: &$tv) { for i in 0 .. $dimension { unsafe { self.unsafe_set((i, i), diagonal.unsafe_at(i)) } } diff --git a/src/structs/rotation_macros.rs b/src/structs/rotation_macros.rs index 9f21deb7..d59daf1a 100644 --- a/src/structs/rotation_macros.rs +++ b/src/structs/rotation_macros.rs @@ -123,8 +123,8 @@ macro_rules! diag_impl( ($t: ident, $tv: ident) => ( impl Diagonal<$tv> for $t { #[inline] - fn from_diag(diagonal: &$tv) -> $t { - $t { submatrix: Diagonal::from_diag(diagonal) } + fn from_diagonal(diagonal: &$tv) -> $t { + $t { submatrix: Diagonal::from_diagonal(diagonal) } } #[inline] diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 4afc7031..488839d1 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -169,7 +169,7 @@ pub trait Dimension: Sized { /// Trait to get the diagonal of square matrices. pub trait Diagonal { /// Creates a new matrix with the given diagonal. - fn from_diag(diagonal: &V) -> Self; + fn from_diagonal(diagonal: &V) -> Self; /// The diagonal of this matrix. fn diagonal(&self) -> V; @@ -178,7 +178,7 @@ pub trait Diagonal { /// Trait to set the diagonal of square matrices. pub trait DiagMut: Diagonal { /// Sets the diagonal of this matrix. - fn set_diag(&mut self, diagonal: &V); + fn set_diagonal(&mut self, diagonal: &V); } /// The shape of an indexable object. diff --git a/tests/mat.rs b/tests/mat.rs index c1187c17..5acbb0d0 100644 --- a/tests/mat.rs +++ b/tests/mat.rs @@ -49,7 +49,7 @@ macro_rules! test_cholesky_impl( // construct symmetric positive definite matrix let mut randmatrix : $t = random(); - let mut diagmatrix : $t = Diagonal::from_diag(&na::diagonal(&randmatrix)); + let mut diagmatrix : $t = Diagonal::from_diagonal(&na::diagonal(&randmatrix)); diagmatrix = na::abs(&diagmatrix) + 1.0; randmatrix = randmatrix * diagmatrix * na::transpose(&randmatrix); @@ -98,7 +98,7 @@ macro_rules! test_eigen_qr_impl( let randmatrix = na::transpose(&randmatrix) * randmatrix; let (eigenvectors, eigenvalues) = na::eigen_qr(&randmatrix, &1e-13, 100); - let diagonal: $t = Diagonal::from_diag(&eigenvalues); + let diagonal: $t = Diagonal::from_diagonal(&eigenvalues); let recomp = eigenvectors * diagonal * na::transpose(&eigenvectors); println!("eigenvalues: {:?}", eigenvalues); println!(" matrix: {:?}", randmatrix); @@ -110,10 +110,10 @@ macro_rules! test_eigen_qr_impl( for _ in 0usize .. 10000 { let randmatrix : $t = random(); // Take only diagonal part - let randmatrix: $t = Diagonal::from_diag(&randmatrix.diagonal()); + let randmatrix: $t = Diagonal::from_diagonal(&randmatrix.diagonal()); let (eigenvectors, eigenvalues) = na::eigen_qr(&randmatrix, &1e-13, 100); - let diagonal: $t = Diagonal::from_diag(&eigenvalues); + let diagonal: $t = Diagonal::from_diagonal(&eigenvalues); let recomp = eigenvectors * diagonal * na::transpose(&eigenvectors); println!("eigenvalues: {:?}", eigenvalues); println!(" matrix: {:?}", randmatrix);