@@ -951,27 +951,36 @@ _banded_axpy!(a::Number, X::AbstractMatrix, Y::AbstractMatrix, notbandedX, notba
951
951
Xl, Xu = bandwidths (X)
952
952
Yl, Yu = bandwidths (Y)
953
953
954
+ if - Xl > Xu #= no bands in X =#
955
+ return Y
956
+ end
957
+
954
958
@boundscheck if Xl > Yl
955
- # test that all entries are zero in extra bands
956
- for j= 1 : size (X, 2 ),k= max (1 ,j+ Yl+ 1 ): min (j+ Xl,n)
959
+ # test that all entries are zero in extra bands below the diagonal
960
+ for j= rowsupport (X ),k= max (1 ,j+ Yl+ 1 ): min (j+ Xl,n)
957
961
if inbands_getindex (X, k, j) ≠ 0
958
- throw (BandError (X , (k,j)))
962
+ throw (BandError (Y , (k,j)))
959
963
end
960
964
end
961
965
end
962
966
@boundscheck if Xu > Yu
963
- # test that all entries are zero in extra bands
964
- for j= 1 : size (X, 2 ),k= max (1 ,j- Xu): min (j- Yu- 1 ,n)
967
+ # test that all entries are zero in extra bands above the diagonal
968
+ for j= rowsupport (X ),k= max (1 ,j- Xu): min (j- Yu- 1 ,n)
965
969
if inbands_getindex (X, k, j) ≠ 0
966
- throw (BandError (X , (k,j)))
970
+ throw (BandError (Y , (k,j)))
967
971
end
968
972
end
969
973
end
970
974
975
+ if - Yl > Yu #= no bands in Y =#
976
+ return Y
977
+ end
978
+
979
+ # only fill overlapping bands
971
980
l = min (Xl,Yl)
972
981
u = min (Xu,Yu)
973
982
974
- @inbounds for j= 1 : m, k= max (1 ,j- u): min (n,j+ l)
983
+ @inbounds for j= rowsupport (X), k= max (1 ,j- u): min (n,j+ l)
975
984
inbands_setindex! (Y, a* inbands_getindex (X,k,j) + inbands_getindex (Y,k,j) ,k, j)
976
985
end
977
986
Y
@@ -981,7 +990,7 @@ function banded_dense_axpy!(a::Number, X::AbstractMatrix, Y::AbstractMatrix)
981
990
if size (X) != size (Y)
982
991
throw (DimensionMismatch (" +" ))
983
992
end
984
- @inbounds for j= 1 : size (X, 2 ), k= colrange (X,j)
993
+ @inbounds for j= rowsupport (X), k= colrange (X,j)
985
994
Y[k,j] += a* inbands_getindex (X,k,j)
986
995
end
987
996
Y
0 commit comments