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

Fix compilation for Julia builds without GPL libraries #2

Closed
wants to merge 1 commit into from
Closed
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
54 changes: 30 additions & 24 deletions src/SparseInverseSubset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ end
"""
Construct sparse Julia versions of L, D, U, and P from a CHOLMOD Cholesky factorization.
"""
function get_ldup(F::SuiteSparse.CHOLMOD.Factor)
L = sparse(F.L)
P = F.p
d = Vector(diag(L))
L = tril(L * Diagonal(1 ./ d), -1)
U = sparse(L')
d = d.^2
D = Diagonal(d)
return (L=L, D=D, U=U, P=P)
function get_ldup end

if Base.USE_GPL_LIBS
ElOceanografo marked this conversation as resolved.
Show resolved Hide resolved
function get_ldup(F::SuiteSparse.CHOLMOD.Factor)
L = sparse(F.L)
P = F.p
d = Vector(diag(L))
L = tril(L * Diagonal(1 ./ d), -1)
U = sparse(L')
d = d.^2
D = Diagonal(d)
return (L=L, D=D, U=U, P=P)
end
end

"""
Expand Down Expand Up @@ -91,21 +95,23 @@ function sparseinv(A::SparseMatrixCSC; depermute=false)
return sparseinv(F; depermute=depermute)
end

function sparseinv(F::SuiteSparse.CHOLMOD.Factor; depermute=false)
L, D, U, P = get_ldup(F)
n = size(L, 1)
sparsity = get_subset(L)
Z = float(sparsity)
ii, jj, zz = findnz(Z)
Z[n,n] = 1 / D[n,n]
for j in sort(unique(jj), rev=true)
fill_col!(Z, j, U, D)
fill_transposed_col!(Z, j)
end
if depermute
return (Z = Z[invperm(P), invperm(P)], P = P)
else
return (Z=Z, P=P)
if Base.USE_GPL_LIBS
function sparseinv(F::SuiteSparse.CHOLMOD.Factor; depermute=false)
L, D, U, P = get_ldup(F)
n = size(L, 1)
sparsity = get_subset(L)
Z = float(sparsity)
ii, jj, zz = findnz(Z)
Z[n,n] = 1 / D[n,n]
for j in sort(unique(jj), rev=true)
fill_col!(Z, j, U, D)
fill_transposed_col!(Z, j)
end
if depermute
return (Z = Z[invperm(P), invperm(P)], P = P)
else
return (Z=Z, P=P)
end
end
end

Expand Down