Skip to content

Commit

Permalink
Rename MatrixVec to VecStorage.
Browse files Browse the repository at this point in the history
See #470.
  • Loading branch information
jswrenn authored and sebcrozet committed Dec 6, 2018
1 parent b83c3b8 commit 0f66403
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
6 changes: 3 additions & 3 deletions src/base/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use base::dimension::Dynamic;
use base::dimension::{U1, U2, U3, U4, U5, U6};
#[cfg(any(feature = "std", feature = "alloc"))]
use base::matrix_vec::MatrixVec;
use base::vec_storage::VecStorage;
use base::storage::Owned;
use base::Matrix;

Expand Down Expand Up @@ -119,7 +119,7 @@ pub type Matrix6x5<N> = MatrixMN<N, U6, U5>;
*/
/// A dynamically sized column vector.
#[cfg(any(feature = "std", feature = "alloc"))]
pub type DVector<N> = Matrix<N, Dynamic, U1, MatrixVec<N, Dynamic, U1>>;
pub type DVector<N> = Matrix<N, Dynamic, U1, VecStorage<N, Dynamic, U1>>;

/// A statically sized D-dimensional column vector.
pub type VectorN<N, D> = MatrixMN<N, D, U1>;
Expand All @@ -146,7 +146,7 @@ pub type Vector6<N> = VectorN<N, U6>;
*/
/// A dynamically sized row vector.
#[cfg(any(feature = "std", feature = "alloc"))]
pub type RowDVector<N> = Matrix<N, U1, Dynamic, MatrixVec<N, U1, Dynamic>>;
pub type RowDVector<N> = Matrix<N, U1, Dynamic, VecStorage<N, U1, Dynamic>>;

/// A statically sized D-dimensional row vector.
pub type RowVectorN<N, D> = MatrixMN<N, U1, D>;
Expand Down
10 changes: 5 additions & 5 deletions src/base/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use base::dimension::{
use base::iter::{MatrixIter, MatrixIterMut};
use base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut};
#[cfg(any(feature = "std", feature = "alloc"))]
use base::MatrixVec;
use base::VecStorage;
use base::{DefaultAllocator, Matrix, ArrayStorage, MatrixMN, MatrixSlice, MatrixSliceMut, Scalar};

// FIXME: too bad this won't work allo slice conversions.
Expand Down Expand Up @@ -353,7 +353,7 @@ where

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, N, C, RStride, CStride> From<MatrixSlice<'a, N, Dynamic, C, RStride, CStride>>
for Matrix<N, Dynamic, C, MatrixVec<N, Dynamic, C>>
for Matrix<N, Dynamic, C, VecStorage<N, Dynamic, C>>
where
N: Scalar,
C: Dim,
Expand All @@ -367,7 +367,7 @@ where

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, N, R, RStride, CStride> From<MatrixSlice<'a, N, R, Dynamic, RStride, CStride>>
for Matrix<N, R, Dynamic, MatrixVec<N, R, Dynamic>>
for Matrix<N, R, Dynamic, VecStorage<N, R, Dynamic>>
where
N: Scalar,
R: DimName,
Expand Down Expand Up @@ -397,7 +397,7 @@ where

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, N, C, RStride, CStride> From<MatrixSliceMut<'a, N, Dynamic, C, RStride, CStride>>
for Matrix<N, Dynamic, C, MatrixVec<N, Dynamic, C>>
for Matrix<N, Dynamic, C, VecStorage<N, Dynamic, C>>
where
N: Scalar,
C: Dim,
Expand All @@ -411,7 +411,7 @@ where

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, N, R, RStride, CStride> From<MatrixSliceMut<'a, N, R, Dynamic, RStride, CStride>>
for Matrix<N, R, Dynamic, MatrixVec<N, R, Dynamic>>
for Matrix<N, R, Dynamic, VecStorage<N, R, Dynamic>>
where
N: Scalar,
R: DimName,
Expand Down
44 changes: 22 additions & 22 deletions src/base/default_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use base::dimension::Dynamic;
use base::dimension::{Dim, DimName};
use base::array_storage::ArrayStorage;
#[cfg(any(feature = "std", feature = "alloc"))]
use base::matrix_vec::MatrixVec;
use base::vec_storage::VecStorage;
use base::storage::{Storage, StorageMut};
use base::Scalar;

