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

Fix rdiv of complex lhs by real factorizations #50671

Merged
merged 4 commits into from
Jul 29, 2023
Merged

Conversation

dkarrasch
Copy link
Member

This fixes overseen typos, contained in untested methods, and fixes JuliaLang/LinearAlgebra.jl#1019. The faulty methods were introduced in #46874 and need to be backported to v1.10.

@martinholters

Copy link
Member

@martinholters martinholters left a comment

Choose a reason for hiding this comment

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

The new methods all look good to me, but I haven't checked whether the removed ones leave any holes.

I think we should be able to extent this to Transpose, but I'm not totally sure. Try?

stdlib/LinearAlgebra/src/factorization.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/src/factorization.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/src/factorization.jl Show resolved Hide resolved
stdlib/LinearAlgebra/test/hessenberg.jl Show resolved Hide resolved
@dkarrasch
Copy link
Member Author

The "removed" rdiv!s have just moved. Instead of specializing on the factorization, I turned them into generic fallbacks. Transpose complex looks a bit weird, but I'll give it a try after CI finishes on the current status.

@martinholters
Copy link
Member

Transpose complex looks a bit weird

True, but transpose real is simply unnecessary given that it's equivalent to adjoint real.

Anyway, test failures look unrelated (though some of them are a bit scary), so this seems to be on a good track.

Co-authored-by: Martin Holters <martin@holters.name>
@dkarrasch dkarrasch added linear algebra Linear algebra bugfix This change fixes an existing bug backport 1.10 Change should be backported to the 1.10 release labels Jul 26, 2023
@martinholters
Copy link
Member

All green CI!

I'm not 100% sold this qualifies as a bugfix. Is there anything that gives a wrong result without this PR or gives an error while it used to work in an earlier version? But even if it does not, I'm still in favor of backporting, as 1.10 is not yet released and this indeed is cleanup to #46874 worth including in the release. (It also adds a feature, so I'd be reluctant to backport it to 1.10.1).

rdiv!(copy_similar(B, TFB), F)
end
# reinterpretation trick for complex lhs and real factorization
function (/)(B::Union{Matrix{Complex{T}},Adjoint{Complex{T},Vector{Complex{T}}},Transpose{Complex{T},Vector{Complex{T}}}}, F::Factorization{T}) where {T<:BlasReal}
Copy link
Member

Choose a reason for hiding this comment

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

Uh, this line is quite long. I'm not sure how best to wrap it though. The extreme other end would be

Suggested change
function (/)(B::Union{Matrix{Complex{T}},Adjoint{Complex{T},Vector{Complex{T}}},Transpose{Complex{T},Vector{Complex{T}}}}, F::Factorization{T}) where {T<:BlasReal}
function (/)(
B::Union{
Matrix{Complex{T}},
Adjoint{Complex{T},Vector{Complex{T}}},
Transpose{Complex{T},Vector{Complex{T}}}
},
F::Factorization{T}
) where {T<:BlasReal}

Maybe there is some reasonable middle-ground?

return copy(reinterpret(Complex{T}, x))
end
# don't do the reinterpretation for [Adjoint/Transpose]Factorization
(/)(B::Union{Matrix{Complex{T}},Adjoint{Complex{T},Vector{Complex{T}}},Transpose{Complex{T},Vector{Complex{T}}}}, F::TransposeFactorization{T}) where {T<:BlasReal} =
Copy link
Member

Choose a reason for hiding this comment

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

Here too.

@dkarrasch dkarrasch removed the bugfix This change fixes an existing bug label Jul 26, 2023
@dkarrasch
Copy link
Member Author

Yeah, "bugfix" might be a bit misleading, but there were typos in the / methods (I must have copied from \ above and changed the signature line, but not the code line) which are corrected here. Whatever that is called if not bugfix. As such, this should definitely be backported.

@martinholters
Copy link
Member

There's

