Skip to content

Commit

Permalink
Add jl_cholmod_sizeof_long to SuiteSparse_wrapper. Select supported i…
Browse files Browse the repository at this point in the history
…ndex types based on size of SuitSparse_long. Test adjusted.
  • Loading branch information
acroy committed Dec 8, 2014
1 parent 877a29c commit 5f333b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions base/linalg/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ function cmn(::Type{Int64})
chm_l_com
end

typealias CHMITypes Union(Int32,Int64)
# check the size of SuiteSparse_long
if int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) == 4
const CholmodIndexTypes = (:Int32, )
typealias CHMITypes Union(Int32)
else
const CholmodIndexTypes = (:Int32, :Int64)
typealias CHMITypes Union(Int32, Int64)
end


typealias CHMVTypes Union(Complex128, Float64)
typealias CHMVRealTypes Union(Float64)

Expand Down Expand Up @@ -424,6 +433,7 @@ function CholmodSparse!{Tv<:CHMVTypes,Ti<:CHMITypes}(colpt::Vector{Ti},
xtyp(Tv),dtyp(Tv),
CHOLMOD_FALSE,CHOLMOD_TRUE),
colpt,rowval,nzval)

@isok isvalid(cs)

cs = sort!(cs)
Expand Down Expand Up @@ -479,7 +489,7 @@ function chm_rdsp(fnm::AbstractString)
CholmodSparse(res)
end

for Ti in (:Int32,:Int64)
for Ti in CholmodIndexTypes
@eval begin
function (*){Tv<:CHMVRealTypes}(A::CholmodSparse{Tv,$Ti},
B::CholmodSparse{Tv,$Ti})
Expand Down
1 change: 1 addition & 0 deletions deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ install-mojibake: $(MOJIBAKE_OBJ_TARGET)
SUITESPARSE_OBJ_SOURCE = SuiteSparse-$(SUITESPARSE_VER)/UMFPACK/Lib/libumfpack.a
SUITESPARSE_OBJ_TARGET = $(build_shlibdir)/libspqr.$(SHLIB_EXT)


ifeq ($(USE_BLAS64), 1)
UMFPACK_CONFIG = -DLONGBLAS='long long'
CHOLMOD_CONFIG = -DLONGBLAS='long long'
Expand Down
4 changes: 4 additions & 0 deletions deps/SuiteSparse_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ extern size_t jl_cholmod_common_size(void) {
return sizeof(cholmod_common);
}

extern size_t jl_cholmod_sizeof_long(void) {
return sizeof(SuiteSparse_long);
}

extern int jl_cholmod_version(int *ver) {
if (ver != (int*) NULL) {
ver[0] = CHOLMOD_MAIN_VERSION;
Expand Down
4 changes: 2 additions & 2 deletions test/linalg/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ using Base.Test
let # Issue 9160
const CHOLMOD = Base.LinAlg.CHOLMOD

for Ti in (Int32, Int64)
for elty in (Float64, )
for Ti in CHOLMOD.CHMITypes.types
for elty in CHOLMOD.CHMVRealTypes.types

A = sprand(10,10,0.1)
A = convert(SparseMatrixCSC{elty,Ti},A)
Expand Down

0 comments on commit 5f333b1

Please sign in to comment.