1 #include <catch2/catch_all.hpp>
25 DiagnosticAndResult::x = x.array() + 0.1;
30 DiagnosticAndResult::x = warm.
x.array() + 0.1;
73 GIVEN(
"The maximum number of iteration is zero") {
75 WHEN(
"The reweighting algorithm is called") {
76 auto const result = l0algo(input);
77 THEN(
"The algorithm exited at the first iteration") {
78 CHECK(result.niters == 0);
79 CHECK(result.good ==
true);
81 THEN(
"The weights is set to 1") {
82 CHECK(result.weights.size() == 1);
83 CHECK(std::abs(result.weights(0) - 1) < 1e-12);
85 THEN(
"The inner algorithm was called once") {
88 CHECK(result.algo.x.array().isApprox(input.array() + 0.1));
93 GIVEN(
"The maximum number of iterations is one") {
95 WHEN(
"The reweighting algorithm is called") {
96 auto const result = l0algo(input);
97 THEN(
"The algorithm exited at the second iteration") {
98 CHECK(result.niters == 1);
99 CHECK(result.good ==
true);
101 THEN(
"The weights are not one") {
102 CHECK(result.weights.size() == input.size());
106 CHECK(result.weights.array().isApprox(delta / (delta + PsiT_x.array().abs())));
108 THEN(
"The inner algorithm was called twice") {
111 CHECK(result.algo.x.array().isApprox(input.array() + 0.2));
Reweighted< ALGORITHM > reweighted(ALGORITHM const &algo, typename Reweighted< ALGORITHM >::t_SetWeights const &set_weights, typename Reweighted< ALGORITHM >::t_Reweightee const &reweightee)
Factory function to create an l0-approximation by reweighting an l1 norm.
real_type< typename T::Scalar >::type standard_deviation(Eigen::ArrayBase< T > const &x)
Computes the standard deviation of a vector.
double t_real
Root of the type hierarchy for real numbers.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
std::function< bool(Vector< SCALAR > const &)> ConvergenceFunction
Typical function signature for convergence.
static t_Vector x
Expected by reweighted algorithm.
Minimum set of functions and type aliases needed by reweighting.
static int called_with_warm
static int called_reweightee
static int called_weights
DiagnosticAndResult operator()(DiagnosticAndResult const &warm) const
static t_Vector reweightee(DummyAlgorithm const &, t_Vector const &x)
Applies Ψ^T * x.
ConvergenceFunction< Scalar > t_IsConverged
static void set_weights(DummyAlgorithm &, t_Vector const &weights)
sets the weights
DiagnosticAndResult operator()(t_Vector const &x) const
Vector< Scalar > t_Vector
TEST_CASE("L0-Approximation")