forked from M-Labs/nalgebra
Fix compilation with and without #![no_std].
This commit is contained in:
parent
ca093fad29
commit
40e74e0186
@ -16,6 +16,9 @@ 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.
|
||||
* Entries of matrices displayed using `println!("{}", matrix)` will not be correctly aligned vertically.
|
||||
* The computation of the orthogonormal subspace basis of a vector is limited to vector with dimension up
|
||||
to 3 (we will attempt to lift this restriction in a future release).
|
||||
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
|
||||
|
@ -17,7 +17,7 @@ path = "src/lib.rs"
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = [ "matrixmultiply" ]
|
||||
std = [ "matrixmultiply", "rand/std" ]
|
||||
arbitrary = [ "quickcheck" ]
|
||||
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
|
||||
abomonation-serialize = [ "abomonation" ]
|
||||
|
@ -459,7 +459,7 @@ where
|
||||
+ SameNumberOfColumns<C1, C3>
|
||||
+ AreMultipliable<R2, C2, R3, C3>,
|
||||
{
|
||||
let ncols1 = self.shape();
|
||||
let ncols1 = self.ncols();
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
|
@ -919,6 +919,7 @@ where
|
||||
DefaultAllocator: Allocator<usize, R, C>,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
#[cfg(feature = "std")]
|
||||
fn val_width<N: Scalar + fmt::Display>(val: N, f: &mut fmt::Formatter) -> usize {
|
||||
match f.precision() {
|
||||
Some(precision) => format!("{:.1$}", val, precision).chars().count(),
|
||||
@ -926,6 +927,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn val_width<N: Scalar + fmt::Display>(val: N, f: &mut fmt::Formatter) -> usize {
|
||||
4
|
||||
}
|
||||
|
||||
let (nrows, ncols) = self.data.shape();
|
||||
|
||||
if nrows.value() == 0 || ncols.value() == 0 {
|
||||
|
@ -1,16 +1,19 @@
|
||||
use num::{One, Zero};
|
||||
|
||||
use alga::general::{AbstractGroup, AbstractGroupAbelian, AbstractLoop, AbstractMagma,
|
||||
AbstractModule, AbstractMonoid, AbstractQuasigroup, AbstractSemigroup,
|
||||
Additive, ClosedAdd, ClosedMul, ClosedNeg, Field, Identity, Inverse,
|
||||
JoinSemilattice, Lattice, MeetSemilattice, Module, Multiplicative, Real,
|
||||
RingCommutative};
|
||||
use alga::linear::{FiniteDimInnerSpace, FiniteDimVectorSpace, InnerSpace, NormedSpace, VectorSpace};
|
||||
use alga::general::{
|
||||
AbstractGroup, AbstractGroupAbelian, AbstractLoop, AbstractMagma, AbstractModule,
|
||||
AbstractMonoid, AbstractQuasigroup, AbstractSemigroup, Additive, ClosedAdd, ClosedMul,
|
||||
ClosedNeg, Field, Identity, Inverse, JoinSemilattice, Lattice, MeetSemilattice, Module,
|
||||
Multiplicative, Real, RingCommutative,
|
||||
};
|
||||
use alga::linear::{
|
||||
FiniteDimInnerSpace, FiniteDimVectorSpace, InnerSpace, NormedSpace, VectorSpace,
|
||||
};
|
||||
|
||||
use base::{DefaultAllocator, MatrixMN, MatrixN, Scalar};
|
||||
use base::allocator::Allocator;
|
||||
use base::dimension::{Dim, DimName};
|
||||
use base::storage::{Storage, StorageMut};
|
||||
use base::allocator::Allocator;
|
||||
use base::{DefaultAllocator, MatrixMN, MatrixN, Scalar};
|
||||
|
||||
/*
|
||||
*
|
||||
@ -283,27 +286,35 @@ where
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// XXX: use a GenericArray instead.
|
||||
let mut known_basis = Vec::new();
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
{
|
||||
// XXX: use a GenericArray instead.
|
||||
let mut known_basis = Vec::new();
|
||||
|
||||
for v in vs.iter() {
|
||||
known_basis.push(v.normalize())
|
||||
for v in vs.iter() {
|
||||
known_basis.push(v.normalize())
|
||||
}
|
||||
|
||||
for i in 0..Self::dimension() - vs.len() {
|
||||
let mut elt = Self::canonical_basis_element(i);
|
||||
|
||||
for v in &known_basis {
|
||||
elt -= v * elt.dot(v)
|
||||
}
|
||||
|
||||
if let Some(subsp_elt) = elt.try_normalize(N::zero()) {
|
||||
if !f(&subsp_elt) {
|
||||
return;
|
||||
};
|
||||
|
||||
known_basis.push(subsp_elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i in 0..Self::dimension() - vs.len() {
|
||||
let mut elt = Self::canonical_basis_element(i);
|
||||
|
||||
for v in &known_basis {
|
||||
elt -= v * elt.dot(v)
|
||||
}
|
||||
|
||||
if let Some(subsp_elt) = elt.try_normalize(N::zero()) {
|
||||
if !f(&subsp_elt) {
|
||||
return;
|
||||
};
|
||||
|
||||
known_basis.push(subsp_elt);
|
||||
}
|
||||
#[cfg(all(not(feature = "std"), not(feature = "alloc")))]
|
||||
{
|
||||
panic!("Cannot compute the orthogonal subspace basis of a vector with a dimension greater than 3 \
|
||||
if #![no_std] is enabled and the 'alloc' feature is not enabled.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
impl PermutationSequence<Dynamic>
|
||||
where
|
||||
DefaultAllocator: Allocator<(usize, usize), Dynamic>,
|
||||
|
Loading…
Reference in New Issue
Block a user