Skip to content

replace !iszero(x) with x !== zero(x) - #7

Open
davidschlegel wants to merge 3 commits into
QuantumKitHub:mainfrom
davidschlegel:master
Open

replace !iszero(x) with x !== zero(x)#7
davidschlegel wants to merge 3 commits into
QuantumKitHub:mainfrom
davidschlegel:master

Conversation

@davidschlegel

Copy link
Copy Markdown

To work with symbolic numbers.

To work with symbolic numbers.
Comment threadsrc/sparsearray.jl Outdated
@inline function increaseindex!(a::SparseArray{T,N}, v, I::CartesianIndex{N}) where {T,N}
@boundscheck checkbounds(a, I)
iszero(v) && return
v !== zero(v) && return

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should be v == zero(v) of course.

Comment threadsrc/sparsearray.jl Outdated
currentv = h.vals[index]
newv = currentv + convert(T, v)
if iszero(newv)
if v !== zero(newv)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should be v == zero(v) of course.

Comment threadsrc/sparsearray.jl Outdated
d = SparseArray{T,N}(undef, size(a))
for I in CartesianIndices(a)
iszero(a[I]) && continue
v !== zero(a[I]) && continue

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should be v == zero(v) of course.

@Jutho

Copy link
Copy Markdown
Member

Sorry for not responding sooner; could you briefly comment on why iszero does not work? Also, you replace !iszero with !== whereas in iszero with ==, but these two are not opposites. The negation of == is !=, whereas !== is the negation of ===. Is that intentional?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@davidschlegel@Jutho