Description
Hi, I noticed a discrepancy between the managed provider and the native providers in computing the QR factorization of a small test matrix.
According to Matlab, the 2x4 test matrix
testData =
-2.185929268096052 -0.458914070137267 0 -0.748405712906516
-2.262514008467083 0.443380104476701 0 -1.064633478923354
should be factored as:
>> [Q,R] = qr(testData,0)
Q =
-0.694830212770919 -0.719173814470967
-0.719173814470967 0.694830212770918
R =
3.145990528216626 0.000000000000000 0 1.285671420788610
0 0.638112874666953 0 -0.201505715360515
If I reproduce this QR factorization in Math.NET with the Control.LinearAlgebraProvider.QRFactor method, the managed linear algebra provider produces essentially the same results as Matlab (except for sign changes), while both the MKL and the OpenBLAS native providers do not: For both of them, the entry R[1,0] equals about 0.42 instead of 0. This means, that for the native providers Q*R does not equal the test matrix, while this test works for the results of the managed provider.
I've attached a test class (sorry for the .txt format, GitHub wouldn't accept .cs) reproducing the problem.
QRFactorizationTest.txt
I'm using the NuGet packages
MathNet.Numerics V 3.19.0
MathNet.Numerics.MKL.Win-x64 V 2.2.0
MathNet.Numerics.OpenBLAS.Win V 0.2.0
The matrices I'm working on are all rectangular m x n with m < n and I'm aware that other entry points for the QR factorization in Math.NET such as the Double.Factorization.UserQR restrict the QR factorization to matrices with m >= n. If this restriction is in place because of problems like the one I noticed, do you by chance have a suggestion on how to achieve the QR factorization for matrices with m < n in Math.NET?
Kind regards
Armin