1 #include <catch2/catch_all.hpp>
9 TEST_CASE(
"Parallel Euclidian norm",
"[proximal]") {
11 auto const world = mpi::Communicator::World();
17 eucl(out, std::sqrt(world.all_sum_all(x.squaredNorm())) * 1.001, x);
21 CHECK(out.isApprox(x * (1e0 - 0.1 / std::sqrt(world.all_sum_all(x.squaredNorm())))));
26 auto const world = mpi::Communicator::World();
34 CHECK(x.isApprox(out / 0.5 * std::sqrt(world.all_sum_all(x.squaredNorm()))));
35 ball.
epsilon(std::sqrt(world.all_sum_all(x.squaredNorm())) * 1.001);
37 CHECK(x.isApprox(out));
40 TEST_CASE(
"Parallel WeightedL2Ball",
"[proximal]") {
42 auto const world = mpi::Communicator::World();
51 ball((x.array() * weights.array()).matrix()).array() / weights.array();
53 CHECK(actual.isApprox(expected));
55 wball.
epsilon(std::sqrt(world.all_sum_all((x.array() * weights.array()).matrix().squaredNorm())) *
57 CHECK(x.isApprox(wball(x)));
Proximal of euclidian norm.
Proximal for indicator function of L2 ball.
Real epsilon() const
Size of the ball.
Real epsilon() const
Size of the ball.
TEST_CASE("Parallel Euclidian norm", "[proximal]")
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.