forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:40 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: inverted signs in Q and R from rmatrixqr
PostPosted: Mon Aug 19, 2013 10:37 pm 
Offline

Joined: Mon Aug 19, 2013 10:26 pm
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: inverted signs in Q and R from rmatrixqr
PostPosted: Tue Aug 20, 2013 5:41 pm 
Offline

Joined: Fri Feb 08, 2013 5:42 pm
Posts: 4
The QR decomposition is not always unique. Both answer should be good.
more information can be found here:
http://stackoverflow.com/questions/12713141/how-to-calculate-full-qr-decomposition-using-gram-schmidt


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group