def norm_nuclear(X): r"""Compute the nuclear norm .. math:: \| X \|_* = \sum_i \sigma_i where :math:`\sigma_i` are the singular values of matrix :math:`X`. Parameters ---------- X : array_like Input array :math:`X` Returns ------- nncl : float Nuclear norm of `X` """ return np.sum(np.linalg.svd(sl.promote16(X), compute_uv=False))
def prox_nuclear(v, alpha): r"""Proximal operator of the nuclear norm :cite:`cai-2010-singular`. Parameters ---------- v : array_like Input array :math:`V` alpha : float Parameter :math:`\alpha` Returns ------- x : ndarray Output array s : ndarray Singular values of `x` """ U, s, V = sl.promote16(v, fn=np.linalg.svd, full_matrices=False) ss = np.maximum(0, s - alpha) return np.dot(U, np.dot(np.diag(ss), V)), ss
def prox_nuclear(V, alpha): r"""Proximal operator of the nuclear norm :cite:`cai-2010-singular` with parameter :math:`\alpha`. Parameters ---------- v : array_like Input array :math:`V` alpha : float Parameter :math:`\alpha` Returns ------- X : ndarray Output array s : ndarray Singular values of `X` """ Usvd, s, Vsvd = sl.promote16(V, fn=np.linalg.svd, full_matrices=False) ss = np.maximum(0, s - alpha) return np.dot(Usvd, np.dot(np.diag(ss), Vsvd)), ss
def nucnorm(x): """Nuclear norm""" return np.sum(np.linalg.svd(sl.promote16(x), compute_uv=False))
def shrinksv(v, alpha): """Shrinkage of singular values""" U, s, V = sl.promote16(v, fn=np.linalg.svd, full_matrices=False) ss = np.maximum(0, s - alpha) return np.dot(U, np.dot(np.diag(ss), V)), ss