pub struct StridedView<'a, T, Op = Identity> { /* private fields */ }Expand description
Dynamic-rank immutable strided view with lazy element operations.
This is the Julia-equivalent StridedView type with:
- Dynamic rank (dims/strides are heap-allocated)
- Lazy element operations via the
Optype parameter - Zero-copy transformations (permute, transpose, adjoint, conj)
§Type Parameters
'a: Lifetime of the underlying dataT: Element typeOp: Element operation applied lazily on access (default:Identity)
Implementations§
Source§impl<'a, T, Op> StridedView<'a, T, Op>
impl<'a, T, Op> StridedView<'a, T, Op>
Sourcepub fn new(
data: &'a [T],
dims: &[usize],
strides: &[isize],
offset: isize,
) -> Result<StridedView<'a, T, Op>, StridedError>
pub fn new( data: &'a [T], dims: &[usize], strides: &[isize], offset: isize, ) -> Result<StridedView<'a, T, Op>, StridedError>
Create a new immutable strided view from a borrowed slice.
Sourcepub unsafe fn new_unchecked(
data: &'a [T],
dims: &[usize],
strides: &[isize],
offset: isize,
) -> StridedView<'a, T, Op>
pub unsafe fn new_unchecked( data: &'a [T], dims: &[usize], strides: &[isize], offset: isize, ) -> StridedView<'a, T, Op>
Create a view without bounds checking.
§Safety
The caller must ensure all index combinations stay within bounds.
Sourcepub fn permute(
&self,
perm: &[usize],
) -> Result<StridedView<'a, T, Op>, StridedError>
pub fn permute( &self, perm: &[usize], ) -> Result<StridedView<'a, T, Op>, StridedError>
Permute dimensions.
Sourcepub fn diagonal_view(
&self,
axis_pairs: &[(usize, usize)],
) -> Result<StridedView<'a, T, Op>, StridedError>
pub fn diagonal_view( &self, axis_pairs: &[(usize, usize)], ) -> Result<StridedView<'a, T, Op>, StridedError>
Create a diagonal view by fusing repeated axis pairs via stride trick (zero-copy).
For each pair (a, b):
- New stride =
strides[a] + strides[b] - New dim =
min(dims[a], dims[b]) - The higher-numbered axis is removed
- Pairs use original axis numbering
§Example
A[i,i,j] shape=[n,n,m] strides=[s0,s1,s2] -> shape=[n,m] strides=[s0+s1, s2]
Sourcepub fn broadcast(
&self,
target_dims: &[usize],
) -> Result<StridedView<'a, T, Op>, StridedError>
pub fn broadcast( &self, target_dims: &[usize], ) -> Result<StridedView<'a, T, Op>, StridedError>
Broadcast this view to a target shape.
Size-1 dimensions are expanded (stride set to 0) to match target.
Source§impl<'a, T, Op> StridedView<'a, T, Op>
Composition methods: require T: ElementOpApply and Op: ComposableElementOp<T>.
impl<'a, T, Op> StridedView<'a, T, Op>
Composition methods: require T: ElementOpApply and Op: ComposableElementOp<T>.
Sourcepub fn transpose_2d(
&self,
) -> Result<StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeTranspose>, StridedError>
pub fn transpose_2d( &self, ) -> Result<StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeTranspose>, StridedError>
Transpose a 2D view: reverses dimensions and composes the Transpose element op.
Julia equivalent: Base.transpose(a::AbstractStridedView{<:Any, 2})
Sourcepub fn adjoint_2d(
&self,
) -> Result<StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeAdjoint>, StridedError>
pub fn adjoint_2d( &self, ) -> Result<StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeAdjoint>, StridedError>
Adjoint (conjugate transpose) of a 2D view.
Julia equivalent: Base.adjoint(a::AbstractStridedView{<:Any, 2})
Sourcepub fn conj(
&self,
) -> StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeConj>
pub fn conj( &self, ) -> StridedView<'a, T, <Op as ComposableElementOp<T>>::ComposeConj>
Complex conjugate (compose Conj without changing dims/strides).
Julia equivalent: Base.conj(a::AbstractStridedView)
Source§impl<'a, T, Op> StridedView<'a, T, Op>
Element access: requires Op: ElementOp<T>.
impl<'a, T, Op> StridedView<'a, T, Op>
Element access: requires Op: ElementOp<T>.
Trait Implementations§
Source§impl<T, Op> Clone for StridedView<'_, T, Op>
impl<T, Op> Clone for StridedView<'_, T, Op>
Source§fn clone(&self) -> StridedView<'_, T, Op>
fn clone(&self) -> StridedView<'_, T, Op>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T, Op> Debug for StridedView<'_, T, Op>where
T: Debug,
impl<T, Op> Debug for StridedView<'_, T, Op>where
T: Debug,
impl<T, Op> Send for StridedView<'_, T, Op>
impl<T, Op> Sync for StridedView<'_, T, Op>
Auto Trait Implementations§
impl<'a, T, Op> Freeze for StridedView<'a, T, Op>
impl<'a, T, Op> RefUnwindSafe for StridedView<'a, T, Op>where
T: RefUnwindSafe,
Op: RefUnwindSafe,
impl<'a, T, Op> Unpin for StridedView<'a, T, Op>where
Op: Unpin,
impl<'a, T, Op> UnsafeUnpin for StridedView<'a, T, Op>
impl<'a, T, Op> UnwindSafe for StridedView<'a, T, Op>where
T: RefUnwindSafe,
Op: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more