All problems
Frobenius Norm
Problem
Compute the Frobenius norm of matrix A: the square root of the sum of squared entries.
||A||_F = sqrt(sum(A[i][j]^2)).
Hint
Flatten the matrix and take the L2 norm of all entries.
Test cases
case 1
in: [[[1,2],[3,4]]]
expected: 5.477225575051661
case 2
in: [[[3,0],[0,4]]]
expected: 5
case 3
in: [[[1,1],[1,1]]]
expected: 2
case 4
in: [[[0]]]
expected: 0
Starter codePython
def frobenius_norm(A):
# Your code here
pass4 test cases · run your code against them in the editor