Replace "col" by "column".

Related to #176.
This commit is contained in:
Sébastien Crozet 2016-04-18 08:29:22 +02:00
parent 830c19aeba
commit df872f407d
18 changed files with 96 additions and 87 deletions

View File

@ -4,6 +4,15 @@ documented here.
This project adheres to [Semantic Versioning](http://semver.org/). 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] ## [0.8.0]
## Modified ## Modified
* Almost everything (types, methods, and traits) now use full names instead * Almost everything (types, methods, and traits) now use full names instead

View File

@ -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 `. * Square matrices with static sizes: `Matrix1`, `Matrix2`, `Matrix3`, `Matrix4`, `Matrix5`, `Matrix6 `.
* Rotation matrices: `Rotation2`, `Rotation3` * Rotation matrices: `Rotation2`, `Rotation3`
* Quaternions: `Quaternion`, `UnitQuaternion`. * Quaternions: `Quaternion`, `UnitQuaternion`.
* Isometrymetries (translation rotation): `Isometry2`, `Isometry3` * Isometries (translation rotation): `Isometry2`, `Isometry3`
* Similarity transformations (translation rotation uniform scale): `Similarity2`, `Similarity3`. * Similarity transformations (translation rotation uniform scale): `Similarity2`, `Similarity3`.
* 3D projections for computer graphics: `Persp3`, `PerspMatrix3`, `Ortho3`, `OrthoMatrix3`. * 3D projections for computer graphics: `Persp3`, `PerspMatrix3`, `Ortho3`, `OrthoMatrix3`.
* Dynamically sized heap-allocated vector: `DVector`. * Dynamically sized heap-allocated vector: `DVector`.

View File

@ -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 `. * Square matrices with static sizes: `Matrix1`, `Matrix2`, `Matrix3`, `Matrix4`, `Matrix5`, `Matrix6 `.
* Rotation matrices: `Rotation2`, `Rotation3` * Rotation matrices: `Rotation2`, `Rotation3`
* Quaternions: `Quaternion`, `UnitQuaternion`. * Quaternions: `Quaternion`, `UnitQuaternion`.
* Isometrymetries (translation rotation): `Isometry2`, `Isometry3` * Isometries (translation rotation): `Isometry2`, `Isometry3`
* Similarity transformations (translation rotation uniform scale): `Similarity2`, `Similarity3`. * Similarity transformations (translation rotation uniform scale): `Similarity2`, `Similarity3`.
* 3D projections for computer graphics: `Perspective3`, `PerspectiveMatrix3`, `Orthographic3`, `OrthographicMatrix3`. * 3D projections for computer graphics: `Perspective3`, `PerspectiveMatrix3`, `Orthographic3`, `OrthographicMatrix3`.
* Dynamically sized heap-allocated vector: `DVector`. * Dynamically sized heap-allocated vector: `DVector`.

View File

@ -49,7 +49,7 @@ pub fn qr<N, V, M>(m: &M) -> (M, M)
let mut r = *m; let mut r = *m;
for ite in 0 .. cmp::min(rows - 1, cols) { 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 = let alpha =
if unsafe { v.unsafe_at(ite) } >= ::zero() { if unsafe { v.unsafe_at(ite) } >= ::zero() {
-Norm::norm(&v) -Norm::norm(&v)
@ -330,7 +330,7 @@ pub fn hessenberg<N, V, M>(m: &M) -> (M, M)
} }
for ite in 0 .. (cols - 2) { 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); let alpha = Norm::norm(&v);

View File

@ -40,7 +40,7 @@ impl<N> DMatrix<N> {
impl<N: Clone + Copy> DMatrix<N> { impl<N: Clone + Copy> DMatrix<N> {
/// Builds a matrix filled with a given constant. /// Builds a matrix filled with a given constant.
#[inline] #[inline]
pub fn from_elem(nrows: usize, ncols: usize, val: N) -> DMatrix<N> { pub fn from_element(nrows: usize, ncols: usize, val: N) -> DMatrix<N> {
DMatrix { DMatrix {
nrows: nrows, nrows: nrows,
ncols: ncols, ncols: ncols,
@ -50,7 +50,7 @@ impl<N: Clone + Copy> DMatrix<N> {
/// Builds a matrix filled with the components provided by a vector. /// Builds a matrix filled with the components provided by a vector.
/// The vector contains the matrix data in row-major order. /// 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. /// in column-major order.
/// ///
/// The vector must have exactly `nrows * ncols` elements. /// The vector must have exactly `nrows * ncols` elements.
@ -61,24 +61,24 @@ impl<N: Clone + Copy> DMatrix<N> {
/// Builds a matrix filled with the components provided by a vector. /// Builds a matrix filled with the components provided by a vector.
/// The vector contains the matrix data in column-major order. /// 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. /// in column-major order.
/// ///
/// The vector must have exactly `nrows * ncols` elements. /// The vector must have exactly `nrows * ncols` elements.
#[inline] #[inline]
pub fn from_col_vector(nrows: usize, ncols: usize, vector: &[N]) -> DMatrix<N> { pub fn from_column_vector(nrows: usize, ncols: usize, vector: &[N]) -> DMatrix<N> {
DMatrix::from_col_iter(nrows, ncols, vector.to_vec()) 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. /// 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. /// 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. /// in column-major order.
/// ///
/// The source must have exactly `nrows * ncols` elements. /// The source must have exactly `nrows * ncols` elements.
#[inline] #[inline]
pub fn from_row_iter<I: IntoIterator<Item = N>>(nrows: usize, ncols: usize, param: I) -> DMatrix<N> { pub fn from_row_iter<I: IntoIterator<Item = N>>(nrows: usize, ncols: usize, param: I) -> DMatrix<N> {
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 // we transpose because the buffer is row_major
res.transpose_mut(); res.transpose_mut();
@ -89,12 +89,12 @@ impl<N: Clone + Copy> DMatrix<N> {
/// Builds a matrix filled with the components provided by a source that may be moved into an iterator. /// 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. /// 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. /// in column-major order.
/// ///
/// The source must have exactly `nrows * ncols` elements. /// The source must have exactly `nrows * ncols` elements.
#[inline] #[inline]
pub fn from_col_iter<I: IntoIterator<Item = N>>(nrows: usize, ncols: usize, param: I) -> DMatrix<N> { pub fn from_column_iter<I: IntoIterator<Item = N>>(nrows: usize, ncols: usize, param: I) -> DMatrix<N> {
let mij: Vec<N> = param.into_iter().collect(); let mij: Vec<N> = param.into_iter().collect();
assert!(nrows * ncols == mij.len(), "The ammount of data provided does not matches the matrix size."); assert!(nrows * ncols == mij.len(), "The ammount of data provided does not matches the matrix size.");

View File

@ -10,7 +10,7 @@ macro_rules! dmat_impl(
/// components. /// components.
#[inline] #[inline]
pub fn new_zeros(nrows: usize, ncols: usize) -> $dmatrix<N> { pub fn new_zeros(nrows: usize, ncols: usize) -> $dmatrix<N> {
$dmatrix::from_elem(nrows, ncols, ::zero()) $dmatrix::from_element(nrows, ncols, ::zero())
} }
/// Tests if all components of the matrix are zeroes. /// 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. /// Builds a matrix filled with a given constant.
#[inline] #[inline]
pub fn new_ones(nrows: usize, ncols: usize) -> $dmatrix<N> { pub fn new_ones(nrows: usize, ncols: usize) -> $dmatrix<N> {
$dmatrix::from_elem(nrows, ncols, ::one()) $dmatrix::from_element(nrows, ncols, ::one())
} }
} }
@ -745,35 +745,35 @@ macro_rules! dmat_impl(
} }
#[inline] #[inline]
fn set_col(&mut self, col_id: usize, column: $dvector<N>) { fn set_column(&mut self, column_id: usize, column: $dvector<N>) {
assert!(col_id < self.ncols); assert!(column_id < self.ncols);
assert!(column.len() == self.nrows); assert!(column.len() == self.nrows);
for row_id in 0 .. self.nrows { for row_id in 0 .. self.nrows {
unsafe { 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<N> { fn column(&self, column_id: usize) -> $dvector<N> {
assert!(col_id < self.ncols); assert!(column_id < self.ncols);
let start = self.offset(0, col_id); let start = self.offset(0, column_id);
let stop = self.offset(self.nrows, col_id); let stop = self.offset(self.nrows, column_id);
$dvector::from_slice(self.nrows, &self.mij[start .. stop]) $dvector::from_slice(self.nrows, &self.mij[start .. stop])
} }
} }
impl<N: Copy + Clone + Zero> ColumnSlice<$dvector<N>> for $dmatrix<N> { impl<N: Copy + Clone + Zero> ColumnSlice<$dvector<N>> for $dmatrix<N> {
fn col_slice(&self, col_id :usize, row_start: usize, row_end: usize) -> $dvector<N> { fn column_slice(&self, column_id :usize, row_start: usize, row_end: usize) -> $dvector<N> {
assert!(col_id < self.ncols); assert!(column_id < self.ncols);
assert!(row_start < row_end); assert!(row_start < row_end);
assert!(row_end <= self.nrows); assert!(row_end <= self.nrows);
// We can init from slice thanks to the matrix being column-major. // We can init from slice thanks to the matrix being column-major.
let start = self.offset(row_start, col_id); let start = self.offset(row_start, column_id);
let stop = self.offset(row_end, col_id); let stop = self.offset(row_end, column_id);
let slice = $dvector::from_slice(row_end - row_start, &self.mij[start .. stop]); let slice = $dvector::from_slice(row_end - row_start, &self.mij[start .. stop]);
slice slice
@ -791,9 +791,9 @@ macro_rules! dmat_impl(
assert!(row_id < self.nrows); assert!(row_id < self.nrows);
assert!(row.len() == self.ncols); assert!(row.len() == self.ncols);
for col_id in 0 .. self.ncols { for column_id in 0 .. self.ncols {
unsafe { 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) $dvector::new_uninitialized(self.ncols)
}; };
for col_id in 0 .. self.ncols { for column_id in 0 .. self.ncols {
unsafe { 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 slice
@ -816,18 +816,18 @@ macro_rules! dmat_impl(
} }
impl<N: Copy> RowSlice<$dvector<N>> for $dmatrix<N> { impl<N: Copy> RowSlice<$dvector<N>> for $dmatrix<N> {
fn row_slice(&self, row_id :usize, col_start: usize, col_end: usize) -> $dvector<N> { fn row_slice(&self, row_id :usize, column_start: usize, column_end: usize) -> $dvector<N> {
assert!(row_id < self.nrows); assert!(row_id < self.nrows);
assert!(col_start < col_end); assert!(column_start < column_end);
assert!(col_end <= self.ncols); assert!(column_end <= self.ncols);
let mut slice : $dvector<N> = unsafe { let mut slice : $dvector<N> = unsafe {
$dvector::new_uninitialized(col_end - col_start) $dvector::new_uninitialized(column_end - column_start)
}; };
let mut slice_idx = 0; let mut slice_idx = 0;
for col_id in col_start .. col_end { for column_id in column_start .. column_end {
unsafe { 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; slice_idx += 1;
} }
@ -1083,7 +1083,7 @@ macro_rules! small_dmat_from_impl(
impl<N: Zero + Clone + Copy> $dmatrix<N> { impl<N: Zero + Clone + Copy> $dmatrix<N> {
/// Builds a matrix filled with a given constant. /// Builds a matrix filled with a given constant.
#[inline] #[inline]
pub fn from_elem(nrows: usize, ncols: usize, elem: N) -> $dmatrix<N> { pub fn from_element(nrows: usize, ncols: usize, elem: N) -> $dmatrix<N> {
assert!(nrows <= $dimension); assert!(nrows <= $dimension);
assert!(ncols <= $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. /// Builds a matrix filled with the components provided by a vector.
/// The vector contains the matrix data in row-major order. /// 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. /// in column-major order.
/// ///
/// The vector must have at least `nrows * ncols` elements. /// The vector must have at least `nrows * ncols` elements.
#[inline] #[inline]
pub fn from_row_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix<N> { pub fn from_row_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix<N> {
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 // we transpose because the buffer is row_major
res.transpose_mut(); res.transpose_mut();
@ -1118,12 +1118,12 @@ macro_rules! small_dmat_from_impl(
/// Builds a matrix filled with the components provided by a vector. /// Builds a matrix filled with the components provided by a vector.
/// The vector contains the matrix data in column-major order. /// 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. /// in column-major order.
/// ///
/// The vector must have at least `nrows * ncols` elements. /// The vector must have at least `nrows * ncols` elements.
#[inline] #[inline]
pub fn from_col_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix<N> { pub fn from_column_vector(nrows: usize, ncols: usize, vector: &[N]) -> $dmatrix<N> {
assert!(nrows * ncols == vector.len()); assert!(nrows * ncols == vector.len());
let mut mij: [N; $dimension * $dimension] = [ $( $zeros, )* ]; let mut mij: [N; $dimension * $dimension] = [ $( $zeros, )* ];

View File

@ -37,7 +37,7 @@ impl<N> DVector<N> {
impl<N: Clone> DVector<N> { impl<N: Clone> DVector<N> {
/// Builds a vector filled with a constant. /// Builds a vector filled with a constant.
#[inline] #[inline]
pub fn from_elem(dimension: usize, elem: N) -> DVector<N> { pub fn from_element(dimension: usize, elem: N) -> DVector<N> {
DVector { at: repeat(elem).take(dimension).collect() } DVector { at: repeat(elem).take(dimension).collect() }
} }

View File

@ -11,7 +11,7 @@ macro_rules! dvec_impl(
/// * `dimension` - The dimension of the vector. /// * `dimension` - The dimension of the vector.
#[inline] #[inline]
pub fn new_zeros(dimension: usize) -> $dvector<N> { pub fn new_zeros(dimension: usize) -> $dvector<N> {
$dvector::from_elem(dimension, ::zero()) $dvector::from_element(dimension, ::zero())
} }
} }
@ -22,7 +22,7 @@ macro_rules! dvec_impl(
/// * `dimension` - The dimension of the vector. /// * `dimension` - The dimension of the vector.
#[inline] #[inline]
pub fn new_ones(dimension: usize) -> $dvector<N> { pub fn new_ones(dimension: usize) -> $dvector<N> {
$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 /// 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 /// vectors, mutually orthogonal, with all its component equal to 0.0 except one which is equal
/// to 1.0. /// to 1.0.
pub fn canonical_basis_with_dim(dimension: usize) -> Vec<$dvector<N>> { pub fn canonical_basis_with_dimension(dimension: usize) -> Vec<$dvector<N>> {
let mut res : Vec<$dvector<N>> = Vec::new(); let mut res : Vec<$dvector<N>> = Vec::new();
for i in 0 .. dimension { for i in 0 .. dimension {
@ -151,7 +151,7 @@ macro_rules! small_dvec_from_impl (
impl<N: Copy + Zero> $dvector<N> { impl<N: Copy + Zero> $dvector<N> {
/// Builds a vector filled with a constant. /// Builds a vector filled with a constant.
#[inline] #[inline]
pub fn from_elem(dimension: usize, elem: N) -> $dvector<N> { pub fn from_element(dimension: usize, elem: N) -> $dvector<N> {
assert!(dimension <= $dimension); assert!(dimension <= $dimension);
let mut at: [N; $dimension] = [ $( $zeros, )* ]; let mut at: [N; $dimension] = [ $( $zeros, )* ];

View File

@ -20,7 +20,7 @@ use quickcheck::{Arbitrary, Gen};
/// ///
/// This is the composition of a rotation followed by a translation. Vectors `Vector2` are not /// 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. /// 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)] #[repr(C)]
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)] #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
pub struct Isometry2<N> { pub struct Isometry2<N> {
@ -34,7 +34,7 @@ pub struct Isometry2<N> {
/// ///
/// This is the composition of a rotation followed by a translation. Vectors `Vector3` are not /// 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. /// 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)] #[repr(C)]
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)] #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
pub struct Isometry3<N> { pub struct Isometry3<N> {

View File

@ -347,7 +347,7 @@ macro_rules! to_homogeneous_impl(
// copy the translation // copy the translation
let dimension = Dimension::dimension(None::<$th<N>>); let dimension = Dimension::dimension(None::<$th<N>>);
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 res
} }

View File

@ -72,8 +72,8 @@ point_mul_mat_impl!(Matrix1, Point1, 1, Origin::origin);
transpose_impl!(Matrix1, 1); transpose_impl!(Matrix1, 1);
approx_eq_impl!(Matrix1); approx_eq_impl!(Matrix1);
row_impl!(Matrix1, Vector1, 1); row_impl!(Matrix1, Vector1, 1);
col_impl!(Matrix1, Vector1, 1); column_impl!(Matrix1, Vector1, 1);
col_slice_impl!(Matrix1, Vector1, DVector1, 1); column_slice_impl!(Matrix1, Vector1, DVector1, 1);
row_slice_impl!(Matrix1, Vector1, DVector1, 1); row_slice_impl!(Matrix1, Vector1, DVector1, 1);
diag_impl!(Matrix1, Vector1, 1); diag_impl!(Matrix1, Vector1, 1);
to_homogeneous_impl!(Matrix1, Matrix2, 1, 2); to_homogeneous_impl!(Matrix1, Matrix2, 1, 2);
@ -127,8 +127,8 @@ at_fast_impl!(Matrix2, 2);
transpose_impl!(Matrix2, 2); transpose_impl!(Matrix2, 2);
approx_eq_impl!(Matrix2); approx_eq_impl!(Matrix2);
row_impl!(Matrix2, Vector2, 2); row_impl!(Matrix2, Vector2, 2);
col_impl!(Matrix2, Vector2, 2); column_impl!(Matrix2, Vector2, 2);
col_slice_impl!(Matrix2, Vector2, DVector2, 2); column_slice_impl!(Matrix2, Vector2, DVector2, 2);
row_slice_impl!(Matrix2, Vector2, DVector2, 2); row_slice_impl!(Matrix2, Vector2, DVector2, 2);
diag_impl!(Matrix2, Vector2, 2); diag_impl!(Matrix2, Vector2, 2);
to_homogeneous_impl!(Matrix2, Matrix3, 2, 3); to_homogeneous_impl!(Matrix2, Matrix3, 2, 3);
@ -217,8 +217,8 @@ at_fast_impl!(Matrix3, 3);
transpose_impl!(Matrix3, 3); transpose_impl!(Matrix3, 3);
approx_eq_impl!(Matrix3); approx_eq_impl!(Matrix3);
// (specialized); row_impl!(Matrix3, Vector3, 3); // (specialized); row_impl!(Matrix3, Vector3, 3);
// (specialized); col_impl!(Matrix3, Vector3, 3); // (specialized); column_impl!(Matrix3, Vector3, 3);
col_slice_impl!(Matrix3, Vector3, DVector3, 3); column_slice_impl!(Matrix3, Vector3, DVector3, 3);
row_slice_impl!(Matrix3, Vector3, DVector3, 3); row_slice_impl!(Matrix3, Vector3, DVector3, 3);
diag_impl!(Matrix3, Vector3, 3); diag_impl!(Matrix3, Vector3, 3);
to_homogeneous_impl!(Matrix3, Matrix4, 3, 4); to_homogeneous_impl!(Matrix3, Matrix4, 3, 4);
@ -336,8 +336,8 @@ inverse_impl!(Matrix4, 4);
transpose_impl!(Matrix4, 4); transpose_impl!(Matrix4, 4);
approx_eq_impl!(Matrix4); approx_eq_impl!(Matrix4);
row_impl!(Matrix4, Vector4, 4); row_impl!(Matrix4, Vector4, 4);
col_impl!(Matrix4, Vector4, 4); column_impl!(Matrix4, Vector4, 4);
col_slice_impl!(Matrix4, Vector4, DVector4, 4); column_slice_impl!(Matrix4, Vector4, DVector4, 4);
row_slice_impl!(Matrix4, Vector4, DVector4, 4); row_slice_impl!(Matrix4, Vector4, DVector4, 4);
diag_impl!(Matrix4, Vector4, 4); diag_impl!(Matrix4, Vector4, 4);
to_homogeneous_impl!(Matrix4, Matrix5, 4, 5); to_homogeneous_impl!(Matrix4, Matrix5, 4, 5);
@ -472,8 +472,8 @@ inverse_impl!(Matrix5, 5);
transpose_impl!(Matrix5, 5); transpose_impl!(Matrix5, 5);
approx_eq_impl!(Matrix5); approx_eq_impl!(Matrix5);
row_impl!(Matrix5, Vector5, 5); row_impl!(Matrix5, Vector5, 5);
col_impl!(Matrix5, Vector5, 5); column_impl!(Matrix5, Vector5, 5);
col_slice_impl!(Matrix5, Vector5, DVector5, 5); column_slice_impl!(Matrix5, Vector5, DVector5, 5);
row_slice_impl!(Matrix5, Vector5, DVector5, 5); row_slice_impl!(Matrix5, Vector5, DVector5, 5);
diag_impl!(Matrix5, Vector5, 5); diag_impl!(Matrix5, Vector5, 5);
to_homogeneous_impl!(Matrix5, Matrix6, 5, 6); to_homogeneous_impl!(Matrix5, Matrix6, 5, 6);
@ -615,8 +615,8 @@ inverse_impl!(Matrix6, 6);
transpose_impl!(Matrix6, 6); transpose_impl!(Matrix6, 6);
approx_eq_impl!(Matrix6); approx_eq_impl!(Matrix6);
row_impl!(Matrix6, Vector6, 6); row_impl!(Matrix6, Vector6, 6);
col_impl!(Matrix6, Vector6, 6); column_impl!(Matrix6, Vector6, 6);
col_slice_impl!(Matrix6, Vector6, DVector6, 6); column_slice_impl!(Matrix6, Vector6, DVector6, 6);
row_slice_impl!(Matrix6, Vector6, DVector6, 6); row_slice_impl!(Matrix6, Vector6, DVector6, 6);
diag_impl!(Matrix6, Vector6, 6); diag_impl!(Matrix6, Vector6, 6);
outer_impl!(Vector6, Matrix6); outer_impl!(Vector6, Matrix6);

View File

@ -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) => ( ($t: ident, $tv: ident, $slice: ident, $dimension: expr) => (
impl<N: Clone + Copy + Zero> ColumnSlice<$slice<N>> for $t<N> { impl<N: Clone + Copy + Zero> ColumnSlice<$slice<N>> for $t<N> {
fn col_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice<N> { fn column_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice<N> {
let column = self.column(cid); let column = self.column(cid);
$slice::from_slice(rend - rstart, &column.as_ref()[rstart .. rend]) $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) => ( ($t: ident, $tv: ident, $dimension: expr) => (
impl<N: Copy + Zero> Column<$tv<N>> for $t<N> { impl<N: Copy + Zero> Column<$tv<N>> for $t<N> {
#[inline] #[inline]
@ -475,7 +475,7 @@ macro_rules! col_impl(
} }
#[inline] #[inline]
fn set_col(&mut self, column: usize, v: $tv<N>) { fn set_column(&mut self, column: usize, v: $tv<N>) {
for (i, e) in v.iter().enumerate() { for (i, e) in v.iter().enumerate() {
self[(i, column)] = *e; self[(i, column)] = *e;
} }

View File

@ -372,7 +372,7 @@ point_mul_rotation_impl!(Rotation2, Point2);
one_impl!(Rotation2); one_impl!(Rotation2);
eye_impl!(Rotation2); eye_impl!(Rotation2);
rotation_matrix_impl!(Rotation2, Vector2, Vector1); rotation_matrix_impl!(Rotation2, Vector2, Vector1);
col_impl!(Rotation2, Vector2); column_impl!(Rotation2, Vector2);
row_impl!(Rotation2, Vector2); row_impl!(Rotation2, Vector2);
index_impl!(Rotation2); index_impl!(Rotation2);
absolute_impl!(Rotation2, Matrix2); absolute_impl!(Rotation2, Matrix2);
@ -395,7 +395,7 @@ point_mul_rotation_impl!(Rotation3, Point3);
one_impl!(Rotation3); one_impl!(Rotation3);
eye_impl!(Rotation3); eye_impl!(Rotation3);
rotation_matrix_impl!(Rotation3, Vector3, Vector3); rotation_matrix_impl!(Rotation3, Vector3, Vector3);
col_impl!(Rotation3, Vector3); column_impl!(Rotation3, Vector3);
row_impl!(Rotation3, Vector3); row_impl!(Rotation3, Vector3);
index_impl!(Rotation3); index_impl!(Rotation3);
absolute_impl!(Rotation3, Matrix3); absolute_impl!(Rotation3, Matrix3);

View File

@ -256,7 +256,7 @@ macro_rules! row_impl(
) )
); );
macro_rules! col_impl( macro_rules! column_impl(
($t: ident, $tv: ident) => ( ($t: ident, $tv: ident) => (
impl<N: Copy + Zero> Column<$tv<N>> for $t<N> { impl<N: Copy + Zero> Column<$tv<N>> for $t<N> {
#[inline] #[inline]
@ -269,8 +269,8 @@ macro_rules! col_impl(
} }
#[inline] #[inline]
fn set_col(&mut self, i: usize, column: $tv<N>) { fn set_column(&mut self, i: usize, column: $tv<N>) {
self.submatrix.set_col(i, column); self.submatrix.set_column(i, column);
} }
} }
) )

View File

@ -275,7 +275,7 @@ macro_rules! sim_to_homogeneous_impl(
// copy the translation // copy the translation
let dimension = Dimension::dimension(None::<$th<N>>); let dimension = Dimension::dimension(None::<$th<N>>);
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 res
} }

View File

@ -187,7 +187,7 @@ impl<N: Copy> Column<Vector3<N>> for Matrix3<N> {
} }
#[inline] #[inline]
fn set_col(&mut self, i: usize, r: Vector3<N>) { fn set_column(&mut self, i: usize, r: Vector3<N>) {
match i { match i {
0 => { 0 => {
self.m11 = r.x; self.m11 = r.x;

View File

@ -142,7 +142,7 @@ pub trait Column<C> {
fn column(&self, i: usize) -> C; fn column(&self, i: usize) -> C;
/// Writes the `i`-th column of `self`. /// 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 // FIXME: add iterators on columns: this could be a very good way to generalize _and_ optimize
// a lot of operations. // a lot of operations.
@ -151,13 +151,13 @@ pub trait Column<C> {
/// Trait to access part of a column of a matrix /// Trait to access part of a column of a matrix
pub trait ColumnSlice<C> { pub trait ColumnSlice<C> {
/// Returns a view to a slice of a column of a matrix. /// 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 /// Trait to access part of a row of a matrix
pub trait RowSlice<R> { pub trait RowSlice<R> {
/// Returns a view to a slice of a row of a matrix. /// 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. /// Trait of objects having a spacial dimension known at compile time.

View File

@ -332,7 +332,7 @@ fn test_row_slice_dmatrix() {
} }
#[test] #[test]
fn test_col_dmatrix() { fn test_column_dmatrix() {
let matrix = DMatrix::from_row_vector( let matrix = DMatrix::from_row_vector(
8, 8,
4, 4,
@ -355,7 +355,7 @@ fn test_col_dmatrix() {
} }
#[test] #[test]
fn test_col_slice_dmatrix() { fn test_column_slice_dmatrix() {
let matrix = DMatrix::from_row_vector( let matrix = DMatrix::from_row_vector(
8, 8,
4, 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(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.col_slice(0, 0, 3)); 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.col_slice(2, 2, 7)); 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.col_slice(3, 6, 8)); assert_eq!(&DVector::from_slice(2, &[28u32, 32]), &matrix.column_slice(3, 6, 8));
} }
#[test] #[test]
@ -394,7 +394,7 @@ fn test_dmat_from_vector() {
] ]
); );
let mat2 = DMatrix::from_col_vector( let mat2 = DMatrix::from_column_vector(
8, 8,
4, 4,
&[ &[
@ -541,7 +541,7 @@ fn test_dmat_subtraction() {
} }
#[test] #[test]
fn test_dmat_col() { fn test_dmat_column() {
let matrix = DMatrix::from_row_vector( let matrix = DMatrix::from_row_vector(
3, 3,
3, 3,
@ -556,7 +556,7 @@ fn test_dmat_col() {
} }
#[test] #[test]
fn test_dmat_set_col() { fn test_dmat_set_column() {
let mut matrix = DMatrix::from_row_vector( let mut matrix = DMatrix::from_row_vector(
3, 3,
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( let expected = DMatrix::from_row_vector(
3, 3,
@ -823,13 +823,13 @@ fn test_hessenberg_mat6() {
#[test] #[test]
fn test_transpose_square_matrix() { 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, 0, 1, 2, 3,
0, 1, 2, 3]; 0, 1, 2, 3];
let num_rows = 4; let num_rows = 4;
let num_cols = 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(); matrix.transpose_mut();
for i in 0..num_rows { for i in 0..num_rows {
assert_eq!(&[0, 1, 2, 3], &matrix.row_slice(i, 0, num_cols)[..]); assert_eq!(&[0, 1, 2, 3], &matrix.row_slice(i, 0, num_cols)[..]);