@@ -659,14 +659,19 @@ end
659
659
# disambiguation methods: * of Diagonal and Adj/Trans AbsVec
660
660
* (x:: Adjoint{<:Any,<:AbstractVector} , D:: Diagonal ) = Adjoint (map ((t,s) -> t' * s, D. diag, parent (x)))
661
661
* (x:: Transpose{<:Any,<:AbstractVector} , D:: Diagonal ) = Transpose (map ((t,s) -> transpose (t)* s, D. diag, parent (x)))
662
- * (x:: Adjoint{<:Any,<:AbstractVector} , D:: Diagonal , y:: AbstractVector ) =
663
- mapreduce (t -> t[1 ]* t[2 ]* t[3 ], + , zip (x, D. diag, y))
664
- * (x:: Transpose{<:Any,<:AbstractVector} , D:: Diagonal , y:: AbstractVector ) =
665
- mapreduce (t -> t[1 ]* t[2 ]* t[3 ], + , zip (x, D. diag, y))
666
- function dot (x:: AbstractVector , D:: Diagonal , y:: AbstractVector )
667
- mapreduce (t -> dot (t[1 ], t[2 ], t[3 ]), + , zip (x, D. diag, y))
662
+ * (x:: Adjoint{<:Any,<:AbstractVector} , D:: Diagonal , y:: AbstractVector ) = _mapreduce_prod (* , x, D, y)
663
+ * (x:: Transpose{<:Any,<:AbstractVector} , D:: Diagonal , y:: AbstractVector ) = _mapreduce_prod (* , x, D, y)
664
+ dot (x:: AbstractVector , D:: Diagonal , y:: AbstractVector ) = _mapreduce_prod (dot, x, D, y)
665
+
666
+ function _mapreduce_prod (f, x, D:: Diagonal , y)
667
+ if isempty (x) && isempty (D) && isempty (y)
668
+ return zero (Base. promote_op (f, eltype (x), eltype (D), eltype (y)))
669
+ else
670
+ return mapreduce (t -> f (t[1 ], t[2 ], t[3 ]), + , zip (x, D. diag, y))
671
+ end
668
672
end
669
673
674
+
670
675
function cholesky! (A:: Diagonal , :: Val{false} = Val (false ); check:: Bool = true )
671
676
info = 0
672
677
for (i, di) in enumerate (A. diag)
0 commit comments