-
-
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
Define chol for UniformScaling's #22633
Changes from all commits
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 |
---|---|---|
|
@@ -313,3 +313,27 @@ function hvcat(rows::Tuple{Vararg{Int}}, A::Union{AbstractVecOrMat,UniformScalin | |
end | ||
return hvcat(rows, promote_to_arrays(n,1, promote_to_array_type(A), A...)...) | ||
end | ||
|
||
|
||
## Cholesky | ||
function _chol!(J::UniformScaling, uplo) | ||
c, info = _chol!(J.λ, uplo) | ||
UniformScaling(c), info | ||
end | ||
|
||
chol!(J::UniformScaling, uplo) = ((J, info) = _chol!(J, uplo); @assertposdef J info) | ||
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. What is the motivation for this method? Should fall in the same category as the now deprecated 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. The function |
||
|
||
""" | ||
chol(J::UniformScaling) -> C | ||
|
||
Compute the square root of a non-negative UniformScaling `J`. | ||
|
||
# Examples | ||
```jldoctest | ||
julia> chol(16I) | ||
UniformScaling{Float64} | ||
4.0*I | ||
``` | ||
""" | ||
chol(J::UniformScaling, args...) = ((C, info) = _chol!(J, nothing); @assertposdef C info) | ||
|
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 mutating?
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.
This is following verbatim the chol(::Number) implementation.
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.
It is a trick to allow a recursive definition of
chol
. Seejulia/base/linalg/cholesky.jl
Line 75 in 71d7c16
!
is not saying "will mutate", just "be aware, might mutate".