diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a8f213..4988e77e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ documented here. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.9.0] +## Modified + * Renamed: + - `::from_col_vector` -> `::from_column_vector` + - `::from_col_iter` -> `::from_column_iter` + - `.col_slice` -> `.column_slice` + - `.set_col` -> `.set_column` + - `::canonical_basis_with_dim` -> `::canonical_basis_with_dimension` + ## [0.8.0] ## Modified * Almost everything (types, methods, and traits) now use full names instead diff --git a/README.md b/README.md index 7ddc7084..bf0c8391 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ an optimized set of tools for computer graphics and physics. Those features incl * Square matrices with static sizes: `Matrix1`, `Matrix2`, `Matrix3`, `Matrix4`, `Matrix5`, `Matrix6 `. * Rotation matrices: `Rotation2`, `Rotation3` * Quaternions: `Quaternion`, `UnitQuaternion`. -* Isometrymetries (translation ⨯ rotation): `Isometry2`, `Isometry3` +* Isometries (translation ⨯ rotation): `Isometry2`, `Isometry3` * Similarity transformations (translation ⨯ rotation ⨯ uniform scale): `Similarity2`, `Similarity3`. * 3D projections for computer graphics: `Persp3`, `PerspMatrix3`, `Ortho3`, `OrthoMatrix3`. * Dynamically sized heap-allocated vector: `DVector`. diff --git a/src/lib.rs b/src/lib.rs index 2d14fd62..564ec7b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ an optimized set of tools for computer graphics and physics. Those features incl * Square matrices with static sizes: `Matrix1`, `Matrix2`, `Matrix3`, `Matrix4`, `Matrix5`, `Matrix6 `. * Rotation matrices: `Rotation2`, `Rotation3` * Quaternions: `Quaternion`, `UnitQuaternion`. -* Isometrymetries (translation ⨯ rotation): `Isometry2`, `Isometry3` +* Isometries (translation ⨯ rotation): `Isometry2`, `Isometry3` * Similarity transformations (translation ⨯ rotation ⨯ uniform scale): `Similarity2`, `Similarity3`. * 3D projections for computer graphics: `Perspective3`, `PerspectiveMatrix3`, `Orthographic3`, `OrthographicMatrix3`. * Dynamically sized heap-allocated vector: `DVector`. diff --git a/src/linalg/decompositions.rs b/src/linalg/decompositions.rs index ed6b2c1f..112923b9 100644 --- a/src/linalg/decompositions.rs +++ b/src/linalg/decompositions.rs @@ -49,7 +49,7 @@ pub fn qr(m: &M) -> (M, M) let mut r = *m; for ite in 0 .. cmp::min(rows - 1, cols) { - let mut v = r.col_slice(ite, ite, rows); + let mut v = r.column_slice(ite, ite, rows); let alpha = if unsafe { v.unsafe_at(ite) } >= ::zero() { -Norm::norm(&v) @@ -330,7 +330,7 @@ pub fn hessenberg(m: &M) -> (M, M) } for ite in 0 .. (cols - 2) { - let mut v = h.col_slice(ite, ite + 1, rows); + let mut v = h.column_slice(ite, ite + 1, rows); let alpha = Norm::norm(&v); diff --git a/src/structs/dmatrix.rs b/src/structs/dmatrix.rs index b38f3774..b0e47f6d 100644 --- a/src/structs/dmatrix.rs +++ b/src/structs/dmatrix.rs @@ -40,7 +40,7 @@ impl DMatrix { impl DMatrix { /// Builds a matrix filled with a given constant. #[inline] - pub fn from_elem(nrows: usize, ncols: usize, val: N) -> DMatrix { + pub fn from_element(nrows: usize, ncols: usize, val: N) -> DMatrix { DMatrix { nrows: nrows, ncols: ncols, @@ -50,7 +50,7 @@ impl DMatrix { /// Builds a matrix filled with the components provided by a vector. /// The vector contains the matrix data in row-major order. - /// Note that `from_col_vector` is much faster than `from_row_vector` since a `DMatrix` stores its data + /// Note that `from_column_vector` is much faster than `from_row_vector` since a `DMatrix` stores its data /// in column-major order. /// /// The vector must have exactly `nrows * ncols` elements. @@ -61,24 +61,24 @@ impl DMatrix { /// Builds a matrix filled with the components provided by a vector. /// The vector contains the matrix data in column-major order. - /// Note that `from_col_vector` is much faster than `from_row_vector` since a `DMatrix` stores its data + /// Note that `from_column_vector` is much faster than `from_row_vector` since a `DMatrix` stores its data /// in column-major order. /// /// The vector must have exactly `nrows * ncols` elements. #[inline] - pub fn from_col_vector(nrows: usize, ncols: usize, vector: &[N]) -> DMatrix { - DMatrix::from_col_iter(nrows, ncols, vector.to_vec()) + pub fn from_column_vector(nrows: usize, ncols: usize, vector: &[N]) -> DMatrix { + DMatrix::from_column_iter(nrows, ncols, vector.to_vec()) } /// Builds a matrix filled with the components provided by a source that may be moved into an iterator. /// The source contains the matrix data in row-major order. - /// Note that `from_col_iter` is much faster than `from_row_iter` since a `DMatrix` stores its data + /// Note that `from_column_iter` is much faster than `from_row_iter` since a `DMatrix` stores its data /// in column-major order. /// /// The source must have exactly `nrows * ncols` elements. #[inline] pub fn from_row_iter>(nrows: usize, ncols: usize, param: I) -> DMatrix { - let mut res = DMatrix::from_col_iter(ncols, nrows, param); + let mut res = DMatrix::from_column_iter(ncols, nrows, param); // we transpose because the buffer is row_major res.transpose_mut(); @@ -89,12 +89,12 @@ impl DMatrix { /// Builds a matrix filled with the components provided by a source that may be moved into an iterator. /// The source contains the matrix data in column-major order. - /// Note that `from_col_iter` is much faster than `from_row_iter` since a `DMatrix` stores its data + /// Note that `from_column_iter` is much faster than `from_row_iter` since a `DMatrix` stores its data /// in column-major order. /// /// The source must have exactly `nrows * ncols` elements. #[inline] - pub fn from_col_iter>(nrows: usize, ncols: usize, param: I) -> DMatrix { + pub fn from_column_iter>(nrows: usize, ncols: usize, param: I) -> DMatrix { let mij: Vec = param.into_iter().collect(); assert!(nrows * ncols == mij.len(), "The ammount of data provided does not matches the matrix size."); diff --git a/src/structs/dmatrix_macros.rs b/src/structs/dmatrix_macros.rs index f254474f..96868f7c 100644 --- a/src/structs/dmatrix_macros.rs +++ b/src/structs/dmatrix_macros.rs @@ -10,7 +10,7 @@ macro_rules! dmat_impl( /// components. #[inline] pub fn new_zeros(nrows: usize, ncols: usize) -> $dmatrix { - $dmatrix::from_elem(nrows, ncols, ::zero()) + $dmatrix::from_element(nrows, ncols, ::zero()) } /// Tests if all components of the matrix are zeroes. @@ -40,7 +40,7 @@ macro_rules! dmat_impl( /// Builds a matrix filled with a given constant. #[inline] pub fn new_ones(nrows: usize, ncols: usize) -> $dmatrix { - $dmatrix::from_elem(nrows, ncols, ::one()) + $dmatrix::from_element(nrows, ncols, ::one()) } } @@ -745,35 +745,35 @@ macro_rules! dmat_impl( } #[inline] - fn set_col(&mut self, col_id: usize, column: $dvector) { - assert!(col_id < self.ncols); + fn set_column(&mut self, column_id: usize, column: $dvector) { + assert!(column_id < self.ncols); assert!(column.len() == self.nrows); for row_id in 0 .. self.nrows { unsafe { - self.unsafe_set((row_id, col_id), column.unsafe_at(row_id)); + self.unsafe_set((row_id, column_id), column.unsafe_at(row_id)); } } } - fn column(&self, col_id: usize) -> $dvector { - assert!(col_id < self.ncols); + fn column(&self, column_id: usize) -> $dvector { + assert!(column_id < self.ncols); - let start = self.offset(0, col_id); - let stop = self.offset(self.nrows, col_id); + let start = self.offset(0, column_id); + let stop = self.offset(self.nrows, column_id); $dvector::from_slice(self.nrows, &self.mij[start .. stop]) } } impl ColumnSlice<$dvector> for $dmatrix { - fn col_slice(&self, col_id :usize, row_start: usize, row_end: usize) -> $dvector { - assert!(col_id < self.ncols); + fn column_slice(&self, column_id :usize, row_start: usize, row_end: usize) -> $dvector { + assert!(column_id < self.ncols); assert!(row_start < row_end); assert!(row_end <= self.nrows); // We can init from slice thanks to the matrix being column-major. - let start = self.offset(row_start, col_id); - let stop = self.offset(row_end, col_id); + let start = self.offset(row_start, column_id); + let stop = self.offset(row_end, column_id); let slice = $dvector::from_slice(row_end - row_start, &self.mij[start .. stop]); slice @@ -791,9 +791,9 @@ macro_rules! dmat_impl( assert!(row_id < self.nrows); assert!(row.len() == self.ncols); - for col_id in 0 .. self.ncols { + for column_id in 0 .. self.ncols { unsafe { - self.unsafe_set((row_id, col_id), row.unsafe_at(col_id)); + self.unsafe_set((row_id, column_id), row.unsafe_at(column_id)); } } } @@ -806,9 +806,9 @@ macro_rules! dmat_impl( $dvector::new_uninitialized(self.ncols) }; - for col_id in 0 .. self.ncols { + for column_id in 0 .. self.ncols { unsafe { - slice.unsafe_set(col_id, self.unsafe_at((row_id, col_id))); + slice.unsafe_set(column_id, self.unsafe_at((row_id, column_id))); } } slice @@ -816,18 +816,18 @@ macro_rules! dmat_impl( } impl RowSlice<$dvector> for $dmatrix { - fn row_slice(&self, row_id :usize, col_start: usize, col_end: usize) -> $dvector { + fn row_slice(&self, row_id :usize, column_start: usize, column_end: usize) -> $dvector { assert!(row_id < self.nrows); - assert!(col_start < col_end); - assert!(col_end <= self.ncols); + assert!(column_start < column_end); + assert!(column_end <= self.ncols); let mut slice : $dvector = unsafe { - $dvector::new_uninitialized(col_end - col_start) + $dvector::new_uninitialized(column_end - column_start) }; let mut slice_idx = 0; - for col_id in col_start .. col_end { + for column_id in column_start .. column_end { unsafe { - slice.unsafe_set(slice_idx, self.unsafe_at((row_id, col_id))); + slice.unsafe_set(slice_idx, self.unsafe_at((row_id, column_id))); } slice_idx += 1; } @@ -1083,7 +1083,7 @@ macro_rules! small_dmat_from_impl( impl $dmatrix { /// Builds a matrix filled with a given constant. #[inline] - pub fn from_elem(nrows: usize, ncols: usize, elem: N) -> $dmatrix { + pub fn from_element(nrows: usize, ncols: usize, elem: N) -> $dmatrix { assert!(nrows <= $dimension); assert!(ncols <= $dimension); @@ -1102,13 +1102,13 @@ macro_rules! small_dmat_from_impl( /// Builds a matrix filled with the components provided by a vector. /// The vector contains the matrix data in row-major order. - /// Note that `from_col_vector` is a lot faster than `from_row_vector` since a `$dmatrix` stores its data + /// Note that `from_column_vector` is a lot faster than `from_row_vector` since a `$dmatrix` stores its data /// in column-major order. /// /// The vector must have at least `nrows * ncols` elements. #[inline] pub fn from_row_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix { - let mut res = $dmatrix::from_col_vector(ncols, nrows, vector); + let mut res = $dmatrix::from_column_vector(ncols, nrows, vector); // we transpose because the buffer is row_major res.transpose_mut(); @@ -1118,12 +1118,12 @@ macro_rules! small_dmat_from_impl( /// Builds a matrix filled with the components provided by a vector. /// The vector contains the matrix data in column-major order. - /// Note that `from_col_vector` is a lot faster than `from_row_vector` since a `$dmatrix` stores its data + /// Note that `from_column_vector` is a lot faster than `from_row_vector` since a `$dmatrix` stores its data /// in column-major order. /// /// The vector must have at least `nrows * ncols` elements. #[inline] - pub fn from_col_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix { + pub fn from_column_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix { assert!(nrows * ncols == vector.len()); let mut mij: [N; $dimension * $dimension] = [ $( $zeros, )* ]; diff --git a/src/structs/dvector.rs b/src/structs/dvector.rs index 7f857d94..d90370bd 100644 --- a/src/structs/dvector.rs +++ b/src/structs/dvector.rs @@ -37,7 +37,7 @@ impl DVector { impl DVector { /// Builds a vector filled with a constant. #[inline] - pub fn from_elem(dimension: usize, elem: N) -> DVector { + pub fn from_element(dimension: usize, elem: N) -> DVector { DVector { at: repeat(elem).take(dimension).collect() } } diff --git a/src/structs/dvector_macros.rs b/src/structs/dvector_macros.rs index f7242b9a..eee85cd6 100644 --- a/src/structs/dvector_macros.rs +++ b/src/structs/dvector_macros.rs @@ -11,7 +11,7 @@ macro_rules! dvec_impl( /// * `dimension` - The dimension of the vector. #[inline] pub fn new_zeros(dimension: usize) -> $dvector { - $dvector::from_elem(dimension, ::zero()) + $dvector::from_element(dimension, ::zero()) } } @@ -22,7 +22,7 @@ macro_rules! dvec_impl( /// * `dimension` - The dimension of the vector. #[inline] pub fn new_ones(dimension: usize) -> $dvector { - $dvector::from_elem(dimension, ::one()) + $dvector::from_element(dimension, ::one()) } } @@ -38,7 +38,7 @@ macro_rules! dvec_impl( /// Computes the canonical basis for the given dimension. A canonical basis is a set of /// vectors, mutually orthogonal, with all its component equal to 0.0 except one which is equal /// to 1.0. - pub fn canonical_basis_with_dim(dimension: usize) -> Vec<$dvector> { + pub fn canonical_basis_with_dimension(dimension: usize) -> Vec<$dvector> { let mut res : Vec<$dvector> = Vec::new(); for i in 0 .. dimension { @@ -151,7 +151,7 @@ macro_rules! small_dvec_from_impl ( impl $dvector { /// Builds a vector filled with a constant. #[inline] - pub fn from_elem(dimension: usize, elem: N) -> $dvector { + pub fn from_element(dimension: usize, elem: N) -> $dvector { assert!(dimension <= $dimension); let mut at: [N; $dimension] = [ $( $zeros, )* ]; diff --git a/src/structs/isometry.rs b/src/structs/isometry.rs index 60269b99..9d43961d 100644 --- a/src/structs/isometry.rs +++ b/src/structs/isometry.rs @@ -20,7 +20,7 @@ use quickcheck::{Arbitrary, Gen}; /// /// This is the composition of a rotation followed by a translation. Vectors `Vector2` are not /// affected by the translational component of this transformation while points `Point2` are. -/// Isometrymetries conserve angles and distances, hence do not allow shearing nor scaling. +/// Isometries conserve angles and distances, hence do not allow shearing nor scaling. #[repr(C)] #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)] pub struct Isometry2 { @@ -34,7 +34,7 @@ pub struct Isometry2 { /// /// This is the composition of a rotation followed by a translation. Vectors `Vector3` are not /// affected by the translational component of this transformation while points `Point3` are. -/// Isometrymetries conserve angles and distances, hence do not allow shearing nor scaling. +/// Isometries conserve angles and distances, hence do not allow shearing nor scaling. #[repr(C)] #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)] pub struct Isometry3 { diff --git a/src/structs/isometry_macros.rs b/src/structs/isometry_macros.rs index 5af92616..8d9742be 100644 --- a/src/structs/isometry_macros.rs +++ b/src/structs/isometry_macros.rs @@ -347,7 +347,7 @@ macro_rules! to_homogeneous_impl( // copy the translation let dimension = Dimension::dimension(None::<$th>); - res.set_col(dimension - 1, self.translation.as_point().to_homogeneous().to_vector()); + res.set_column(dimension - 1, self.translation.as_point().to_homogeneous().to_vector()); res } diff --git a/src/structs/matrix.rs b/src/structs/matrix.rs index 75f78a61..4949d770 100644 --- a/src/structs/matrix.rs +++ b/src/structs/matrix.rs @@ -72,8 +72,8 @@ point_mul_mat_impl!(Matrix1, Point1, 1, Origin::origin); transpose_impl!(Matrix1, 1); approx_eq_impl!(Matrix1); row_impl!(Matrix1, Vector1, 1); -col_impl!(Matrix1, Vector1, 1); -col_slice_impl!(Matrix1, Vector1, DVector1, 1); +column_impl!(Matrix1, Vector1, 1); +column_slice_impl!(Matrix1, Vector1, DVector1, 1); row_slice_impl!(Matrix1, Vector1, DVector1, 1); diag_impl!(Matrix1, Vector1, 1); to_homogeneous_impl!(Matrix1, Matrix2, 1, 2); @@ -127,8 +127,8 @@ at_fast_impl!(Matrix2, 2); transpose_impl!(Matrix2, 2); approx_eq_impl!(Matrix2); row_impl!(Matrix2, Vector2, 2); -col_impl!(Matrix2, Vector2, 2); -col_slice_impl!(Matrix2, Vector2, DVector2, 2); +column_impl!(Matrix2, Vector2, 2); +column_slice_impl!(Matrix2, Vector2, DVector2, 2); row_slice_impl!(Matrix2, Vector2, DVector2, 2); diag_impl!(Matrix2, Vector2, 2); to_homogeneous_impl!(Matrix2, Matrix3, 2, 3); @@ -217,8 +217,8 @@ at_fast_impl!(Matrix3, 3); transpose_impl!(Matrix3, 3); approx_eq_impl!(Matrix3); // (specialized); row_impl!(Matrix3, Vector3, 3); -// (specialized); col_impl!(Matrix3, Vector3, 3); -col_slice_impl!(Matrix3, Vector3, DVector3, 3); +// (specialized); column_impl!(Matrix3, Vector3, 3); +column_slice_impl!(Matrix3, Vector3, DVector3, 3); row_slice_impl!(Matrix3, Vector3, DVector3, 3); diag_impl!(Matrix3, Vector3, 3); to_homogeneous_impl!(Matrix3, Matrix4, 3, 4); @@ -336,8 +336,8 @@ inverse_impl!(Matrix4, 4); transpose_impl!(Matrix4, 4); approx_eq_impl!(Matrix4); row_impl!(Matrix4, Vector4, 4); -col_impl!(Matrix4, Vector4, 4); -col_slice_impl!(Matrix4, Vector4, DVector4, 4); +column_impl!(Matrix4, Vector4, 4); +column_slice_impl!(Matrix4, Vector4, DVector4, 4); row_slice_impl!(Matrix4, Vector4, DVector4, 4); diag_impl!(Matrix4, Vector4, 4); to_homogeneous_impl!(Matrix4, Matrix5, 4, 5); @@ -472,8 +472,8 @@ inverse_impl!(Matrix5, 5); transpose_impl!(Matrix5, 5); approx_eq_impl!(Matrix5); row_impl!(Matrix5, Vector5, 5); -col_impl!(Matrix5, Vector5, 5); -col_slice_impl!(Matrix5, Vector5, DVector5, 5); +column_impl!(Matrix5, Vector5, 5); +column_slice_impl!(Matrix5, Vector5, DVector5, 5); row_slice_impl!(Matrix5, Vector5, DVector5, 5); diag_impl!(Matrix5, Vector5, 5); to_homogeneous_impl!(Matrix5, Matrix6, 5, 6); @@ -615,8 +615,8 @@ inverse_impl!(Matrix6, 6); transpose_impl!(Matrix6, 6); approx_eq_impl!(Matrix6); row_impl!(Matrix6, Vector6, 6); -col_impl!(Matrix6, Vector6, 6); -col_slice_impl!(Matrix6, Vector6, DVector6, 6); +column_impl!(Matrix6, Vector6, 6); +column_slice_impl!(Matrix6, Vector6, DVector6, 6); row_slice_impl!(Matrix6, Vector6, DVector6, 6); diag_impl!(Matrix6, Vector6, 6); outer_impl!(Vector6, Matrix6); diff --git a/src/structs/matrix_macros.rs b/src/structs/matrix_macros.rs index f736398f..6bbd0aa8 100644 --- a/src/structs/matrix_macros.rs +++ b/src/structs/matrix_macros.rs @@ -413,10 +413,10 @@ macro_rules! index_impl( ) ); -macro_rules! col_slice_impl( +macro_rules! column_slice_impl( ($t: ident, $tv: ident, $slice: ident, $dimension: expr) => ( impl ColumnSlice<$slice> for $t { - fn col_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice { + fn column_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice { let column = self.column(cid); $slice::from_slice(rend - rstart, &column.as_ref()[rstart .. rend]) @@ -466,7 +466,7 @@ macro_rules! row_slice_impl( ) ); -macro_rules! col_impl( +macro_rules! column_impl( ($t: ident, $tv: ident, $dimension: expr) => ( impl Column<$tv> for $t { #[inline] @@ -475,7 +475,7 @@ macro_rules! col_impl( } #[inline] - fn set_col(&mut self, column: usize, v: $tv) { + fn set_column(&mut self, column: usize, v: $tv) { for (i, e) in v.iter().enumerate() { self[(i, column)] = *e; } diff --git a/src/structs/rotation.rs b/src/structs/rotation.rs index 98d71acb..d1520fab 100644 --- a/src/structs/rotation.rs +++ b/src/structs/rotation.rs @@ -372,7 +372,7 @@ point_mul_rotation_impl!(Rotation2, Point2); one_impl!(Rotation2); eye_impl!(Rotation2); rotation_matrix_impl!(Rotation2, Vector2, Vector1); -col_impl!(Rotation2, Vector2); +column_impl!(Rotation2, Vector2); row_impl!(Rotation2, Vector2); index_impl!(Rotation2); absolute_impl!(Rotation2, Matrix2); @@ -395,7 +395,7 @@ point_mul_rotation_impl!(Rotation3, Point3); one_impl!(Rotation3); eye_impl!(Rotation3); rotation_matrix_impl!(Rotation3, Vector3, Vector3); -col_impl!(Rotation3, Vector3); +column_impl!(Rotation3, Vector3); row_impl!(Rotation3, Vector3); index_impl!(Rotation3); absolute_impl!(Rotation3, Matrix3); diff --git a/src/structs/rotation_macros.rs b/src/structs/rotation_macros.rs index d59daf1a..a0074393 100644 --- a/src/structs/rotation_macros.rs +++ b/src/structs/rotation_macros.rs @@ -256,7 +256,7 @@ macro_rules! row_impl( ) ); -macro_rules! col_impl( +macro_rules! column_impl( ($t: ident, $tv: ident) => ( impl Column<$tv> for $t { #[inline] @@ -269,8 +269,8 @@ macro_rules! col_impl( } #[inline] - fn set_col(&mut self, i: usize, column: $tv) { - self.submatrix.set_col(i, column); + fn set_column(&mut self, i: usize, column: $tv) { + self.submatrix.set_column(i, column); } } ) diff --git a/src/structs/similarity_macros.rs b/src/structs/similarity_macros.rs index d05f07e7..8bac2e62 100644 --- a/src/structs/similarity_macros.rs +++ b/src/structs/similarity_macros.rs @@ -275,7 +275,7 @@ macro_rules! sim_to_homogeneous_impl( // copy the translation let dimension = Dimension::dimension(None::<$th>); - res.set_col(dimension - 1, self.isometry.translation.as_point().to_homogeneous().to_vector()); + res.set_column(dimension - 1, self.isometry.translation.as_point().to_homogeneous().to_vector()); res } diff --git a/src/structs/specializations/matrix.rs b/src/structs/specializations/matrix.rs index 883fb651..d390f912 100644 --- a/src/structs/specializations/matrix.rs +++ b/src/structs/specializations/matrix.rs @@ -187,7 +187,7 @@ impl Column> for Matrix3 { } #[inline] - fn set_col(&mut self, i: usize, r: Vector3) { + fn set_column(&mut self, i: usize, r: Vector3) { match i { 0 => { self.m11 = r.x; diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 488839d1..cc3ddea9 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -142,7 +142,7 @@ pub trait Column { fn column(&self, i: usize) -> C; /// Writes the `i`-th column of `self`. - fn set_col(&mut self, i: usize, C); + fn set_column(&mut self, i: usize, C); // FIXME: add iterators on columns: this could be a very good way to generalize _and_ optimize // a lot of operations. @@ -151,13 +151,13 @@ pub trait Column { /// Trait to access part of a column of a matrix pub trait ColumnSlice { /// Returns a view to a slice of a column of a matrix. - fn col_slice(&self, col_id: usize, row_start: usize, row_end: usize) -> C; + fn column_slice(&self, column_id: usize, row_start: usize, row_end: usize) -> C; } /// Trait to access part of a row of a matrix pub trait RowSlice { /// Returns a view to a slice of a row of a matrix. - fn row_slice(&self, row_id: usize, col_start: usize, col_end: usize) -> R; + fn row_slice(&self, row_id: usize, column_start: usize, column_end: usize) -> R; } /// Trait of objects having a spacial dimension known at compile time. diff --git a/tests/mat.rs b/tests/mat.rs index 5acbb0d0..6df6fbcc 100644 --- a/tests/mat.rs +++ b/tests/mat.rs @@ -332,7 +332,7 @@ fn test_row_slice_dmatrix() { } #[test] -fn test_col_dmatrix() { +fn test_column_dmatrix() { let matrix = DMatrix::from_row_vector( 8, 4, @@ -355,7 +355,7 @@ fn test_col_dmatrix() { } #[test] -fn test_col_slice_dmatrix() { +fn test_column_slice_dmatrix() { let matrix = DMatrix::from_row_vector( 8, 4, @@ -371,10 +371,10 @@ fn test_col_slice_dmatrix() { ] ); - assert_eq!(&DVector::from_slice(8, &[1u32, 5, 9, 13, 17, 21, 25, 29]), &matrix.col_slice(0, 0, 8)); - assert_eq!(&DVector::from_slice(3, &[1u32, 5, 9]), &matrix.col_slice(0, 0, 3)); - assert_eq!(&DVector::from_slice(5, &[11u32, 15, 19, 23, 27]), &matrix.col_slice(2, 2, 7)); - assert_eq!(&DVector::from_slice(2, &[28u32, 32]), &matrix.col_slice(3, 6, 8)); + assert_eq!(&DVector::from_slice(8, &[1u32, 5, 9, 13, 17, 21, 25, 29]), &matrix.column_slice(0, 0, 8)); + assert_eq!(&DVector::from_slice(3, &[1u32, 5, 9]), &matrix.column_slice(0, 0, 3)); + assert_eq!(&DVector::from_slice(5, &[11u32, 15, 19, 23, 27]), &matrix.column_slice(2, 2, 7)); + assert_eq!(&DVector::from_slice(2, &[28u32, 32]), &matrix.column_slice(3, 6, 8)); } #[test] @@ -394,7 +394,7 @@ fn test_dmat_from_vector() { ] ); - let mat2 = DMatrix::from_col_vector( + let mat2 = DMatrix::from_column_vector( 8, 4, &[ @@ -541,7 +541,7 @@ fn test_dmat_subtraction() { } #[test] -fn test_dmat_col() { +fn test_dmat_column() { let matrix = DMatrix::from_row_vector( 3, 3, @@ -556,7 +556,7 @@ fn test_dmat_col() { } #[test] -fn test_dmat_set_col() { +fn test_dmat_set_column() { let mut matrix = DMatrix::from_row_vector( 3, 3, @@ -567,7 +567,7 @@ fn test_dmat_set_col() { ] ); - matrix.set_col(1, DVector::from_slice(3, &[12.0, 15.0, 18.0])); + matrix.set_column(1, DVector::from_slice(3, &[12.0, 15.0, 18.0])); let expected = DMatrix::from_row_vector( 3, @@ -823,13 +823,13 @@ fn test_hessenberg_mat6() { #[test] fn test_transpose_square_matrix() { - let col_major_matrix = &[0, 1, 2, 3, + let column_major_matrix = &[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]; let num_rows = 4; let num_cols = 4; - let mut matrix = DMatrix::from_col_vector(num_rows, num_cols, col_major_matrix); + let mut matrix = DMatrix::from_column_vector(num_rows, num_cols, column_major_matrix); matrix.transpose_mut(); for i in 0..num_rows { assert_eq!(&[0, 1, 2, 3], &matrix.row_slice(i, 0, num_cols)[..]);