9#if EIGEN_VERSION_AT_LEAST(3, 4, 1)
11using DefaultSVD = Eigen::BDCSVD<
typename Conf::mat,
12 Eigen::ComputeThinU | Eigen::ComputeThinV>;
20template <Config Conf,
class SVD = DefaultSVD<Conf>>
26 if (
λ < 0 || !std::isfinite(
λ))
27 throw std::invalid_argument(
"NuclearNorm::λ must be nonnegative");
32#if EIGEN_VERSION_AT_LEAST(3, 4, 1)
35 svd{
rows,
cols, Eigen::ComputeThinU | Eigen::ComputeThinV},
38 if (
λ < 0 || !std::isfinite(
λ))
39 throw std::invalid_argument(
"NuclearNorm::λ must be nonnegative");
53 assert(in.rows() == out.rows());
54 assert(in.cols() == out.cols());
55#if EIGEN_VERSION_AT_LEAST(3, 4, 1)
58 svd.compute(in, Eigen::ComputeThinU | Eigen::ComputeThinV);
63#if EIGEN_VERSION_AT_LEAST(3, 4, 1)
67 Eigen::ComputeThinU | Eigen::ComputeThinV);
71 auto step = vec::Constant(n,
λ * γ);
77 using Eigen::placeholders::all, Eigen::seqN;
78 auto sel = seqN(0, rank);
79 auto &&U =
svd.matrixU(), &&V =
svd.matrixV();
80 auto &&U1 = U(all, sel);
82 auto &&V1T = V.transpose()(sel, all);
83 out.reshaped().noalias() = (U1 * Σ1 * V1T).reshaped();
89 return self.
prox(std::move(in), std::move(out), γ);
#define USING_ALPAQA_CONFIG(Conf)
Eigen::BDCSVD< typename Conf::mat > DefaultSVD
auto norm_1(const Eigen::MatrixBase< Derived > &v)
Get the 1-norm of the given vector.
typename Conf::crmat crmat
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
real_t prox(crmat in, rmat out, real_t γ=1)
NuclearNorm(real_t λ=1)
Construct without pre-allocation.
friend real_t guanaqo_tag_invoke(tag_t< alpaqa::prox >, NuclearNorm &self, crmat in, rmat out, real_t γ)
NuclearNorm(real_t λ, length_t rows, length_t cols)
Construct with pre-allocation.