-
-
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
Improve isassigned
implementation
#49827
Changes from all commits
d172e27
735f0eb
1615fe6
9250d47
d75d701
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 |
---|---|---|
|
@@ -413,6 +413,19 @@ end | |
det(A::SymTridiagonal; shift::Number=false) = det_usmani(A.ev, A.dv, A.ev, shift) | ||
logabsdet(A::SymTridiagonal; shift::Number=false) = logabsdet(ldlt(A; shift=shift)) | ||
|
||
@inline function Base.isassigned(A::SymTridiagonal, i::Int, j::Int) | ||
@boundscheck checkbounds(Bool, A, i, j) || return false | ||
if i == j | ||
return @inbounds isassigned(A.dv, i) | ||
elseif i == j + 1 | ||
return @inbounds isassigned(A.ev, j) | ||
elseif i + 1 == j | ||
return @inbounds isassigned(A.ev, i) | ||
else | ||
return true | ||
end | ||
end | ||
|
||
@inline function getindex(A::SymTridiagonal{T}, i::Integer, j::Integer) where T | ||
@boundscheck checkbounds(A, i, j) | ||
if i == j | ||
|
@@ -604,6 +617,19 @@ function diag(M::Tridiagonal{T}, n::Integer=0) where T | |
end | ||
end | ||
|
||
@inline function Base.isassigned(A::Tridiagonal, i::Int, j::Int) | ||
@boundscheck checkbounds(A, i, j) | ||
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. is this ok? in all other 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. You're right. That should be fixed |
||
if i == j | ||
return @inbounds isassigned(A.d, i) | ||
elseif i == j + 1 | ||
return @inbounds isassigned(A.dl, j) | ||
elseif i + 1 == j | ||
return @inbounds isassigned(A.du, i) | ||
else | ||
return true | ||
end | ||
end | ||
|
||
@inline function getindex(A::Tridiagonal{T}, i::Integer, j::Integer) where T | ||
@boundscheck checkbounds(A, i, j) | ||
if i == j | ||
|
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.
Is this true for StepRange? I think it might only be true for Unit ranges
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'm not aware of an instance where it could produce an undefined variable
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.
oh, right, I was thinking of values, not index