Skip to content

Commit b425454

Browse files
authored
compare to 0/1 instead of zero/one (#32)
1 parent 3b3cd69 commit b425454

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/LinearMaps.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ Base.length(A::LinearMap) = size(A)[1] * size(A)[2]
2222
Base.:(*)(A::LinearMap, x::AbstractVector) = mul!(similar(x, promote_type(eltype(A), eltype(x)), size(A, 1)), A, x)
2323
function LinearAlgebra.mul!(y::AbstractVector, A::LinearMap{T}, x::AbstractVector, α::Number=one(T), β::Number=zero(T)) where {T}
2424
length(y) == size(A, 1) || throw(DimensionMismatch("mul!"))
25-
if α == one(α)
26-
β == zero(β) && (A_mul_B!(y, A, x); return y)
27-
β == one(β) && (y .+= A * x; return y)
25+
if α == 1
26+
β == 0 && (A_mul_B!(y, A, x); return y)
27+
β == 1 && (y .+= A * x; return y)
2828
# β != 0, 1
2929
rmul!(y, β)
3030
y .+= A * x
3131
return y
32-
elseif α == zero(α)
33-
β == zero(β) && (fill!(y, zero(eltype(y))); return y)
34-
β == one(β) && return y
32+
elseif α == 0
33+
β == 0 && (fill!(y, zero(eltype(y))); return y)
34+
β == 1 && return y
3535
# β != 0, 1
3636
rmul!(y, β)
3737
return y
3838
else # α != 0, 1
39-
β == zero(β) && (A_mul_B!(y, A, x); rmul!(y, α); return y)
40-
β == one(β) && (y .+= rmul!(A * x, α); return y)
39+
β == 0 && (A_mul_B!(y, A, x); rmul!(y, α); return y)
40+
β == 1 && (y .+= rmul!(A * x, α); return y)
4141
# β != 0, 1
4242
rmul!(y, β)
4343
y .+= rmul!(A * x, α)

0 commit comments

Comments
 (0)