Skip to content

Commit d26c461

Browse files
Merge pull request #21 from nickrobinson251/npr/guard-gpl-libs
Only define methods on SuiteSparse.UMFPACK if GPL libs present
2 parents dbe71cf + 79a5a6f commit d26c461

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SparseMatricesCSR"
22
uuid = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
33
authors = ["Víctor Sande <[email protected]>", "Francesc Verdugo <[email protected]>"]
4-
version = "0.6.6"
4+
version = "0.6.7"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/SparseMatrixCSR.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ function LinearAlgebra.lu(a::SparseMatrixCSR{1})
140140
Transpose(lu(SparseMatrixCSC(a.m,a.n,a.rowptr,a.colval,a.nzval)))
141141
end
142142

143+
if Base.USE_GPL_LIBS
144+
143145
function LinearAlgebra.lu!(
144146
translu::Transpose{T,<:SuiteSparse.UMFPACK.UmfpackLU{T}},
145147
a::SparseMatrixCSR{1}) where {T}
@@ -154,6 +156,8 @@ function LinearAlgebra.lu!(
154156
Transpose(lu!(translu.parent,SparseMatrixCSC(a.m,a.n,rowptr,colval,a.nzval)))
155157
end
156158

159+
end # Base.USE_GPL_LIBS
160+
157161
size(S::SparseMatrixCSR) = (S.m, S.n)
158162
IndexStyle(::Type{<:SparseMatrixCSR}) = IndexCartesian()
159163
function getindex(A::SparseMatrixCSR{Bi,T}, i0::Integer, i1::Integer) where {Bi,T}

test/SparseMatrixCSR.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ for Bi in (0,1)
133133
end
134134
end
135135

136-
I = [1,1,2,2,2,3,3]
137-
J = [1,2,1,2,3,2,3]
138-
V = [4.0,1.0,-1.0,4.0,1.0,-1.0,4.0]
139-
test_lu(0,I,J,V)
140-
test_lu(1,I,J,V)
136+
if Base.USE_GPL_LIBS # `lu!` requires `SuiteSparse.UMFPACK`
137+
I = [1,1,2,2,2,3,3]
138+
J = [1,2,1,2,3,2,3]
139+
V = [4.0,1.0,-1.0,4.0,1.0,-1.0,4.0]
140+
test_lu(0,I,J,V)
141+
test_lu(1,I,J,V)
142+
else
143+
@warn "Tests run without GPL libraries."
144+
end
141145

142146
end # module

0 commit comments

Comments
 (0)