forked from M-Labs/nalgebra
Implement conversion methods for RowDVector
This commit is contained in:
parent
d1d7422761
commit
2233a38048
@ -20,7 +20,7 @@ use crate::base::{
|
||||
MatrixSliceMut, OMatrix, Scalar,
|
||||
};
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
use crate::base::{DVector, VecStorage};
|
||||
use crate::base::{DVector, RowDVector, VecStorage};
|
||||
use crate::base::{SliceStorage, SliceStorageMut};
|
||||
use crate::constraint::DimEq;
|
||||
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>
|
||||
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::uninit::{Init, InitStatus, Uninit};
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
use crate::{DMatrix, DVector, Dynamic, VecStorage};
|
||||
use crate::{DMatrix, DVector, Dynamic, RowDVector, VecStorage};
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
/// 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>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R, C>,
|
||||
|
Loading…
Reference in New Issue
Block a user