From 0c5253d4b376ffb9c3d99546db66ecfdc2308605 Mon Sep 17 00:00:00 2001 From: nathanemac <91251698+nathanemac@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:39:14 -0400 Subject: [PATCH] add __init__() function to ProxTV.jl --- .DS_Store | Bin 8196 -> 8196 bytes src/.DS_Store | Bin 6148 -> 6148 bytes src/ProxTV.jl | 14 ++++++++------ src/libproxtv.jl | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.DS_Store b/.DS_Store index 1f4f0c1f75f20ae90f69cdda3efa777bf4524c23..cea9ce7cf7ac0a9f6f62adbea87466480ef39c75 100644 GIT binary patch delta 103 zcmZp1XmOa}&nUDpU^hRb&}JTi^^E$w489DB40#Nh3~3Ch48;s340=GE&ydTIsuK~055my3}S`|mLlN59Vk$^h02N?DQlPMG< Lvsx9c0+E0>=kO9G diff --git a/src/.DS_Store b/src/.DS_Store index 19f15a0fbb02c18d71dd8e62c05da228d1decae6..354d02a6f33b8d1c6361273558d2ac0d3be05ff5 100644 GIT binary patch delta 21 ccmZoMXffEZhl#_`(nv?a*wAA05he#w07+v8F#rGn delta 21 ccmZoMXffEZhl#_;%s@xM*u-e_5he#w07)kXDgXcg 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},