11 #include <Eigen/Dense>
17 template <
typename Derived>
18 inline bool IsNaN(
const Eigen::MatrixBase<Derived>&
x);
21 template <
typename Derived>
22 inline bool IsInf(
const Eigen::MatrixBase<Derived>&
x);
27 template <
typename MatrixType>
34 template <
typename Derived>
35 bool IsNaN(
const Eigen::MatrixBase<Derived>&
x) {
36 return !(
x.array() ==
x.array()).all();
39 template <
typename Derived>
40 bool IsInf(
const Eigen::MatrixBase<Derived>&
x) {
41 return !((
x -
x).array() == (
x -
x).array()).all();
44 template <
typename MatrixType>
46 const MatrixType A_flipud_transpose =
47 A.transpose().rowwise().reverse().eval();
49 const Eigen::HouseholderQR<MatrixType> QR(A_flipud_transpose);
50 const MatrixType& Q0 = QR.householderQ();
51 const MatrixType& R0 = QR.matrixQR();
53 *R = R0.transpose().colwise().reverse().eval();
54 *R = R->rowwise().reverse().eval();
55 for (
int i = 0; i < R->rows(); ++i) {
56 for (
int j = 0; j < R->cols() && (R->cols() - j) > (R->rows() - i);
62 *Q = Q0.transpose().colwise().reverse().eval();
65 if (Q->determinant() < 0) {
void DecomposeMatrixRQ(const MatrixType &A, MatrixType *R, MatrixType *Q)
bool IsNaN(const float x)
bool IsInf(const float x)