4040
4141function _banded_muladd! (α, A, x:: AbstractVector , β, y)
4242 m, n = size (A)
43- (length (y) ≠ m || length (x) ≠ n) && throw (DimensionMismatch (" *" ))
4443 l, u = bandwidths (A)
4544 if - l > u # no bands
4645 _fill_lmul! (β, y)
@@ -51,40 +50,43 @@ function _banded_muladd!(α, A, x::AbstractVector, β, y)
5150 elseif u < 0 # with -l <= u < 0, that is, all bands lie below the diagnoal.
5251 # E.g. (l,u) = (2,-1)
5352 # set lview = l + u >= 0 and uview = 0
54- y[1 : - u] . = zero ( eltype (y ))
53+ _fill_lmul! (β, @view ( y[1 : - u]))
5554 _banded_gbmv! (' N' , α, view (A, 1 - u: m, :), x, β, view (y, 1 - u: m))
5655 y
5756 else
5857 _banded_gbmv! (' N' , α, A, x, β, y)
5958 end
6059end
6160
62- materialize! (M:: BlasMatMulVecAdd{<:BandedColumnMajor,<:AbstractStridedLayout,<:AbstractStridedLayout,T} ) where T<: BlasFloat =
61+ function materialize! (M:: BlasMatMulVecAdd{<:BandedColumnMajor,<:AbstractStridedLayout,<:AbstractStridedLayout,<:BlasFloat} )
62+ checkdimensions (M)
6363 _banded_muladd! (M. α, M. A, M. B, M. β, M. C)
64+ end
6465
6566function _banded_muladd_row! (tA, α, At, x, β, y)
6667 n, m = size (At)
67- (length (y) ≠ m || length (x) ≠ n) && throw (DimensionMismatch (" *" ))
6868 u, l = bandwidths (At)
6969 if - l > u # no bands
7070 _fill_lmul! (β, y)
7171 elseif l < 0
7272 _banded_gbmv! (tA, α, view (At, 1 - l: n, :,), view (x, 1 - l: n), β, y)
7373 elseif u < 0
74- y[1 : - u] . = zero ( eltype (y ))
74+ _fill_lmul! (β, @view ( y[1 : - u]))
7575 _banded_gbmv! (tA, α, view (At, :, 1 - u: m), x, β, view (y, 1 - u: m))
7676 y
7777 else
7878 _banded_gbmv! (tA, α, At, x, β, y)
7979 end
8080end
8181
82- function materialize! (M:: BlasMatMulVecAdd{<:BandedRowMajor,<:AbstractStridedLayout,<:AbstractStridedLayout,T} ) where T<: BlasFloat
82+ function materialize! (M:: BlasMatMulVecAdd{<:BandedRowMajor,<:AbstractStridedLayout,<:AbstractStridedLayout,<:BlasFloat} )
83+ checkdimensions (M)
8384 α, A, x, β, y = M. α, M. A, M. B, M. β, M. C
8485 _banded_muladd_row! (' T' , α, transpose (A), x, β, y)
8586end
8687
87- function materialize! (M:: BlasMatMulVecAdd{<:ConjLayout{<:BandedRowMajor},<:AbstractStridedLayout,<:AbstractStridedLayout,T} ) where T<: BlasComplex
88+ function materialize! (M:: BlasMatMulVecAdd{<:ConjLayout{<:BandedRowMajor},<:AbstractStridedLayout,<:AbstractStridedLayout,<:BlasComplex} )
89+ checkdimensions (M)
8890 α, A, x, β, y = M. α, M. A, M. B, M. β, M. C
8991 _banded_muladd_row! (' C' , α, A' , x, β, y)
9092end
@@ -173,25 +175,17 @@ const ConjOrBandedLayout = Union{AbstractBandedLayout,ConjLayout{<:AbstractBande
173175const ConjOrBandedColumnMajor = Union{<: BandedColumnMajor ,ConjLayout{<: BandedColumnMajor }}
174176
175177function _banded_muladd! (α:: T , A, B:: AbstractMatrix , β, C) where T
176- Am, An = size (A)
177- Bm, Bn = size (B)
178- if An != Bm || size (C, 1 ) != Am || size (C, 2 ) != Bn
179- throw (DimensionMismatch (" *" ))
180- end
181-
182- Al, Au = bandwidths (A)
183- Bl, Bu = bandwidths (B)
184-
185178 gbmm! (' N' , ' N' , α, A, B, β, C)
186-
187179 C
188180end
189181
190182materialize! (M:: BlasMatMulMatAdd{<:AbstractBandedLayout,<:AbstractBandedLayout,<:BandedColumnMajor} ) =
191183 materialize! (MulAdd (M. α, convert (DefaultBandedMatrix,M. A), convert (DefaultBandedMatrix,M. B), M. β, M. C))
192184
193- materialize! (M:: BlasMatMulMatAdd{<:BandedColumnMajor,<:BandedColumnMajor,<:BandedColumnMajor} ) =
185+ function materialize! (M:: BlasMatMulMatAdd{<:BandedColumnMajor,<:BandedColumnMajor,<:BandedColumnMajor} )
186+ checkdimensions (M)
194187 _banded_muladd! (M. α, M. A, M. B, M. β, M. C)
188+ end
195189
196190
197191# function generally_banded_matmatmul!(C::AbstractMatrix{T}, tA::Val, tB::Val, A::AbstractMatrix{U}, B::AbstractMatrix{V}) where {T, U, V}
246240# ## BandedMatrix * dense matrix
247241
248242function materialize! (M:: MatMulMatAdd{<:BandedColumns, <:AbstractColumnMajor, <:AbstractColumnMajor} )
243+ checkdimensions (M)
249244 α, β, A, B, C = M. α, M. β, M. A, M. B, M. C
250245
251- mA, nA = size (A)
252- mB, nB = size (B)
253- mC, nC = size (C)
254- (nA == mB && mC == mA && nC == nB) || throw (DimensionMismatch (" A has size ($mA , $nA ), B has size ($mB , $nB ), C has size ($mC , $nC )" ))
255-
256246 if iszero (α)
257247 lmul! (β, C)
258248 else
@@ -265,11 +255,8 @@ function materialize!(M::MatMulMatAdd{<:BandedColumns, <:AbstractColumnMajor, <:
265255end
266256
267257function materialize! (M:: MatMulMatAdd{<:AbstractColumnMajor, <:BandedColumns, <:AbstractColumnMajor} )
258+ checkdimensions (M)
268259 α, β, A, B, C = M. α, M. β, M. A, M. B, M. C
269- mA, nA = size (A)
270- mB, nB = size (B)
271- mC, nC = size (C)
272- (nA == mB && mC == mA && nC == nB) || throw (DimensionMismatch (" A has size ($mA , $nA ), B has size ($mB , $nB ), C has size ($mC , $nC )" ))
273260
274261 if iszero (α)
275262 lmul! (β, C)
0 commit comments