Skip to content

Commit

Permalink
Format the source with JuliaFormatter (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Feb 24, 2023
1 parent dd434ca commit 06be73a
Show file tree
Hide file tree
Showing 20 changed files with 2,136 additions and 1,320 deletions.
24 changes: 14 additions & 10 deletions src/cholesky.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using LinearAlgebra: rdiv!

function cholUnblocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}) where T<:Number
function cholUnblocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}) where {T<:Number}
n = LinearAlgebra.checksquare(A)
A[1,1] = sqrt(A[1,1])
A[1, 1] = sqrt(A[1, 1])
if n > 1
a21 = view(A, 2:n, 1)
rmul!(a21, inv(real(A[1,1])))
rmul!(a21, inv(real(A[1, 1])))

A22 = view(A, 2:n, 2:n)
rankUpdate!(Hermitian(A22, :L), a21, -1)
Expand All @@ -14,36 +14,40 @@ function cholUnblocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}) where T<:Number
A
end

function cholBlocked!(A::AbstractMatrix{T}, ::Type{Val{:L}}, blocksize::Integer) where T<:Number
function cholBlocked!(
A::AbstractMatrix{T},
::Type{Val{:L}},
blocksize::Integer,
) where {T<:Number}
n = LinearAlgebra.checksquare(A)
mnb = min(n, blocksize)
A11 = view(A, 1:mnb, 1:mnb)
cholUnblocked!(A11, Val{:L})
if n > blocksize
A21 = view(A, (blocksize + 1):n, 1:blocksize)
A21 = view(A, (blocksize+1):n, 1:blocksize)
rdiv!(A21, LowerTriangular(A11)')

A22 = view(A, (blocksize + 1):n, (blocksize + 1):n)
A22 = view(A, (blocksize+1):n, (blocksize+1):n)
rankUpdate!(Hermitian(A22, :L), A21, -1)
cholBlocked!(A22, Val{:L}, blocksize)
end
A
end

function cholRecursive!(A::StridedMatrix{T}, ::Type{Val{:L}}, cutoff = 1) where T
function cholRecursive!(A::StridedMatrix{T}, ::Type{Val{:L}}, cutoff = 1) where {T}
n = LinearAlgebra.checksquare(A)
if n == 1
A[1,1] = sqrt(A[1,1])
A[1, 1] = sqrt(A[1, 1])
elseif n < cutoff
cholUnblocked!(A, Val{:L})
else
n2 = div(n, 2)
A11 = view(A, 1:n2, 1:n2)
cholRecursive!(A11, Val{:L})
A21 = view(A, n2 + 1:n, 1:n2)
A21 = view(A, n2+1:n, 1:n2)
rdiv!(A21, LowerTriangular(A11)')

A22 = view(A, n2 + 1:n, n2 + 1:n)
A22 = view(A, n2+1:n, n2+1:n)
rankUpdate!(Hermitian(A22, :L), A21, -1)
cholRecursive!(A22, Val{:L}, cutoff)
end
Expand Down
Loading

0 comments on commit 06be73a

Please sign in to comment.