subspace.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Matrix-Analysis 作者: kingofspace0wzz 项目源码 文件源码
def rotation_measure(A, B):
    '''
    function rotationMeasure measures how close a matrix can be to another matrix by rotation
     @param1: Matrix A
     @param2: Matrix B
     find the orthogonal matrix Q that minimizes ||A - BQ||_2
    '''
    # ask if the two matrics have the same shape
    if A.shape != B.shape:
        raise Exception('Two matrics do not have the same shape')

    # C=B^T * A
    C = B.conjugate().T.dot(A)

    U = la.svd(C)[0]
    Vh = la.svd(C)[2]

    # Q = UVh
    return U.dot(Vh)


# compute the minimal angle between subspaces
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号