All problems
Nuclear Norm from Singular Values
Problem
Compute the nuclear norm (trace norm) of a matrix from its singular values:
||A||_* = sum(sigma_i)
The input is a list of non-negative singular values.
Hint
The nuclear norm is the L1 norm of the singular value vector.
Test cases
case 1
in: [[3,0,0]]
expected: 3
case 2
in: [[5,3,1]]
expected: 9
case 3
in: [[2.5,1.5]]
expected: 4
case 4
in: [[0,0]]
expected: 0
Starter codePython
def nuclear_norm(singular_values):
# Your code here
pass4 test cases · run your code against them in the editor