Skip to content

Commit c9e46a9

Browse files
committed
as_view
1 parent 8dc079d commit c9e46a9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fftw/src/array.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::types::*;
44
use ffi;
5+
use ndarray::*;
56

67
use num_traits::Zero;
78
use std::ops::{Deref, DerefMut};
@@ -55,6 +56,14 @@ impl<T> AlignedVec<T> {
5556
pub fn as_slice_mut(&mut self) -> &mut [T] {
5657
unsafe { from_raw_parts_mut(self.data, self.n) }
5758
}
59+
60+
pub fn as_view<D, Shape>(&self, shape: Shape) -> Result<ArrayView<T, D>, ShapeError>
61+
where
62+
D: Dimension,
63+
Shape: Into<StrideShape<D>>,
64+
{
65+
ArrayView::from_shape(shape, self.as_slice())
66+
}
5867
}
5968

6069
impl<T> Deref for AlignedVec<T> {

0 commit comments

Comments
 (0)