In some of our code we use views based on integer indexing (we need to remove some colums from our matrices). I noticed that these views have very poor performance in multiplication.
a = rand(1000, 1000)
@btime a*a
# 13 ms
av1 = @view a[1000:1000]
@btime av1*av1
# 13 ms
av2 = @view a[Not(12), Not(12)]
@btime av2*av2
# 733 ms
@btime Matrix(av2)*Matrix(av2)
# 19 ms
I think its because the view with Integer indices / inverted indices is not a StridedArray
anymore…
Is there a smarter way to remove certain columns/rows from my matrices and still have good multiplication performance? Right now the best way is to explicitly turn them into a “regular” Matrix before multiplying.
I looked at StridedViews but it looks like it only works on ranges and not on indices/inverted indices. Does someone have some advise? Should I just make the copy with Matrix
or is there some package that can solve this for me?