diff --git a/CHANGELOG.md b/CHANGELOG.md index b749db7d..57063ccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,21 @@ documented here. This project adheres to [Semantic Versioning](http://semver.org/). ## [0.15.0] - WIP +The most notable change of this release is the support for using part of the library without the rust standard +library (i.e. it supports `#![no_std]`). Use the following in your `Cargo.toml` to work with a version of +nalgebra that does not rely on libstd: +```toml +#[dependencies] +nalgebra = { version = "0.15", default_features = false } +``` +Some feature are no longer available when libstd is not used: + * Support for dynamically-sized matrices. + * Support for the `::new_random()` matrix constructor. + * Support for the `.resize(...)` method since it returns a dynamically-sized matrix. +All other feature, including matrix factorizations, will still work on statically-sized matrices! ### Modified + * Rename the `core` module to `base` to avoid conflicts with the `core` crate implicitly imported when + `#![no_std]` is enabled. * Constructors of the `MatrixSlice*` types have been renamed from `new_*` to `from_slice_*`. This was necessary to avoid the `incoherent_fundamental_impls` lint that is going to become a hard error. ### Added diff --git a/Cargo.toml b/Cargo.toml index a4425d1b..c7444cf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,24 +16,26 @@ name = "nalgebra" path = "src/lib.rs" [features] +default = [ "std" ] +std = [ "matrixmultiply" ] arbitrary = [ "quickcheck" ] serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ] abomonation-serialize = [ "abomonation" ] debug = [ ] [dependencies] -typenum = "1.7" -generic-array = "0.8" -rand = "0.4" -num-traits = "0.1" -num-complex = { version = "0.1", default-features = false } -approx = "0.1" -alga = "0.5" -matrixmultiply = "0.1" +typenum = "1.10" +generic-array = "0.11" +rand = { version = "0.4", default-features = false } +num-traits = { version = "0.2", default-features = false } +num-complex = { version = "0.2.0-git", git = "https://github.com/rust-num/num-complex", default-features = false } +approx = { version = "0.1", default-features = false } +alga = { version = "0.5", default-features = false } +matrixmultiply = { version = "0.1", optional = true } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } abomonation = { version = "0.4", optional = true } -mint = { version = "0.4.2", optional = true } +mint = { version = "0.5", optional = true } [dependencies.quickcheck] optional = true diff --git a/src/core/alias.rs b/src/base/alias.rs similarity index 94% rename from src/core/alias.rs rename to src/base/alias.rs index f3dfccd3..6c49cf1e 100644 --- a/src/core/alias.rs +++ b/src/base/alias.rs @@ -1,7 +1,8 @@ -use core::Matrix; -use core::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; -use core::matrix_vec::MatrixVec; -use core::storage::Owned; +use base::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; +#[cfg(any(feature = "std", feature = "alloc"))] +use base::matrix_vec::MatrixVec; +use base::storage::Owned; +use base::Matrix; /* * @@ -21,6 +22,7 @@ pub type MatrixMN = Matrix>; pub type MatrixN = MatrixMN; /// A dynamically sized column-major matrix. +#[cfg(any(feature = "std", feature = "alloc"))] pub type DMatrix = MatrixN; /// A stack-allocated, column-major, 1x1 square matrix. @@ -114,6 +116,7 @@ pub type Matrix6x5 = MatrixMN; * */ /// A dynamically sized column vector. +#[cfg(any(feature = "std", feature = "alloc"))] pub type DVector = Matrix>; /// A statically sized D-dimensional column vector. @@ -140,6 +143,7 @@ pub type Vector6 = VectorN; * */ /// A dynamically sized row vector. +#[cfg(any(feature = "std", feature = "alloc"))] pub type RowDVector = Matrix>; /// A statically sized D-dimensional row vector. diff --git a/src/core/alias_slice.rs b/src/base/alias_slice.rs similarity index 99% rename from src/core/alias_slice.rs rename to src/base/alias_slice.rs index 624549df..14519344 100644 --- a/src/core/alias_slice.rs +++ b/src/base/alias_slice.rs @@ -1,6 +1,6 @@ -use core::Matrix; -use core::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; -use core::matrix_slice::{SliceStorage, SliceStorageMut}; +use base::Matrix; +use base::dimension::{Dynamic, U1, U2, U3, U4, U5, U6}; +use base::matrix_slice::{SliceStorage, SliceStorageMut}; /* * diff --git a/src/core/allocator.rs b/src/base/allocator.rs similarity index 95% rename from src/core/allocator.rs rename to src/base/allocator.rs index 7404eed0..61dd71eb 100644 --- a/src/core/allocator.rs +++ b/src/base/allocator.rs @@ -2,10 +2,10 @@ use std::any::Any; -use core::{DefaultAllocator, Scalar}; -use core::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::dimension::{Dim, U1}; -use core::storage::ContiguousStorageMut; +use base::{DefaultAllocator, Scalar}; +use base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::{Dim, U1}; +use base::storage::ContiguousStorageMut; /// A matrix allocator of a memory buffer that may contain `R::to_usize() * C::to_usize()` /// elements of type `N`. diff --git a/src/core/blas.rs b/src/base/blas.rs similarity index 84% rename from src/core/blas.rs rename to src/base/blas.rs index de8020ec..71d1e1f5 100644 --- a/src/core/blas.rs +++ b/src/base/blas.rs @@ -1,14 +1,16 @@ -use std::mem; -use num::{One, Signed, Zero}; -use matrixmultiply; use alga::general::{ClosedAdd, ClosedMul}; +#[cfg(feature = "std")] +use matrixmultiply; +use num::{One, Signed, Zero}; +use std::mem; -use core::{DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector}; -use core::dimension::{Dim, Dynamic, U1, U2, U3, U4}; -use core::constraint::{AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, - ShapeConstraint}; -use core::storage::{Storage, StorageMut}; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::constraint::{ + AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint, +}; +use base::dimension::{Dim, Dynamic, U1, U2, U3, U4}; +use base::storage::{Storage, StorageMut}; +use base::{DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector}; impl> Vector { /// Computes the index of the vector component with the largest absolute value. @@ -457,85 +459,93 @@ where + SameNumberOfColumns + AreMultipliable, { - let (nrows1, ncols1) = self.shape(); - let (nrows2, ncols2) = a.shape(); - let (nrows3, ncols3) = b.shape(); + let ncols1 = self.shape(); - assert_eq!( - ncols2, nrows3, - "gemm: dimensions mismatch for multiplication." - ); - assert_eq!( - (nrows1, ncols1), - (nrows2, ncols3), - "gemm: dimensions mismatch for addition." - ); - - // We assume large matrices will be Dynamic but small matrices static. - // We could use matrixmultiply for large statically-sized matrices but the performance - // threshold to activate it would be different from SMALL_DIM because our code optimizes - // better for statically-sized matrices. - let is_dynamic = R1::is::() || C1::is::() || R2::is::() - || C2::is::() || R3::is::() - || C3::is::(); - // Thershold determined ampirically. - const SMALL_DIM: usize = 5; - - if is_dynamic && nrows1 > SMALL_DIM && ncols1 > SMALL_DIM && nrows2 > SMALL_DIM - && ncols2 > SMALL_DIM + #[cfg(feature = "std")] { - if N::is::() { - let (rsa, csa) = a.strides(); - let (rsb, csb) = b.strides(); - let (rsc, csc) = self.strides(); + // matrixmultiply can be used only if the std feature is available. + let nrows1 = self.nrows(); + let (nrows2, ncols2) = a.shape(); + let (nrows3, ncols3) = b.shape(); - unsafe { - matrixmultiply::sgemm( - nrows2, - ncols2, - ncols3, - mem::transmute_copy(&alpha), - a.data.ptr() as *const f32, - rsa as isize, - csa as isize, - b.data.ptr() as *const f32, - rsb as isize, - csb as isize, - mem::transmute_copy(&beta), - self.data.ptr_mut() as *mut f32, - rsc as isize, - csc as isize, - ); - } - } else if N::is::() { - let (rsa, csa) = a.strides(); - let (rsb, csb) = b.strides(); - let (rsc, csc) = self.strides(); + assert_eq!( + ncols2, nrows3, + "gemm: dimensions mismatch for multiplication." + ); + assert_eq!( + (nrows1, ncols1), + (nrows2, ncols3), + "gemm: dimensions mismatch for addition." + ); - unsafe { - matrixmultiply::dgemm( - nrows2, - ncols2, - ncols3, - mem::transmute_copy(&alpha), - a.data.ptr() as *const f64, - rsa as isize, - csa as isize, - b.data.ptr() as *const f64, - rsb as isize, - csb as isize, - mem::transmute_copy(&beta), - self.data.ptr_mut() as *mut f64, - rsc as isize, - csc as isize, - ); + // We assume large matrices will be Dynamic but small matrices static. + // We could use matrixmultiply for large statically-sized matrices but the performance + // threshold to activate it would be different from SMALL_DIM because our code optimizes + // better for statically-sized matrices. + let is_dynamic = R1::is::() || C1::is::() || R2::is::() + || C2::is::() || R3::is::() + || C3::is::(); + // Thershold determined ampirically. + const SMALL_DIM: usize = 5; + + if is_dynamic && nrows1 > SMALL_DIM && ncols1 > SMALL_DIM && nrows2 > SMALL_DIM + && ncols2 > SMALL_DIM + { + if N::is::() { + let (rsa, csa) = a.strides(); + let (rsb, csb) = b.strides(); + let (rsc, csc) = self.strides(); + + unsafe { + matrixmultiply::sgemm( + nrows2, + ncols2, + ncols3, + mem::transmute_copy(&alpha), + a.data.ptr() as *const f32, + rsa as isize, + csa as isize, + b.data.ptr() as *const f32, + rsb as isize, + csb as isize, + mem::transmute_copy(&beta), + self.data.ptr_mut() as *mut f32, + rsc as isize, + csc as isize, + ); + } + } else if N::is::() { + let (rsa, csa) = a.strides(); + let (rsb, csb) = b.strides(); + let (rsc, csc) = self.strides(); + + unsafe { + matrixmultiply::dgemm( + nrows2, + ncols2, + ncols3, + mem::transmute_copy(&alpha), + a.data.ptr() as *const f64, + rsa as isize, + csa as isize, + b.data.ptr() as *const f64, + rsb as isize, + csb as isize, + mem::transmute_copy(&beta), + self.data.ptr_mut() as *mut f64, + rsc as isize, + csc as isize, + ); + } } + + return; } - } else { - for j1 in 0..ncols1 { - // FIXME: avoid bound checks. - self.column_mut(j1).gemv(alpha, a, &b.column(j1), beta); - } + } + + for j1 in 0..ncols1 { + // FIXME: avoid bound checks. + self.column_mut(j1).gemv(alpha, a, &b.column(j1), beta); } } @@ -698,10 +708,8 @@ where S2: StorageMut, S3: Storage, S4: Storage, - ShapeConstraint: DimEq - + DimEq - + DimEq - + AreMultipliable, + ShapeConstraint: + DimEq + DimEq + DimEq + AreMultipliable, { work.gemv(N::one(), mid, &rhs.column(0), N::zero()); self.column_mut(0).gemv_tr(alpha, &rhs, work, beta); diff --git a/src/core/cg.rs b/src/base/cg.rs similarity index 98% rename from src/core/cg.rs rename to src/base/cg.rs index 193801c5..098795f1 100644 --- a/src/core/cg.rs +++ b/src/base/cg.rs @@ -7,11 +7,11 @@ use num::One; -use core::{DefaultAllocator, Matrix3, Matrix4, MatrixN, Scalar, SquareMatrix, Unit, Vector, +use base::{DefaultAllocator, Matrix3, Matrix4, MatrixN, Scalar, SquareMatrix, Unit, Vector, Vector3, VectorN}; -use core::dimension::{DimName, DimNameDiff, DimNameSub, U1}; -use core::storage::{Storage, StorageMut}; -use core::allocator::Allocator; +use base::dimension::{DimName, DimNameDiff, DimNameSub, U1}; +use base::storage::{Storage, StorageMut}; +use base::allocator::Allocator; use geometry::{Isometry, IsometryMatrix3, Orthographic3, Perspective3, Point, Point3, Rotation2, Rotation3}; diff --git a/src/core/componentwise.rs b/src/base/componentwise.rs similarity index 95% rename from src/core/componentwise.rs rename to src/base/componentwise.rs index 47201431..2a4036e4 100644 --- a/src/core/componentwise.rs +++ b/src/base/componentwise.rs @@ -1,15 +1,15 @@ // Non-convensional componentwise operators. -use std::ops::{Add, Mul}; use num::{Signed, Zero}; +use std::ops::{Add, Mul}; use alga::general::{ClosedDiv, ClosedMul}; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixSum, Scalar}; -use core::dimension::Dim; -use core::storage::{Storage, StorageMut}; -use core::allocator::{Allocator, SameShapeAllocator}; -use core::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::allocator::{Allocator, SameShapeAllocator}; +use base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::Dim; +use base::storage::{Storage, StorageMut}; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixSum, Scalar}; /// The type of the result of a matrix componentwise operation. pub type MatrixComponentOp = MatrixSum; diff --git a/src/core/constraint.rs b/src/base/constraint.rs similarity index 98% rename from src/core/constraint.rs rename to src/base/constraint.rs index 4f148c5c..369841b5 100644 --- a/src/core/constraint.rs +++ b/src/base/constraint.rs @@ -1,6 +1,6 @@ //! Compatibility constraints between matrix shapes, e.g., for addition or multiplication. -use core::dimension::{Dim, DimName, Dynamic}; +use base::dimension::{Dim, DimName, Dynamic}; /// A type used in `where` clauses for enforcing constraints. pub struct ShapeConstraint; diff --git a/src/core/construction.rs b/src/base/construction.rs similarity index 98% rename from src/core/construction.rs rename to src/base/construction.rs index 52391147..c85d2d8f 100644 --- a/src/core/construction.rs +++ b/src/base/construction.rs @@ -1,5 +1,5 @@ #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; @@ -10,10 +10,10 @@ use typenum::{self, Cmp, Greater}; use alga::general::{ClosedAdd, ClosedMul}; -use core::allocator::Allocator; -use core::dimension::{Dim, DimName, Dynamic, U1, U2, U3, U4, U5, U6}; -use core::storage::Storage; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar, Unit, Vector, VectorN}; +use base::allocator::Allocator; +use base::dimension::{Dim, DimName, Dynamic, U1, U2, U3, U4, U5, U6}; +use base::storage::Storage; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar, Unit, Vector, VectorN}; /* * @@ -228,6 +228,7 @@ where /// Creates a matrix filled with random values. #[inline] + #[cfg(feature = "std")] pub fn new_random_generic(nrows: R, ncols: C) -> Self where N: Rand, @@ -384,6 +385,7 @@ macro_rules! impl_constructors( /// Creates a matrix filled with random values. #[inline] + #[cfg(feature = "std")] pub fn new_random($($args: usize),*) -> Self { Self::new_random_generic($($gargs),*) } diff --git a/src/core/construction_slice.rs b/src/base/construction_slice.rs similarity index 98% rename from src/core/construction_slice.rs rename to src/base/construction_slice.rs index f38abab4..d7d2d159 100644 --- a/src/core/construction_slice.rs +++ b/src/base/construction_slice.rs @@ -1,6 +1,6 @@ -use core::dimension::{Dim, DimName, Dynamic, U1}; -use core::matrix_slice::{SliceStorage, SliceStorageMut}; -use core::{MatrixSliceMN, MatrixSliceMutMN, Scalar}; +use base::dimension::{Dim, DimName, Dynamic, U1}; +use base::matrix_slice::{SliceStorage, SliceStorageMut}; +use base::{MatrixSliceMN, MatrixSliceMutMN, Scalar}; /* * diff --git a/src/core/construction_slice_deprecated.rs b/src/base/construction_slice_deprecated.rs similarity index 88% rename from src/core/construction_slice_deprecated.rs rename to src/base/construction_slice_deprecated.rs index 042067bf..257c52dc 100644 --- a/src/core/construction_slice_deprecated.rs +++ b/src/base/construction_slice_deprecated.rs @@ -1,6 +1,6 @@ -use core::{MatrixSliceMN, MatrixSliceMutMN, Scalar}; -use core::dimension::{Dim, DimName, Dynamic, U1}; -use core::matrix_slice::{SliceStorage, SliceStorageMut}; +use base::dimension::{Dim, DimName, Dynamic, U1}; +use base::matrix_slice::{SliceStorage, SliceStorageMut}; +use base::{MatrixSliceMN, MatrixSliceMutMN, Scalar}; /* * @@ -15,7 +15,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic_unchecked instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic_unchecked instead." + )] pub unsafe fn new_with_strides_generic_unchecked( data: &'a [N], start: usize, @@ -37,7 +39,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// Panics if the input data array dose not contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic instead." + )] pub fn new_with_strides_generic( data: &'a [N], nrows: R, @@ -54,7 +58,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> "Matrix slice: input data buffer to small." ); - unsafe { Self::from_slice_with_strides_generic_unchecked(data, 0, nrows, ncols, rstride, cstride) } + unsafe { + Self::from_slice_with_strides_generic_unchecked(data, 0, nrows, ncols, rstride, cstride) + } } } @@ -66,7 +72,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic_unchecked instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic_unchecked instead." + )] pub unsafe fn new_with_strides_generic_mut_unchecked( data: &'a mut [N], start: usize, @@ -88,7 +96,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> /// Panics if the input data array dose not contain enough elements. /// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_with_strides_generic instead." + )] pub fn new_with_strides_generic_mut( data: &'a mut [N], nrows: R, @@ -117,7 +127,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic_unchecked instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic_unchecked instead." + )] pub unsafe fn new_generic_unchecked(data: &'a [N], start: usize, nrows: R, ncols: C) -> Self { Self::from_slice_with_strides_generic_unchecked(data, start, nrows, ncols, U1, nrows) } @@ -127,7 +139,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> { /// Panics if the input data array dose not contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic instead." + )] pub fn new_generic(data: &'a [N], nrows: R, ncols: C) -> Self { Self::from_slice_with_strides_generic(data, nrows, ncols, U1, nrows) } @@ -139,7 +153,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { /// This method is unsafe because the input data array is not checked to contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic_unchecked instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic_unchecked instead." + )] pub unsafe fn new_generic_mut_unchecked( data: &'a mut [N], start: usize, @@ -154,7 +170,9 @@ impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> { /// Panics if the input data array dose not contain enough elements. /// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`. #[inline] - #[deprecated(note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic instead.")] + #[deprecated( + note = "This constructor is being removed to avoid the incoherent_fundamental_impls lint error. Use ::from_slice_generic instead." + )] pub fn new_generic_mut(data: &'a mut [N], nrows: R, ncols: C) -> Self { Self::from_slice_with_strides_generic(data, nrows, ncols, U1, nrows) } diff --git a/src/core/conversion.rs b/src/base/conversion.rs similarity index 95% rename from src/core/conversion.rs rename to src/base/conversion.rs index d6d3cda1..b6a3d270 100644 --- a/src/core/conversion.rs +++ b/src/base/conversion.rs @@ -1,16 +1,16 @@ -use std::ptr; -use std::mem; -use std::convert::{AsMut, AsRef, From, Into}; use alga::general::{SubsetOf, SupersetOf}; #[cfg(feature = "mint")] use mint; +use std::convert::{AsMut, AsRef, From, Into}; +use std::mem; +use std::ptr; -use core::{DefaultAllocator, Matrix, MatrixMN, Scalar}; -use core::dimension::{Dim, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9}; -use core::iter::{MatrixIter, MatrixIterMut}; -use core::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut}; -use core::allocator::{Allocator, SameShapeAllocator}; +use base::allocator::{Allocator, SameShapeAllocator}; +use base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::{Dim, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9}; +use base::iter::{MatrixIter, MatrixIterMut}; +use base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut}; +use base::{DefaultAllocator, Matrix, MatrixMN, Scalar}; // FIXME: too bad this won't work allo slice conversions. impl SubsetOf> for MatrixMN @@ -21,9 +21,8 @@ where C2: Dim, N1: Scalar, N2: Scalar + SupersetOf, - DefaultAllocator: Allocator - + Allocator - + SameShapeAllocator, + DefaultAllocator: + Allocator + Allocator + SameShapeAllocator, ShapeConstraint: SameNumberOfRows + SameNumberOfColumns, { #[inline] @@ -75,7 +74,8 @@ impl<'a, N: Scalar, R: Dim, C: Dim, S: Storage> IntoIterator for &'a Ma } impl<'a, N: Scalar, R: Dim, C: Dim, S: StorageMut> IntoIterator - for &'a mut Matrix { + for &'a mut Matrix +{ type Item = &'a mut N; type IntoIter = MatrixIterMut<'a, N, R, C, S>; diff --git a/src/core/coordinates.rs b/src/base/coordinates.rs similarity index 98% rename from src/core/coordinates.rs rename to src/base/coordinates.rs index 2d557847..e092763e 100644 --- a/src/core/coordinates.rs +++ b/src/base/coordinates.rs @@ -7,9 +7,9 @@ use std::mem; use std::ops::{Deref, DerefMut}; -use core::{Matrix, Scalar}; -use core::dimension::{U1, U2, U3, U4, U5, U6}; -use core::storage::{ContiguousStorage, ContiguousStorageMut}; +use base::{Matrix, Scalar}; +use base::dimension::{U1, U2, U3, U4, U5, U6}; +use base::storage::{ContiguousStorage, ContiguousStorageMut}; /* * diff --git a/src/core/default_allocator.rs b/src/base/default_allocator.rs similarity index 90% rename from src/core/default_allocator.rs rename to src/base/default_allocator.rs index 77fe6ee2..d8ac1382 100644 --- a/src/core/default_allocator.rs +++ b/src/base/default_allocator.rs @@ -3,20 +3,21 @@ //! This will use stack-allocated buffers for matrices with dimensions known at compile-time, and //! heap-allocated buffers for matrices with at least one dimension unknown at compile-time. -use std::mem; -use std::ptr; use std::cmp; +use std::mem; use std::ops::Mul; +use std::ptr; -use typenum::Prod; use generic_array::ArrayLength; +use typenum::Prod; -use core::Scalar; -use core::dimension::{Dim, DimName, Dynamic}; -use core::allocator::{Allocator, Reallocator}; -use core::storage::{Storage, StorageMut}; -use core::matrix_array::MatrixArray; -use core::matrix_vec::MatrixVec; +use base::allocator::{Allocator, Reallocator}; +use base::dimension::{Dim, DimName, Dynamic}; +use base::matrix_array::MatrixArray; +#[cfg(any(feature = "std", feature = "alloc"))] +use base::matrix_vec::MatrixVec; +use base::storage::{Storage, StorageMut}; +use base::Scalar; /* * @@ -68,6 +69,7 @@ where // Dynamic - Static // Dynamic - Dynamic +#[cfg(any(feature = "std", feature = "alloc"))] impl Allocator for DefaultAllocator { type Buffer = MatrixVec; @@ -97,6 +99,7 @@ impl Allocator for DefaultAllocator { } // Static - Dynamic +#[cfg(any(feature = "std", feature = "alloc"))] impl Allocator for DefaultAllocator { type Buffer = MatrixVec; @@ -160,6 +163,7 @@ where } // Static × Static -> Dynamic × Any +#[cfg(any(feature = "std", feature = "alloc"))] impl Reallocator for DefaultAllocator where RFrom: DimName, @@ -187,6 +191,7 @@ where } // Static × Static -> Static × Dynamic +#[cfg(any(feature = "std", feature = "alloc"))] impl Reallocator for DefaultAllocator where RFrom: DimName, @@ -214,8 +219,10 @@ where } // All conversion from a dynamic buffer to a dynamic buffer. +#[cfg(any(feature = "std", feature = "alloc"))] impl Reallocator - for DefaultAllocator { + for DefaultAllocator +{ #[inline] unsafe fn reallocate_copy( rto: Dynamic, @@ -227,8 +234,10 @@ impl Reallocator Reallocator - for DefaultAllocator { + for DefaultAllocator +{ #[inline] unsafe fn reallocate_copy( rto: RTo, @@ -240,8 +249,10 @@ impl Reallocator Reallocator - for DefaultAllocator { + for DefaultAllocator +{ #[inline] unsafe fn reallocate_copy( rto: Dynamic, @@ -253,8 +264,10 @@ impl Reallocator Reallocator - for DefaultAllocator { + for DefaultAllocator +{ #[inline] unsafe fn reallocate_copy( rto: RTo, diff --git a/src/core/dimension.rs b/src/base/dimension.rs similarity index 100% rename from src/core/dimension.rs rename to src/base/dimension.rs diff --git a/src/core/edition.rs b/src/base/edition.rs similarity index 97% rename from src/core/edition.rs rename to src/base/edition.rs index b3b549dd..58517614 100644 --- a/src/core/edition.rs +++ b/src/base/edition.rs @@ -2,12 +2,15 @@ use num::{One, Zero}; use std::cmp; use std::ptr; -use core::{DMatrix, DefaultAllocator, Matrix, MatrixMN, RowVector, Scalar, Vector}; -use core::dimension::{Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimName, DimSub, DimSum, Dynamic, - U1}; -use core::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::allocator::{Allocator, Reallocator}; -use core::storage::{Storage, StorageMut}; +use base::allocator::{Allocator, Reallocator}; +use base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::{ + Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimName, DimSub, DimSum, Dynamic, U1, +}; +use base::storage::{Storage, StorageMut}; +#[cfg(any(feature = "std", feature = "alloc"))] +use base::DMatrix; +use base::{DefaultAllocator, Matrix, MatrixMN, RowVector, Scalar, Vector}; impl> Matrix { /// Extracts the upper triangular part of this matrix (including the diagonal). @@ -544,6 +547,7 @@ impl> Matrix { /// /// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more /// rows and/or columns than `self`, then the extra rows or columns are filled with `val`. + #[cfg(any(feature = "std", feature = "alloc"))] pub fn resize(self, new_nrows: usize, new_ncols: usize, val: N) -> DMatrix where DefaultAllocator: Reallocator, @@ -581,7 +585,7 @@ impl> Matrix { if new_nrows.value() == nrows { let res = unsafe { DefaultAllocator::reallocate_copy(new_nrows, new_ncols, data) }; - let mut res = Matrix::from_data(res); + let mut res = Matrix::from_data(res); if new_ncols.value() > ncols { res.columns_range_mut(ncols..).fill(val); } @@ -600,15 +604,11 @@ impl> Matrix { nrows - new_nrows.value(), ); res = Matrix::from_data(DefaultAllocator::reallocate_copy( - new_nrows, - new_ncols, - data, + new_nrows, new_ncols, data, )); } else { res = Matrix::from_data(DefaultAllocator::reallocate_copy( - new_nrows, - new_ncols, - data, + new_nrows, new_ncols, data, )); extend_rows( &mut res.data.as_mut_slice(), diff --git a/src/core/helper.rs b/src/base/helper.rs similarity index 100% rename from src/core/helper.rs rename to src/base/helper.rs diff --git a/src/core/iter.rs b/src/base/iter.rs similarity index 97% rename from src/core/iter.rs rename to src/base/iter.rs index c4cb515b..52d492da 100644 --- a/src/core/iter.rs +++ b/src/base/iter.rs @@ -3,9 +3,9 @@ use std::marker::PhantomData; use std::mem; -use core::Scalar; -use core::dimension::Dim; -use core::storage::{Storage, StorageMut}; +use base::Scalar; +use base::dimension::Dim; +use base::storage::{Storage, StorageMut}; macro_rules! iterator { (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => { diff --git a/src/core/matrix.rs b/src/base/matrix.rs similarity index 99% rename from src/core/matrix.rs rename to src/base/matrix.rs index 949ef043..9be0cc32 100644 --- a/src/core/matrix.rs +++ b/src/base/matrix.rs @@ -16,14 +16,14 @@ use abomonation::Abomonation; use alga::general::{Real, Ring}; -use core::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; -use core::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::dimension::{Dim, DimAdd, DimSum, U1, U2, U3}; -use core::iter::{MatrixIter, MatrixIterMut}; -use core::storage::{ +use base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; +use base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::{Dim, DimAdd, DimSum, U1, U2, U3}; +use base::iter::{MatrixIter, MatrixIterMut}; +use base::storage::{ ContiguousStorage, ContiguousStorageMut, Owned, SameShapeStorage, Storage, StorageMut, }; -use core::{DefaultAllocator, MatrixMN, MatrixN, Scalar, Unit, VectorN}; +use base::{DefaultAllocator, MatrixMN, MatrixN, Scalar, Unit, VectorN}; /// A square matrix. pub type SquareMatrix = Matrix; diff --git a/src/core/matrix_alga.rs b/src/base/matrix_alga.rs similarity index 98% rename from src/core/matrix_alga.rs rename to src/base/matrix_alga.rs index ddf6bb35..2630eaf9 100644 --- a/src/core/matrix_alga.rs +++ b/src/base/matrix_alga.rs @@ -7,10 +7,10 @@ use alga::general::{AbstractGroup, AbstractGroupAbelian, AbstractLoop, AbstractM RingCommutative}; use alga::linear::{FiniteDimInnerSpace, FiniteDimVectorSpace, InnerSpace, NormedSpace, VectorSpace}; -use core::{DefaultAllocator, MatrixMN, MatrixN, Scalar}; -use core::dimension::{Dim, DimName}; -use core::storage::{Storage, StorageMut}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixMN, MatrixN, Scalar}; +use base::dimension::{Dim, DimName}; +use base::storage::{Storage, StorageMut}; +use base::allocator::Allocator; /* * diff --git a/src/core/matrix_array.rs b/src/base/matrix_array.rs similarity index 97% rename from src/core/matrix_array.rs rename to src/base/matrix_array.rs index d2c9e4bc..59bdb9e0 100644 --- a/src/core/matrix_array.rs +++ b/src/base/matrix_array.rs @@ -19,11 +19,11 @@ use abomonation::Abomonation; use typenum::Prod; use generic_array::{ArrayLength, GenericArray}; -use core::Scalar; -use core::dimension::{DimName, U1}; -use core::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; -use core::allocator::Allocator; -use core::default_allocator::DefaultAllocator; +use base::Scalar; +use base::dimension::{DimName, U1}; +use base::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; +use base::allocator::Allocator; +use base::default_allocator::DefaultAllocator; /* * diff --git a/src/core/matrix_slice.rs b/src/base/matrix_slice.rs similarity index 99% rename from src/core/matrix_slice.rs rename to src/base/matrix_slice.rs index 664121c4..871aee41 100644 --- a/src/core/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -2,12 +2,12 @@ use std::marker::PhantomData; use std::ops::{Range, RangeFrom, RangeFull, RangeTo}; use std::slice; -use core::{Matrix, Scalar}; -use core::dimension::{Dim, DimName, Dynamic, U1}; -use core::iter::MatrixIter; -use core::storage::{Owned, Storage, StorageMut}; -use core::allocator::Allocator; -use core::default_allocator::DefaultAllocator; +use base::{Matrix, Scalar}; +use base::dimension::{Dim, DimName, Dynamic, U1}; +use base::iter::MatrixIter; +use base::storage::{Owned, Storage, StorageMut}; +use base::allocator::Allocator; +use base::default_allocator::DefaultAllocator; macro_rules! slice_storage_impl( ($doc: expr; $Storage: ident as $SRef: ty; $T: ident.$get_addr: ident ($Ptr: ty as $Ref: ty)) => { diff --git a/src/core/matrix_vec.rs b/src/base/matrix_vec.rs similarity index 96% rename from src/core/matrix_vec.rs rename to src/base/matrix_vec.rs index 39a3d28e..e9f4d799 100644 --- a/src/core/matrix_vec.rs +++ b/src/base/matrix_vec.rs @@ -1,10 +1,10 @@ use std::ops::Deref; -use core::Scalar; -use core::dimension::{Dim, DimName, Dynamic, U1}; -use core::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; -use core::allocator::Allocator; -use core::default_allocator::DefaultAllocator; +use base::allocator::Allocator; +use base::default_allocator::DefaultAllocator; +use base::dimension::{Dim, DimName, Dynamic, U1}; +use base::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; +use base::Scalar; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; diff --git a/src/core/mod.rs b/src/base/mod.rs similarity index 89% rename from src/core/mod.rs rename to src/base/mod.rs index c1f5c99e..d4a8b680 100644 --- a/src/core/mod.rs +++ b/src/base/mod.rs @@ -1,45 +1,47 @@ //! [Reexported at the root of this crate.] Data structures for vector and matrix computations. -pub mod dimension; -pub mod constraint; pub mod allocator; -pub mod storage; -pub mod coordinates; -mod ops; mod blas; -pub mod iter; +pub mod constraint; +pub mod coordinates; pub mod default_allocator; +pub mod dimension; +pub mod iter; +mod ops; +pub mod storage; -mod scalar; -mod matrix; +mod alias; +mod alias_slice; +mod cg; +mod componentwise; mod construction; mod construction_slice; mod construction_slice_deprecated; -mod properties; -mod alias; -mod alias_slice; -mod matrix_alga; mod conversion; -mod matrix_slice; -mod matrix_array; -mod matrix_vec; -mod cg; -mod unit; -mod componentwise; mod edition; +mod matrix; +mod matrix_alga; +mod matrix_array; +mod matrix_slice; +#[cfg(any(feature = "std", feature = "alloc"))] +mod matrix_vec; +mod properties; +mod scalar; +mod unit; #[doc(hidden)] pub mod helper; -pub use self::scalar::*; pub use self::matrix::*; +pub use self::scalar::*; pub use self::unit::*; -pub use self::dimension::*; pub use self::default_allocator::*; +pub use self::dimension::*; pub use self::alias::*; pub use self::alias_slice::*; -pub use self::matrix_slice::*; pub use self::matrix_array::*; +pub use self::matrix_slice::*; +#[cfg(any(feature = "std", feature = "alloc"))] pub use self::matrix_vec::*; diff --git a/src/core/ops.rs b/src/base/ops.rs similarity index 98% rename from src/core/ops.rs rename to src/base/ops.rs index 21e64b51..2daa77ce 100644 --- a/src/core/ops.rs +++ b/src/base/ops.rs @@ -6,12 +6,12 @@ use num::{One, Signed, Zero}; use alga::general::{ClosedAdd, ClosedDiv, ClosedMul, ClosedNeg, ClosedSub}; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, MatrixSum, Scalar}; -use core::dimension::{Dim, DimMul, DimName, DimProd}; -use core::constraint::{AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, MatrixSum, Scalar}; +use base::dimension::{Dim, DimMul, DimName, DimProd}; +use base::constraint::{AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::storage::{ContiguousStorageMut, Storage, StorageMut}; -use core::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; +use base::storage::{ContiguousStorageMut, Storage, StorageMut}; +use base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; /* * diff --git a/src/core/properties.rs b/src/base/properties.rs similarity index 95% rename from src/core/properties.rs rename to src/base/properties.rs index 5a77e8f3..0033ef69 100644 --- a/src/core/properties.rs +++ b/src/base/properties.rs @@ -4,10 +4,10 @@ use num::{One, Zero}; use alga::general::{ClosedAdd, ClosedMul, Real}; -use core::allocator::Allocator; -use core::dimension::{Dim, DimMin}; -use core::storage::Storage; -use core::{DefaultAllocator, Matrix, Scalar, SquareMatrix}; +use base::allocator::Allocator; +use base::dimension::{Dim, DimMin}; +use base::storage::Storage; +use base::{DefaultAllocator, Matrix, Scalar, SquareMatrix}; impl> Matrix { /// Indicates if this is a square matrix. diff --git a/src/core/scalar.rs b/src/base/scalar.rs similarity index 100% rename from src/core/scalar.rs rename to src/base/scalar.rs diff --git a/src/core/storage.rs b/src/base/storage.rs similarity index 98% rename from src/core/storage.rs rename to src/base/storage.rs index b53c3b38..68936022 100644 --- a/src/core/storage.rs +++ b/src/base/storage.rs @@ -3,10 +3,10 @@ use std::fmt::Debug; use std::mem; -use core::Scalar; -use core::default_allocator::DefaultAllocator; -use core::dimension::{Dim, U1}; -use core::allocator::{Allocator, SameShapeC, SameShapeR}; +use base::Scalar; +use base::default_allocator::DefaultAllocator; +use base::dimension::{Dim, U1}; +use base::allocator::{Allocator, SameShapeC, SameShapeR}; /* * Aliases for allocation results. diff --git a/src/core/unit.rs b/src/base/unit.rs similarity index 100% rename from src/core/unit.rs rename to src/base/unit.rs diff --git a/src/debug/random_orthogonal.rs b/src/debug/random_orthogonal.rs index d993eb94..a699d867 100644 --- a/src/debug/random_orthogonal.rs +++ b/src/debug/random_orthogonal.rs @@ -1,14 +1,14 @@ #[cfg(feature = "arbitrary")] +use base::storage::Owned; +#[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; -#[cfg(feature = "arbitrary")] -use core::storage::Owned; -use num_complex::Complex; use alga::general::Real; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{Dim, Dynamic, U2}; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::dimension::{Dim, Dynamic, U2}; +use base::{DefaultAllocator, MatrixN}; use geometry::UnitComplex; +use num_complex::Complex; /// A random orthogonal matrix. #[derive(Clone, Debug)] diff --git a/src/debug/random_sdp.rs b/src/debug/random_sdp.rs index c1d43417..a49f7b80 100644 --- a/src/debug/random_sdp.rs +++ b/src/debug/random_sdp.rs @@ -1,12 +1,12 @@ #[cfg(feature = "arbitrary")] +use base::storage::Owned; +#[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; -#[cfg(feature = "arbitrary")] -use core::storage::Owned; use alga::general::Real; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{Dim, Dynamic}; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::dimension::{Dim, Dynamic}; +use base::{DefaultAllocator, MatrixN}; use debug::RandomOrthogonal; diff --git a/src/geometry/isometry.rs b/src/geometry/isometry.rs index 86aca469..a8357181 100644 --- a/src/geometry/isometry.rs +++ b/src/geometry/isometry.rs @@ -12,10 +12,10 @@ use abomonation::Abomonation; use alga::general::{Real, SubsetOf}; use alga::linear::Rotation; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::storage::Owned; -use core::{DefaultAllocator, MatrixN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::storage::Owned; +use base::{DefaultAllocator, MatrixN}; use geometry::{Point, Translation}; /// A direct isometry, i.e., a rotation followed by a translation. diff --git a/src/geometry/isometry_alga.rs b/src/geometry/isometry_alga.rs index ae601a4f..58ddc692 100644 --- a/src/geometry/isometry_alga.rs +++ b/src/geometry/isometry_alga.rs @@ -5,9 +5,9 @@ use alga::linear::Isometry as AlgaIsometry; use alga::linear::{AffineTransformation, DirectIsometry, ProjectiveTransformation, Rotation, Similarity, Transformation}; -use core::allocator::Allocator; -use core::dimension::DimName; -use core::{DefaultAllocator, VectorN}; +use base::allocator::Allocator; +use base::dimension::DimName; +use base::{DefaultAllocator, VectorN}; use geometry::{Isometry, Point, Translation}; diff --git a/src/geometry/isometry_alias.rs b/src/geometry/isometry_alias.rs index 89ddd2fd..684db007 100644 --- a/src/geometry/isometry_alias.rs +++ b/src/geometry/isometry_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U2, U3}; +use base::dimension::{U2, U3}; use geometry::{Isometry, Rotation2, Rotation3, UnitComplex, UnitQuaternion}; diff --git a/src/geometry/isometry_construction.rs b/src/geometry/isometry_construction.rs index e6a2b364..704b9e66 100644 --- a/src/geometry/isometry_construction.rs +++ b/src/geometry/isometry_construction.rs @@ -1,7 +1,7 @@ #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; use num::One; use rand::{Rand, Rng}; @@ -9,9 +9,9 @@ use rand::{Rand, Rng}; use alga::general::Real; use alga::linear::Rotation as AlgaRotation; -use core::{DefaultAllocator, Vector2, Vector3}; -use core::dimension::{DimName, U2, U3}; -use core::allocator::Allocator; +use base::{DefaultAllocator, Vector2, Vector3}; +use base::dimension::{DimName, U2, U3}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Point3, Rotation, Rotation2, Rotation3, Translation, UnitComplex, UnitQuaternion}; diff --git a/src/geometry/isometry_conversion.rs b/src/geometry/isometry_conversion.rs index c06dba7b..3a19de5c 100644 --- a/src/geometry/isometry_conversion.rs +++ b/src/geometry/isometry_conversion.rs @@ -1,9 +1,9 @@ use alga::general::{Real, SubsetOf, SupersetOf}; use alga::linear::Rotation; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Transform, Translation}; diff --git a/src/geometry/isometry_ops.rs b/src/geometry/isometry_ops.rs index dced84dc..7145269c 100644 --- a/src/geometry/isometry_ops.rs +++ b/src/geometry/isometry_ops.rs @@ -3,9 +3,9 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; use alga::general::Real; use alga::linear::Rotation as AlgaRotation; -use core::allocator::Allocator; -use core::dimension::{DimName, U1, U3, U4}; -use core::{DefaultAllocator, Unit, VectorN}; +use base::allocator::Allocator; +use base::dimension::{DimName, U1, U3, U4}; +use base::{DefaultAllocator, Unit, VectorN}; use geometry::{Isometry, Point, Rotation, Translation, UnitQuaternion}; diff --git a/src/geometry/orthographic.rs b/src/geometry/orthographic.rs index 19b63a56..ee743b5b 100644 --- a/src/geometry/orthographic.rs +++ b/src/geometry/orthographic.rs @@ -7,10 +7,10 @@ use std::fmt; use alga::general::Real; -use core::{Matrix4, Vector, Vector3}; -use core::dimension::U3; -use core::storage::Storage; -use core::helper; +use base::{Matrix4, Vector, Vector3}; +use base::dimension::U3; +use base::storage::Storage; +use base::helper; use geometry::Point3; diff --git a/src/geometry/perspective.rs b/src/geometry/perspective.rs index 52a574c0..afed785d 100644 --- a/src/geometry/perspective.rs +++ b/src/geometry/perspective.rs @@ -8,10 +8,10 @@ use std::fmt; use alga::general::Real; -use core::{Matrix4, Scalar, Vector, Vector3}; -use core::dimension::U3; -use core::storage::Storage; -use core::helper; +use base::{Matrix4, Scalar, Vector, Vector3}; +use base::dimension::U3; +use base::storage::Storage; +use base::helper; use geometry::Point3; diff --git a/src/geometry/point.rs b/src/geometry/point.rs index 0f167a6d..56f8be45 100644 --- a/src/geometry/point.rs +++ b/src/geometry/point.rs @@ -10,10 +10,10 @@ use serde; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::iter::{MatrixIter, MatrixIterMut}; -use core::{DefaultAllocator, Scalar, VectorN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::iter::{MatrixIter, MatrixIterMut}; +use base::{DefaultAllocator, Scalar, VectorN}; /// A point in a n-dimensional euclidean space. #[repr(C)] diff --git a/src/geometry/point_alga.rs b/src/geometry/point_alga.rs index 8296e32e..e3bb32e0 100644 --- a/src/geometry/point_alga.rs +++ b/src/geometry/point_alga.rs @@ -1,9 +1,9 @@ use alga::general::{Field, JoinSemilattice, Lattice, MeetSemilattice, Real}; use alga::linear::{AffineSpace, EuclideanSpace}; -use core::{DefaultAllocator, Scalar, VectorN}; -use core::dimension::DimName; -use core::allocator::Allocator; +use base::{DefaultAllocator, Scalar, VectorN}; +use base::dimension::DimName; +use base::allocator::Allocator; use geometry::Point; diff --git a/src/geometry/point_alias.rs b/src/geometry/point_alias.rs index c779e57d..42086d04 100644 --- a/src/geometry/point_alias.rs +++ b/src/geometry/point_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U1, U2, U3, U4, U5, U6}; +use base::dimension::{U1, U2, U3, U4, U5, U6}; use geometry::Point; diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 8f80424f..3ffff968 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -5,9 +5,9 @@ use rand::{Rand, Rng}; use num::{Bounded, One, Zero}; use alga::general::ClosedDiv; -use core::{DefaultAllocator, Scalar, VectorN}; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1, U2, U3, U4, U5, U6}; +use base::{DefaultAllocator, Scalar, VectorN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1, U2, U3, U4, U5, U6}; use geometry::Point; diff --git a/src/geometry/point_conversion.rs b/src/geometry/point_conversion.rs index ec1346ec..582f5caf 100644 --- a/src/geometry/point_conversion.rs +++ b/src/geometry/point_conversion.rs @@ -1,9 +1,9 @@ use num::{One, Zero}; use alga::general::{ClosedDiv, SubsetOf, SupersetOf}; -use core::{DefaultAllocator, Matrix, Scalar, VectorN}; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, Matrix, Scalar, VectorN}; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::Point; diff --git a/src/geometry/point_coordinates.rs b/src/geometry/point_coordinates.rs index 3e22a578..b24ec052 100644 --- a/src/geometry/point_coordinates.rs +++ b/src/geometry/point_coordinates.rs @@ -1,10 +1,10 @@ use std::mem; use std::ops::{Deref, DerefMut}; -use core::{DefaultAllocator, Scalar}; -use core::dimension::{U1, U2, U3, U4, U5, U6}; -use core::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB}; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB}; +use base::dimension::{U1, U2, U3, U4, U5, U6}; +use base::{DefaultAllocator, Scalar}; use geometry::Point; diff --git a/src/geometry/point_ops.rs b/src/geometry/point_ops.rs index 602f48ef..1ea8413a 100644 --- a/src/geometry/point_ops.rs +++ b/src/geometry/point_ops.rs @@ -1,14 +1,15 @@ -use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, - SubAssign}; use num::{One, Zero}; +use std::ops::{ + Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign, +}; use alga::general::{ClosedAdd, ClosedDiv, ClosedMul, ClosedNeg, ClosedSub}; -use core::{DefaultAllocator, Matrix, Scalar, Vector, VectorSum}; -use core::dimension::{Dim, DimName, U1}; -use core::constraint::{AreMultipliable, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::storage::Storage; -use core::allocator::{Allocator, SameShapeAllocator}; +use base::allocator::{Allocator, SameShapeAllocator}; +use base::constraint::{AreMultipliable, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::dimension::{Dim, DimName, U1}; +use base::storage::Storage; +use base::{DefaultAllocator, Matrix, Scalar, Vector, VectorSum}; use geometry::Point; diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 72fe0790..41dcde24 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -4,7 +4,7 @@ use std::fmt; use std::hash; #[cfg(feature = "serde-serialize")] -use core::storage::Owned; +use base::storage::Owned; #[cfg(feature = "serde-serialize")] use serde; @@ -13,9 +13,9 @@ use abomonation::Abomonation; use alga::general::Real; -use core::dimension::{U1, U3, U4}; -use core::storage::{CStride, RStride}; -use core::{Matrix3, MatrixN, MatrixSlice, MatrixSliceMut, Unit, Vector3, Vector4}; +use base::dimension::{U1, U3, U4}; +use base::storage::{CStride, RStride}; +use base::{Matrix3, MatrixN, MatrixSlice, MatrixSliceMut, Unit, Vector3, Vector4}; use geometry::Rotation; diff --git a/src/geometry/quaternion_alga.rs b/src/geometry/quaternion_alga.rs index f97b3460..44fa5143 100644 --- a/src/geometry/quaternion_alga.rs +++ b/src/geometry/quaternion_alga.rs @@ -7,7 +7,7 @@ use alga::linear::{AffineTransformation, DirectIsometry, FiniteDimVectorSpace, I NormedSpace, OrthogonalTransformation, ProjectiveTransformation, Rotation, Similarity, Transformation, VectorSpace}; -use core::{Vector3, Vector4}; +use base::{Vector3, Vector4}; use geometry::{Point3, Quaternion, UnitQuaternion}; impl Identity for Quaternion { diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index e790925f..6e403b2d 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -1,18 +1,18 @@ #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; #[cfg(feature = "arbitrary")] -use core::dimension::U4; +use base::dimension::U4; use rand::{Rand, Rng}; use num::{One, Zero}; use alga::general::Real; -use core::{Unit, Vector, Vector3, Vector4}; -use core::storage::Storage; -use core::dimension::U3; +use base::{Unit, Vector, Vector3, Vector4}; +use base::storage::Storage; +use base::dimension::U3; use geometry::{Quaternion, Rotation, UnitQuaternion}; diff --git a/src/geometry/quaternion_conversion.rs b/src/geometry/quaternion_conversion.rs index f2bc18f9..15c6fc63 100644 --- a/src/geometry/quaternion_conversion.rs +++ b/src/geometry/quaternion_conversion.rs @@ -6,8 +6,8 @@ use alga::linear::Rotation as AlgaRotation; #[cfg(feature = "mint")] use mint; -use core::{Matrix4, Vector4}; -use core::dimension::U3; +use base::{Matrix4, Vector4}; +use base::dimension::U3; use geometry::{Isometry, Point3, Quaternion, Rotation, Rotation3, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, UnitQuaternion}; diff --git a/src/geometry/quaternion_coordinates.rs b/src/geometry/quaternion_coordinates.rs index 8f728501..228f74bf 100644 --- a/src/geometry/quaternion_coordinates.rs +++ b/src/geometry/quaternion_coordinates.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use alga::general::Real; -use core::coordinates::IJKW; +use base::coordinates::IJKW; use geometry::Quaternion; diff --git a/src/geometry/quaternion_ops.rs b/src/geometry/quaternion_ops.rs index bf31a690..b6144226 100644 --- a/src/geometry/quaternion_ops.rs +++ b/src/geometry/quaternion_ops.rs @@ -55,10 +55,10 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, use alga::general::Real; -use core::{DefaultAllocator, Unit, Vector, Vector3}; -use core::storage::Storage; -use core::allocator::Allocator; -use core::dimension::{U1, U3, U4}; +use base::{DefaultAllocator, Unit, Vector, Vector3}; +use base::storage::Storage; +use base::allocator::Allocator; +use base::dimension::{U1, U3, U4}; use geometry::{Point3, Quaternion, Rotation, UnitQuaternion}; diff --git a/src/geometry/reflection.rs b/src/geometry/reflection.rs index cb6827eb..f3a3ecdb 100644 --- a/src/geometry/reflection.rs +++ b/src/geometry/reflection.rs @@ -1,7 +1,7 @@ use alga::general::Real; -use core::{DefaultAllocator, Matrix, Scalar, Unit, Vector}; -use core::constraint::{AreMultipliable, DimEq, SameNumberOfRows, ShapeConstraint}; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::constraint::{AreMultipliable, DimEq, SameNumberOfRows, ShapeConstraint}; +use base::{DefaultAllocator, Matrix, Scalar, Unit, Vector}; use dimension::{Dim, DimName, U1}; use storage::{Storage, StorageMut}; diff --git a/src/geometry/rotation.rs b/src/geometry/rotation.rs index 7d0a9416..68a5342f 100644 --- a/src/geometry/rotation.rs +++ b/src/geometry/rotation.rs @@ -7,16 +7,16 @@ use std::hash; use serde; #[cfg(feature = "serde-serialize")] -use core::storage::Owned; +use base::storage::Owned; #[cfg(feature = "abomonation-serialize")] use abomonation::Abomonation; use alga::general::Real; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::{DefaultAllocator, MatrixN, Scalar}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::{DefaultAllocator, MatrixN, Scalar}; /// A rotation matrix. #[repr(C)] diff --git a/src/geometry/rotation_alga.rs b/src/geometry/rotation_alga.rs index db16530e..17e92bbf 100644 --- a/src/geometry/rotation_alga.rs +++ b/src/geometry/rotation_alga.rs @@ -4,9 +4,9 @@ use alga::general::{AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, use alga::linear::{self, AffineTransformation, DirectIsometry, Isometry, OrthogonalTransformation, ProjectiveTransformation, Similarity, Transformation}; -use core::{DefaultAllocator, VectorN}; -use core::dimension::DimName; -use core::allocator::Allocator; +use base::{DefaultAllocator, VectorN}; +use base::dimension::DimName; +use base::allocator::Allocator; use geometry::{Point, Rotation}; diff --git a/src/geometry/rotation_alias.rs b/src/geometry/rotation_alias.rs index 7e8edbaa..a11bba99 100644 --- a/src/geometry/rotation_alias.rs +++ b/src/geometry/rotation_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U2, U3}; +use base::dimension::{U2, U3}; use geometry::Rotation; diff --git a/src/geometry/rotation_construction.rs b/src/geometry/rotation_construction.rs index f8d7f35d..14fa28b3 100644 --- a/src/geometry/rotation_construction.rs +++ b/src/geometry/rotation_construction.rs @@ -2,9 +2,9 @@ use num::{One, Zero}; use alga::general::{ClosedAdd, ClosedMul}; -use core::{DefaultAllocator, MatrixN, Scalar}; -use core::dimension::DimName; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN, Scalar}; +use base::dimension::DimName; +use base::allocator::Allocator; use geometry::Rotation; diff --git a/src/geometry/rotation_conversion.rs b/src/geometry/rotation_conversion.rs index 1f5f0b0d..5e98fbb8 100644 --- a/src/geometry/rotation_conversion.rs +++ b/src/geometry/rotation_conversion.rs @@ -6,9 +6,9 @@ use alga::linear::Rotation as AlgaRotation; #[cfg(feature = "mint")] use mint; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Rotation, Rotation2, Rotation3, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, UnitComplex, UnitQuaternion}; diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index ea52e1cf..11b319e9 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -21,11 +21,11 @@ use num::{One, Zero}; use alga::general::{ClosedAdd, ClosedMul}; -use core::{DefaultAllocator, Matrix, MatrixMN, Scalar}; -use core::dimension::{Dim, DimName, U1}; -use core::constraint::{AreMultipliable, ShapeConstraint}; -use core::storage::Storage; -use core::allocator::Allocator; +use base::{DefaultAllocator, Matrix, MatrixMN, Scalar}; +use base::dimension::{Dim, DimName, U1}; +use base::constraint::{AreMultipliable, ShapeConstraint}; +use base::storage::Storage; +use base::allocator::Allocator; use geometry::{Point, Rotation}; diff --git a/src/geometry/rotation_specialization.rs b/src/geometry/rotation_specialization.rs index d6635f1b..9b6deb59 100644 --- a/src/geometry/rotation_specialization.rs +++ b/src/geometry/rotation_specialization.rs @@ -1,16 +1,16 @@ #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; use std::ops::Neg; use num::Zero; use rand::{Rand, Rng}; use alga::general::Real; -use core::{MatrixN, Unit, Vector, Vector1, Vector3, VectorN}; -use core::dimension::{U1, U2, U3}; -use core::storage::Storage; +use base::{MatrixN, Unit, Vector, Vector1, Vector3, VectorN}; +use base::dimension::{U1, U2, U3}; +use base::storage::Storage; use geometry::{Rotation2, Rotation3, UnitComplex}; diff --git a/src/geometry/similarity.rs b/src/geometry/similarity.rs index ef8fd95d..1a9a0d30 100644 --- a/src/geometry/similarity.rs +++ b/src/geometry/similarity.rs @@ -11,10 +11,10 @@ use abomonation::Abomonation; use alga::general::{Real, SubsetOf}; use alga::linear::Rotation; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::storage::Owned; -use core::{DefaultAllocator, MatrixN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::storage::Owned; +use base::{DefaultAllocator, MatrixN}; use geometry::{Isometry, Point, Translation}; /// A similarity, i.e., an uniform scaling, followed by a rotation, followed by a translation. diff --git a/src/geometry/similarity_alga.rs b/src/geometry/similarity_alga.rs index 0f3ebee4..8ad0e674 100644 --- a/src/geometry/similarity_alga.rs +++ b/src/geometry/similarity_alga.rs @@ -3,9 +3,9 @@ use alga::general::{AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, use alga::linear::{AffineTransformation, ProjectiveTransformation, Rotation, Transformation}; use alga::linear::Similarity as AlgaSimilarity; -use core::{DefaultAllocator, VectorN}; -use core::dimension::DimName; -use core::allocator::Allocator; +use base::{DefaultAllocator, VectorN}; +use base::dimension::DimName; +use base::allocator::Allocator; use geometry::{Point, Similarity, Translation}; diff --git a/src/geometry/similarity_alias.rs b/src/geometry/similarity_alias.rs index d1eec6b4..9d3a2f45 100644 --- a/src/geometry/similarity_alias.rs +++ b/src/geometry/similarity_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U2, U3}; +use base::dimension::{U2, U3}; use geometry::{Rotation2, Rotation3, Similarity, UnitComplex, UnitQuaternion}; diff --git a/src/geometry/similarity_construction.rs b/src/geometry/similarity_construction.rs index 0b6f2372..30004eb2 100644 --- a/src/geometry/similarity_construction.rs +++ b/src/geometry/similarity_construction.rs @@ -1,7 +1,7 @@ #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; use num::One; use rand::{Rand, Rng}; @@ -9,9 +9,9 @@ use rand::{Rand, Rng}; use alga::general::Real; use alga::linear::Rotation as AlgaRotation; -use core::{DefaultAllocator, Vector2, Vector3}; -use core::dimension::{DimName, U2, U3}; -use core::allocator::Allocator; +use base::{DefaultAllocator, Vector2, Vector3}; +use base::dimension::{DimName, U2, U3}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Point3, Rotation2, Rotation3, Similarity, Translation, UnitComplex, UnitQuaternion}; diff --git a/src/geometry/similarity_conversion.rs b/src/geometry/similarity_conversion.rs index 702036b3..2c7a1eac 100644 --- a/src/geometry/similarity_conversion.rs +++ b/src/geometry/similarity_conversion.rs @@ -1,9 +1,9 @@ use alga::general::{Real, SubsetOf, SupersetOf}; use alga::linear::Rotation; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Transform, Translation}; diff --git a/src/geometry/similarity_ops.rs b/src/geometry/similarity_ops.rs index f5c88487..171a351a 100644 --- a/src/geometry/similarity_ops.rs +++ b/src/geometry/similarity_ops.rs @@ -3,9 +3,9 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; use alga::general::Real; use alga::linear::Rotation as AlgaRotation; -use core::{DefaultAllocator, VectorN}; -use core::dimension::{DimName, U1, U3, U4}; -use core::allocator::Allocator; +use base::{DefaultAllocator, VectorN}; +use base::dimension::{DimName, U1, U3, U4}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Rotation, Similarity, Translation, UnitQuaternion}; diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 282df5e3..23ca5b29 100644 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -7,10 +7,10 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::storage::Owned; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::storage::Owned; +use base::allocator::Allocator; /// Trait implemented by phantom types identifying the projective transformation type. /// @@ -350,7 +350,7 @@ where #[cfg(test)] mod tests { use super::*; - use core::Matrix4; + use base::Matrix4; #[test] fn checks_homogeneous_invariants_of_square_identity_matrix() { diff --git a/src/geometry/transform_alga.rs b/src/geometry/transform_alga.rs index 34003e90..d01e61bf 100644 --- a/src/geometry/transform_alga.rs +++ b/src/geometry/transform_alga.rs @@ -2,9 +2,9 @@ use alga::general::{AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, AbstractQuasigroup, AbstractSemigroup, Identity, Inverse, Multiplicative, Real}; use alga::linear::{ProjectiveTransformation, Transformation}; -use core::{DefaultAllocator, VectorN}; -use core::dimension::{DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, VectorN}; +use base::dimension::{DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{Point, SubTCategoryOf, TCategory, TProjective, Transform}; diff --git a/src/geometry/transform_alias.rs b/src/geometry/transform_alias.rs index 01f2c6b7..999b5224 100644 --- a/src/geometry/transform_alias.rs +++ b/src/geometry/transform_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U2, U3}; +use base::dimension::{U2, U3}; use geometry::{TAffine, TGeneral, TProjective, Transform}; diff --git a/src/geometry/transform_construction.rs b/src/geometry/transform_construction.rs index 51f10d42..6d5bb135 100644 --- a/src/geometry/transform_construction.rs +++ b/src/geometry/transform_construction.rs @@ -2,9 +2,9 @@ use num::One; use alga::general::Real; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{TCategory, Transform}; diff --git a/src/geometry/transform_conversion.rs b/src/geometry/transform_conversion.rs index c50dc56a..1dd02681 100644 --- a/src/geometry/transform_conversion.rs +++ b/src/geometry/transform_conversion.rs @@ -1,8 +1,8 @@ use alga::general::{Real, SubsetOf}; -use core::{DefaultAllocator, MatrixN}; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN}; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{SuperTCategoryOf, TCategory, Transform}; diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index 7479f5ed..41bf80f4 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -3,9 +3,9 @@ use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign}; use alga::general::{ClosedAdd, ClosedMul, Real, SubsetOf}; -use core::{DefaultAllocator, MatrixN, Scalar, VectorN}; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1, U3, U4}; +use base::{DefaultAllocator, MatrixN, Scalar, VectorN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1, U3, U4}; use geometry::{Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory, TCategoryMul, TGeneral, TProjective, Transform, Translation, diff --git a/src/geometry/translation.rs b/src/geometry/translation.rs index e19acbdb..af7fceba 100644 --- a/src/geometry/translation.rs +++ b/src/geometry/translation.rs @@ -11,10 +11,10 @@ use abomonation::Abomonation; use alga::general::{ClosedNeg, Real}; -use core::allocator::Allocator; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::storage::Owned; -use core::{DefaultAllocator, MatrixN, Scalar, VectorN}; +use base::allocator::Allocator; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::storage::Owned; +use base::{DefaultAllocator, MatrixN, Scalar, VectorN}; /// A translation. #[repr(C)] diff --git a/src/geometry/translation_alga.rs b/src/geometry/translation_alga.rs index 0eaabc22..296d6e17 100644 --- a/src/geometry/translation_alga.rs +++ b/src/geometry/translation_alga.rs @@ -5,9 +5,9 @@ use alga::linear::{AffineTransformation, DirectIsometry, Isometry, ProjectiveTra Similarity, Transformation}; use alga::linear::Translation as AlgaTranslation; -use core::{DefaultAllocator, VectorN}; -use core::dimension::DimName; -use core::allocator::Allocator; +use base::{DefaultAllocator, VectorN}; +use base::dimension::DimName; +use base::allocator::Allocator; use geometry::{Point, Translation}; diff --git a/src/geometry/translation_alias.rs b/src/geometry/translation_alias.rs index c6dfcf4b..331c1405 100644 --- a/src/geometry/translation_alias.rs +++ b/src/geometry/translation_alias.rs @@ -1,4 +1,4 @@ -use core::dimension::{U2, U3}; +use base::dimension::{U2, U3}; use geometry::Translation; diff --git a/src/geometry/translation_construction.rs b/src/geometry/translation_construction.rs index 5b8a6ffa..d867637c 100644 --- a/src/geometry/translation_construction.rs +++ b/src/geometry/translation_construction.rs @@ -1,16 +1,16 @@ #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; #[cfg(feature = "arbitrary")] -use core::storage::Owned; +use base::storage::Owned; use num::{One, Zero}; use rand::{Rand, Rng}; use alga::general::ClosedAdd; -use core::{DefaultAllocator, Scalar, VectorN}; -use core::dimension::{DimName, U1, U2, U3, U4, U5, U6}; -use core::allocator::Allocator; +use base::{DefaultAllocator, Scalar, VectorN}; +use base::dimension::{DimName, U1, U2, U3, U4, U5, U6}; +use base::allocator::Allocator; use geometry::Translation; diff --git a/src/geometry/translation_conversion.rs b/src/geometry/translation_conversion.rs index a05fbec8..c75a401a 100644 --- a/src/geometry/translation_conversion.rs +++ b/src/geometry/translation_conversion.rs @@ -1,9 +1,9 @@ use alga::general::{Real, SubsetOf, SupersetOf}; use alga::linear::Rotation; -use core::{DefaultAllocator, MatrixN, Scalar, VectorN}; -use core::dimension::{DimName, DimNameAdd, DimNameSum, U1}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN, Scalar, VectorN}; +use base::dimension::{DimName, DimNameAdd, DimNameSum, U1}; +use base::allocator::Allocator; use geometry::{Isometry, Point, Similarity, SuperTCategoryOf, TAffine, Transform, Translation}; diff --git a/src/geometry/translation_ops.rs b/src/geometry/translation_ops.rs index a04db87a..8b0f49f0 100644 --- a/src/geometry/translation_ops.rs +++ b/src/geometry/translation_ops.rs @@ -2,10 +2,10 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; use alga::general::{ClosedAdd, ClosedSub}; -use core::{DefaultAllocator, Scalar}; -use core::dimension::{DimName, U1}; -use core::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use core::allocator::{Allocator, SameShapeAllocator}; +use base::{DefaultAllocator, Scalar}; +use base::dimension::{DimName, U1}; +use base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; +use base::allocator::{Allocator, SameShapeAllocator}; use geometry::{Point, Translation}; diff --git a/src/geometry/unit_complex.rs b/src/geometry/unit_complex.rs index 2ffe369b..d58e7b82 100644 --- a/src/geometry/unit_complex.rs +++ b/src/geometry/unit_complex.rs @@ -3,7 +3,7 @@ use num_complex::Complex; use std::fmt; use alga::general::Real; -use core::{Matrix2, Matrix3, Unit, Vector1}; +use base::{Matrix2, Matrix3, Unit, Vector1}; use geometry::Rotation2; /// A complex number with a norm equal to 1. diff --git a/src/geometry/unit_complex_alga.rs b/src/geometry/unit_complex_alga.rs index d9ee19fb..bfc99202 100644 --- a/src/geometry/unit_complex_alga.rs +++ b/src/geometry/unit_complex_alga.rs @@ -4,9 +4,9 @@ use alga::general::{AbstractGroup, AbstractLoop, AbstractMagma, AbstractMonoid, use alga::linear::{AffineTransformation, DirectIsometry, Isometry, OrthogonalTransformation, ProjectiveTransformation, Rotation, Similarity, Transformation}; -use core::{DefaultAllocator, Vector2}; -use core::allocator::Allocator; -use core::dimension::U2; +use base::{DefaultAllocator, Vector2}; +use base::allocator::Allocator; +use base::dimension::U2; use geometry::{Point2, UnitComplex}; /* diff --git a/src/geometry/unit_complex_construction.rs b/src/geometry/unit_complex_construction.rs index 4ea268f5..f7f96311 100644 --- a/src/geometry/unit_complex_construction.rs +++ b/src/geometry/unit_complex_construction.rs @@ -6,10 +6,10 @@ use num_complex::Complex; use rand::{Rand, Rng}; use alga::general::Real; -use core::{DefaultAllocator, Unit, Vector}; -use core::dimension::{U1, U2}; -use core::storage::Storage; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::dimension::{U1, U2}; +use base::storage::Storage; +use base::{DefaultAllocator, Unit, Vector}; use geometry::{Rotation, UnitComplex}; impl UnitComplex { diff --git a/src/geometry/unit_complex_conversion.rs b/src/geometry/unit_complex_conversion.rs index 2da53bc5..ee0ed5d8 100644 --- a/src/geometry/unit_complex_conversion.rs +++ b/src/geometry/unit_complex_conversion.rs @@ -4,10 +4,12 @@ use num_complex::Complex; use alga::general::{Real, SubsetOf, SupersetOf}; use alga::linear::Rotation as AlgaRotation; -use core::Matrix3; -use core::dimension::U2; -use geometry::{Isometry, Point2, Rotation2, Similarity, SuperTCategoryOf, TAffine, Transform, - Translation, UnitComplex}; +use base::dimension::U2; +use base::Matrix3; +use geometry::{ + Isometry, Point2, Rotation2, Similarity, SuperTCategoryOf, TAffine, Transform, Translation, + UnitComplex, +}; /* * This file provides the following conversions: diff --git a/src/geometry/unit_complex_ops.rs b/src/geometry/unit_complex_ops.rs index 864cb5b8..3d737f75 100644 --- a/src/geometry/unit_complex_ops.rs +++ b/src/geometry/unit_complex_ops.rs @@ -1,11 +1,11 @@ use std::ops::{Div, DivAssign, Mul, MulAssign}; use alga::general::Real; -use core::allocator::Allocator; -use core::constraint::{DimEq, ShapeConstraint}; -use core::dimension::{Dim, U1, U2}; -use core::storage::{Storage, StorageMut}; -use core::{DefaultAllocator, Matrix, Unit, Vector, Vector2}; +use base::allocator::Allocator; +use base::constraint::{DimEq, ShapeConstraint}; +use base::dimension::{Dim, U1, U2}; +use base::storage::{Storage, StorageMut}; +use base::{DefaultAllocator, Matrix, Unit, Vector, Vector2}; use geometry::{Isometry, Point2, Rotation, Similarity, Translation, UnitComplex}; /* diff --git a/src/lib.rs b/src/lib.rs index b2768569..1fc58a1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,6 +84,7 @@ an optimized set of tools for computer graphics and physics. Those features incl #![deny(missing_docs)] #![warn(incoherent_fundamental_impls)] #![doc(html_root_url = "http://nalgebra.org/rustdoc")] +#![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "arbitrary")] extern crate quickcheck; @@ -103,6 +104,7 @@ extern crate mint; #[macro_use] extern crate approx; extern crate generic_array; +#[cfg(feature = "std")] extern crate matrixmultiply; extern crate num_complex; extern crate num_traits as num; @@ -111,20 +113,30 @@ extern crate typenum; extern crate alga; -pub mod core; +#[cfg(not(feature = "std"))] +extern crate core as std; + +pub mod base; #[cfg(feature = "debug")] pub mod debug; pub mod geometry; pub mod linalg; -pub use core::*; +#[cfg(feature = "std")] +#[deprecated( + note = "The 'core' module is being renamed 'based' to avoid conflicts with the 'core' crate." +)] +pub use base as core; +pub use base::*; pub use geometry::*; pub use linalg::*; use std::cmp::{self, Ordering, PartialOrd}; -use alga::general::{Additive, AdditiveGroup, Identity, Inverse, JoinSemilattice, Lattice, - MeetSemilattice, Multiplicative, SupersetOf}; +use alga::general::{ + Additive, AdditiveGroup, Identity, Inverse, JoinSemilattice, Lattice, MeetSemilattice, + Multiplicative, SupersetOf, +}; use alga::linear::SquareMatrix as AlgaSquareMatrix; use alga::linear::{EuclideanSpace, FiniteDimVectorSpace, InnerSpace, NormedSpace}; use num::Signed; diff --git a/src/linalg/balancing.rs b/src/linalg/balancing.rs index 832c8d32..54c325cf 100644 --- a/src/linalg/balancing.rs +++ b/src/linalg/balancing.rs @@ -1,12 +1,12 @@ //! Functions for balancing a matrix. -use std::ops::{DivAssign, MulAssign}; use alga::general::Real; +use std::ops::{DivAssign, MulAssign}; -use core::{DefaultAllocator, MatrixN, VectorN}; -use core::dimension::{Dim, U1}; -use core::storage::Storage; use allocator::Allocator; +use base::dimension::{Dim, U1}; +use base::storage::Storage; +use base::{DefaultAllocator, MatrixN, VectorN}; /// Applies in-place a modified Parlett and Reinsch matrix balancing with 2-norm to the matrix `m` and returns /// the corresponding diagonal transformation. diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index 895e7ef6..06286078 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -2,33 +2,45 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Unit, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Unit, VectorN}; +use constraint::{DimEq, ShapeConstraint}; use dimension::{Dim, DimDiff, DimMin, DimMinimum, DimSub, Dynamic, U1}; use storage::Storage; -use allocator::Allocator; -use constraint::{DimEq, ShapeConstraint}; -use linalg::householder; use geometry::Reflection; +use linalg::householder; /// The bidiagonalization of a general matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DimMinimum: DimSub, +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DimMinimum: DimSub, DefaultAllocator: Allocator + Allocator> + Allocator, U1>>, MatrixMN: serde::Serialize, VectorN>: serde::Serialize, - VectorN, U1>>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DimMinimum: DimSub, + VectorN, U1>>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DimMinimum: DimSub, DefaultAllocator: Allocator + Allocator> + Allocator, U1>>, MatrixMN: serde::Deserialize<'de>, VectorN>: serde::Deserialize<'de>, - VectorN, U1>>: serde::Deserialize<'de>")))] + VectorN, U1>>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct Bidiagonal, C: Dim> where diff --git a/src/linalg/cholesky.rs b/src/linalg/cholesky.rs index a07d40e0..a77e6b2e 100644 --- a/src/linalg/cholesky.rs +++ b/src/linalg/cholesky.rs @@ -3,20 +3,32 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, SquareMatrix}; -use constraint::{SameNumberOfRows, ShapeConstraint}; -use storage::{Storage, StorageMut}; use allocator::Allocator; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, SquareMatrix}; +use constraint::{SameNumberOfRows, ShapeConstraint}; use dimension::{Dim, DimSub, Dynamic}; +use storage::{Storage, StorageMut}; /// The Cholesky decomposion of a symmetric-definite-positive matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator, - MatrixN: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator, - MatrixN: serde::Deserialize<'de>")))] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator, + MatrixN: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator, + MatrixN: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct Cholesky where diff --git a/src/linalg/determinant.rs b/src/linalg/determinant.rs index 5541999a..56a21c38 100644 --- a/src/linalg/determinant.rs +++ b/src/linalg/determinant.rs @@ -1,9 +1,9 @@ use alga::general::Real; -use core::{DefaultAllocator, SquareMatrix}; -use core::dimension::DimMin; -use core::storage::Storage; -use core::allocator::Allocator; +use base::allocator::Allocator; +use base::dimension::DimMin; +use base::storage::Storage; +use base::{DefaultAllocator, SquareMatrix}; use linalg::LU; diff --git a/src/linalg/eigen.rs b/src/linalg/eigen.rs index 26c2b312..e45d5948 100644 --- a/src/linalg/eigen.rs +++ b/src/linalg/eigen.rs @@ -1,64 +1,79 @@ #[cfg(feature = "serde-serialize")] use serde; -use std::fmt::Display; -use std::cmp; -use num_complex::Complex; use alga::general::Real; +use num_complex::Complex; +use std::cmp; +use std::fmt::Display; use std::ops::MulAssign; -use core::{DefaultAllocator, SquareMatrix, VectorN, MatrixN, Hessenberg, Unit, Vector2, Vector3}; -use core::dimension::{Dim, DimSub, DimDiff, Dynamic, U1, U2, U3}; -use core::storage::Storage; -use constraint::{ShapeConstraint, DimEq}; use allocator::Allocator; +use base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3}; +use base::storage::Storage; +use base::{DefaultAllocator, Hessenberg, MatrixN, SquareMatrix, Unit, Vector2, Vector3, VectorN}; +use constraint::{DimEq, ShapeConstraint}; +use geometry::{Reflection, UnitComplex}; use linalg::householder; use linalg::RealSchur; -use geometry::{Reflection, UnitComplex}; - /// Eigendecomposition of a matrix with real eigenvalues. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = - "DefaultAllocator: Allocator, +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator, VectorN: serde::Serialize, - MatrixN: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = - "DefaultAllocator: Allocator, + MatrixN: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator, VectorN: serde::Serialize, - MatrixN: serde::Deserialize<'de>")))] + MatrixN: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct RealEigen - where DefaultAllocator: Allocator + - Allocator { +where + DefaultAllocator: Allocator + Allocator, +{ pub eigenvectors: MatrixN, - pub eigenvalues: VectorN + pub eigenvalues: VectorN, } - impl Copy for RealEigen - where DefaultAllocator: Allocator + - Allocator, - MatrixN: Copy, - VectorN: Copy { } +where + DefaultAllocator: Allocator + Allocator, + MatrixN: Copy, + VectorN: Copy, +{ +} impl RealEigen - where D: DimSub, // For Hessenberg. - ShapeConstraint: DimEq>, // For Hessenberg. - DefaultAllocator: Allocator> + // For Hessenberg. - Allocator> + // For Hessenberg. - Allocator + - Allocator, - // XXX: for debug - DefaultAllocator: Allocator, - MatrixN: Display { - +where + D: DimSub, // For Hessenberg. + ShapeConstraint: DimEq>, // For Hessenberg. + DefaultAllocator: Allocator> + + Allocator> + + Allocator + + Allocator, + // XXX: for debug + DefaultAllocator: Allocator, + MatrixN: Display, +{ /// Computes the eigendecomposition of a diagonalizable matrix with real eigenvalues. pub fn new(m: MatrixN) -> Option> { - assert!(m.is_square(), "Unable to compute the eigendecomposition of a non-square matrix."); + assert!( + m.is_square(), + "Unable to compute the eigendecomposition of a non-square matrix." + ); let dim = m.nrows(); let (mut eigenvectors, mut eigenvalues) = RealSchur::new(m, 0).unwrap().unpack(); @@ -66,14 +81,14 @@ impl RealEigen println!("Schur eigenvalues: {}", eigenvalues); // Check that the eigenvalues are all real. - for i in 0 .. dim - 1 { + for i in 0..dim - 1 { if !eigenvalues[(i + 1, i)].is_zero() { return None; } } - for j in 1 .. dim { - for i in 0 .. j { + for j in 1..dim { + for i in 0..j { let diff = eigenvalues[(i, i)] - eigenvalues[(j, j)]; if diff.is_zero() && !eigenvalues[(i, j)].is_zero() { @@ -82,24 +97,24 @@ impl RealEigen let z = -eigenvalues[(i, j)] / diff; - for k in j + 1 .. dim { + for k in j + 1..dim { eigenvalues[(i, k)] -= z * eigenvalues[(j, k)]; } - for k in 0 .. dim { + for k in 0..dim { eigenvectors[(k, j)] += z * eigenvectors[(k, i)]; } } } // Normalize the eigenvector basis. - for i in 0 .. dim { + for i in 0..dim { let _ = eigenvectors.column_mut(i).normalize_mut(); } Some(RealEigen { eigenvectors: eigenvectors, - eigenvalues: eigenvalues.diagonal() + eigenvalues: eigenvalues.diagonal(), }) } } diff --git a/src/linalg/full_piv_lu.rs b/src/linalg/full_piv_lu.rs index 8c9f3944..366c27bd 100644 --- a/src/linalg/full_piv_lu.rs +++ b/src/linalg/full_piv_lu.rs @@ -2,27 +2,39 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN}; +use allocator::Allocator; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN}; +use constraint::{SameNumberOfRows, ShapeConstraint}; use dimension::{Dim, DimMin, DimMinimum}; use storage::{Storage, StorageMut}; -use allocator::Allocator; -use constraint::{SameNumberOfRows, ShapeConstraint}; use linalg::lu; use linalg::PermutationSequence; /// LU decomposition with full row and column pivoting. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, MatrixMN: serde::Serialize, - PermutationSequence>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + PermutationSequence>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, MatrixMN: serde::Deserialize<'de>, - PermutationSequence>: serde::Deserialize<'de>")))] + PermutationSequence>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct FullPivLU, C: Dim> where diff --git a/src/linalg/givens.rs b/src/linalg/givens.rs index 80b47790..9175bff9 100644 --- a/src/linalg/givens.rs +++ b/src/linalg/givens.rs @@ -3,9 +3,9 @@ use alga::general::Real; use num_complex::Complex; -use core::Vector; -use core::storage::Storage; -use core::dimension::U2; +use base::dimension::U2; +use base::storage::Storage; +use base::Vector; use geometry::UnitComplex; diff --git a/src/linalg/hessenberg.rs b/src/linalg/hessenberg.rs index bc79f1ad..405adb5b 100644 --- a/src/linalg/hessenberg.rs +++ b/src/linalg/hessenberg.rs @@ -2,26 +2,38 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN}; +use constraint::{DimEq, ShapeConstraint}; use dimension::{DimDiff, DimSub, Dynamic, U1}; use storage::Storage; -use allocator::Allocator; -use constraint::{DimEq, ShapeConstraint}; use linalg::householder; /// Hessenberg decomposition of a general matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator>, MatrixN: serde::Serialize, - VectorN>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + VectorN>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator>, MatrixN: serde::Deserialize<'de>, - VectorN>: serde::Deserialize<'de>")))] + VectorN>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct Hessenberg> where diff --git a/src/linalg/householder.rs b/src/linalg/householder.rs index c7cad195..f3a1f2bf 100644 --- a/src/linalg/householder.rs +++ b/src/linalg/householder.rs @@ -1,10 +1,10 @@ //! Construction of householder elementary reflections. use alga::general::Real; -use core::{DefaultAllocator, MatrixMN, MatrixN, Unit, Vector, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, MatrixMN, MatrixN, Unit, Vector, VectorN}; use dimension::Dim; use storage::{Storage, StorageMut}; -use allocator::Allocator; use geometry::Reflection; diff --git a/src/linalg/inverse.rs b/src/linalg/inverse.rs index f62626ce..7b07698c 100644 --- a/src/linalg/inverse.rs +++ b/src/linalg/inverse.rs @@ -1,9 +1,9 @@ use alga::general::Real; -use core::{DefaultAllocator, MatrixN, SquareMatrix}; -use core::dimension::Dim; -use core::storage::{Storage, StorageMut}; -use core::allocator::Allocator; +use base::{DefaultAllocator, MatrixN, SquareMatrix}; +use base::dimension::Dim; +use base::storage::{Storage, StorageMut}; +use base::allocator::Allocator; use linalg::lu; diff --git a/src/linalg/lu.rs b/src/linalg/lu.rs index f5d32574..0925b82b 100644 --- a/src/linalg/lu.rs +++ b/src/linalg/lu.rs @@ -1,28 +1,40 @@ #[cfg(feature = "serde-serialize")] use serde; -use std::mem; use alga::general::{Field, Real}; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar}; -use dimension::{Dim, DimMin, DimMinimum}; -use storage::{Storage, StorageMut}; use allocator::{Allocator, Reallocator}; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Scalar}; use constraint::{SameNumberOfRows, ShapeConstraint}; +use dimension::{Dim, DimMin, DimMinimum}; +use std::mem; +use storage::{Storage, StorageMut}; use linalg::PermutationSequence; /// LU decomposition with partial (row) pivoting. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, MatrixMN: serde::Serialize, - PermutationSequence>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + PermutationSequence>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator<(usize, usize), DimMinimum>, MatrixMN: serde::Deserialize<'de>, - PermutationSequence>: serde::Deserialize<'de>")))] + PermutationSequence>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct LU, C: Dim> where diff --git a/src/linalg/permutation_sequence.rs b/src/linalg/permutation_sequence.rs index 6badb823..34f451c8 100644 --- a/src/linalg/permutation_sequence.rs +++ b/src/linalg/permutation_sequence.rs @@ -1,22 +1,34 @@ #[cfg(feature = "serde-serialize")] use serde; -use num::One; use alga::general::ClosedNeg; +use num::One; -use core::{DefaultAllocator, Matrix, Scalar, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, Matrix, Scalar, VectorN}; use dimension::{Dim, DimName, Dynamic, U1}; use storage::StorageMut; -use allocator::Allocator; /// A sequence of row or column permutations. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator<(usize, usize), D>, - VectorN<(usize, usize), D>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator<(usize, usize), D>, - VectorN<(usize, usize), D>: serde::Deserialize<'de>")))] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator<(usize, usize), D>, + VectorN<(usize, usize), D>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator<(usize, usize), D>, + VectorN<(usize, usize), D>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct PermutationSequence where diff --git a/src/linalg/qr.rs b/src/linalg/qr.rs index 3cfb0da2..c7892a9b 100644 --- a/src/linalg/qr.rs +++ b/src/linalg/qr.rs @@ -2,7 +2,7 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Unit, VectorN}; +use base::{DefaultAllocator, Matrix, MatrixMN, MatrixN, Unit, VectorN}; use dimension::{Dim, DimMin, DimMinimum, U1}; use storage::{Storage, StorageMut}; use allocator::{Allocator, Reallocator}; diff --git a/src/linalg/schur.rs b/src/linalg/schur.rs index cbda8dcc..ec2028c7 100644 --- a/src/linalg/schur.rs +++ b/src/linalg/schur.rs @@ -1,28 +1,40 @@ #[cfg(feature = "serde-serialize")] use serde; -use std::cmp; -use num_complex::Complex; use alga::general::Real; +use num_complex::Complex; +use std::cmp; -use core::{DefaultAllocator, MatrixN, SquareMatrix, Unit, Vector2, Vector3, VectorN}; -use core::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3}; -use core::storage::Storage; -use constraint::{DimEq, ShapeConstraint}; use allocator::Allocator; +use base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3}; +use base::storage::Storage; +use base::{DefaultAllocator, MatrixN, SquareMatrix, Unit, Vector2, Vector3, VectorN}; +use constraint::{DimEq, ShapeConstraint}; +use geometry::{Reflection, UnitComplex}; use linalg::householder; use linalg::Hessenberg; -use geometry::{Reflection, UnitComplex}; /// Real Schur decomposition of a square matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator, - MatrixN: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator, - MatrixN: serde::Deserialize<'de>")))] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator, + MatrixN: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator, + MatrixN: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct RealSchur where diff --git a/src/linalg/solve.rs b/src/linalg/solve.rs index ebc40c2f..b770295e 100644 --- a/src/linalg/solve.rs +++ b/src/linalg/solve.rs @@ -1,10 +1,10 @@ use alga::general::Real; -use core::{DefaultAllocator, Matrix, MatrixMN, SquareMatrix, Vector}; -use core::dimension::{Dim, U1}; -use core::storage::{Storage, StorageMut}; -use core::allocator::Allocator; -use core::constraint::{SameNumberOfRows, ShapeConstraint}; +use base::allocator::Allocator; +use base::constraint::{SameNumberOfRows, ShapeConstraint}; +use base::dimension::{Dim, U1}; +use base::storage::{Storage, StorageMut}; +use base::{DefaultAllocator, Matrix, MatrixMN, SquareMatrix, Vector}; impl> SquareMatrix { /// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index fe016362..2fe1f985 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -5,35 +5,47 @@ use num_complex::Complex; use std::ops::MulAssign; use alga::general::Real; -use core::{DefaultAllocator, Matrix, Matrix2x3, MatrixMN, Vector2, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, Matrix, Matrix2x3, MatrixMN, Vector2, VectorN}; +use constraint::{SameNumberOfRows, ShapeConstraint}; use dimension::{Dim, DimDiff, DimMin, DimMinimum, DimSub, U1, U2}; use storage::Storage; -use allocator::Allocator; -use constraint::{SameNumberOfRows, ShapeConstraint}; +use geometry::UnitComplex; use linalg::givens; use linalg::symmetric_eigen; use linalg::Bidiagonal; -use geometry::UnitComplex; /// Singular Value Decomposition of a general matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator> + Allocator, C> + Allocator>, MatrixMN>: serde::Serialize, MatrixMN, C>: serde::Serialize, - VectorN>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + VectorN>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator> + Allocator, C> + Allocator>, MatrixMN>: serde::Deserialize<'de>, MatrixMN, C>: serde::Deserialize<'de>, - VectorN>: serde::Deserialize<'de>")))] + VectorN>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct SVD, C: Dim> where diff --git a/src/linalg/symmetric_eigen.rs b/src/linalg/symmetric_eigen.rs index d22c8bf8..3ccd0e88 100644 --- a/src/linalg/symmetric_eigen.rs +++ b/src/linalg/symmetric_eigen.rs @@ -5,27 +5,39 @@ use num_complex::Complex; use std::ops::MulAssign; use alga::general::Real; -use core::{DefaultAllocator, Matrix2, MatrixN, SquareMatrix, Vector2, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, Matrix2, MatrixN, SquareMatrix, Vector2, VectorN}; use dimension::{Dim, DimDiff, DimSub, U1, U2}; use storage::Storage; -use allocator::Allocator; +use geometry::UnitComplex; use linalg::givens; use linalg::SymmetricTridiagonal; -use geometry::UnitComplex; /// Eigendecomposition of a symmetric matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator, VectorN: serde::Serialize, - MatrixN: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + MatrixN: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator, VectorN: serde::Deserialize<'de>, - MatrixN: serde::Deserialize<'de>")))] + MatrixN: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct SymmetricEigen where @@ -336,7 +348,7 @@ where #[cfg(test)] mod test { - use core::Matrix2; + use base::Matrix2; fn expected_shift(m: Matrix2) -> f64 { let vals = m.eigenvalues().unwrap(); diff --git a/src/linalg/symmetric_tridiagonal.rs b/src/linalg/symmetric_tridiagonal.rs index 5ffaa256..16c7ba47 100644 --- a/src/linalg/symmetric_tridiagonal.rs +++ b/src/linalg/symmetric_tridiagonal.rs @@ -2,25 +2,37 @@ use serde; use alga::general::Real; -use core::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN}; +use allocator::Allocator; +use base::{DefaultAllocator, MatrixMN, MatrixN, SquareMatrix, VectorN}; use dimension::{DimDiff, DimSub, U1}; use storage::Storage; -use allocator::Allocator; use linalg::householder; /// Tridiagonalization of a symmetric matrix. #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(serialize = "DefaultAllocator: Allocator + +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + serialize = "DefaultAllocator: Allocator + Allocator>, MatrixN: serde::Serialize, - VectorN>: serde::Serialize")))] -#[cfg_attr(feature = "serde-serialize", - serde(bound(deserialize = "DefaultAllocator: Allocator + + VectorN>: serde::Serialize" + ) + ) +)] +#[cfg_attr( + feature = "serde-serialize", + serde( + bound( + deserialize = "DefaultAllocator: Allocator + Allocator>, MatrixN: serde::Deserialize<'de>, - VectorN>: serde::Deserialize<'de>")))] + VectorN>: serde::Deserialize<'de>" + ) + ) +)] #[derive(Clone, Debug)] pub struct SymmetricTridiagonal> where