Expand All @@ -29,7 +29,7 @@ use base::Scalar;
* Allocator.
*
*/
/// An allocator based on `GenericArray` and `MatrixVec` for statically-sized and dynamically-sized
/// An allocator based on `GenericArray` and `VecStorage` for statically-sized and dynamically-sized
/// matrices respectively.
pub struct DefaultAllocator;

Expand Down Expand Up @@ -77,7 +77,7 @@ where
// Dynamic - Dynamic
#[cfg(any(feature = "std", feature = "alloc"))]
impl<N: Scalar, C: Dim> Allocator<N, Dynamic, C> for DefaultAllocator {
type Buffer = MatrixVec<N, Dynamic, C>;
type Buffer = VecStorage<N, Dynamic, C>;

#[inline]
unsafe fn allocate_uninitialized(nrows: Dynamic, ncols: C) -> Self::Buffer {
Expand All @@ -86,7 +86,7 @@ impl<N: Scalar, C: Dim> Allocator<N, Dynamic, C> for DefaultAllocator {
res.reserve_exact(length);
res.set_len(length);

MatrixVec::new(nrows, ncols, res)
VecStorage::new(nrows, ncols, res)
}

#[inline]
Expand All @@ -101,14 +101,14 @@ impl<N: Scalar, C: Dim> Allocator<N, Dynamic, C> for DefaultAllocator {
assert!(res.len() == nrows.value() * ncols.value(),
"Allocation from iterator error: the iterator did not yield the correct number of elements.");

MatrixVec::new(nrows, ncols, res)
VecStorage::new(nrows, ncols, res)
}
}

// Static - Dynamic
#[cfg(any(feature = "std", feature = "alloc"))]
impl<N: Scalar, R: DimName> Allocator<N, R, Dynamic> for DefaultAllocator {
type Buffer = MatrixVec<N, R, Dynamic>;
type Buffer = VecStorage<N, R, Dynamic>;

#[inline]
unsafe fn allocate_uninitialized(nrows: R, ncols: Dynamic) -> Self::Buffer {
Expand All @@ -117,7 +117,7 @@ impl<N: Scalar, R: DimName> Allocator<N, R, Dynamic> for DefaultAllocator {
res.reserve_exact(length);
res.set_len(length);

MatrixVec::new(nrows, ncols, res)
VecStorage::new(nrows, ncols, res)
}

#[inline]
Expand All @@ -132,7 +132,7 @@ impl<N: Scalar, R: DimName> Allocator<N, R, Dynamic> for DefaultAllocator {
assert!(res.len() == nrows.value() * ncols.value(),
"Allocation from iterator error: the iterator did not yield the correct number of elements.");

MatrixVec::new(nrows, ncols, res)
VecStorage::new(nrows, ncols, res)
}
}

Expand Down Expand Up @@ -186,7 +186,7 @@ where
rto: Dynamic,
cto: CTo,
buf: ArrayStorage<N, RFrom, CFrom>,
) -> MatrixVec<N, Dynamic, CTo>
) -> VecStorage<N, Dynamic, CTo>
{
let mut res = <Self as Allocator<N, Dynamic, CTo>>::allocate_uninitialized(rto, cto);

Expand Down Expand Up @@ -215,7 +215,7 @@ where
rto: RTo,
cto: Dynamic,
buf: ArrayStorage<N, RFrom, CFrom>,
) -> MatrixVec<N, RTo, Dynamic>
) -> VecStorage<N, RTo, Dynamic>
{
let mut res = <Self as Allocator<N, RTo, Dynamic>>::allocate_uninitialized(rto, cto);

Expand All @@ -238,11 +238,11 @@ impl<N: Scalar, CFrom: Dim, CTo: Dim> Reallocator<N, Dynamic, CFrom, Dynamic, CT
unsafe fn reallocate_copy(
rto: Dynamic,
cto: CTo,
buf: MatrixVec<N, Dynamic, CFrom>,
) -> MatrixVec<N, Dynamic, CTo>
buf: VecStorage<N, Dynamic, CFrom>,
) -> VecStorage<N, Dynamic, CTo>
{
let new_buf = buf.resize(rto.value() * cto.value());
MatrixVec::new(rto, cto, new_buf)
VecStorage::new(rto, cto, new_buf)
}
}

