@@ -216,13 +216,16 @@ function diagind(::IndexCartesian, m::Integer, n::Integer, k::Integer=0)
216
216
end
217
217
218
218
"""
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())
220
221
221
222
An `AbstractRange` giving the indices of the `k`th diagonal of the matrix `M`.
222
223
Optionally, an index style may be specified which determines the type of the range returned.
223
224
If `indstyle isa IndexLinear` (default), this returns an `AbstractRange{Integer}`.
224
225
On the other hand, if `indstyle isa IndexCartesian`, this returns an `AbstractRange{CartesianIndex{2}}`.
225
226
227
+ If `k` is not provided, it is assumed to be `0` (corresponding to the main diagonal).
228
+
226
229
See also: [`diag`](@ref), [`diagm`](@ref), [`Diagonal`](@ref).
227
230
228
231
# Examples
@@ -233,9 +236,15 @@ julia> A = [1 2 3; 4 5 6; 7 8 9]
233
236
4 5 6
234
237
7 8 9
235
238
236
- julia> diagind(A,-1)
239
+ julia> diagind(A, -1)
237
240
2:4:6
241
+
242
+ julia> diagind(A, IndexCartesian())
243
+ StepRangeLen(CartesianIndex(1, 1), CartesianIndex(1, 1), 3)
238
244
```
245
+
246
+ !!! compat "Julia 1.11"
247
+ Specifying an `IndexStyle` requires at least Julia 1.11.
239
248
"""
240
249
function diagind (A:: AbstractMatrix , k:: Integer = 0 , indexstyle:: IndexStyle = IndexLinear ())
241
250
require_one_based_indexing (A)
0 commit comments