@@ -216,13 +216,16 @@ function diagind(::IndexCartesian, m::Integer, n::Integer, k::Integer=0)
216216end
217217
218218"""
219- diagind(M::AbstractMatrix, [k::Integer=0,] indstyle::IndexStyle = IndexLinear())
219+ diagind(M::AbstractMatrix, k::Integer = 0, indstyle::IndexStyle = IndexLinear())
220+ diagind(M::AbstractMatrix, indstyle::IndexStyle = IndexLinear())
220221
221222An `AbstractRange` giving the indices of the `k`th diagonal of the matrix `M`.
222223Optionally, an index style may be specified which determines the type of the range returned.
223224If `indstyle isa IndexLinear` (default), this returns an `AbstractRange{Integer}`.
224225On the other hand, if `indstyle isa IndexCartesian`, this returns an `AbstractRange{CartesianIndex{2}}`.
225226
227+ If `k` is not provided, it is assumed to be `0` (corresponding to the main diagonal).
228+
226229See also: [`diag`](@ref), [`diagm`](@ref), [`Diagonal`](@ref).
227230
228231# Examples
@@ -233,9 +236,15 @@ julia> A = [1 2 3; 4 5 6; 7 8 9]
233236 4 5 6
234237 7 8 9
235238
236- julia> diagind(A,-1)
239+ julia> diagind(A, -1)
2372402:4:6
241+
242+ julia> diagind(A, IndexCartesian())
243+ StepRangeLen(CartesianIndex(1, 1), CartesianIndex(1, 1), 3)
238244```
245+
246+ !!! compat "Julia 1.11"
247+ Specifying an `IndexStyle` requires at least Julia 1.11.
239248"""
240249function diagind (A:: AbstractMatrix , k:: Integer = 0 , indexstyle:: IndexStyle = IndexLinear ())
241250 require_one_based_indexing (A)
0 commit comments