Skip to content
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

unused z array in entropy #938

Closed
feanor12 opened this issue Oct 3, 2024 · 2 comments
Closed

unused z array in entropy #938

feanor12 opened this issue Oct 3, 2024 · 2 comments

Comments

@feanor12
Copy link

feanor12 commented Oct 3, 2024

function entropy(p::AbstractArray{T}) where T<:Real
s = zero(T)
z = zero(T)
for i = 1:length(p)
@inbounds pi = p[i]
if pi > z
s += pi * log(pi)
end
end
return -s
end

@devmotion
Copy link
Member

devmotion commented Oct 3, 2024

z here is not an array but a zero value of the same type as the elements in the array p. It is used in line 434.

@feanor12
Copy link
Author

feanor12 commented Oct 3, 2024

I think I understand it now. Thank you!

@feanor12 feanor12 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants