-
Notifications
You must be signed in to change notification settings - Fork 33
Create blockcholesky.jl #126
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
Changes from 1 commit
9c47f78
030a054
b977d8d
0ff3e67
dc54673
5605d8f
bb7355b
2d782fe
72259da
883da65
09a8a54
b6f7d3a
dc6e020
8793acd
f994fc0
44b1490
2d43bda
025a4ce
04af833
f1059ef
99f54d5
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
# Function for cholesky decomposition on block matries | ||
# 'cholesky' is the build-in one in LAPACK | ||
|
||
function Bcholesky(A::Symmetric{<:Any,<:BlockArray}) | ||
chol_U = BlockArray{Float64}(zeros(size(A)), fill(size(A)[1]÷blocksize(A)[1], blocksize(A)[1]), fill(size(A)[1]÷blocksize(A)[1], blocksize(A)[1])) | ||
|
||
# Initializing the first role of blocks | ||
chol_U[Block(1,1)] = cholesky!(A[Block(1,1)]).U | ||
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. When we change this to be properly in-place, we will want to replace this with |
||
for j = 2:blocksize(A)[1] | ||
chol_U[Block(1,j)] = chol_U[Block(1,1)]' \ A[Block(1,j)] | ||
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. When this is in-place it will look something like: P = parent(A)
ldiv!(UpperTriangular(getblock(P,1,1))', getblock(P,1,j)) |
||
end | ||
|
||
# For the left blocks | ||
for i = 2:blocksize(A)[1] | ||
for j = i:blocksize(A)[1] | ||
if j == i | ||
chol_U[Block(i,j)] = cholesky!(A[Block(i,j)] - sum(chol_U[Block(k,j)]'chol_U[Block(k,j)] for k in 1:j-1)).U | ||
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. Here we will want to use Pij = getblock(P,i,j)
for k = 1:j-1
mul!(Pij,getblock(P,k,j)',getblock(P,k,j),-1.0,1.0)
end
cholesky!(Pij) |
||
else | ||
chol_U[Block(i,j)] = chol_U[Block(i,i)]' \ (A[Block(i,j)] - sum(chol_U[Block(k,i)]'chol_U[Block(k,j)] for k in 1:j-1)) | ||
end | ||
end | ||
end | ||
|
||
return chol_U | ||
|
||
end |
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.
In src/BlockArrays.jl, add
And then you can overload
cholesky
andcholesky!