From ec9c3f88ce04a5bde37ef1745989d1db85abe254 Mon Sep 17 00:00:00 2001 From: mforets Date: Sun, 30 Sep 2018 22:39:24 -0300 Subject: [PATCH 1/4] add Compat to REQUIRE --- REQUIRE | 1 + 1 file changed, 1 insertion(+) diff --git a/REQUIRE b/REQUIRE index c65ecc4..6805d3d 100644 --- a/REQUIRE +++ b/REQUIRE @@ -4,3 +4,4 @@ MathProgBase 0.6 Polyhedra 0.3 0.4 @windows WinRPM @osx Homebrew +Compat 1.0.0 From 255efa04d873b489e031a9404a4186b680bad1b7 Mon Sep 17 00:00:00 2001 From: mforets Date: Sun, 30 Sep 2018 22:39:45 -0300 Subject: [PATCH 2/4] Void -> Nothing --- src/CDDLib.jl | 3 ++- src/lp.jl | 8 ++++---- src/matrix.jl | 28 ++++++++++++++-------------- src/mytype.jl | 22 +++++++++++----------- src/polyhedra.jl | 6 +++--- src/settype.jl | 4 ++-- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/CDDLib.jl b/src/CDDLib.jl index ae3e735..b63e704 100644 --- a/src/CDDLib.jl +++ b/src/CDDLib.jl @@ -2,6 +2,7 @@ __precompile__() module CDDLib +using Compat using BinDeps using Polyhedra @@ -34,7 +35,7 @@ macro cdd_ccall(f, args...) end function __init__() - @dd_ccall set_global_constants Void () + @dd_ccall set_global_constants Nothing () end import Base.convert, Base.push!, Base.eltype, Base.copy diff --git a/src/lp.jl b/src/lp.jl index 018e0de..4d658fe 100644 --- a/src/lp.jl +++ b/src/lp.jl @@ -34,10 +34,10 @@ mutable struct Cdd_LPSolutionData{T<:MyType} end function dd_freelpsolution(lp::Ptr{Cdd_LPSolutionData{Cdouble}}) - @ddf_ccall FreeLPSolution Void (Ptr{Cdd_LPSolutionData{Cdouble}},) lp + @ddf_ccall FreeLPSolution Nothing (Ptr{Cdd_LPSolutionData{Cdouble}},) lp end function dd_freelpsolution(lp::Ptr{Cdd_LPSolutionData{GMPRational}}) - @dd_ccall FreeLPSolution Void (Ptr{Cdd_LPSolutionData{GMPRational}},) lp + @dd_ccall FreeLPSolution Nothing (Ptr{Cdd_LPSolutionData{GMPRational}},) lp end mutable struct CDDLPSolution{T<:MyType} @@ -181,10 +181,10 @@ mutable struct Cdd_LPData{T<:MyType} end function dd_freelpdata(lp::Ptr{Cdd_LPData{Cdouble}}) - @ddf_ccall FreeLPData Void (Ptr{Cdd_LPData{Cdouble}},) lp + @ddf_ccall FreeLPData Nothing (Ptr{Cdd_LPData{Cdouble}},) lp end function dd_freelpdata(lp::Ptr{Cdd_LPData{GMPRational}}) - @dd_ccall FreeLPData Void (Ptr{Cdd_LPData{GMPRational}},) lp + @dd_ccall FreeLPData Nothing (Ptr{Cdd_LPData{GMPRational}},) lp end mutable struct CDDLP{T<:MyType} diff --git a/src/matrix.jl b/src/matrix.jl index d033b0a..b4b61e9 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -17,42 +17,42 @@ function dd_creatematrix(::Type{GMPRational}, m::Cdd_rowrange, n::Cdd_colrange) end # function dd_copyAmatrixvectorizedbycolumn(mat::Cdd_Amatrix{Cdouble}, M::Matrix{Cdouble}, m::Cdd_rowrange, n::Cdd_colrange) -# @ddf_ccall CopyAmatrixVectorizedByColumn Void (Cdd_Amatrix{Cdouble}, Ptr{Cdouble}, Cdd_rowrange, Cdd_colrange) mat M m n +# @ddf_ccall CopyAmatrixVectorizedByColumn Nothing (Cdd_Amatrix{Cdouble}, Ptr{Cdouble}, Cdd_rowrange, Cdd_colrange) mat M m n # end # function dd_copyAmatrixvectorizedbycolumn(mat::Cdd_Amatrix{GMPRational}, M::Matrix{GMPRational}, m::Cdd_rowrange, n::Cdd_colrange) -# @dd_ccall CopyAmatrixVectorizedByColumn Void (Cdd_Amatrix{GMPRational}, Ptr{GMPRational}, Cdd_rowrange, Cdd_colrange) mat M m n +# @dd_ccall CopyAmatrixVectorizedByColumn Nothing (Cdd_Amatrix{GMPRational}, Ptr{GMPRational}, Cdd_rowrange, Cdd_colrange) mat M m n # end function dd_copyArow(acopy::Cdd_Arow{Cdouble}, a::Vector{Cdouble}) - @ddf_ccall CopyArow Void (Cdd_Arow{Cdouble}, Cdd_Arow{Cdouble}, Cdd_colrange) acopy a length(a) + @ddf_ccall CopyArow Nothing (Cdd_Arow{Cdouble}, Cdd_Arow{Cdouble}, Cdd_colrange) acopy a length(a) end function dd_copyArow(acopy::Cdd_Arow{GMPRational}, a::Vector{Rational{BigInt}}) b = Vector{GMPRational}(a) - @dd_ccall CopyArow Void (Cdd_Arow{GMPRational}, Cdd_Arow{GMPRational}, Cdd_colrange) acopy b length(b) + @dd_ccall CopyArow Nothing (Cdd_Arow{GMPRational}, Cdd_Arow{GMPRational}, Cdd_colrange) acopy b length(b) myfree(b) end dd_copyArow(acopy::Cdd_Arow, a::AbstractVector) = dd_copyArow(acopy, collect(a)) # e.g. for sparse a function dd_setmatrixobjective(matrix::Ptr{Cdd_MatrixData{Cdouble}}, objective::Cdd_LPObjectiveType) - @ddf_ccall SetMatrixObjective Void (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_LPObjectiveType) matrix objective + @ddf_ccall SetMatrixObjective Nothing (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_LPObjectiveType) matrix objective end function dd_setmatrixobjective(matrix::Ptr{Cdd_MatrixData{GMPRational}}, objective::Cdd_LPObjectiveType) - @dd_ccall SetMatrixObjective Void (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_LPObjectiveType) matrix objective + @dd_ccall SetMatrixObjective Nothing (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_LPObjectiveType) matrix objective end function dd_setmatrixnumbertype(matrix::Ptr{Cdd_MatrixData{Cdouble}}) - @ddf_ccall SetMatrixNumberType Void (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_NumberType) matrix dd_Real + @ddf_ccall SetMatrixNumberType Nothing (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_NumberType) matrix dd_Real end function dd_setmatrixnumbertype(matrix::Ptr{Cdd_MatrixData{GMPRational}}) - @dd_ccall SetMatrixNumberType Void (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_NumberType) matrix dd_Rational + @dd_ccall SetMatrixNumberType Nothing (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_NumberType) matrix dd_Rational end function dd_setmatrixrepresentationtype(matrix::Ptr{Cdd_MatrixData{Cdouble}}, inequality::Bool) - @ddf_ccall SetMatrixRepresentationType Void (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_RepresentationType) matrix (inequality ? dd_Inequality : dd_Generator) + @ddf_ccall SetMatrixRepresentationType Nothing (Ptr{Cdd_MatrixData{Cdouble}}, Cdd_RepresentationType) matrix (inequality ? dd_Inequality : dd_Generator) end function dd_setmatrixrepresentationtype(matrix::Ptr{Cdd_MatrixData{GMPRational}}, inequality::Bool) - @dd_ccall SetMatrixRepresentationType Void (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_RepresentationType) matrix (inequality ? dd_Inequality : dd_Generator) + @dd_ccall SetMatrixRepresentationType Nothing (Ptr{Cdd_MatrixData{GMPRational}}, Cdd_RepresentationType) matrix (inequality ? dd_Inequality : dd_Generator) end function dd_matrixcopy(matrix::Ptr{Cdd_MatrixData{Cdouble}}) @@ -154,10 +154,10 @@ Base.length(matrix::CDDInequalityMatrix{N}) where N = _length(matrix.matrix, N) Base.length(matrix::CDDGeneratorMatrix{N}) where N = _length(matrix.matrix, N) + matrix.cone function dd_freematrix(matrix::Ptr{Cdd_MatrixData{Cdouble}}) - @ddf_ccall FreeMatrix Void (Ptr{Cdd_MatrixData{Cdouble}},) matrix + @ddf_ccall FreeMatrix Nothing (Ptr{Cdd_MatrixData{Cdouble}},) matrix end function dd_freematrix(matrix::Ptr{Cdd_MatrixData{GMPRational}}) - @dd_ccall FreeMatrix Void (Ptr{Cdd_MatrixData{GMPRational}},) matrix + @dd_ccall FreeMatrix Nothing (Ptr{Cdd_MatrixData{GMPRational}},) matrix end function myfree(matrix::CDDMatrix) dd_freematrix(matrix.matrix) @@ -203,7 +203,7 @@ function extractrow(mat::Cdd_MatrixData{GMPRational}, i) row = unsafe_load(mat.matrix, i) for j = 1:n b[j] = GMPRationalMut() - ccall((:__gmpq_set, :libgmp), Void, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(b[j]), row + ((j-1)*sizeof(GMPRational))) + ccall((:__gmpq_set, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(b[j]), row + ((j-1)*sizeof(GMPRational))) end Array{Rational{BigInt}}(Array{GMPRational}(b)) end @@ -308,7 +308,7 @@ function extractA(mat::Cdd_MatrixData{GMPRational}) row = unsafe_load(mat.matrix, i) for j = 1:n A[i, j] = GMPRationalMut() - ccall((:__gmpq_set, :libgmp), Void, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(A[i,j]), row + ((j-1)*sizeof(GMPRational))) + ccall((:__gmpq_set, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(A[i,j]), row + ((j-1)*sizeof(GMPRational))) end end Array{GMPRational}(A) diff --git a/src/mytype.jl b/src/mytype.jl index 062d3d8..9c0adec 100644 --- a/src/mytype.jl +++ b/src/mytype.jl @@ -14,7 +14,7 @@ mutable struct GMPRationalMut function GMPRationalMut() m = new() - ccall((:__gmpq_init, :libgmp), Void, (Ptr{GMPRationalMut},), &m) + ccall((:__gmpq_init, :libgmp), Nothing, (Ptr{GMPRationalMut},), &m) # No need to clear anything since the num and den are used by # the GMPRational that is created #finalizer(m, _mpq_clear_fn) @@ -24,9 +24,9 @@ end function Base.convert(::Type{GMPRationalMut}, a::Rational{BigInt}) m = GMPRationalMut() - ccall((:__gmpq_set_num, :libgmp), Void, + ccall((:__gmpq_set_num, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{BigInt}), &m, &a.num) - ccall((:__gmpq_set_den, :libgmp), Void, + ccall((:__gmpq_set_den, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{BigInt}), &m, &a.den) m end @@ -40,7 +40,7 @@ function GMPRationalMut(a::Int, b::Int) b = -b end m = GMPRationalMut() - ccall((:__gmpq_set_si, :libgmp), Void, + ccall((:__gmpq_set_si, :libgmp), Nothing, (Ptr{GMPRationalMut}, Clong, Culong), &m, a, b) m end @@ -65,7 +65,7 @@ function myfree(a::Array{Cdouble}) end function myfree(a::Array{GMPRational}) for el in a - ccall((:__gmpq_clear, :libgmp), Void, (Ptr{GMPRational},), &el) + ccall((:__gmpq_clear, :libgmp), Nothing, (Ptr{GMPRational},), &el) end end @@ -92,19 +92,19 @@ end function -(a::GMPRational) m = GMPRationalMut() - ccall((:__gmpq_neg, :libgmp), Void, + ccall((:__gmpq_neg, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}), &m, &a) GMPRational(m) end function *(a::GMPRational, b::GMPRational) m = GMPRationalMut() - ccall((:__gmpq_mul, :libgmp), Void, + ccall((:__gmpq_mul, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), &m, &a, &b) GMPRational(m) end function +(a::GMPRational, b::GMPRational) m = GMPRationalMut() - ccall((:__gmpq_add, :libgmp), Void, + ccall((:__gmpq_add, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), &m, &a, &b) GMPRational(m) end @@ -120,10 +120,10 @@ end function Base.convert(::Type{Rational{BigInt}}, r::GMPRational) a = BigInt() - ccall((:__gmpq_get_num, :libgmp), Void, + ccall((:__gmpq_get_num, :libgmp), Nothing, (Ptr{BigInt}, Ptr{GMPRational}), &a, &r) b = BigInt() - ccall((:__gmpq_get_den, :libgmp), Void, + ccall((:__gmpq_get_den, :libgmp), Nothing, (Ptr{BigInt}, Ptr{GMPRational}), &b, &r) a // b end @@ -160,7 +160,7 @@ function myconvert(::Type{Array}, x::Ptr{GMPRational}, n) y = Array{GMPRationalMut, 1}(n) for i = 1:n y[i] = GMPRationalMut() - ccall((:__gmpq_set, :libgmp), Void, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(y[i]), x+((i-1)*sizeof(GMPRational))) + ccall((:__gmpq_set, :libgmp), Nothing, (Ptr{GMPRationalMut}, Ptr{GMPRational}), pointer_from_objref(y[i]), x+((i-1)*sizeof(GMPRational))) end Array{GMPRational}(y) end diff --git a/src/polyhedra.jl b/src/polyhedra.jl index 2fd7c52..0e9ff13 100644 --- a/src/polyhedra.jl +++ b/src/polyhedra.jl @@ -7,7 +7,7 @@ mutable struct Cdd_PolyhedraData{T<:MyType} A::Cdd_Amatrix{T} # Inequality System: m times d matrix numbtype::Cdd_NumberType - child::Ptr{Void} # dd_ConePtr + child::Ptr{Nothing} # dd_ConePtr # pointing to the homogenized cone data m_alloc::Cdd_rowrange # allocated row size of matrix A @@ -74,10 +74,10 @@ mutable struct CDDPolyhedra{N, T<:PolyType, S} end function myfree(poly::CDDPolyhedra{N, Cdouble}) where N - @ddf_ccall FreePolyhedra Void (Ptr{Cdd_PolyhedraData{Cdouble}},) poly.poly + @ddf_ccall FreePolyhedra Nothing (Ptr{Cdd_PolyhedraData{Cdouble}},) poly.poly end function myfree(poly::CDDPolyhedra{N, Rational{BigInt}}) where N - @dd_ccall FreePolyhedra Void (Ptr{Cdd_PolyhedraData{GMPRational}},) poly.poly + @dd_ccall FreePolyhedra Nothing (Ptr{Cdd_PolyhedraData{GMPRational}},) poly.poly end CDDPolyhedra(matrix::CDDMatrix{N, T, S}) where {N, T, S} = CDDPolyhedra{N, T, S}(matrix) diff --git a/src/settype.jl b/src/settype.jl index 9c576aa..be4ff29 100644 --- a/src/settype.jl +++ b/src/settype.jl @@ -1,11 +1,11 @@ function dd_set_initialize(maxel::Clong) x = Ref{Cset_type}(0) - @cdd_ccall set_initialize Void (Ref{Ptr{Culong}}, Clong) x maxel + @cdd_ccall set_initialize Nothing (Ref{Ptr{Culong}}, Clong) x maxel x[] end function dd_set_addelem(st::Cset_type, el::Clong) - @cdd_ccall set_addelem Void (Cset_type, Clong) st convert(Clong, el) + @cdd_ccall set_addelem Nothing (Cset_type, Clong) st convert(Clong, el) end function dd_set_member(st::Cset_type, el::Clong) From c71b33b45791341b49b8f674cd28831a8b38e76f Mon Sep 17 00:00:00 2001 From: mforets Date: Sun, 30 Sep 2018 22:45:29 -0300 Subject: [PATCH 3/4] IntSet -> BitSet --- src/matrix.jl | 6 +++--- src/settype.jl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/matrix.jl b/src/matrix.jl index b4b61e9..3912573 100644 --- a/src/matrix.jl +++ b/src/matrix.jl @@ -62,7 +62,7 @@ function dd_matrixcopy(matrix::Ptr{Cdd_MatrixData{GMPRational}}) @dd_ccall MatrixCopy Ptr{Cdd_MatrixData{GMPRational}} (Ptr{Cdd_MatrixData{GMPRational}},) matrix end -function fillmatrix(inequality::Bool, matrix::Ptr{Ptr{T}}, itr, linset::IntSet, offset) where T +function fillmatrix(inequality::Bool, matrix::Ptr{Ptr{T}}, itr, linset::BitSet, offset) where T for (i, item) in enumerate(itr) row = unsafe_load(matrix, offset+i) if islin(item) @@ -83,7 +83,7 @@ function initmatrix(::Polyhedra.FullDim{N}, ::Type{T}, inequality::Bool, itr::Po offset = [0; cs[1:end-1]] matrix = dd_creatematrix(mytype(T), Cdd_rowrange(m), Cdd_colrange(n)) mat = unsafe_load(matrix) - linset = IntSet() + linset = BitSet() fillmatrix.(inequality, mat.matrix, itr, linset, offset) dd_settype(mat.linset, linset) dd_setmatrixnumbertype(matrix) @@ -133,7 +133,7 @@ Polyhedra.similar_type(::Type{<:CDDGeneratorMatrix}, ::FullDim{N}, ::Type{T}) wh function linset(matrix::CDDMatrix) mat = unsafe_load(matrix.matrix) - Base.convert(IntSet, CDDSet(mat.linset, mat.rowsize)) + Base.convert(BitSet, CDDSet(mat.linset, mat.rowsize)) end CDDMatrix(hrep::HRepresentation) = CDDInequalityMatrix(hrep) diff --git a/src/settype.jl b/src/settype.jl index be4ff29..00737b4 100644 --- a/src/settype.jl +++ b/src/settype.jl @@ -37,8 +37,8 @@ function CDDSet(s, maxel::Clong, offset::Integer) end CDDSet(s, maxel, offset::Integer) = CDDSet(s, Clong(maxel), offset) -function Base.convert(::Type{IntSet}, st::CDDSet) - s = IntSet() +function Base.convert(::Type{BitSet}, st::CDDSet) + s = BitSet() for i = 1:st.maxel if dd_set_member(st.s, convert(Clong, i)) push!(s, i) @@ -48,9 +48,9 @@ function Base.convert(::Type{IntSet}, st::CDDSet) end # I don't want it to overwrite Base.convert behaviour -function myconvert(::Type{IntSet}, a::Matrix) +function myconvert(::Type{BitSet}, a::Matrix) b = Array{Bool}(a) - s = IntSet() + s = BitSet() for i = 1:length(a) if b[i] push!(s, i) From 9481e80daf2ef4eea51e8432b75dd6cea2afd953 Mon Sep 17 00:00:00 2001 From: mforets Date: Sun, 30 Sep 2018 22:50:02 -0300 Subject: [PATCH 4/4] & -> Ref --- src/mytype.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mytype.jl b/src/mytype.jl index 9c0adec..4fa5789 100644 --- a/src/mytype.jl +++ b/src/mytype.jl @@ -14,7 +14,7 @@ mutable struct GMPRationalMut function GMPRationalMut() m = new() - ccall((:__gmpq_init, :libgmp), Nothing, (Ptr{GMPRationalMut},), &m) + ccall((:__gmpq_init, :libgmp), Nothing, (Ptr{GMPRationalMut},), Ref(m)) # No need to clear anything since the num and den are used by # the GMPRational that is created #finalizer(m, _mpq_clear_fn) @@ -25,9 +25,9 @@ end function Base.convert(::Type{GMPRationalMut}, a::Rational{BigInt}) m = GMPRationalMut() ccall((:__gmpq_set_num, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Ptr{BigInt}), &m, &a.num) + (Ptr{GMPRationalMut}, Ptr{BigInt}), Ref(m), Ref(a.num)) ccall((:__gmpq_set_den, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Ptr{BigInt}), &m, &a.den) + (Ptr{GMPRationalMut}, Ptr{BigInt}), Ref(m), Ref(a.den)) m end Base.convert(::Type{GMPRationalMut}, a::Rational) = GMPRationalMut(Rational{BigInt}(a)) @@ -41,7 +41,7 @@ function GMPRationalMut(a::Int, b::Int) end m = GMPRationalMut() ccall((:__gmpq_set_si, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Clong, Culong), &m, a, b) + (Ptr{GMPRationalMut}, Clong, Culong), Ref(m), a, b) m end Base.convert(::Type{GMPRationalMut}, a::Int) = GMPRationalMut(a, 1) @@ -65,7 +65,7 @@ function myfree(a::Array{Cdouble}) end function myfree(a::Array{GMPRational}) for el in a - ccall((:__gmpq_clear, :libgmp), Nothing, (Ptr{GMPRational},), &el) + ccall((:__gmpq_clear, :libgmp), Nothing, (Ptr{GMPRational},), Ref(el)) end end @@ -93,19 +93,19 @@ end function -(a::GMPRational) m = GMPRationalMut() ccall((:__gmpq_neg, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Ptr{GMPRational}), &m, &a) + (Ptr{GMPRationalMut}, Ptr{GMPRational}), Ref(m), Ref(a)) GMPRational(m) end function *(a::GMPRational, b::GMPRational) m = GMPRationalMut() ccall((:__gmpq_mul, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), &m, &a, &b) + (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), Ref(m), Ref(a), Ref(b)) GMPRational(m) end function +(a::GMPRational, b::GMPRational) m = GMPRationalMut() ccall((:__gmpq_add, :libgmp), Nothing, - (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), &m, &a, &b) + (Ptr{GMPRationalMut}, Ptr{GMPRational}, Ptr{GMPRational}), Ref(m), Ref(a), Ref(b)) GMPRational(m) end @@ -121,10 +121,10 @@ end function Base.convert(::Type{Rational{BigInt}}, r::GMPRational) a = BigInt() ccall((:__gmpq_get_num, :libgmp), Nothing, - (Ptr{BigInt}, Ptr{GMPRational}), &a, &r) + (Ptr{BigInt}, Ptr{GMPRational}), Ref(a), Ref(r)) b = BigInt() ccall((:__gmpq_get_den, :libgmp), Nothing, - (Ptr{BigInt}, Ptr{GMPRational}), &b, &r) + (Ptr{BigInt}, Ptr{GMPRational}), Ref(b), Ref(r)) a // b end Base.convert(::Type{Rational}, r::GMPRational) = Base.convert(Rational{BigInt}, r)