Expand All @@ -254,11 +254,11 @@ impl<N: Scalar, CFrom: Dim, RTo: DimName> Reallocator<N, Dynamic, CFrom, RTo, Dy
unsafe fn reallocate_copy(
rto: RTo,
cto: Dynamic,
buf: MatrixVec<N, Dynamic, CFrom>,
) -> MatrixVec<N, RTo, Dynamic>
buf: VecStorage<N, Dynamic, CFrom>,
) -> VecStorage<N, RTo, Dynamic>
{
let new_buf = buf.resize(rto.value() * cto.value());
MatrixVec::new(rto, cto, new_buf)
VecStorage::new(rto, cto, new_buf)
}
}

Expand All @@ -270,11 +270,11 @@ impl<N: Scalar, RFrom: DimName, CTo: Dim> Reallocator<N, RFrom, Dynamic, Dynamic
unsafe fn reallocate_copy(
rto: Dynamic,
cto: CTo,
buf: MatrixVec<N, RFrom, Dynamic>,
) -> MatrixVec<N, Dynamic, CTo>
buf: VecStorage<N, RFrom, Dynamic>,
) -> VecStorage<N, Dynamic, CTo>
{
let new_buf = buf.resize(rto.value() * cto.value());
MatrixVec::new(rto, cto, new_buf)
VecStorage::new(rto, cto, new_buf)
}
}

Expand All @@ -286,10 +286,10 @@ impl<N: Scalar, RFrom: DimName, RTo: DimName> Reallocator<N, RFrom, Dynamic, RTo
unsafe fn reallocate_copy(
rto: RTo,
cto: Dynamic,
buf: MatrixVec<N, RFrom, Dynamic>,
) -> MatrixVec<N, RTo, Dynamic>
buf: VecStorage<N, RFrom, Dynamic>,
) -> VecStorage<N, RTo, Dynamic>
{
let new_buf = buf.resize(rto.value() * cto.value());
MatrixVec::new(rto, cto, new_buf)
VecStorage::new(rto, cto, new_buf)
}
}
4 changes: 2 additions & 2 deletions src/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod matrix_alga;
mod array_storage;
mod matrix_slice;
#[cfg(any(feature = "std", feature = "alloc"))]
mod matrix_vec;
mod vec_storage;
mod properties;
mod scalar;
mod swizzle;
Expand All @@ -44,4 +44,4 @@ pub use self::alias_slice::*;
pub use self::array_storage::*;
pub use self::matrix_slice::*;
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::matrix_vec::*;
pub use self::vec_storage::*;
2 changes: 1 addition & 1 deletion src/base/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub type CStride<N, R, C = U1> =
/// Note that `Self` must always have a number of elements compatible with the matrix length (given
/// by `R` and `C` if they are known at compile-time). For example, implementors of this trait
/// should **not** allow the user to modify the size of the underlying buffer with safe methods
/// (for example the `MatrixVec::data_mut` method is unsafe because the user could change the
/// (for example the `VecStorage::data_mut` method is unsafe because the user could change the
/// vector's size so that it no longer contains enough elements: this will lead to UB.
pub unsafe trait Storage<N: Scalar, R: Dim, C: Dim = U1>: Debug + Sized {
/// The static stride of this storage's rows.
Expand Down
Loading

0 comments on commit 0f66403

Please sign in to comment.