【问题标题】:QR decomposition for rectangular matrices in which n > m in scipy/numpy在 scipy/numpy 中 n > m 的矩形矩阵的 QR 分解
【发布时间】:2014-10-18 00:12:11
【问题描述】:

我有一个 n > m 的 m x n 矩形矩阵 A。给定 A 的秩 r

当我从 numpy.linalg 应用 qr 函数时(在 scipy.linalg 中也有这个函数的一个版本,看起来是一样的),它返回矩阵 Q 具有 mxm 维度,R 具有 mxn 维度,即使当矩阵 A 的秩小于 m。这似乎是“完整”的 QR 分解,其中 Q 的列是 Re^m 的正交基。是否可以通过numpy.linalg;scipy.linalg中函数qr返回的这个R矩阵来识别A的独立列?

【问题讨论】:

    标签: python numpy scipy linear-algebra qr-decomposition


    【解决方案1】:

    检查 R 的非零对角线元素:

    import numpy as np
    min_tol = 1e-9
    A = np.array([[1,2,3],[4,3,2],[1,1,1]])
    print("Matrix rank of: {}".format(np.linalg.matrix_rank(A)))
    Q,R = np.linalg.qr(A)
    indep = np.where(np.abs(R.diagonal()) >  min_tol)[0]
    print(A[:, indep])
    print("Independent columns are: {}".format(indep))
    

    另见此处: How to find degenerate rows/columns in a covariance matrix

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 2018-09-06
      • 1970-01-01
      • 2012-05-18
      • 1970-01-01
      • 2017-03-07
      • 1970-01-01
      相关资源
      最近更新 更多