diff --git a/.travis.yml b/.travis.yml index c0c1fdc..6192bd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,12 @@ install: script: - source activate testenv - nosetests --with-coverage --cover-package=prox_tv -- bash -x ./.travis/deploy.sh +# - bash -x ./.travis/deploy.sh +# Build C lib with CMake +- mkdir -p build && cd build +- cmake -DENABLE_TESTING:BOOL=ON ../ +- cmake --build . +- ctest -VV after_success: - source activate testenv - coveralls diff --git a/.travis/installconda.sh b/.travis/installconda.sh index dcb9ede..20a9314 100644 --- a/.travis/installconda.sh +++ b/.travis/installconda.sh @@ -22,6 +22,7 @@ export PATH="$HOME/miniconda3/bin:$PATH" rm miniconda.sh conda config --set always_yes yes --set changeps1 no conda update -q conda +pip install cmake # Create environment with specific python version conda create -n testenv python=${TRAVIS_PYTHON_VERSION} diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..086d985 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,119 @@ +cmake_minimum_required(VERSION 3.12) + +project(proxTV + VERSION 3.2.1 + DESCRIPTION "Toolbox for fast Total Variation proximity operators" + ) +message(STATUS "Configuring ${PROJECT_NAME}") +message(STATUS " version: ${proxTV_VERSION}") +message(STATUS " description: ${proxTV_DESCRIPTION}") + +# Update CMake module path to lookup proxTV custom CMake modules +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +#------------------------------------------------------------------------------ +option(proxTV_INSTALL_DEVELOPMENT "Install development files" ON) +option(ENABLE_TESTING "Compile tests" OFF) + +#------------------------------------------------------------------------------ +# Set a default build type if none was specified +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Release' as none was specified.") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE) + mark_as_advanced(CMAKE_BUILD_TYPE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + +#------------------------------------------------------------------------------ +# Install directories +if(NOT DEFINED proxTV_INSTALL_BIN_DIR) + set(proxTV_INSTALL_BIN_DIR bin) +endif() +if(NOT DEFINED proxTV_INSTALL_LIB_DIR) + set(proxTV_INSTALL_LIB_DIR lib) +endif() +if(NOT DEFINED proxTV_INSTALL_INCLUDE_DIR) + set(proxTV_INSTALL_INCLUDE_DIR include) +endif() + +#------------------------------------------------------------------------------ +# External dependencies + +find_package(LAPACKE REQUIRED) +message(STATUS "Lapacke libraries: ${LAPACKE_LIBRARIES}") + +find_package(LAPACK REQUIRED) +message(STATUS "Lapack libraries: ${LAPACK_LIBRARIES}") + +set(THREADS_PREFER_PTHREAD_FLAG 1) +find_package(Threads) + +find_package(OpenMP) +message(STATUS "OpenMP found: ${OpenMP_FOUND}") + +#------------------------------------------------------------------------------ +# Add libraries + +add_subdirectory(src) + +#------------------------------------------------------------------------------ +# Testing +if(ENABLE_TESTING) + enable_testing() + add_subdirectory(test) +endif() + +#------------------------------------------------------------------------------ +# Configure proxTVConfigVersion.cmake common to build and install tree +include(CMakePackageConfigHelpers) +set(config_version_file "${proxTV_BINARY_DIR}/proxTVConfigVersion.cmake") +write_basic_package_version_file(${config_version_file} + VERSION ${proxTV_VERSION} + COMPATIBILITY SameMajorVersion + ) + +#------------------------------------------------------------------------------ +# Export 'proxTVTargets.cmake' for a build tree +export(TARGETS proxTV + FILE ${PROJECT_BINARY_DIR}/proxTVTargets.cmake + NAMESPACE proxTV:: + ) + +# Configure 'proxTVConfig.cmake' for a build tree +include(CMakePackageConfigHelpers) +set(build_config ${PROJECT_BINARY_DIR}/proxTVConfig.cmake) +configure_package_config_file( + cmake/proxTVConfig.cmake.in + ${build_config} + INSTALL_DESTINATION ${PROJECT_BINARY_DIR} + INSTALL_PREFIX ${PROJECT_BINARY_DIR} + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + +#------------------------------------------------------------------------------ +# Configure 'proxTVConfig.cmake' for an install tree +if(proxTV_INSTALL_DEVELOPMENT) + set(install_config ${PROJECT_BINARY_DIR}/CMakeFiles/proxTVConfig.cmake) + configure_package_config_file( + cmake/proxTVConfig.cmake.in + ${install_config} + INSTALL_DESTINATION ${proxTV_INSTALL_LIB_DIR}/cmake/proxTV + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + + # Install 'proxTVTargets.cmake' + install(EXPORT proxTVTargets + FILE proxTVTargets.cmake + NAMESPACE proxTV:: + DESTINATION ${proxTV_INSTALL_LIB_DIR}/cmake/proxTV + COMPONENT Development + ) + + # Install config files + install( + FILES ${config_version_file} ${install_config} + DESTINATION ${proxTV_INSTALL_LIB_DIR}/cmake/proxTV + COMPONENT Development + ) +endif() diff --git a/README.md b/README.md index 6ba6280..dbeca13 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,33 @@ More technically, the library provides efficient solvers for the following Total | Anisotropic Total Variation on a 3-dimensional signal (video denoising) | ![alt tag](docs/img/TV3D.png) | | Generalized N-dimensional Anisotropic Total Variation (tensor denoising) | ![alt tag](docs/img/TVND.png), with X(di) every possible 1-dimensional slice of X following dimension di.| +## C interface + +You can generate a **c** static or dynamic library using **cmake**. If `libproxTV` is not provided by your package-manager, install it from source: + + mkdir proxTV-dev ; cd proxTV-dev + git clone https://github.com/albarji/proxTV proxTV + mkdir build ; cd build + cmake ../proxTV + make -j4 + make install + +The required dependencies are `lapack` and `lapacke`, the c-interface for `lapack`, and optionally, but recommended: `OpenMP` with `pthreads` for multi-threading support. + +You can provide extra options to `cmake` via the command line or a gui (i.e `ccmake`). + + cmake ../proxTV -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_INSTALL_PREFIX=/opt/ -DENABLE_TESTING:BOOL=ON + +To use proxTV in your `cmake` project just write in your `CMakeLists.txt`: + + find_package(proxTV) + add_executable(foo main.cpp) + target_link_libraries(foo PUBLIC proxTV::proxTV) + +That will propagate all the dependencies of proxTV to your target. If you haven't installed proxTV in a system folder, you have to point to the installation directory when configuring your project with `cmake`. + + cmake /path/my_project_source_folder -DproxTV_DIR:PATH="/proxTV_install_folder/lib/cmake/proxTV" + ## Python interface ### Install diff --git a/cmake/FindLAPACKE.cmake b/cmake/FindLAPACKE.cmake new file mode 100644 index 0000000..b0e9639 --- /dev/null +++ b/cmake/FindLAPACKE.cmake @@ -0,0 +1,190 @@ +#.rst: +# FindLAPACKE +# ------------- +# +# Find the LAPACKE library +# +# Using LAPACKE: +# +# :: +# +# find_package(LAPACKE REQUIRED) +# include_directories(${LAPACKE_INCLUDE_DIRS}) +# add_executable(foo foo.cc) +# target_link_libraries(foo ${LAPACKE_LIBRARIES}) +# +# This module sets the following variables: +# +# :: +# +# LAPACKE_FOUND - set to true if the library is found +# LAPACKE_INCLUDE_DIRS - list of required include directories +# LAPACKE_LIBRARIES - list of libraries to be linked +# LAPACKE_VERSION_MAJOR - major version number +# LAPACKE_VERSION_MINOR - minor version number +# LAPACKE_VERSION_PATCH - patch version number +# LAPACKE_VERSION_STRING - version number as a string (ex: "0.2.18") + +#============================================================================= +# Copyright 2016 Hans J. Johnson +# +# Distributed under the OSI-approved BSD License (the "License") +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#============================================================================= +# +set(LAPACKE_SEARCH_PATHS + ${LAPACKE_DIR} + $ENV{LAPACKE_DIR} + $ENV{CMAKE_PREFIX_PATH} + ${CMAKE_PREFIX_PATH} + /usr + /usr/local + /usr/local/opt/lapack ## Mac Homebrew install path + /opt/LAPACKE +) +message(STATUS "LAPACKE_SEARCH_PATHS: ${LAPACKE_SEARCH_PATHS}") + +set(CMAKE_PREFIX_PATH ${LAPACKE_SEARCH_PATHS}) +list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) + +## First try to find LAPACKE with NO_MODULE, +## As of 20160706 version 0.2.18 there is limited cmake support for LAPACKE +## that is not as complete as this version, if found, use it +## to identify the LAPACKE_VERSION_STRING and improve searching. +find_package(LAPACKE NO_MODULE QUIET) +if(LAPACKE_FOUND) + if(EXISTS ${LAPACKE_DIR}/lapacke-config-version.cmake) + include(${LAPACKE_DIR}/lapacke-config-version.cmake) + set(LAPACKE_VERSION_STRING ${PACKAGE_VERSION}) + unset(PACKAGE_VERSION) # Use cmake conventional naming + endif() + find_package(LAPACK NO_MODULE QUIET) #Require matching versions here! + find_package(BLAS NO_MODULE QUIET) #Require matching versions here! +endif() + +################################################################################################## +### First search for headers +find_path(LAPACKE_CBLAS_INCLUDE_DIR + NAMES cblas.h + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES include include/lapack) +find_path(LAPACKE_LAPACKE_INCLUDE_DIR + NAMES lapacke.h + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES include) + +################################################################################################## +### Second, search for libraries +set(PATH_SUFFIXES_LIST + lib64 + lib +) +find_library(LAPACKE_LIB + NAMES lapacke + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES ${PATH_SUFFIXES_LIST}) +find_library(CBLAS_LIB + NAMES cblas + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES ${PATH_SUFFIXES_LIST}) +find_library(LAPACK_LIB + NAMES lapack + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES ${PATH_SUFFIXES_LIST}) +find_library(BLAS_LIB + NAMES blas + PATHS ${LAPACKE_SEARCH_PATHS} + PATH_SUFFIXES ${PATH_SUFFIXES_LIST}) + +## TODO: Get version components +# ------------------------------------------------------------------------ +# Extract version information +# ------------------------------------------------------------------------ + +# WARNING: We may not be able to determine the version of some LAPACKE +set(LAPACKE_VERSION_MAJOR 0) +set(LAPACKE_VERSION_MINOR 0) +set(LAPACKE_VERSION_PATCH 0) +if(LAPACKE_VERSION_STRING) + string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\1" LAPACKE_VERSION_MAJOR "${LAPACKE_VERSION_STRING}") + string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\2" LAPACKE_VERSION_MINOR "${LAPACKE_VERSION_STRING}") + string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3" LAPACKE_VERSION_PATCH "${LAPACKE_VERSION_STRING}") +endif() + +#====================== +# Checks 'REQUIRED', 'QUIET' and versions. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LAPACKE FOUND_VAR LAPACKE_FOUND + REQUIRED_VARS LAPACKE_CBLAS_INCLUDE_DIR + LAPACKE_LAPACKE_INCLUDE_DIR + LAPACKE_LIB + LAPACK_LIB + CBLAS_LIB + BLAS_LIB + VERSION_VAR LAPACKE_VERSION_STRING +) + +if (LAPACKE_FOUND) + set(LAPACKE_INCLUDE_DIRS ${LAPACKE_CBLAS_INCLUDE_DIR} ${LAPACKE_CBLAS_INCLUDE_DIR}) + list(REMOVE_DUPLICATES LAPACKE_INCLUDE_DIRS) + if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" OR + "${CMAKE_C_COMPILER_ID}" MATCHES ".*GNU.*" OR + "${CMAKE_C_COMPILER_ID}" MATCHES ".*Intel.*" + ) #NOT MSVC + set(MATH_LIB m) + endif() + list(APPEND LAPACKE_LIBRARIES ${LAPACKE_LIB} ${LAPACK_LIB} ${BLAS_LIB} ${CBLAS_LIB}) + # Check for a common combination, and find required gfortran support libraries + + if(1) + if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + message(STATUS "\n\n WARNING: ${CMAKE_C_COMPILER} identified as ${CMAKE_C_COMPILER_ID}\n" + "AND: ${CMAKE_Fortran_COMPILER} identified as ${CMAKE_Fortran_COMPILER_ID}\n" + "\n" + "may be require special configurations. The most common is the need to" + "explicitly link C programs against the gfortran support library.") + + endif() + else() + ## This code automated code is hard to determine if it is robust in many different environments. + # Check for a common combination, and find required gfortran support libraries + if("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*" AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + include(FortranCInterface) + FortranCInterface_VERIFY() + if(NOT FortranCInterface_VERIFIED_C) + message(FATAL_ERROR "C and fortran compilers are not compatible:\n${CMAKE_Fortran_COMPILER}:${CMAKE_C_COMPILER}") + endif() + + execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -print-file-name=libgfortran.a OUTPUT_VARIABLE FORTRANSUPPORTLIB ERROR_QUIET) + string(STRIP ${FORTRANSUPPORTLIB} FORTRANSUPPORTLIB) + if(EXISTS "${FORTRANSUPPORTLIB}") + list(APPEND LAPACKE_LIBRARIES ${FORTRANSUPPORTLIB}) + message(STATUS "Appending fortran support lib: ${FORTRANSUPPORTLIB}") + else() + message(FATAL_ERROR "COULD NOT FIND libgfortran.a support library:${FORTRANSUPPORTLIB}:") + endif() + endif() + endif() + list(APPEND LAPACKE_LIBRARIES ${MATH_LIB}) +endif() + +mark_as_advanced( + LAPACKE_FOUND + LAPACKE_INCLUDE_DIRS + LAPACKE_LIBRARIES + LAPACKE_VERSION_MAJOR + LAPACKE_VERSION_MINOR + LAPACKE_VERSION_PATCH + LAPACKE_VERSION_STRING +) + +## For debugging +message(STATUS "LAPACKE_FOUND :${LAPACKE_FOUND}: - set to true if the library is found") +message(STATUS "LAPACKE_INCLUDE_DIRS :${LAPACKE_INCLUDE_DIRS}: - list of required include directories") +message(STATUS "LAPACKE_LIBRARIES :${LAPACKE_LIBRARIES}: - list of libraries to be linked") +message(STATUS "LAPACKE_VERSION_MAJOR :${LAPACKE_VERSION_MAJOR}: - major version number") +message(STATUS "LAPACKE_VERSION_MINOR :${LAPACKE_VERSION_MINOR}: - minor version number") +message(STATUS "LAPACKE_VERSION_PATCH :${LAPACKE_VERSION_PATCH}: - patch version number") +message(STATUS "LAPACKE_VERSION_STRING :${LAPACKE_VERSION_STRING}: - version number as a string") diff --git a/cmake/README.md b/cmake/README.md new file mode 100644 index 0000000..be07c7c --- /dev/null +++ b/cmake/README.md @@ -0,0 +1,7 @@ +Modern lapacke provides a lapacke-config.cmake (minimum version unconfirmed, but 3.7.1 does) +so FindLAPACKE.cmake wouldn't be neccesary, (see #38) +however this isn't reliable for older/other lapacke versions, so we provide a FindModule from: https://github.com/mrirecon/bart/blob/master/cmake/FindLAPACKE.cmake. + +Download with `curl -O https://raw.githubusercontent.com/mrirecon/bart/master/cmake/FindLAPACKE.cmake` + +This FindLapacke handles properly the case a lapacke-config.cmake exists in the system. diff --git a/cmake/proxTVConfig.cmake.in b/cmake/proxTVConfig.cmake.in new file mode 100644 index 0000000..19a8112 --- /dev/null +++ b/cmake/proxTVConfig.cmake.in @@ -0,0 +1,13 @@ +@PACKAGE_INIT@ + +set_and_check(proxTV_TARGETS "${CMAKE_CURRENT_LIST_DIR}/proxTVTargets.cmake") + +if(NOT TARGET proxTV::proxTV) + include(${proxTV_TARGETS}) +endif() + +include(CMakeFindDependencyMacro) +find_dependency(LAPACKE) +find_dependency(LAPACK) +find_dependency(OpenMP) +find_dependency(Threads) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..d33abd9 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,91 @@ +set(LIB_INSTALL_DIR lib CACHE STRING "Install folder for lib (relative") +set(INCLUDE_INSTALL_DIR include CACHE STRING "Install folder for headers (relative") +set(EXECUTABLE_INSTALL_DIR bin CACHE STRING "Install folder for executables (relative") + +set(headers + condat_fast_tv.h + general.h + johnsonRyanTV.h + LPopt.h + TVmacros.h + TVopt.h + utils.h + ) + +set(sources + condat_fast_tv.cpp + johnsonRyanTV.cpp + LPopt.cpp + TV2Dopt.cpp + TV2DWopt.cpp + TVgenopt.cpp + TVL1opt.cpp + TVL1opt_hybridtautstring.cpp + TVL1opt_kolmogorov.cpp + TVL1opt_tautstring.cpp + TVL1Wopt.cpp + TVL2opt.cpp + TVLPopt.cpp + TVNDopt.cpp + utils.cpp + ) + +add_library(proxTV ${sources}) + +target_compile_definitions(proxTV PUBLIC NOMATLAB) + +# Create directory with headers at build and install time. +file(COPY ${headers} + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include") +install(FILES ${headers} + DESTINATION ${INCLUDE_INSTALL_DIR}) + +target_include_directories(proxTV PUBLIC + $ + $ + ${LAPACKE_INCLUDE_DIRS} + ) + +# Lapacke, Lapack, pthreads +target_link_libraries(proxTV PUBLIC + ${CMAKE_THREAD_LIBS_INIT} + ${LAPACK_LIBRARIES} + ${LAPACKE_LIBRARIES} + ) + +# OpenMP +target_compile_options(proxTV PUBLIC ${OpenMP_CXX_FLAGS}) +target_link_libraries(proxTV PUBLIC ${OpenMP_CXX_LIBRARIES}) + +install(TARGETS proxTV EXPORT proxTVTargets + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${EXECUTABLE_INSTALL_DIR} + INCLUDES DESTINATION ${INCLUDE_INSTALL_DIR} + ) + +# This saves as to develop a hacky FindproxTV for other to use the library. +# A regular find_package(proxTV) will look for these targets. +# It needs an extra proxTVConfig.cmake to handle dependencies (provided in cmake directory) +install(EXPORT proxTVTargets + FILE proxTVTargets.cmake + NAMESPACE proxTV:: + DESTINATION ${LIB_INSTALL_DIR}/cmake/proxTV + ) + +# Generate and install proxTVConfigVersion.cmake +include(CMakePackageConfigHelpers) +write_basic_package_version_file("proxTVConfigVersion.cmake" + VERSION ${proxTV_VERSION} + COMPATIBILITY SameMajorVersion + ) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/proxTVConfigVersion.cmake + DESTINATION ${LIB_INSTALL_DIR}/cmake/proxTV + ) + +# Install proxTVConfig.cmake +install(FILES + ${CMAKE_SOURCE_DIR}/cmake/proxTVConfig.cmake + DESTINATION ${LIB_INSTALL_DIR}/cmake/proxTV + ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..1541962 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,21 @@ +set(test_names + test_tv1_2d + #other_test + ) + +add_executable(test_tv1_2d "test_tv1_2d.cpp") +add_test(NAME tv1_2d COMMAND test_tv1_2d) + +# To add more tests: append a name to test_names, and add_executable/add_test with that name +# Tests can be run with `ctest` in the build directory, +# it accepts regex, and different verbosity: ctest -R tv1 -VV +# add_executable(other_test "a_test_source_file.cpp") +# add_test(NAME a_name_that_makes_sense COMMAND other_test) + +# Link proxTV and include_directory for each executable. +foreach(test_executable ${test_names}) + target_include_directories(${test_executable} PUBLIC + $) + target_compile_definitions(${test_executable} PUBLIC NOMATLAB) + target_link_libraries(${test_executable} PUBLIC proxTV) +endforeach() diff --git a/test/project_using_proxTV/CMakeLists.txt b/test/project_using_proxTV/CMakeLists.txt new file mode 100644 index 0000000..555ff14 --- /dev/null +++ b/test/project_using_proxTV/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8.12) +project(dummy) +find_package(proxTV) +add_executable(dummy dummy.cpp) +# All the requirements of proxTV: compiler definitions, include_directories, linker flags (INTERFACE) are propagated to the target. +target_link_libraries(dummy PUBLIC proxTV::proxTV ) diff --git a/test/project_using_proxTV/README.md b/test/project_using_proxTV/README.md new file mode 100644 index 0000000..3cdac16 --- /dev/null +++ b/test/project_using_proxTV/README.md @@ -0,0 +1,12 @@ +This a minimal project using proxTV as a third-party. +To compile it, it requires that proxTV is installed somewhere in your system. +The installation folder can be modified when configuring proxTV with the option + + -DCMAKE_INSTALL_PREFIX:PATH="/proxTV_install_folder" + +The default is usually the system folder `/usr`. Please read https://github.com/albarji/proxTV/README.md#c-interface for more info. + +Once installed in your system, if it is not in your system path, provide the folder where the `proxTVConfig.cmake` file is located with the option `-proxTV_DIR`: + + mkdir ~/dummy_project ; cd ~/dummy_project + cmake /path/proxTV/test/project_using_proxTV/ -DproxTV_DIR:PATH="/proxTV_install_folder/lib/cmake/proxTV" diff --git a/test/project_using_proxTV/dummy.cpp b/test/project_using_proxTV/dummy.cpp new file mode 100644 index 0000000..876a299 --- /dev/null +++ b/test/project_using_proxTV/dummy.cpp @@ -0,0 +1,26 @@ +#include "TVopt.h" + + +int main() +{ +// int DR2_TV(size_t M, size_t N, double*unary, double W1, double W2, double norm1, double norm2, double*s, int nThreads, int maxit, double* info); + + size_t M = 1; + size_t N = 1; + double* unary = new double; + double W1 = 1.0; + double W2 = 1.0; + double norm1 = 1.0; + double norm2 = 1.0; + double* s = new double; + int nThreads = 1; + int maxit = 1; + double* info = new double; + int r = DR2_TV(M, N, unary, W1, W2, norm1, norm2, s, nThreads, maxit, info); + + delete unary; + delete s; + delete info; + + return r; +} diff --git a/test/test_tv1_2d.cpp b/test/test_tv1_2d.cpp new file mode 100644 index 0000000..876a299 --- /dev/null +++ b/test/test_tv1_2d.cpp @@ -0,0 +1,26 @@ +#include "TVopt.h" + + +int main() +{ +// int DR2_TV(size_t M, size_t N, double*unary, double W1, double W2, double norm1, double norm2, double*s, int nThreads, int maxit, double* info); + + size_t M = 1; + size_t N = 1; + double* unary = new double; + double W1 = 1.0; + double W2 = 1.0; + double norm1 = 1.0; + double norm2 = 1.0; + double* s = new double; + int nThreads = 1; + int maxit = 1; + double* info = new double; + int r = DR2_TV(M, N, unary, W1, W2, norm1, norm2, s, nThreads, maxit, info); + + delete unary; + delete s; + delete info; + + return r; +}