[llvm] ADT/Matrix: two-dimensional Container with View (PR #98893)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 09:36:33 PDT 2024
artagnon wrote:
> > Yes, and that's what I've implemented in MatrixView. The storage class is essentially SmallVector with an additional field for tracking the number of columns. I need to track the number of columns, so that I can reconstruct the View after the underlying storage has been reallocated.
>
> Thanks you for the explanation. If this is the case, I don't think the name `Matrix*` is the most fitting. I'd call it something like 'JaggedArray': https://en.wikipedia.org/wiki/Jagged_array.
I suppose it is a MatrixStorage with a JaggedArrayView. Thanks for the name suggestion: I wasn't aware of this terminology. I would, however, like some suggestions for names from other reviewers as well, before we finalize on something.
> > The constructors, drop_back, drop_front, slice, for instance.
>
> What I'm missing is:
>
> * What compile-time computation do we intend to do and why we need it?
The compile-time computation is very minor, and amounts to a few pointer subtractions. See `MutableArrayRef<T>::slice(Begin, End - Begin);` for instance.
> * Why does this computation include 2d arrays and, transitively, array ref?
So, the 2D View returns a 1D View (called MatrixRowView) with an `operator[]`, and this struct inherits from MutableArrayRef.
https://github.com/llvm/llvm-project/pull/98893
More information about the llvm-commits
mailing list