Skip to content

Commit 88343ab

Browse files
authored
improve band doctest examples (#330)
1 parent d0e7a16 commit 88343ab

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

src/generic/Band.jl

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,31 @@ Represents the `i`-th band of a banded matrix.
1313
```jldoctest
1414
julia> using BandedMatrices
1515
16-
julia> A = BandedMatrix(Ones(5,5),(1,1))
17-
5×5 BandedMatrix{Float64} with bandwidths (1, 1):
18-
1.0 1.0 ⋅ ⋅ ⋅
19-
1.0 1.0 1.0 ⋅ ⋅
20-
⋅ 1.0 1.0 1.0 ⋅
21-
⋅ ⋅ 1.0 1.0 1.0
22-
⋅ ⋅ ⋅ 1.0 1.0
16+
julia> A = BandedMatrix(0=>1:4, 1=>5:7, -1=>8:10)
17+
4×4 BandedMatrix{Int64} with bandwidths (1, 1):
18+
1 5 ⋅ ⋅
19+
8 2 6 ⋅
20+
⋅ 9 3 7
21+
⋅ ⋅ 10 4
2322
2423
julia> A[band(1)]
25-
4-element Vector{Float64}:
26-
1.0
27-
1.0
28-
1.0
29-
1.0
24+
3-element Vector{Int64}:
25+
5
26+
6
27+
7
28+
29+
julia> A[band(0)]
30+
4-element Vector{Int64}:
31+
1
32+
2
33+
3
34+
4
35+
36+
julia> A[band(-1)]
37+
3-element Vector{Int64}:
38+
8
39+
9
40+
10
3041
```
3142
"""
3243
band(i::Int) = Band(i)
@@ -41,19 +52,18 @@ Represents the entries in a row/column inside the bands.
4152
```jldoctest
4253
julia> using BandedMatrices
4354
44-
julia> A = BandedMatrix(Ones(5,5),(1,1))
45-
5×5 BandedMatrix{Float64} with bandwidths (1, 1):
46-
1.0 1.0 ⋅ ⋅ ⋅
47-
1.0 1.0 1.0 ⋅ ⋅
48-
⋅ 1.0 1.0 1.0 ⋅
49-
⋅ ⋅ 1.0 1.0 1.0
50-
⋅ ⋅ ⋅ 1.0 1.0
51-
52-
julia> A[2,BandRange]
53-
3-element Vector{Float64}:
54-
1.0
55-
1.0
56-
1.0
55+
julia> A = BandedMatrix(0=>1:4, 1=>5:7, -1=>8:10)
56+
4×4 BandedMatrix{Int64} with bandwidths (1, 1):
57+
1 5 ⋅ ⋅
58+
8 2 6 ⋅
59+
⋅ 9 3 7
60+
⋅ ⋅ 10 4
61+
62+
julia> A[2, BandRange]
63+
3-element Vector{Int64}:
64+
8
65+
2
66+
6
5767
```
5868
"""
5969
const BandRange = BandRangeType()

0 commit comments

Comments
 (0)