forum.alglib.net

ALGLIB forum
It is currently Sat Dec 21, 2024 4:38 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  [ 13 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: QR decomposition, how to unpack Q in full
PostPosted: Tue May 11, 2010 7:14 pm 
Offline

Joined: Mon May 10, 2010 3:19 pm
Posts: 8
Your piece of code worked. Actually I have to comment out the line getch() to get it compiled but the output is exactly what you attached here and it is exactly what I wanted so my problem is to get your lib work with my code.

Let's me answer your question first.
1. Executed your code and the output is what you have attached. Great!!!Your lib worked but my code that used your lib is not working :-(
2. I decided Q were not fully unpacked because I exam my big Q at the end. Maybe I dont how to transfer the result from q to the big Q.
3. I used gcc compiler without optimization
4. I didn't modify your ALGLIB, using version 2.5

Question for you:
1. I noticed that you don't have to do setlength after you define a, tau, q, r. Wonder if that makes a difference in your code versus my code
2. How do I assign value to each position in a. I saw you do 'setcontent' but it is because you're reading from a file and in my case that matrix was calculated from other functions before . That is why I used
a(i,j) = A(i,j);

A(i,j) is a double value--> wonder if doing that assignment statement is wrong??

How did you get back a double value from the q (lower case) matrix. Does
double(q(i,j)) --> indeed return me a double value?

I did
Q(i,j) = double(q(i,j));


Top
 Profile  
 
 Post subject: Re: QR decomposition, how to unpack Q in full
PostPosted: Tue May 11, 2010 7:50 pm 
Offline

Joined: Mon May 10, 2010 3:19 pm
Posts: 8
Thanks for all your help, Sergy. I got my code worked now. It was all my fault that I just accidently didn't assign any value for my big Q from the q (lower case) after column 16th that is why my big Q values after the column 16 is all zeros. Thanks again.


Top
 Profile  
 
 Post subject: Re: QR decomposition, how to unpack Q in full
PostPosted: Wed May 12, 2010 4:11 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
tam wrote:
2. I decided Q were not fully unpacked because I exam my big Q at the end. Maybe I dont how to transfer the result from q to the big Q.

Code:
for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
        Q(i,j) = double(q(i,j));

Now I see what's wrong. Your code extracts just m*n elements from q to Q, but "full" q is m*n. Just a minor error in the extraction code :)

tam wrote:
1. I noticed that you don't have to do setlength after you define a, tau, q, r. Wonder if that makes a difference in your code versus my code

No difference except for performance. Subroutines set sizes of tau/q/r automatically, rewriting old data if these arrays were already allocated. As for a, setcontent() call allocates memory instead of setlength().

tam wrote:
2. How do I assign value to each position in a.
.....
A(i,j) is a double value--> wonder if doing that assignment statement is wrong??
.....
Does double(q(i,j)) --> indeed return me a double value?

real ALGLIB vectors/matrices store double values, complex vectors/matrices store pairs of doubles. This will NOT be changed in the foreseeable future. So explicit typecasting to double is unnecessary. You can just assign to elements of a.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 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