Is there any inverse np.dot function?

前端 未结 2 382
南方客
南方客 2021-01-19 19:09

If I have two matrices a and b, is there any function I can find the matrix x, that when dot multiplied by a makes b? Looking for python solutions, for matrices in the form

2条回答
  •  攒了一身酷
    2021-01-19 19:29

    if A is a full rank, square matrix

    import numpy as np
    from numpy.linalg import inv
    
    X = inv(A) @ B
    

    if not, then such a matrix does not exist, but we can approximate it

    import numpy as np
    from numpy.linalg import inv
    
    X = inv(A.T @ A) @ A.T @ B
    

提交回复
热议问题