Expression: #= /cache/build/default-amdci5-5/julialang/julia-master/julia-6c4b22f3d1/share/julia/test/abstractarray.jl:762 =# @inferred(cat3v(As)) == zeros(2, 2, 2)
--
  | return type Array{Float64, 3} does not match inferred return type Array{_A, 3} where _A

for more than one CI job. Can that possibly be related? I couldn't explain how.

Copy link
Member

@martinholters martinholters left a comment

Choose a reason for hiding this comment

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

LGTM, but given that this was a bit of collaboration between the two us, another pair of eyes would be welcome.

@martinholters
Copy link
Member

Ah, the CI failures I worried about are #50550, so unrelated (as expected).

@dkarrasch dkarrasch merged commit 210c5b5 into master Jul 29, 2023
@dkarrasch dkarrasch deleted the dk/rdiv_complex_fact branch July 29, 2023 16:59
KristofferC pushed a commit that referenced this pull request Aug 10, 2023
Co-authored-by: Martin Holters <martin@holters.name>
(cherry picked from commit 210c5b5)
KristofferC added a commit that referenced this pull request Aug 16, 2023
Backported PRs:
- [x] #50637 <!-- Remove SparseArrays legacy code -->
- [x] #50665 <!-- print `@time` msg into print buffer -->
- [x] #50523 <!-- Avoid generic call in most cases for getproperty -->
- [x] #50635 <!-- `versioninfo()`: include build info and unofficial
warning -->
- [x] #50670 <!-- Make reinterpret specialize fully. -->
- [x] #50666 <!-- include `--pkgimage=no` caches for stdlibs -->
- [x] #50765 
- [x] #50764
- [x] #50768
- [x] #50767
- [x] #50618 <!-- inference: continue const-prop' when concrete-eval
returns non-inlineable -->
- [x] #50689 <!-- Attach `tanpi` docstring to method -->
- [x] #50671 <!-- Fix rdiv of complex lhs by real factorizations -->
- [x] #50598 <!-- only limit types in stack traces in the REPL -->
- [x] #50766 <!-- Don't partition alwaysinline functions -->
- [x] #50771 <!-- re-allow non-string values in ENV `get!` -->
- [x] #50682 <!-- Add fallback if we have make a weird GC decision. -->
- [x] #50781 <!-- fix `bit_map!` with aliasing -->
- [x] #50172 <!-- print feature flags used for matching pkgimage -->
- [x] #50844 <!-- Bump OpenBLAS binaries to use the new GEMM
multithreading threshold -->
- [x] #50826 <!-- Update dependency builds -->
- [x] #50845 <!-- fix #50438, use default pool for at-threads -->
- [x] #50568 <!-- `Array(::AbstractRange)` should return an `Array` -->
- [x] #50655 <!-- fix hashing regression. -->
- [x] #50779 <!-- Minor refactor to image generation -->
- [x] #50791 <!-- Make symbols internal in jl_create_native, and only
externalize them when partitioning -->
- [x] #50724 <!-- Merge opaque closure modules with the rest of the
workqueue -->
- [x] #50738 <!-- Add alignment to constant globals -->
- [x] #50871 <!-- macOS: Don't inspect dead threadtls during exception
handling. -->

Need manual backport:

Contains multiple commits, manual intervention needed:

Non-merged PRs with backport label:
- [ ] #50850 <!-- Remove weird Rational dispatch and add pi functions to
list -->
- [ ] #50823 <!-- Make ranges more robust with unsigned indexes. -->
- [ ] #50809 <!-- Limit type-printing in MethodError -->
- [ ] #50663 <!-- Fix Expr(:loopinfo) codegen -->
- [ ] #50594 <!-- Disallow non-index Integer types in isassigned -->
- [ ] #50385 <!-- Precompile pidlocks: add to NEWS and docs -->
- [ ] #49805 <!-- Limit TimeType subtraction to AbstractDateTime -->
@KristofferC KristofferC removed the backport 1.10 Change should be backported to the 1.10 release label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing method in /(::Adjoint{ComplexF64}, Hessenberg{Float64})
3 participants