@@ -15,7 +15,7 @@ import Base: USE_BLAS64, abs, acos, acosh, acot, acoth, acsc, acsch, adjoint, as
1515 IndexStyle, kron, kron!, length, log, map, ndims, one, oneunit, parent, permutecols!,
1616 permutedims, permuterows!, power_by_squaring, promote_rule, real, isreal, sec, sech, setindex!,
1717 show, similar, sin, sincos, sinh, size, sqrt, strides, stride, tan, tanh, transpose, trunc,
18- typed_hcat, vec, view, zero
18+ typed_hcat, vec, view, zero, CartesianIndex
1919import Base: AbstractArray, AbstractMatrix, Array, Matrix
2020using Base: IndexLinear, promote_eltype, promote_op, print_matrix,
2121 @propagate_inbounds , reduce, typed_hvcat, typed_vcat, require_one_based_indexing,
@@ -508,21 +508,23 @@ struct BandIndex
508508 band :: Int
509509 index :: Int
510510end
511- function _cartinds (b:: BandIndex )
511+ function _torowcol (b:: BandIndex )
512512 (; band, index) = b
513- bandg0 = max (band,0 )
514- row = index - band + bandg0
515- col = index + bandg0
516- CartesianIndex ( row, col)
513+ minband0, maxband0 = minmax (band,0 )
514+ row = index - minband0
515+ col = index + maxband0
516+ row, col
517517end
518- function Base. to_indices (A, inds, t:: Tuple{BandIndex, Vararg{Any}} )
519- to_indices (A, inds, (_cartinds (first (t)), Base. tail (t)... ))
518+ CartesianIndex (b:: BandIndex ) = CartesianIndex {2} (b)
519+ CartesianIndex {2} (b:: BandIndex ) = CartesianIndex {2} (_torowcol (b))
520+ function Base. to_indices (A, inds, t:: Tuple{BandIndex, Vararg} )
521+ to_indices (A, inds, (_torowcol (first (t))... , Base. tail (t)... ))
520522end
521523function Base. checkbounds (:: Type{Bool} , A:: AbstractMatrix , b:: BandIndex )
522- checkbounds (Bool, A, _cartinds (b))
524+ checkbounds (Bool, A, _torowcol (b)... )
523525end
524526function Base. checkbounds (A:: Broadcasted , b:: BandIndex )
525- checkbounds (A, _cartinds (b))
527+ checkbounds (A, _torowcol (b)... )
526528end
527529
528530include (" adjtrans.jl" )
0 commit comments