Rename MatrixArray to ArrayStorage.

See #470.
This commit is contained in:
Jack Wrenn 2018-12-05 16:40:03 -05:00 committed by Sébastien Crozet
parent 1f2ef4bb44
commit b83c3b857b
4 changed files with 38 additions and 34 deletions

View File

@ -34,7 +34,7 @@ use base::Scalar;
*/
/// A array-based statically sized matrix data storage.
#[repr(C)]
pub struct MatrixArray<N, R, C>
pub struct ArrayStorage<N, R, C>
where
R: DimName,
C: DimName,
@ -44,7 +44,11 @@ where
data: GenericArray<N, Prod<R::Value, C::Value>>,
}
impl<N, R, C> Hash for MatrixArray<N, R, C>
#[deprecated(note="renamed to `ArrayStorage`")]
/// Renamed to [ArrayStorage].
pub type MatrixArray<N, R, C> = ArrayStorage<N, R, C>;
impl<N, R, C> Hash for ArrayStorage<N, R, C>
where
N: Hash,
R: DimName,
@ -57,7 +61,7 @@ where
}
}
impl<N, R, C> Deref for MatrixArray<N, R, C>
impl<N, R, C> Deref for ArrayStorage<N, R, C>
where
R: DimName,
C: DimName,
@ -72,7 +76,7 @@ where
}
}
impl<N, R, C> DerefMut for MatrixArray<N, R, C>
impl<N, R, C> DerefMut for ArrayStorage<N, R, C>
where
R: DimName,
C: DimName,
@ -85,7 +89,7 @@ where
}
}
impl<N, R, C> Debug for MatrixArray<N, R, C>
impl<N, R, C> Debug for ArrayStorage<N, R, C>
where
N: Debug,
R: DimName,
@ -99,7 +103,7 @@ where
}
}
impl<N, R, C> Copy for MatrixArray<N, R, C>
impl<N, R, C> Copy for ArrayStorage<N, R, C>
where
N: Copy,
R: DimName,
@ -109,7 +113,7 @@ where
GenericArray<N, Prod<R::Value, C::Value>>: Copy,
{}
impl<N, R, C> Clone for MatrixArray<N, R, C>
impl<N, R, C> Clone for ArrayStorage<N, R, C>
where
N: Clone,
R: DimName,
@ -119,13 +123,13 @@ where
{
#[inline]
fn clone(&self) -> Self {
MatrixArray {
ArrayStorage {
data: self.data.clone(),
}
}
}
impl<N, R, C> Eq for MatrixArray<N, R, C>
impl<N, R, C> Eq for ArrayStorage<N, R, C>
where
N: Eq,
R: DimName,
@ -134,7 +138,7 @@ where
Prod<R::Value, C::Value>: ArrayLength<N>,
{}
impl<N, R, C> PartialEq for MatrixArray<N, R, C>
impl<N, R, C> PartialEq for ArrayStorage<N, R, C>
where
N: PartialEq,
R: DimName,
@ -148,7 +152,7 @@ where
}
}
unsafe impl<N, R, C> Storage<N, R, C> for MatrixArray<N, R, C>
unsafe impl<N, R, C> Storage<N, R, C> for ArrayStorage<N, R, C>
where
N: Scalar,
R: DimName,
@ -200,7 +204,7 @@ where
}
}
unsafe impl<N, R, C> StorageMut<N, R, C> for MatrixArray<N, R, C>
unsafe impl<N, R, C> StorageMut<N, R, C> for ArrayStorage<N, R, C>
where
N: Scalar,
R: DimName,
@ -220,7 +224,7 @@ where
}
}
unsafe impl<N, R, C> ContiguousStorage<N, R, C> for MatrixArray<N, R, C>
unsafe impl<N, R, C> ContiguousStorage<N, R, C> for ArrayStorage<N, R, C>
where
N: Scalar,
R: DimName,
@ -230,7 +234,7 @@ where
DefaultAllocator: Allocator<N, R, C, Buffer = Self>,
{}
unsafe impl<N, R, C> ContiguousStorageMut<N, R, C> for MatrixArray<N, R, C>
unsafe impl<N, R, C> ContiguousStorageMut<N, R, C> for ArrayStorage<N, R, C>
where
N: Scalar,
R: DimName,
@ -247,7 +251,7 @@ where
*/
// XXX: open an issue for GenericArray so that it implements serde traits?
#[cfg(feature = "serde-serialize")]
impl<N, R, C> Serialize for MatrixArray<N, R, C>
impl<N, R, C> Serialize for ArrayStorage<N, R, C>
where
N: Scalar + Serialize,
R: DimName,
@ -268,7 +272,7 @@ where
}
#[cfg(feature = "serde-serialize")]
impl<'a, N, R, C> Deserialize<'a> for MatrixArray<N, R, C>
impl<'a, N, R, C> Deserialize<'a> for ArrayStorage<N, R, C>
where
N: Scalar + Deserialize<'a>,
R: DimName,
@ -278,18 +282,18 @@ where
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'a> {
deserializer.deserialize_seq(MatrixArrayVisitor::new())
deserializer.deserialize_seq(ArrayStorageVisitor::new())
}
}
#[cfg(feature = "serde-serialize")]
/// A visitor that produces a matrix array.
struct MatrixArrayVisitor<N, R, C> {
struct ArrayStorageVisitor<N, R, C> {
marker: PhantomData<(N, R, C)>,
}
#[cfg(feature = "serde-serialize")]
impl<N, R, C> MatrixArrayVisitor<N, R, C>
impl<N, R, C> ArrayStorageVisitor<N, R, C>
where
N: Scalar,
R: DimName,
@ -299,14 +303,14 @@ where
{
/// Construct a new sequence visitor.
pub fn new() -> Self {
MatrixArrayVisitor {
ArrayStorageVisitor {
marker: PhantomData,
}
}
}
#[cfg(feature = "serde-serialize")]
impl<'a, N, R, C> Visitor<'a> for MatrixArrayVisitor<N, R, C>
impl<'a, N, R, C> Visitor<'a> for ArrayStorageVisitor<N, R, C>
where
N: Scalar + Deserialize<'a>,
R: DimName,
@ -314,14 +318,14 @@ where
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
{
type Value = MatrixArray<N, R, C>;
type Value = ArrayStorage<N, R, C>;
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
formatter.write_str("a matrix array")
}
#[inline]
fn visit_seq<V>(self, mut visitor: V) -> Result<MatrixArray<N, R, C>, V::Error>
fn visit_seq<V>(self, mut visitor: V) -> Result<ArrayStorage<N, R, C>, V::Error>
where V: SeqAccess<'a> {
let mut out: Self::Value = unsafe { mem::uninitialized() };
let mut curr = 0;
@ -340,7 +344,7 @@ where
}
#[cfg(feature = "abomonation-serialize")]
impl<N, R, C> Abomonation for MatrixArray<N, R, C>
impl<N, R, C> Abomonation for ArrayStorage<N, R, C>
where
R: DimName,
C: DimName,

View File

@ -18,7 +18,7 @@ use base::iter::{MatrixIter, MatrixIterMut};
use base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut};
#[cfg(any(feature = "std", feature = "alloc"))]
use base::MatrixVec;
use base::{DefaultAllocator, Matrix, MatrixArray, MatrixMN, MatrixSlice, MatrixSliceMut, Scalar};
use base::{DefaultAllocator, Matrix, ArrayStorage, MatrixMN, MatrixSlice, MatrixSliceMut, Scalar};
// FIXME: too bad this won't work allo slice conversions.
impl<N1, N2, R1, C1, R2, C2> SubsetOf<MatrixMN<N2, R2, C2>> for MatrixMN<N1, R1, C1>
@ -336,7 +336,7 @@ impl_from_into_mint_2D!(
);
impl<'a, N, R, C, RStride, CStride> From<MatrixSlice<'a, N, R, C, RStride, CStride>>
for Matrix<N, R, C, MatrixArray<N, R, C>>
for Matrix<N, R, C, ArrayStorage<N, R, C>>
where
N: Scalar,
R: DimName,
@ -380,7 +380,7 @@ where
}
impl<'a, N, R, C, RStride, CStride> From<MatrixSliceMut<'a, N, R, C, RStride, CStride>>
for Matrix<N, R, C, MatrixArray<N, R, C>>
for Matrix<N, R, C, ArrayStorage<N, R, C>>
where
N: Scalar,
R: DimName,

