-
-
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
Fix edge cases in SymTridiagonal
when ev
has an extra element (+
, -
, iszero
, isone
, etc.)
#42472
Merged
dkarrasch
merged 3 commits into
JuliaLang:master
from
mcognetta:symtridiag_ev_last_element
Oct 8, 2021
Merged
Fix edge cases in SymTridiagonal
when ev
has an extra element (+
, -
, iszero
, isone
, etc.)
#42472
dkarrasch
merged 3 commits into
JuliaLang:master
from
mcognetta:symtridiag_ev_last_element
Oct 8, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Seems like there are a few more that need to be added here: julia> SymTridiagonal(rand(3), rand(2)) + SymTridiagonal(rand(3), rand(3))
ERROR: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(2),), b has dims (Base.OneTo(3),), mismatch at 1")
Stacktrace:
[1] promote_shape
@ ./indices.jl:178 [inlined]
[2] promote_shape
@ ./indices.jl:169 [inlined]
[3] +(A::Vector{Float64}, Bs::Vector{Float64})
@ Base ./arraymath.jl:45
[4] +(A::SymTridiagonal{Float64, Vector{Float64}}, B::SymTridiagonal{Float64, Vector{Float64}})
@ LinearAlgebra ~/github/julia-dev/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/tridiag.jl:210
[5] top-level scope
@ REPL[2]:1
julia> SymTridiagonal(rand(3), rand(2)) - SymTridiagonal(rand(3), rand(3))
ERROR: DimensionMismatch("dimensions must match: a has dims (Base.OneTo(2),), b has dims (Base.OneTo(3),), mismatch at 1")
Stacktrace:
[1] promote_shape
@ ./indices.jl:178 [inlined]
[2] promote_shape
@ ./indices.jl:169 [inlined]
[3] -(A::Vector{Float64}, B::Vector{Float64})
@ Base ./arraymath.jl:38
[4] -(A::SymTridiagonal{Float64, Vector{Float64}}, B::SymTridiagonal{Float64, Vector{Float64}})
@ LinearAlgebra ~/github/julia-dev/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/tridiag.jl:211
[5] top-level scope
@ REPL[3]:1 |
mcognetta
changed the title
Fix edge cases in
Fix edge cases in Oct 3, 2021
SymTridiagonal
when ev
has an extra element (iszero
, isone
, etc.)SymTridiagonal
when ev
has an extra element (+
, -
, iszero
, isone
, etc.)
mcognetta
force-pushed
the
symtridiag_ev_last_element
branch
from
October 3, 2021 00:53
89aff82
to
6da5108
Compare
mcognetta
force-pushed
the
symtridiag_ev_last_element
branch
from
October 3, 2021 04:21
67953dd
to
d199de0
Compare
andreasnoack
approved these changes
Oct 6, 2021
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.
LGTM. There is a small conflict that needs to be resolved.
Should be good to go now. Thanks for the review. |
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Feb 22, 2022
…`, `-`, `iszero`, `isone`, etc.) (JuliaLang#42472)
LilithHafner
pushed a commit
to LilithHafner/julia
that referenced
this pull request
Mar 8, 2022
…`, `-`, `iszero`, `isone`, etc.) (JuliaLang#42472)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
SymTridiagonal
,ev
can have the same number of elements asdv
, but the last element inev
is typically ignored. This can, however, cause some issues for things that just check all elements ofev
. For example,iszero
,isone
, etc can all fail due to a particular choice of the final element ofev
, even though that element is not used.This PR fixes the issue for
iszero
,isone
,isdiag
,istriu
, andistril
. See also #41089.Update:
This bug is also present in some constructors (see JuliaLang/LinearAlgebra.jl#874) and in some binary operations (
+
/-
when one operand isSymTridiagonal
and the other beingTridiagonal
,Bidiagonal
, etc whenev
has the same number of elements asev
.This PR was updated to include fixes for these cases as well.
Head:
This PR: