@@ -24,6 +24,10 @@ SimpleOrSpecialOrAdjMat{T, M} = Union{M,
24
24
AdjOrTranspMat{T, <: SpecialMat{T,<:M} },
25
25
SpecialMat{T,<: AdjOrTranspMat{T,<:M} }}
26
26
27
+ const SpecialMatrices = (LowerTriangular, UpperTriangular,
28
+ UnitLowerTriangular, UnitUpperTriangular,
29
+ Symmetric, Hermitian)
30
+
27
31
# unwraps matrix A from Adjoint/Transpose transform
28
32
unwrap_trans (A:: AbstractMatrix ) = A
29
33
unwrap_trans (A:: Union{Adjoint, Transpose} ) = unwrap_trans (parent (A))
@@ -219,17 +223,45 @@ end
219
223
# sparse * sparse overloads, have to be more specific than
220
224
# the ones in SparseArrays.jl to avoid ambiguity
221
225
222
- (* )(A:: SparseMat{T} , B:: SparseMat{T} ) where T =
223
- spmatmul_sparse (A, B)
226
+ for Amat in (nothing , SpecialMatrices... ), Bmat in (nothing , SpecialMatrices... )
227
+ Atype = ! isnothing (Amat) ? :($ Amat{T,S}) : :S
228
+ tAtype = ! isnothing (Amat) ? :($ Amat{T, <: AdjOrTranspMat{T, S} }) : nothing
229
+ Btype = ! isnothing (Bmat) ? :($ Bmat{T,S}) : :S
230
+ tBtype = ! isnothing (Bmat) ? :($ Bmat{T, <: AdjOrTranspMat{T, S} }) : nothing
231
+
232
+ @eval (* )(A:: $Atype , B:: $Btype ) where {T <: BlasFloat , S <: SparseMat{T} } =
233
+ spmatmul_sparse (A, B)
234
+
235
+ @eval (* )(A:: AdjOrTranspMat{T, $Atype} , B:: $Btype ) where {T <: BlasFloat , S <: SparseMat{T} } =
236
+ spmatmul_sparse (A, B)
224
237
225
- (* )(A:: AdjOrTranspMat{T, S} , B :: S ) where {T <: BlasFloat , S <: SparseMat{T} } =
226
- spmatmul_sparse (A, B)
238
+ @eval (* )(A:: $Atype , B :: AdjOrTranspMat{T, $Btype} ) where {T <: BlasFloat , S <: SparseMat{T} } =
239
+ spmatmul_sparse (A, B)
227
240
228
- (* )(A:: S , B:: AdjOrTranspMat{T, S} ) where {T <: BlasFloat , S <: SparseMat{T} } =
229
- spmatmul_sparse (A, B)
241
+ @eval (* )(A:: AdjOrTranspMat{T, $Atype} , B:: AdjOrTranspMat{T, $Btype} ) where {T <: BlasFloat , S <: SparseMat{T} } =
242
+ spmatmul_sparse (A, B)
243
+
244
+ if tAtype != = nothing
245
+ @eval (* )(A:: $tAtype , B:: $Btype ) where {T <: BlasFloat , S <: SparseMat{T} } =
246
+ spmatmul_sparse (A, B)
247
+
248
+ @eval (* )(A:: $tAtype , B:: AdjOrTranspMat{T, $Btype} ) where {T <: BlasFloat , S <: SparseMat{T} } =
249
+ spmatmul_sparse (A, B)
250
+ end
230
251
231
- (* )(A:: AdjOrTranspMat{T, S} , B:: AdjOrTranspMat{T, S} ) where {T <: BlasFloat , S <: SparseMat{T} } =
232
- spmatmul_sparse (A, B)
252
+ if tBtype != = nothing
253
+ @eval (* )(A:: $Atype , B:: $tBtype ) where {T <: BlasFloat , S <: SparseMat{T} } =
254
+ spmatmul_sparse (A, B)
255
+
256
+ @eval (* )(A:: AdjOrTranspMat{T, $Atype} , B:: $tBtype ) where {T <: BlasFloat , S <: SparseMat{T} } =
257
+ spmatmul_sparse (A, B)
258
+ end
259
+
260
+ if tAtype != = nothing && tBtype != = nothing
261
+ @eval (* )(A:: $tAtype , B:: $tBtype ) where {T <: BlasFloat , S <: SparseMat{T} } =
262
+ spmatmul_sparse (A, B)
263
+ end
264
+ end
233
265
234
266
if VERSION < v " 1.11" # in 1.11 these wrappers are already defined in LinearAlgebra
235
267
@@ -245,9 +277,7 @@ function (\)(A::Union{S, AdjOrTranspMat{T, S}}, B::StridedMatrix{T}) where {T <:
245
277
return ldiv! (C, A, B)
246
278
end
247
279
248
- for mat in (LowerTriangular, UpperTriangular,
249
- UnitLowerTriangular, UnitUpperTriangular,
250
- Symmetric, Hermitian)
280
+ for mat in SpecialMatrices
251
281
252
282
@eval function (\ )(A:: Union{$mat{T, S}, AdjOrTranspMat{T, $mat{T, S}}, $mat{T, <:AdjOrTranspMat{T, S}}} ,
253
283
x:: StridedVector{T}
0 commit comments