Skip to content

Commit 63ba215

Browse files
refactor: switch to unrolled utils for band matrix multiplication
1 parent 05daa2b commit 63ba215

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/MatrixFields/band_matrix_row.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@ is_auto_broadcastable(::Type{BMR}) where {BMR <: BandMatrixRow} =
163163
add_auto_broadcasters(row::BandMatrixRow) = map(add_auto_broadcasters, row)
164164
drop_auto_broadcasters(row::BandMatrixRow) = map(drop_auto_broadcasters, row)
165165

166-
167-
@generated function (row::BandMatrixRow{ld, bw, T})(args::Vararg{Any, N}) where {ld, bw, T, N}
166+
function (row::BandMatrixRow{ld, bw, T})(args::Vararg{Any, N}) where {ld, bw, T, N}
168167
N == bw || error(
169-
"BandMatrixRow with bandwidth $bw expected $bw arguments, but got $N"
168+
"BandMatrixRow with bandwidth $bw expected $bw arguments, but got $N",
170169
)
171-
terms = [:(row.entries[$i] * args[$i]) for i in 1:bw]
172-
return Expr(:call, :+, terms...)
170+
171+
result = unrolled_sum(Iterators.zip(row.entries, args)) do (entry, arg)
172+
entry * arg
173+
end
174+
return result
173175
end

0 commit comments

Comments
 (0)