ITADN

missing ldiv for transpose of sparse QR

#656Openstevengj 创建于 2025-10-31
S
stevengjcommented
This would be useful to find the minimum-norm solution of a "wide" (underdetermined) system of equations: ```jl julia> qr(sprand(3,100,0.1)')' \ rand(100) ERROR: MethodError: no method matching ldiv!(::LinearAlgebra.AdjointFactorization{Float64, SparseArrays.SPQR.QRSparse{Float64, Int64}}, ::Vector{Float64}) The function `ldiv!` exists, but no method is defined for this combination of argument types. ``` Here is a simple example implementation of this: ```jl function myldiv(Fadj::LinearAlgebra.AdjointFactorization{<:Number, <:SparseArrays.SPQR.QRSparse}, b::AbstractVector{<:Number}) F = parent(Fadj) m, n = size(F) y = [UpperTriangular(F.R)' \ b[F.pcol]; zeros(m - n)] xperm = F.Q * y x = similar(xperm); x[F.prow] = xperm return x end ``` (Needed for #301.)
0 条评论