All problems
Pseudoinverse of Outer Product
Problem
Compute the Moore-Penrose pseudoinverse of the rank-1 outer product A = a*b^T, where a has length m and b has length n.
Using the formula inv(A^T A) A^T, the pseudoinverse reduces to the n x m matrix (b*a^T) / (||a||^2 * ||b||^2). Return an n x m zero matrix if a or b is the zero vector.
Hint
For a rank-1 matrix, the pseudoinverse is another scaled outer product.
Test cases
case 1
in: [[1,0],[1,1]]
expected: [[0.5,0],[0.5,0]]
case 2
in: [[2,0],[1,0]]
expected: [[0.5,0],[0,0]]
case 3
in: [[1,1],[1,1]]
expected: [[0.25,0.25],[0.25,0.25]]
case 4
in: [[0,0],[1,1]]
expected: [[0,0],[0,0]]
Starter codePython
def pinv_outer_product(a, b):
# Your code here
pass4 test cases · run your code against them in the editor