1 #include <catch2/catch_all.hpp>
32 .l1_proximal_weights(t_Vector::Ones(
target.size()))
37 .regulariser_strength(0.4)
38 .l2ball_proximal_epsilon(
epsilon)
39 .relative_variation(1e-4)
42 auto const result = primaldual();
43 CHECK((result.x -
target).stableNorm() <= Approx(
epsilon).margin(1e-10));
47 output = regulariser_strength * input;
49 .l1_proximal_weighted(
51 output = 10 * regulariser_strength.array() * input.array();
53 CHECK_THROWS(primaldual());
55 TEST_CASE(
"Primal Dual with 0.5 * ||x - x0||_2^2 function",
"[primaldual]") {
57 t_Vector const target0 = t_Vector::Random(
N);
62 const t_Vector x_guess = t_Vector::Random(target0.size());
63 const t_Vector res = x_guess - target0;
64 auto const convergence = [&target0](
const t_Vector &x,
const t_Vector &res) ->
bool {
65 return x.isApprox(target0, 1e-9);
72 .regulariser_strength(0.9)
76 auto const result = pd(std::make_tuple(x_guess, res));
77 CAPTURE(result.niters);
79 CAPTURE(result.residual);
80 CHECK(result.x.isApprox(target0, 1e-9));
82 CHECK(result.niters < 200);
86 struct is_primal_dual_ref :
public std::is_same<sopt::algorithm::ImagingPrimalDual<double> &, T> {};
87 TEST_CASE(
"Check type returned on setting variables") {
sopt::Vector< Scalar > t_Vector
sopt::Matrix< Scalar > t_Matrix
ImagingPrimalDual &::type Psi(ARGS &&... args)
ImagingPrimalDual< Scalar > & residual_convergence(Real const &tolerance)
Helper function to set-up default residual convergence function.
ImagingPrimalDual &::type Phi(ARGS &&... args)
PrimalDual< Scalar > & is_converged(std::function< bool(t_Vector const &x)> const &func)
Convergence function that takes only the output as argument.
Proximal for the L2 norm.
void id(Eigen::DenseBase< T0 > &out, typename real_type< typename T0::Scalar >::type gamma, Eigen::DenseBase< T1 > const &x)
Proximal of a function that is always zero, the identity.
Eigen::CwiseUnaryOp< const details::ProjectPositiveQuadrant< typename T::Scalar >, const T > positive_quadrant(Eigen::DenseBase< T > const &input)
Expression to create projection onto positive quadrant.
double t_real
Root of the type hierarchy for real numbers.
Vector< T > target(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
real_type< T >::type epsilon(sopt::LinearTransform< Vector< T >> const &sampling, sopt::Image< T > const &image)
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.
TEST_CASE("Primal Dual Imaging", "[primaldual]")