TransWikia.com

Range of a matrix from its complete orthogonal decomposition

Computational Science Asked on May 4, 2021

In this StackOverflow answer, @Gokul has shown how to get a basis of the kernel of a matrix with the help of the ‘Eigen’ function CompleteOrthogonalDecomposition. The complete orthogonal decomposition of a matrix is related to the so-called URV decomposition of this matrix. I don’t know this topic. I read somewhere that the URV decomposition also allows to get the image (range, or span) of the matrix. I would like to know how to use Eigen::CompleteOrthogonalDecomposition to get a basis of the image of a matrix.

One Answer

I get it.

template <typename Number> // e.g. double or complex
Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic> image_COD(
    const Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic>& M) {
  Eigen::CompleteOrthogonalDecomposition<
    Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic>> cod(M);
  const Eigen::Matrix<Number, Eigen::Dynamic, Eigen::Dynamic> Q =
    cod.householderQ();
  return Q.leftCols(cod.rank());
}

It is slightly slower than the QR method, but has the advantage that one can get both the kernel and the range from this decomposition. The LU method is faster but does not return orthonormal bases.

Correct answer by Stéphane Laurent on May 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP