@@ -20,6 +20,30 @@ function sub(x::_MatTypes, r::AbstractUnitRange{Int}, c::AbstractUnitRange{Int})
2020 return deepcopy (view (x, r, c))
2121end
2222
23+ # flint does not support windows with non-continuous row or column indices
24+ # we overload some specific types to not hit the AA fallback
25+ for T in [ZZMatrix, QQMatrix]
26+ @eval begin
27+ # have to "duplicate" this, otherwise we get ambiguity errors
28+ function sub (x:: $T , r:: AbstractUnitRange{Int} , c:: AbstractUnitRange{Int} )
29+ return deepcopy (view (x, r, c))
30+ end
31+
32+ function sub (M:: $T , r:: AbstractVector{Int} , c:: AbstractVector{Int} )
33+ N = zero_matrix (base_ring (M), length (r), length (c))
34+ GC. @preserve M N begin
35+ for (ii, i) in enumerate (r)
36+ for (jj, j) in enumerate (c)
37+ set! (mat_entry_ptr (N, ii, jj), mat_entry_ptr (M, i, j))
38+ end
39+ end
40+ end
41+ return N
42+ end
43+ end
44+ end
45+
46+ # make x[r, c] sugar for sub(x, r, c)
2347getindex (x:: _MatTypes , r:: AbstractUnitRange{Int} , c:: AbstractUnitRange{Int} ) = sub (x, r, c)
2448
2549# ###############################################################################
0 commit comments