diff --git a/.DS_Store b/.DS_Store index 1f4f0c1..cea9ce7 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/src/.DS_Store b/src/.DS_Store index 19f15a0..354d02a 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/ProxTV.jl b/src/ProxTV.jl index 9363b6b..5d6703b 100644 --- a/src/ProxTV.jl +++ b/src/ProxTV.jl @@ -3,13 +3,15 @@ module ProxTV using OpenBLAS32_jll using LAPACK_jll using LinearAlgebra -# Include wrappers and the main library -include("libproxtv.jl") -# include("gen/wrapper.jl") -config = LinearAlgebra.BLAS.lbt_get_config() -if !any(lib -> lib.interface == :lp64, config.loaded_libs) - LinearAlgebra.BLAS.lbt_forward(OpenBLAS32_jll.libopenblas_path) +function __init__() + config = LinearAlgebra.BLAS.lbt_get_config() + if !any(lib -> lib.interface == :lp64, config.loaded_libs) + LinearAlgebra.BLAS.lbt_forward(OpenBLAS32_jll.libopenblas_path) + end end +# main library functions +include("libproxtv.jl") + end diff --git a/src/libproxtv.jl b/src/libproxtv.jl index aae68e9..0c4746b 100644 --- a/src/libproxtv.jl +++ b/src/libproxtv.jl @@ -1,3 +1,5 @@ +# This file contains the Julia bindings for the ProxTV library. + using proxTV_jll function LPnorm(x, n, p) @@ -109,6 +111,7 @@ function solveLinearLP(z, n, p, lambda, s) )::Cvoid end +# original TV function function TV(y, lambda, x, info, n, p, ws) @ccall libproxtv.TV( y::Ptr{Float64}, @@ -121,6 +124,51 @@ function TV(y, lambda, x, info, n, p, ws) )::Int32 end +# # overloaded TV function +# function TV(y, lambda, x, p, ws) +# n = length(y) # works for nD signals +# info = [] +# if ws != C_NULL +# @warn "Workspace was defined but ignored because of potential memory leak" +# ws == C_NULL +# end +# @ccall libproxtv.TV( +# y::Ptr{Float64}, +# lambda::Float64, +# x::Ptr{Float64}, +# info::Ptr{Float64}, +# n::Int32, +# p::Float64, +# ws::Ptr{Workspace}, +# )::Int32 +# end + +# # overloaded TV function +# function TV(y, lambda, x, p) +# @warn "Workspace was not defined. Defining a default workspace : Potential memory leak." +# n = length(y) # works for nD signals +# info = [] +# # define a workspace allowing local memory management +# ws = newWorkspace(n) +# println("Workspace allocated") +# try +# # Appel de la fonction TV avec le workspace +# result = @ccall libproxtv.TV( +# y::Ptr{Float64}, +# lambda::Float64, +# x::Ptr{Float64}, +# info::Ptr{Float64}, +# n::Int32, +# p::Float64, +# ws::Ptr{Workspace} # Passe le workspace alloué +# )::Int32 +# finally +# # Libère le workspace une fois l'opération terminée +# freeWorkspace(ws) +# end +# return result +# end + function PN_TV1(y, lambda, x, info, n, sigma, ws) @ccall libproxtv.PN_TV1( y::Ptr{Float64},