diff --git a/src/wrapper/qr_mumps_api.jl b/src/wrapper/qr_mumps_api.jl index 3528235..b09a1c5 100644 --- a/src/wrapper/qr_mumps_api.jl +++ b/src/wrapper/qr_mumps_api.jl @@ -861,10 +861,10 @@ for (finame, frname, elty) in ((:sqrm_spfct_get_i8_c, :sqrm_spfct_get_r4_c, :Flo @eval begin function qrm_get(spfct :: qrm_spfct{$elty}, str :: String) if (str ∈ PICNTL) || (str ∈ STATS) - val = Ref{Clonglong}(0) + val = spfct.ref_int err = $finame(spfct, str, val) elseif str ∈ RCNTL - val = Ref{Float32}(0) + val = spfct.ref_float err = $frname(spfct, str, val) else err = Int32(23) diff --git a/src/wrapper/qr_mumps_common.jl b/src/wrapper/qr_mumps_common.jl index ab79222..53bc2e7 100644 --- a/src/wrapper/qr_mumps_common.jl +++ b/src/wrapper/qr_mumps_common.jl @@ -78,10 +78,12 @@ mutable struct qrm_spfct{T} <: Factorization{T} cperm_in :: Vector{Cint} ptr_rp :: Ref{Ptr{Cint}} ptr_cp :: Ref{Ptr{Cint}} + ref_int :: Ref{Clonglong} + ref_float:: Ref{Float32} fct :: c_spfct{T} function qrm_spfct{T}() where T - spfct = new(Cint[], Ref{Ptr{Cint}}(), Ref{Ptr{Cint}}(), c_spfct{T}()) + spfct = new(Cint[], Ref{Ptr{Cint}}(), Ref{Ptr{Cint}}(), Ref{Clonglong}(0), Ref{Float32}(0), c_spfct{T}()) finalizer(qrm_spfct_destroy!, spfct) return spfct end diff --git a/test/test_qrm.jl b/test/test_qrm.jl index ac3fb6c..c7a42be 100644 --- a/test/test_qrm.jl +++ b/test/test_qrm.jl @@ -546,3 +546,27 @@ end @test norm(b - A'*(A*x)) ≥ norm(b - A'*(A*x_refined)) end end + +@testset "allocations" begin + for T in (Float32, Float64, ComplexF32, ComplexF64) + tol = (real(T) == Float32) ? 1e-3 : 1e-12 + transp = (T <: Real) ? 't' : 'c' + + for I in (Int32 , Int64) + A = sprand(T, m, n, 0.3) + A = convert(SparseMatrixCSC{T,I}, A) + + spmat = qrm_spmat_init(T) + qrm_spmat_init!(spmat, A) + + spfct = qrm_spfct_init(spmat) + + qrm_set(spfct, "qrm_rd_eps", tol) + qrm_analyse!(spmat, spfct) + qrm_factorize!(spmat, spfct) + @test (@allocated qrm_get(spfct, "qrm_rd_num")) == 0 + + end + end + +end