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

Introduce cholesky and qr hooks for wrapped sparse matrices #51220

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,16 @@ true
```
"""
cholesky(A::AbstractMatrix, ::NoPivot=NoPivot(); check::Bool = true) =
cholesky!(cholcopy(A); check)
_cholesky(cholcopy(A); check)
@deprecate cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}}, ::Val{false}; check::Bool = true) cholesky(A, NoPivot(); check) false

function cholesky(A::AbstractMatrix{Float16}, ::NoPivot=NoPivot(); check::Bool = true)
X = cholesky!(cholcopy(A); check = check)
X = _cholesky(cholcopy(A); check = check)
return Cholesky{Float16}(X)
end
@deprecate cholesky(A::Union{StridedMatrix{Float16},RealHermSymComplexHerm{Float16,<:StridedMatrix}}, ::Val{false}; check::Bool = true) cholesky(A, NoPivot(); check) false
# allow packages like SparseArrays.jl to hook into here and redirect to out-of-place `cholesky`
_cholesky(A::AbstractMatrix, args...; kwargs...) = cholesky!(A, args...; kwargs...)

## With pivoting
"""
Expand Down Expand Up @@ -465,11 +467,11 @@ true
```
"""
cholesky(A::AbstractMatrix, ::RowMaximum; tol = 0.0, check::Bool = true) =
cholesky!(cholcopy(A), RowMaximum(); tol, check)
_cholesky(cholcopy(A), RowMaximum(); tol, check)
@deprecate cholesky(A::Union{StridedMatrix,RealHermSymComplexHerm{<:Real,<:StridedMatrix}}, ::Val{true}; tol = 0.0, check::Bool = true) cholesky(A, RowMaximum(); tol, check) false

function cholesky(A::AbstractMatrix{Float16}, ::RowMaximum; tol = 0.0, check::Bool = true)
X = cholesky!(cholcopy(A), RowMaximum(); tol, check)
X = _cholesky(cholcopy(A), RowMaximum(); tol, check)
return CholeskyPivoted{Float16}(X)
end

Expand Down
5 changes: 4 additions & 1 deletion stdlib/LinearAlgebra/src/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,15 @@ true
function qr(A::AbstractMatrix{T}, arg...; kwargs...) where T
require_one_based_indexing(A)
AA = copy_similar(A, _qreltype(T))
return qr!(AA, arg...; kwargs...)
return _qr(AA, arg...; kwargs...)
end
# TODO: remove in Julia v2.0
@deprecate qr(A::AbstractMatrix, ::Val{false}; kwargs...) qr(A, NoPivot(); kwargs...)
@deprecate qr(A::AbstractMatrix, ::Val{true}; kwargs...) qr(A, ColumnNorm(); kwargs...)

# allow packages like SparseArrays.jl to hook into here and redirect to out-of-place `qr`
_qr(A::AbstractMatrix, args...; kwargs...) = qr!(A, args...; kwargs...)

qr(x::Number) = qr(fill(x,1,1))
function qr(v::AbstractVector)
require_one_based_indexing(v)
Expand Down