Skip to content

Commit

Permalink
Define chol for UniformScaling's (#22633)
Browse files Browse the repository at this point in the history
* Define chol for UniformScaling's

* Move test for chol(lambda*I) to test/linalg/uniformscaling.jl
  • Loading branch information
mschauer authored and andreasnoack committed Jul 18, 2017
1 parent 88435c0 commit eb133ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions base/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

"""
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)

8 changes: 8 additions & 0 deletions test/linalg/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,11 @@ end
hvcat((2,1,2),B,2eye(3,3),eye(6,6),3eye(3,3),4eye(3,3))
end
end

@testset "chol" begin
for T in (Float64, Complex64, BigFloat, Int)
λ = T(4)
@test chol*I) λ*I
@test_throws LinAlg.PosDefException chol(-λ*I)
end
end

2 comments on commit eb133ab

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something went wrong when running your job:

NanosoldierError: failed to run benchmarks against primary commit: failed process: Process(`sudo cset shield -e su nanosoldier -- -c ./benchscript.sh`, ProcessExited(1)) [1]

Logs and partial data can be found here
cc @ararslan

Please sign in to comment.