Hi I have ran this routine on a few test cases and every time I get the correct Q and R unpacked except that all the signs are reversed.
i.e. real Q: {{1,-2},{1,1}}
unpacked Q: {{-1,2},{-1,-1}}
This is the case for every test QR factorization I ran. Is this a known bug? Do I just need to do a scalar multiplication of (-1) to correct for this?
This was one of my test cases...
double[,] aaa = new double[,] {{1,-2,-1},{2,0,1},{2,-4,2},{4,0,0}}; double[] output = new double[] {}; double[,] Q = new double[4, 3]; double[,] R = new double[4, 3]; alglib.rmatrixqr(ref aaa,4,3,out output); alglib.rmatrixqrunpackq(aaa,4,3,output,3,out Q); alglib.rmatrixqrunpackr(aaa,3,3,out R); Console.WriteLine("Q:"); System.Console.WriteLine("{0}", alglib.ap.format(Q, 3));
unpacked Q: {{-1/5,2/5,4/5},{-2/5,-1/5,-2/5},{-2/5,4/5,-2/5},{-4/5,-2/5,1/5}} real Q: unpacked Q: {{1/5,-2/5,-4/5},{2/5,1/5,2/5},{2/5,-4/5,2/5},{4/5,2/5,-1/5}}
Console.WriteLine("R:"); System.Console.WriteLine("{0}", alglib.ap.format(R, 3));
unpacked R: {{-5,2,-1},{0,-4,1},{0,0,-2}} real R: {{5,-2,1},{0,4,-1},{0,0,2}}
Any insight into this would be appreciated.
|