-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use zero in istriu, istril methods #19399
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 |
---|---|---|
|
@@ -870,8 +870,9 @@ true | |
""" | ||
function istriu(A::AbstractMatrix) | ||
m, n = size(A) | ||
z = zero(eltype(A)) | ||
for j = 1:min(n,m-1), i = j+1:m | ||
if A[i,j] != 0 | ||
if A[i,j] != z | ||
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. Use 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. probably a typo but I guess 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. Indeed |
||
return false | ||
end | ||
end | ||
|
@@ -905,8 +906,9 @@ true | |
""" | ||
function istril(A::AbstractMatrix) | ||
m, n = size(A) | ||
z = zero(eltype(A)) | ||
for j = 2:n, i = 1:min(j-1,m) | ||
if A[i,j] != 0 | ||
if A[i,j] != z | ||
return false | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make this one
because then you use the instance instead of the type to create the zero. Not all types support
zero
, e.g.Matrix
.