Skip to content

Commit 96b872d

Browse files
authored
Merge pull request #114 from JuliaParallel/anj/arith
Use promote_op instead of arithtype
2 parents 5e37ba9 + c66793b commit 96b872d

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/linalg.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,35 @@ Ac_mul_B!(α::Number, A::DMatrix, B::AbstractMatrix, β::Number, C::DMatrix) = _
254254
At_mul_B!::Number, A::DMatrix, B::AbstractMatrix, β::Number, C::DMatrix) = _matmatmul!(α, A, B, β, C, 'T')
255255
At_mul_B!(C::DMatrix, A::DMatrix, B::AbstractMatrix) = At_mul_B!(one(eltype(C)), A, B, zero(eltype(C)), C)
256256

257+
_matmul_op = (t,s) -> t*s + t*s
258+
257259
function (*)(A::DMatrix, x::AbstractVector)
258-
T = promote_type(Base.LinAlg.arithtype(eltype(A)), Base.LinAlg.arithtype(eltype(x)))
260+
T = Base.promote_op(_matmul_op, eltype(A), eltype(x))
259261
y = DArray(I -> Array(T, map(length, I)), (size(A, 1),), procs(A)[:,1], (size(procs(A), 1),))
260262
return A_mul_B!(one(T), A, x, zero(T), y)
261263
end
262264
function (*)(A::DMatrix, B::AbstractMatrix)
263-
T = promote_type(Base.LinAlg.arithtype(eltype(A)), Base.LinAlg.arithtype(eltype(B)))
264-
C = DArray(I -> Array(T, map(length, I)), (size(A, 1), size(B, 2)), procs(A)[:,1:min(size(procs(A), 2), size(procs(B), 2))], (size(procs(A), 1), min(size(procs(A), 2), size(procs(B), 2))))
265+
T = Base.promote_op(_matmul_op, eltype(A), eltype(B))
266+
C = DArray(I -> Array(T, map(length, I)),
267+
(size(A, 1), size(B, 2)),
268+
procs(A)[:,1:min(size(procs(A), 2), size(procs(B), 2))],
269+
(size(procs(A), 1), min(size(procs(A), 2), size(procs(B), 2))))
265270
return A_mul_B!(one(T), A, B, zero(T), C)
266271
end
267272

268273
function Ac_mul_B(A::DMatrix, x::AbstractVector)
269-
T = promote_type(Base.LinAlg.arithtype(eltype(A)), Base.LinAlg.arithtype(eltype(x)))
270-
y = DArray(I -> Array(T, map(length, I)), (size(A, 2),), procs(A)[1,:], (size(procs(A), 2),))
274+
T = Base.promote_op(_matmul_op, eltype(A), eltype(x))
275+
y = DArray(I -> Array(T, map(length, I)),
276+
(size(A, 2),),
277+
procs(A)[1,:],
278+
(size(procs(A), 2),))
271279
return Ac_mul_B!(one(T), A, x, zero(T), y)
272280
end
273281
function Ac_mul_B(A::DMatrix, B::AbstractMatrix)
274-
T = promote_type(Base.LinAlg.arithtype(eltype(A)), Base.LinAlg.arithtype(eltype(B)))
275-
C = DArray(I -> Array(T, map(length, I)), (size(A, 2), size(B, 2)), procs(A)[1:min(size(procs(A), 1), size(procs(B), 2)),:], (size(procs(A), 2), min(size(procs(A), 1), size(procs(B), 2))))
282+
T = Base.promote_op(_matmul_op, eltype(A), eltype(B))
283+
C = DArray(I -> Array(T, map(length, I)), (size(A, 2),
284+
size(B, 2)),
285+
procs(A)[1:min(size(procs(A), 1), size(procs(B), 2)),:],
286+
(size(procs(A), 2), min(size(procs(A), 1), size(procs(B), 2))))
276287
return Ac_mul_B!(one(T), A, B, zero(T), C)
277288
end

0 commit comments

Comments
 (0)