View File

@ -18,7 +18,7 @@ use base::allocator::{Allocator, Reallocator};
#[cfg(any(feature = "alloc", feature = "std"))]
use base::dimension::Dynamic;
use base::dimension::{Dim, DimName};
use base::matrix_array::MatrixArray;
use base::array_storage::ArrayStorage;
#[cfg(any(feature = "std", feature = "alloc"))]
use base::matrix_vec::MatrixVec;
use base::storage::{Storage, StorageMut};
@ -42,7 +42,7 @@ where
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
{
type Buffer = MatrixArray<N, R, C>;
type Buffer = ArrayStorage<N, R, C>;
#[inline]
unsafe fn allocate_uninitialized(_: R, _: C) -> Self::Buffer {
@ -157,7 +157,7 @@ where
rto: RTo,
cto: CTo,
buf: <Self as Allocator<N, RFrom, CFrom>>::Buffer,
) -> MatrixArray<N, RTo, CTo>
) -> ArrayStorage<N, RTo, CTo>
{
let mut res = <Self as Allocator<N, RTo, CTo>>::allocate_uninitialized(rto, cto);
@ -185,7 +185,7 @@ where
unsafe fn reallocate_copy(
rto: Dynamic,
cto: CTo,
buf: MatrixArray<N, RFrom, CFrom>,
buf: ArrayStorage<N, RFrom, CFrom>,
) -> MatrixVec<N, Dynamic, CTo>
{
let mut res = <Self as Allocator<N, Dynamic, CTo>>::allocate_uninitialized(rto, cto);
@ -214,7 +214,7 @@ where
unsafe fn reallocate_copy(
rto: RTo,
cto: Dynamic,
buf: MatrixArray<N, RFrom, CFrom>,
buf: ArrayStorage<N, RFrom, CFrom>,
) -> MatrixVec<N, RTo, Dynamic>
{
let mut res = <Self as Allocator<N, RTo, Dynamic>>::allocate_uninitialized(rto, cto);

View File

@ -20,7 +20,7 @@ mod conversion;
mod edition;
mod matrix;
mod matrix_alga;
mod matrix_array;
mod array_storage;
mod matrix_slice;
#[cfg(any(feature = "std", feature = "alloc"))]
mod matrix_vec;
@ -41,7 +41,7 @@ pub use self::dimension::*;
pub use self::alias::*;
pub use self::alias_slice::*;
pub use self::matrix_array::*;
pub use self::array_storage::*;
pub use self::matrix_slice::*;
#[cfg(any(feature = "std", feature = "alloc"))]
pub use self::matrix_vec::*;