# forum.alglib.net

ALGLIB forum
 It is currently Fri May 24, 2024 4:12 am

 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.

 Page 2 of 2 [ 13 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: QR decomposition, how to unpack Q in fullPosted: Tue May 11, 2010 7:14 pm

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.

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

 Post subject: Re: QR decomposition, how to unpack Q in fullPosted: Tue May 11, 2010 7:50 pm

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

 Post subject: Re: QR decomposition, how to unpack Q in fullPosted: Wed May 12, 2010 4:11 am

Joined: Fri May 07, 2010 7:06 am
Posts: 915
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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 13 posts ] Go to page Previous  1, 2

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 2 guests

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

Search for: