Reconstruct a matrix from only its first k singular components (a truncated singular value decomposition).
Implement solve(A, k).
Returns. Return a NumPy array of the same shape as A. The rank k is clipped into the valid range, and k = 0 gives an all-zero matrix.
Example 1
Input:
solve([[3.0, 0.0], [0.0, 1.0]], 1)
Output:
[[3.0, 0.0], [0.0, 0.0]]
Example 2
Input:
solve([[1.0, 2.0], [3.0, 4.0]], 2)
Output:
[[1.0, 2.0], [3.0, 4.0]]
No results yet
Run your code to check it against the examples, or submit to run every test.