#include <catch2/catch_all.hpp>
#include <numeric>
#include <random>
#include <utility>
#include "sopt/proximal.h"
#include "sopt/types.h"
Go to the source code of this file.
|
| TEST_CASE ("Parallel Euclidian norm", "[proximal]") |
|
| TEST_CASE ("Parallel L2 ball", "[proximal]") |
|
| TEST_CASE ("Parallel WeightedL2Ball", "[proximal]") |
|
◆ TEST_CASE() [1/3]
TEST_CASE |
( |
"Parallel Euclidian norm" |
, |
|
|
"" |
[proximal] |
|
) |
| |
Definition at line 9 of file mpi_proximals.cc.
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())))));
Proximal of euclidian norm.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
◆ TEST_CASE() [2/3]
TEST_CASE |
( |
"Parallel L2 ball" |
, |
|
|
"" |
[proximal] |
|
) |
| |
Definition at line 24 of file mpi_proximals.cc.
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));
Proximal for indicator function of L2 ball.
References sopt::proximal::L2Ball< T >::epsilon().
◆ TEST_CASE() [3/3]
TEST_CASE |
( |
"Parallel WeightedL2Ball" |
, |
|
|
"" |
[proximal] |
|
) |
| |
Definition at line 40 of file mpi_proximals.cc.
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)));
References sopt::proximal::WeightedL2Ball< T >::epsilon().