forked from M-Labs/nalgebra
Merge pull request #976 from saona-raimundo/dev
Implement conversion methods for RowDVector
This commit is contained in:
commit
80c7064bf4
@ -4,6 +4,12 @@ documented here.
|
|||||||
|
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [0.29.1] - WIP
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The conversion trait `From<Vec<T>>` and method `from_vec_storage` for `RowDVector`. See [#975](https://github.com/dimforge/nalgebra/issues/975)
|
||||||
|
|
||||||
## [0.29.0]
|
## [0.29.0]
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
- We updated to the version 0.6 of `simba`. This means that the trait bounds `T: na::RealField`, `na::ComplexField`,
|
- We updated to the version 0.6 of `simba`. This means that the trait bounds `T: na::RealField`, `na::ComplexField`,
|
||||||
|
@ -20,7 +20,7 @@ use crate::base::{
|
|||||||
MatrixSliceMut, OMatrix, Scalar,
|
MatrixSliceMut, OMatrix, Scalar,
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::base::{DVector, VecStorage};
|
use crate::base::{DVector, RowDVector, VecStorage};
|
||||||
use crate::base::{SliceStorage, SliceStorageMut};
|
use crate::base::{SliceStorage, SliceStorageMut};
|
||||||
use crate::constraint::DimEq;
|
use crate::constraint::DimEq;
|
||||||
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector};
|
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector};
|
||||||
@ -453,6 +453,14 @@ impl<'a, T: Scalar> From<Vec<T>> for DVector<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
impl<'a, T: Scalar> From<Vec<T>> for RowDVector<T> {
|
||||||
|
#[inline]
|
||||||
|
fn from(vec: Vec<T>) -> Self {
|
||||||
|
Self::from_vec(vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: RawStorage<T, R, C> + IsContiguous>
|
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: RawStorage<T, R, C> + IsContiguous>
|
||||||
From<&'a Matrix<T, R, C, S>> for &'a [T]
|
From<&'a Matrix<T, R, C, S>> for &'a [T]
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ use crate::{ArrayStorage, SMatrix, SimdComplexField, Storage, UninitMatrix};
|
|||||||
use crate::storage::IsContiguous;
|
use crate::storage::IsContiguous;
|
||||||
use crate::uninit::{Init, InitStatus, Uninit};
|
use crate::uninit::{Init, InitStatus, Uninit};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::{DMatrix, DVector, Dynamic, VecStorage};
|
use crate::{DMatrix, DVector, Dynamic, RowDVector, VecStorage};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
/// A square matrix.
|
/// A square matrix.
|
||||||
@ -411,6 +411,21 @@ impl<T> DVector<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Consider removing/deprecating `from_vec_storage` once we are able to make
|
||||||
|
// `from_data` const fn compatible
|
||||||
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
impl<T> RowDVector<T> {
|
||||||
|
/// Creates a new heap-allocated matrix from the given [`VecStorage`].
|
||||||
|
///
|
||||||
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
|
/// work in `const fn` contexts.
|
||||||
|
pub const fn from_vec_storage(storage: VecStorage<T, U1, Dynamic>) -> Self {
|
||||||
|
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
||||||
|
// to be the same
|
||||||
|
unsafe { Self::from_data_statically_unchecked(storage) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T, R: Dim, C: Dim> UninitMatrix<T, R, C>
|
impl<T, R: Dim, C: Dim> UninitMatrix<T, R, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, C>,
|
DefaultAllocator: Allocator<T, R, C>,
|
||||||
|
Loading…
Reference in New Issue
Block a user