6 int main(
int,
char const **) {
14 auto constexpr
N = 10;
15 t_Matrix const L0 = t_Matrix::Random(
N,
N) * 2;
16 t_Matrix const L1 = t_Matrix::Random(
N,
N) * 4;
19 auto L1_direct = [&L1](
t_Vector &out,
t_Vector const &input) { out = L1 * input; };
20 auto L1_adjoint = [&L1](
t_Vector &out,
t_Vector const &input) { out = L1.adjoint() * input; };
22 t_Vector const target0 = t_Vector::Random(
N);
23 t_Vector const target1 = t_Vector::Random(
N);
36 std::shared_ptr<t_Vector> previous;
37 auto relative = [&previous](
t_Vector const &candidate) {
39 previous = std::make_shared<t_Vector>(candidate);
42 auto const norm = (*previous - candidate).stableNorm();
43 SOPT_TRACE(
" - Checking convergence {}", norm);
44 auto const result = norm < 1e-8 * candidate.size();
45 *previous = candidate;
55 .is_converged(relative)
60 .append(prox_g1, L1_direct, L1_adjoint);
63 t_Vector const input = t_Vector::Random(
N);
64 auto const diagnostic = sdmm(result, input);
69 if (not diagnostic.good)
throw std::runtime_error(
"Did not converge!");
73 auto const objective = [&target0, &target1, &L0, &L1](
t_Vector const &x) {
74 return (L0 * x - target0).norm() + (L1 * x - target1).norm();
76 auto const minimum = objective(result);
77 for (
int i(0); i <
N; ++i) {
80 auto const at_x_plus_epsilon = objective(input +
epsilon);
81 if (minimum >= at_x_plus_epsilon)
throw std::runtime_error(
"That's no minimum!");
sopt::Vector< Scalar > t_Vector
sopt::Matrix< Scalar > t_Matrix
Simultaneous-direction method of the multipliers.
SDMM< SCALAR > & conjugate_gradient(t_uint itermax, t_real tolerance)
Helps setup conjugate gradient.
Proximal of euclidian norm.
Translation< FUNCTION, VECTOR > translate(FUNCTION const &func, VECTOR const &translation)
Translates given proximal by given vector.
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.
std::complex< t_real > t_complex
Root of the type hierarchy for (real) complex numbers.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.
int main(int, char const **)