|
87 | 87 | """ |
88 | 88 | gen_by_access(expr_gen, a::Type{<:AbstractArray}, b::Type{<:AbstractArray}) |
89 | 89 |
|
90 | | -Similar to gen_by_access with only one type argument. The difference is that tests for both |
| 90 | +Similar to `gen_by_access` with only one type argument. The difference is that tests for both |
91 | 91 | arrays of type `a` and `b` are generated and `expr_gen` receives two access arguments, |
92 | 92 | first for matrix `a` and the second for matrix `b`. |
93 | 93 | """ |
@@ -175,7 +175,10 @@ function gen_by_access(expr_gen, a::Type{<:Diagonal{<:Any, <:StaticVector}}, b:: |
175 | 175 | end |
176 | 176 |
|
177 | 177 |
|
178 | | -""" Size that stores whether a Matrix is a Transpose |
| 178 | +""" |
| 179 | + TSize{S,T} |
| 180 | +
|
| 181 | +Size that stores whether a Matrix is a Transpose. |
179 | 182 | Useful when selecting multiplication methods, and avoiding allocations when dealing with |
180 | 183 | the `Transpose` type by passing around the original matrix. |
181 | 184 | Should pair with `parent`. |
@@ -245,11 +248,19 @@ const StaticVecOrMatLikeForFiveArgMulDest{T} = Union{ |
245 | 248 | return _mul!(TSize(dest), mul_parent(dest), Size(A), Size(B), A, B, NoMulAdd{TMul, TDest}()) |
246 | 249 | end |
247 | 250 |
|
248 | | -"Calculate the product of the dimensions being multiplied. Useful as a heuristic for unrolling." |
| 251 | +""" |
| 252 | + multiplied_dimension(A, B) |
| 253 | +
|
| 254 | +Calculate the product of the dimensions being multiplied. Useful as a heuristic for unrolling. |
| 255 | +""" |
249 | 256 | @inline multiplied_dimension(A::Type{<:StaticVecOrMatLike}, B::Type{<:StaticVecOrMatLike}) = |
250 | 257 | prod(size(A)) * size(B,2) |
251 | 258 |
|
252 | | -"Validate the dimensions of a matrix multiplication, including matrix-vector products" |
| 259 | +""" |
| 260 | + check_dims(sc, sa, sb) |
| 261 | +
|
| 262 | +Validate the dimensions of a matrix multiplication, including matrix-vector products |
| 263 | +""" |
253 | 264 | function check_dims(::Size{sc}, ::Size{sa}, ::Size{sb}) where {sa,sb,sc} |
254 | 265 | if sb[1] != sa[2] || sc[1] != sa[1] |
255 | 266 | return false |
@@ -356,10 +367,12 @@ function uplo_access(sa, asym, k, j, uplo) |
356 | 367 | end |
357 | 368 | end |
358 | 369 |
|
359 | | -""" Combine left and right sides of an assignment expression, short-cutting |
360 | | - lhs = α * rhs + β * lhs, |
361 | | - element-wise. |
362 | | -If α = 1, the multiplication by α is removed. If β = 0, the second rhs term is removed. |
| 370 | +""" |
| 371 | + _muladd_expr(lhs, rhs, coeffs) |
| 372 | +
|
| 373 | +Combine left and right sides of an assignment expression, short-cutting |
| 374 | +`lhs = α * rhs + β * lhs`, element-wise. |
| 375 | +If `α = 1`, the multiplication by `α` is removed. If `β = 0`, the second `rhs` term is removed. |
363 | 376 | """ |
364 | 377 | function _muladd_expr(lhs::Array{Expr}, rhs::Array{Expr}, ::Type{<:AlphaBeta}) |
365 | 378 | @assert length(lhs) == length(rhs) |
|
378 | 391 | [:($(lhs[k]) = $(rhs[k])) for k = 1:length(lhs)] |
379 | 392 | end |
380 | 393 |
|
381 | | -"Obtain an expression for the linear index of var[k,j], taking transposes into account" |
| 394 | +""" |
| 395 | + _lind(var, A, k, j) |
| 396 | +
|
| 397 | +Obtain an expression for the linear index of `var[k,j]`, taking transposes into account. |
| 398 | +""" |
382 | 399 | function _lind(var::Symbol, A::Type{TSize{sa,tA}}, k::Int, j::Int) where {sa,tA} |
383 | 400 | ula = uplo_access(sa, var, k, j, tA) |
384 | 401 | if ula.head == :call && ula.args[1] == :transpose |
|
0 commit comments