@@ -64,19 +64,193 @@ bandrange(A) = -bandwidth(A,1):bandwidth(A,2)
6464
6565
6666
67- # start/stop indices of the i-th column/row, bounded by actual matrix size
67+ """
68+ colstart(A, i::Integer)
69+
70+ Return the starting row index of the filled bands in the i-th column,
71+ bounded by the actual matrix size.
72+
73+ # Examples
74+ ```jldoctest
75+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
76+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
77+ 1 5 ⋅ ⋅
78+ ⋅ 2 6 ⋅
79+ ⋅ ⋅ 3 7
80+ ⋅ ⋅ ⋅ 4
81+
82+ julia> BandedMatrices.colstart(A, 3)
83+ 2
84+
85+ julia> BandedMatrices.colstart(A, 4)
86+ 3
87+ ```
88+ """
6889@inline colstart (A, i:: Integer ) = max (i- bandwidth (A,2 ), 1 )
90+
91+ """
92+ colstop(A, i::Integer)
93+
94+ Return the stopping row index of the filled bands in the i-th column,
95+ bounded by the actual matrix size.
96+
97+ # Examples
98+ ```jldoctest
99+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
100+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
101+ 1 5 ⋅ ⋅
102+ ⋅ 2 6 ⋅
103+ ⋅ ⋅ 3 7
104+ ⋅ ⋅ ⋅ 4
105+
106+ julia> BandedMatrices.colstop(A, 3)
107+ 3
108+
109+ julia> BandedMatrices.colstop(A, 4)
110+ 4
111+ ```
112+ """
69113@inline colstop (A, i:: Integer ) = max (min (i+ bandwidth (A,1 ), size (A, 1 )), 0 )
114+
115+ """
116+ rowstart(A, i::Integer)
117+
118+ Return the starting column index of the filled bands in the i-th row,
119+ bounded by the actual matrix size.
120+
121+ # Examples
122+ ```jldoctest
123+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
124+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
125+ 1 5 ⋅ ⋅
126+ ⋅ 2 6 ⋅
127+ ⋅ ⋅ 3 7
128+ ⋅ ⋅ ⋅ 4
129+
130+ julia> BandedMatrices.rowstart(A, 2)
131+ 2
132+
133+ julia> BandedMatrices.rowstart(A, 3)
134+ 3
135+ ```
136+ """
70137@inline rowstart (A, i:: Integer ) = max (i- bandwidth (A,1 ), 1 )
138+
139+ """
140+ rowstop(A, i::Integer)
141+
142+ Return the stopping column index of the filled bands in the i-th row,
143+ bounded by the actual matrix size.
144+
145+ # Examples
146+ ```jldoctest
147+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
148+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
149+ 1 5 ⋅ ⋅
150+ ⋅ 2 6 ⋅
151+ ⋅ ⋅ 3 7
152+ ⋅ ⋅ ⋅ 4
153+
154+ julia> BandedMatrices.rowstop(A, 2)
155+ 3
156+
157+ julia> BandedMatrices.rowstop(A, 4)
158+ 4
159+ ```
160+ """
71161@inline rowstop (A, i:: Integer ) = max (min (i+ bandwidth (A,2 ), size (A, 2 )), 0 )
72162
163+ """
164+ colrange(A, i::Integer)
165+
166+ Return the range of rows in the `i`-th column that correspond to filled bands.
167+
168+ # Examples
169+ ```jldoctest
170+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
171+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
172+ 1 5 ⋅ ⋅
173+ ⋅ 2 6 ⋅
174+ ⋅ ⋅ 3 7
175+ ⋅ ⋅ ⋅ 4
73176
177+ julia> colrange(A, 1)
178+ 1:1
179+
180+ julia> colrange(A, 3)
181+ 2:3
182+ ```
183+ """
74184@inline colrange (A, i:: Integer ) = colstart (A,i): colstop (A,i)
185+
186+ """
187+ rowrange(A, i::Integer)
188+
189+ Return the range of columns in the `i`-th row that correspond to filled bands.
190+
191+ # Examples
192+ ```jldoctest
193+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
194+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
195+ 1 5 ⋅ ⋅
196+ ⋅ 2 6 ⋅
197+ ⋅ ⋅ 3 7
198+ ⋅ ⋅ ⋅ 4
199+
200+ julia> rowrange(A, 1)
201+ 1:2
202+
203+ julia> rowrange(A, 4)
204+ 4:4
205+ ```
206+ """
75207@inline rowrange (A, i:: Integer ) = rowstart (A,i): rowstop (A,i)
76208
77209
78- # length of i-the column/row
210+ """
211+ collength(A, i::Integer)
212+
213+ Return the number of filled bands in the `i`-th column.
214+
215+ # Examples
216+ ```jldoctest
217+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
218+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
219+ 1 5 ⋅ ⋅
220+ ⋅ 2 6 ⋅
221+ ⋅ ⋅ 3 7
222+ ⋅ ⋅ ⋅ 4
223+
224+ julia> BandedMatrices.collength(A, 1)
225+ 1
226+
227+ julia> BandedMatrices.collength(A, 2)
228+ 2
229+ ```
230+ """
79231@inline collength (A, i:: Integer ) = max (colstop (A, i) - colstart (A, i) + 1 , 0 )
232+
233+ """
234+ rowlength(A, i::Integer)
235+
236+ Return the number of filled bands in the `i`-th row.
237+
238+ # Examples
239+ ```jldoctest
240+ julia> A = BandedMatrix(0=>1:4, 1=>5:7)
241+ 4×4 BandedMatrix{Int64} with bandwidths (0, 1):
242+ 1 5 ⋅ ⋅
243+ ⋅ 2 6 ⋅
244+ ⋅ ⋅ 3 7
245+ ⋅ ⋅ ⋅ 4
246+
247+ julia> BandedMatrices.rowlength(A, 1)
248+ 2
249+
250+ julia> BandedMatrices.rowlength(A, 4)
251+ 1
252+ ```
253+ """
80254@inline rowlength (A, i:: Integer ) = max (rowstop (A, i) - rowstart (A, i) + 1 , 0 )
81255
82256@inline banded_colsupport (A, j:: Integer ) = colrange (A, j)
0 commit comments