[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:54:40 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.
> 
> Why does the view support jagged arrays, though? Is that needed?

The immediate motivating example is to migrate existing vector-of-vectors idioms, so yes, this is needed. The more long-term vision is to implement Matrix algorithm: most of these like Guassian Elimination need pivoting, and instead of complicating the code with pivot-tracking, we can use this view which tracks the last element automatically; therefore, we can swap any column index with the last element, and drop_back the row-view, as I've shown in the FM-Elimination in #98895.

https://github.com/llvm/llvm-project/pull/98893


More information about the llvm-commits mailing list