nalgebra
nalgebra copied to clipboard
Owned row/column iterators
https://github.com/dimforge/nalgebra/issues/834
This is an initial draft for this implementation. I only managed to implement into_row_iter
and into_column_iter
for DMatrix
I think because I could not use Owned<N, R, C> where R: Dim and C: Dim
(i.e. R
and C
were either static or dynamic) because of the implementations of Allocator
on DefaultAllocator
, which defines Owned
:
type Owned<N, R, C> = <DefaultAllocator as Allocator<N, R, C>>::Buffer;
So to use Owned<N, R, C>
, R
and C
have to satisfy the trait bounds for any of the impl Allocator<N, R, C> for DefaultAllocator
, but there is no implementation for R: Dim
and C: Dim
.
There are only
-
R = Dynamic, C: Dim
(dynamic, either) -
R: DimName, C: DimName
(static, static) -
R: Dim, C = Dynamic
(either, dynamic)
Maybe there is a way to implement this for R: Dim, C: Dim
, but this is the current state.
I would be glad if someone could review this and help me improve this implementation.
@mankinskin, this seems like a really interesting design space, so I took a stab at into_row_iter
: https://github.com/jswrenn/nalgebra/commit/6e34a2bffe47d4f6724d4364d811808a0737396d (the same approach ought to work for into_col_iter
). I don't think I ran into the same issue you did, but it's entirely possible that I did and just haven't noticed.
I wonder if there's some awkwardness here about the meaning of calling into_row_iter
on a &Matrix
versus on a MatrixSlice
.
Thank you @jenanwise and @jswrenn for the suggestions. I believe the suggestion of @jswrenn is a more adequate way of doing this since it will work for all the matrix types and don't require any additional trait bound on the allocator storage output type.