pub(crate) trait AsFloatSlice {
fn as_float_slice(&self) -> &[f64];
}
pub(crate) trait AsFloatSliceMut: AsFloatSlice {
fn as_float_slice_mut(&mut self) -> &mut [f64];
}
impl AsFloatSlice for Vec<f64> {
fn as_float_slice(&self) -> &[f64] {
self.as_slice()
}
}
impl AsFloatSliceMut for Vec<f64> {
fn as_float_slice_mut(&mut self) -> &mut [f64] {
self.as_mut_slice()
}
}
#[cfg(feature = "nalgebra")]
impl AsFloatSlice for nalgebra::DVector<f64> {
fn as_float_slice(&self) -> &[f64] {
self.as_slice()
}
}
#[cfg(feature = "nalgebra")]
impl AsFloatSliceMut for nalgebra::DVector<f64> {
fn as_float_slice_mut(&mut self) -> &mut [f64] {
self.as_mut_slice()
}
}
#[cfg(feature = "faer")]
impl AsFloatSlice for faer::Col<f64> {
fn as_float_slice(&self) -> &[f64] {
self.try_as_col_major()
.expect("faer::Col<f64> backing storage must be col-major contiguous")
.as_slice()
}
}
#[cfg(feature = "faer")]
impl AsFloatSliceMut for faer::Col<f64> {
fn as_float_slice_mut(&mut self) -> &mut [f64] {
self.try_as_col_major_mut()
.expect("faer::Col<f64> backing storage must be col-major contiguous")
.as_slice_mut()
}
}