@@ -354,14 +354,11 @@ bandwidths(A::BandedMatrix) = (A.l , A.u)
354
354
# ~~ getindex ~~
355
355
356
356
# fast method used below
357
- @inline inbands_getindex (data:: AbstractMatrix , u:: Integer , k:: Integer , j:: Integer ) =
357
+ @propagate_inbounds inbands_getindex (data:: AbstractMatrix , u:: Integer , k:: Integer , j:: Integer ) =
358
358
data[u + k - j + 1 , j]
359
359
360
- @inline function inbands_getindex (A:: BandedMatrix , k:: Integer , j:: Integer )
361
- # it takes a bit of time to extract A.data, A.u since julia checks if those fields exist
362
- # the @inbounds here will suppress those checks
363
- @inbounds r = inbands_getindex (A. data, A. u, k, j)
364
- r
360
+ @propagate_inbounds function inbands_getindex (A:: BandedMatrix , k:: Integer , j:: Integer )
361
+ inbands_getindex (A. data, A. u, k, j)
365
362
end
366
363
367
364
# work around for Any matrices
@@ -475,20 +472,17 @@ data_rowrange(A::BandedMatrix{T}, i::Integer) where {T} = range((i ≤ 1+A.l ? A
475
472
# ~ Special setindex methods ~
476
473
477
474
# fast method used below
478
- @inline @ propagate_inbounds function inbands_setindex! (data:: AbstractMatrix{T} , u:: Integer , v, k:: Integer , j:: Integer ) where {T}
475
+ @propagate_inbounds function inbands_setindex! (data:: AbstractMatrix{T} , u:: Integer , v, k:: Integer , j:: Integer ) where {T}
479
476
data[u + k - j + 1 , j] = convert (T, v):: T
480
477
v
481
478
end
482
479
483
480
# slow fall back method
484
- @inline @propagate_inbounds function inbands_setindex! (A:: BandedMatrix , v, k:: Integer , j:: Integer )
485
- # it takes a bit of time to extract A.data, A.u since julia checks if those fields exist
486
- # the @inbounds here will suppress those checks
487
- @inbounds r = inbands_setindex! (A. data, A. u, v, k, j)
488
- r
481
+ @propagate_inbounds function inbands_setindex! (A:: BandedMatrix , v, k:: Integer , j:: Integer )
482
+ inbands_setindex! (A. data, A. u, v, k, j)
489
483
end
490
484
491
- @inline @ propagate_inbounds function banded_setindex! (data:: AbstractMatrix , l:: Integer , u:: Integer , v, k:: Integer , j:: Integer )
485
+ @propagate_inbounds function banded_setindex! (data:: AbstractMatrix , l:: Integer , u:: Integer , v, k:: Integer , j:: Integer )
492
486
if - l ≤ j- k ≤ u
493
487
inbands_setindex! (data, u, v, k, j)
494
488
elseif ! iszero (v) # allow setting outside bands to zero
@@ -499,14 +493,14 @@ end
499
493
end
500
494
501
495
# scalar - integer - integer
502
- @inline @propagate_inbounds function setindex! (A:: BandedMatrix , v, k:: Integer , j:: Integer )
496
+ @inline function setindex! (A:: BandedMatrix , v, k:: Integer , j:: Integer )
503
497
@boundscheck checkbounds (A, k, j)
504
- @inbounds r = banded_setindex! (A. data, A. l, A. u, v, k ,j)
505
- r
498
+ @inbounds banded_setindex! (A. data, A. l, A. u, v, k ,j)
499
+ A
506
500
end
507
501
508
502
# matrix - colon - colon
509
- @inline @propagate_inbounds function setindex! (A:: BandedMatrix{T} , v:: AbstractMatrix , kr:: Colon , jr:: Colon ) where {T}
503
+ @inline function setindex! (A:: BandedMatrix{T} , v:: AbstractMatrix , kr:: Colon , jr:: Colon ) where {T}
510
504
@boundscheck checkdimensions (size (A), size (v))
511
505
@boundscheck checkbandmatch (A, v, kr, jr)
512
506
524
518
# ~ indexing along a band
525
519
526
520
# vector - band - colon
527
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , b:: Band ) where {T}
521
+ @propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , b:: Band ) where {T}
528
522
@boundscheck checkband (A, b)
529
523
@boundscheck checkdimensions (diaglength (A, b), V)
530
524
row = A. u - b. i + 1
539
533
540
534
# ~ indexing along columns
541
535
# vector - colon - integer -- A[:, 1] = [1, 2, 3] - not allowed
542
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , kr:: Colon , j:: Integer ) where {T}
536
+ @propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , kr:: Colon , j:: Integer ) where {T}
543
537
@boundscheck checkbounds (A, kr, j)
544
538
@boundscheck checkdimensions (1 : size (A,1 ), V)
545
539
@boundscheck checkbandmatch (A,V,:,j)
553
547
(A[colrange (A, j), j] = V) # call range method
554
548
555
549
# vector - range - integer -- A[1:3, 1] = [1, 2, 3]
556
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractVector , kr:: AbstractRange , j:: Integer )
550
+ @propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractVector , kr:: AbstractRange , j:: Integer )
557
551
@boundscheck checkbounds (A, kr, j)
558
552
@boundscheck checkdimensions (kr, V)
559
553
@boundscheck checkbandmatch (A, V, kr, j)
575
569
# ~ indexing along a row
576
570
577
571
# vector - integer - colon -- A[1, :] = [1, 2, 3] - not allowed
578
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , k:: Integer , jr:: Colon ) where {T}
572
+ @propagate_inbounds function setindex! (A:: BandedMatrix{T} , V:: AbstractVector , k:: Integer , jr:: Colon ) where {T}
579
573
@boundscheck if k < 1 || k > size (A,1 )
580
574
throw (BoundsError (A, (k, jr)))
581
575
end
603
597
(A[k, rowstart (A, k): rowstop (A, k)] = V) # call range method
604
598
605
599
# vector - integer - range -- A[1, 2:3] = [3, 4]
606
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractVector , k:: Integer , jr:: AbstractRange )
600
+ @propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractVector , k:: Integer , jr:: AbstractRange )
607
601
@boundscheck checkbounds (A, k, jr)
608
602
@boundscheck checkdimensions (jr, V)
609
603
@boundscheck checkbandmatch (A, V, k, jr)
624
618
# ~ indexing over a rectangular block
625
619
626
620
# matrix - range - range
627
- @inline @ propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractMatrix , kr:: AbstractRange , jr:: AbstractRange )
621
+ @propagate_inbounds function setindex! (A:: BandedMatrix , V:: AbstractMatrix , kr:: AbstractRange , jr:: AbstractRange )
628
622
@boundscheck checkbounds (A, kr, jr)
629
623
@boundscheck checkdimensions (kr, jr, V)
630
624
@boundscheck checkbandmatch (A, V, kr, jr)
650
644
651
645
652
646
function convert (:: Type{Matrix} , A:: BandedMatrix )
653
- ret= zeros (eltype (A),size (A, 1 ), size (A, 2 ))
654
- for j = 1 : size (ret, 2 ), k = colrange (ret,j)
647
+ ret= zeros (eltype (A), size (A))
648
+ for j = rowsupport (A ), k = colrange (ret,j)
655
649
@inbounds ret[k,j] = A[k,j]
656
650
end
657
651
ret
@@ -787,14 +781,12 @@ end
787
781
bandwidths (S:: SubArray{T,2,<:AbstractMatrix,I} ) where {T,I<: Tuple{Vararg{AbstractUnitRange}} } =
788
782
min .(size (S) .- 1 , bandwidths (parent (S)) .+ (- 1 ,1 ) .* bandshift (S))
789
783
790
- @inline function inbands_getindex (S:: BandedSubBandedMatrix{T} , k:: Integer , j:: Integer ) where {T}
791
- @inbounds r = inbands_getindex (parent (S), reindex (parentindices (S), (k, j))... )
792
- r
784
+ @propagate_inbounds function inbands_getindex (S:: BandedSubBandedMatrix{T} , k:: Integer , j:: Integer ) where {T}
785
+ inbands_getindex (parent (S), reindex (parentindices (S), (k, j))... )
793
786
end
794
787
795
- @inline function inbands_setindex! (S:: BandedSubBandedMatrix{T} , v, k:: Integer , j:: Integer ) where {T}
796
- @inbounds r = inbands_setindex! (parent (S), v, reindex (parentindices (S), (k, j))... )
797
- r
788
+ @propagate_inbounds function inbands_setindex! (S:: BandedSubBandedMatrix{T} , v, k:: Integer , j:: Integer ) where {T}
789
+ inbands_setindex! (parent (S), v, reindex (parentindices (S), (k, j))... )
798
790
end
799
791
800
792
0 commit comments