julia> A = sparse(rand(5,5));

julia> lu(view(A,:,:))
ERROR: MethodError: no method matching lu!(::SparseMatrixCSC{Float64, Int64}, ::RowMaximum; check=true)

This arose in this Discourse thread.

The issue appears to be that lu(::SubArray) adds the pivot argument to its lu! call, which is unsupported by the SparseMatrixCSC version. Either the pivot argument should be accepted to the sparse version (even if ignored for now) or this call should be more careful about applying it. Or this should hit a generic fallback (but that might be extremely slow). EDIT: actually it appears to be a bit more complicated because lu! for sparse arrays has a rather different signature. Still, the issue lies somewhere around the call chain invoked by lu(::SubArray).

I personally don't advocate for ever ending up in this place, as one should prefer to materialize the view and use ~~lu!~~ lu (I guess lu! for sparse arrays is a bit more complicated to use) on the materialized version. But this is broken in any case and might be indicative of similarly brittle behaviors with other types so is worth resolving.


Can reproduce on 1.8.3, but seems to be potentially fixed on 1.9.0-alpha1 and 1.10

© 2022 - All rights reserved.