-
-
Notifications
You must be signed in to change notification settings - Fork 38
Fix unitful 3-arg *
#1499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix unitful 3-arg *
#1499
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,7 +605,7 @@ function generic_syrk!(C::StridedMatrix{T}, A::StridedVecOrMat{T}, conjugate::Bo | |
| aA_11 = abs2(A[1,1]) | ||
| fill!(UpperTriangular(C), zero(aA_11 + aA_11)) | ||
| end | ||
| iszero(α) && return C | ||
| (iszero(α) || isempty(A)) && return C | ||
| @inbounds if !conjugate | ||
| if aat | ||
| for k ∈ 1:n, j ∈ 1:m | ||
|
|
@@ -1075,7 +1075,8 @@ function __generic_matvecmul!(::typeof(identity), C::AbstractVector, A::Abstract | |
| elseif length(B) == 0 | ||
| C[i] = zero(eltype(C)) | ||
| else | ||
| C[i] = zero(A[i]*B[1] + A[i]*B[1]) | ||
| ci = @stable_muladdmul MulAddMul(alpha,false)(A[i]*B[1]) | ||
| C[i] = zero(ci + ci) | ||
| end | ||
| end | ||
| if !iszero(alpha) | ||
|
|
@@ -1147,12 +1148,12 @@ function _generic_matmatmul_nonadjtrans!(C, A, B, alpha, beta) | |
| for j in axes(C, 2) | ||
| B_1j = B[b1, j] | ||
| for i in axes(C, 1) | ||
| C_ij = A[i, a1] * B_1j | ||
| C_ij = @stable_muladdmul MulAddMul(alpha, false)(A[i, a1] * B_1j) | ||
| C[i,j] = zero(C_ij + C_ij) | ||
| end | ||
| end | ||
| end | ||
| iszero(alpha) && return C | ||
| (iszero(alpha) || isempty(A) || isempty(B)) && return C | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why this is related. Appears safe, given that we've already dealt with But I'm confused about the case of nonzero beta and non-empty A,B in code just above. It seems that this code does
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in that part it does C = A*B*alpha + C*betaThis change is unrelated, it just avoids "running empty loops" in the sequel. |
||
| @inbounds for n in axes(B, 2), k in axes(B, 1) | ||
| # Balpha = B[k,n] * alpha, but we skip the multiplication in case isone(alpha) | ||
| Balpha = @stable_muladdmul MulAddMul(alpha, false)(B[k,n]) | ||
|
|
@@ -1167,21 +1168,21 @@ function _generic_matmatmul_adjtrans!(C, A, B, alpha, beta) | |
| t = _wrapperop(A) | ||
| pB = parent(B) | ||
| pA = parent(A) | ||
| if (!iszero(beta) || isempty(A) || isempty(B)) # return C*beta | ||
| if (!iszero(beta) || isempty(A) || isempty(B)) | ||
| _rmul_or_fill!(C, beta) | ||
| else # iszero(beta) && A and B are non-empty | ||
| a1 = firstindex(pA, 1) | ||
| b1 = firstindex(pB, 2) | ||
| for j in axes(C, 2) | ||
| tB_1j = t(pB[j, b1]) | ||
| for i in axes(C, 1) | ||
| C_ij = t(pA[a1, i]) * tB_1j | ||
| C_ij = @stable_muladdmul MulAddMul(alpha, false)(t(pA[a1, i]) * tB_1j) | ||
| C[i,j] = zero(C_ij + C_ij) | ||
| end | ||
| end | ||
| end | ||
| iszero(alpha) && return C | ||
| tmp = similar(C, axes(C, 2)) | ||
| (iszero(alpha) || isempty(A) || isempty(B)) && return C | ||
| tmp = similar(C, promote_op(matprod, typeof(first(A)), typeof(first(B))), axes(C, 2)) | ||
| ci = firstindex(C, 1) | ||
| ta = t(alpha) | ||
| if isone(ta) | ||
|
|
@@ -1434,7 +1435,7 @@ mat_vec_scalar(A::StridedMaybeAdjOrTransMat, x::StridedVector, γ) = _mat_vec_sc | |
| mat_vec_scalar(A::AdjOrTransAbsVec, x::StridedVector, γ) = (A * x) * γ | ||
|
|
||
| function _mat_vec_scalar(A, x, γ) | ||
| T = promote_type(eltype(A), eltype(x), typeof(γ)) | ||
| T = promote_op(*, promote_op(matprod, eltype(A), eltype(x)), typeof(γ)) | ||
| C = similar(A, T, axes(A,1)) | ||
| mul!(C, A, x, γ, false) | ||
| end | ||
|
|
@@ -1444,7 +1445,7 @@ mat_mat_scalar(A::StridedMaybeAdjOrTransMat, B::StridedMaybeAdjOrTransMat, γ) = | |
| _mat_mat_scalar(A, B, γ) | ||
|
|
||
| function _mat_mat_scalar(A, B, γ) | ||
| T = promote_type(eltype(A), eltype(B), typeof(γ)) | ||
| T = promote_op(*, promote_op(matprod, eltype(A), eltype(B)), typeof(γ)) | ||
dkarrasch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| C = similar(A, T, axes(A,1), axes(B,2)) | ||
| mul!(C, A, B, γ, false) | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.