householderQR fails with complex matrices and ffast-math
Hi, the following code
#include <iostream>
#include <Eigen/Core>
#include <Eigen/QR>
using namespace Eigen;
int main(int argc, char* argv[]){
MatrixXcd mat = MatrixXcd::Random(3,2);
HouseholderQR<MatrixXcd> qr(mat);
auto rows = mat.rows();
auto cols = mat.cols();
MatrixXcd Q = qr.householderQ() * MatrixXcd::Identity(rows,cols);
MatrixXcd R = MatrixXcd::Identity(cols,rows) * qr.matrixQR().template triangularView<Eigen::Upper>();
MatrixXcd diff = mat - Q * R;
std::cout << "diff=\n" << diff << std::endl;
}
gives wrong results (m1-m2 != 0) when compiled with
g++ -O3 -ffast-math
It works if -ffast-math is disabled. I'm aware of a warning about -ffast-math for Eigen::BDCSVD but not about any warning for householderQR. This code also does not work with enabled MKL (-DEIGEN_USE_MKL_ALL).
The code works well for icpc -fast.
My g++ is
g++ (Arch Linux 9.2.1+20200130-2) 9.2.1 20200130
Copyright (C) 2019 Free Software Foundation, Inc.
I'm using Eigen commit a45d28256d020a4e871267c9bf00206fe9d2265e (Fri Jan 10, 2020)