Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

matrix inverse using qr decomposition

50 views
Skip to first unread message

Marko Mijatovic

unread,
Jan 3, 2010, 2:59:03 PM1/3/10
to
I need to write a homework about the inverse matrix.
I wrote with other methods (ie the LU, LU with pivoting), just missing matlab code with QR factorization ... so if someone knows and is willing to help would be very grateful

John D'Errico

unread,
Jan 3, 2010, 8:07:03 PM1/3/10
to
"Marko Mijatovic" <telek...@gmail.com> wrote in message <hhqsu7$sr1$1...@fred.mathworks.com>...

> I need to write a homework about the inverse matrix.
> I wrote with other methods (ie the LU, LU with pivoting), just missing matlab code with QR factorization ... so if someone knows and is willing to help would be very grateful

But this is YOUR homework, not ours. Surely if
you can deal with the other cases, you can use
a qr factorization. Perhaps it is time to revisit
your notes and your textbook.

Matt J

unread,
Jan 3, 2010, 8:42:03 PM1/3/10
to
"Marko Mijatovic" <telek...@gmail.com> wrote in message <hhqsu7$sr1$1...@fred.mathworks.com>...
> I need to write a homework about the inverse matrix.
> I wrote with other methods (ie the LU, LU with pivoting), just missing matlab code with QR factorization ... so if someone knows and is willing to help would be very grateful


help qr?

Marko Mijatovic

unread,
Jan 4, 2010, 10:31:04 AM1/4/10
to
"John D'Errico" <wood...@rochester.rr.com> wrote in message <hhrevm$2h7$1...@fred.mathworks.com>...

If I knew how to solve it I would not ask. I reviewed my notebook, and I did not managed to find anything important. I know that is similar to LU factorization (ie, solving n systems), and there I stopped ... so I asked if someone knows to help .... and without stupid answers....

Matt J

unread,
Jan 4, 2010, 11:08:02 AM1/4/10
to
"Marko Mijatovic" <telek...@gmail.com> wrote in message <hht1jo$1oh$1...@fred.mathworks.com>...

> If I knew how to solve it I would not ask. I reviewed my notebook, and I did not managed to find anything important. I know that is similar to LU factorization (ie, solving n systems), and there I stopped ... so I asked if someone knows to help .... and without stupid answers....

==================

Once again, why does MATLAB's qr() function not do what you need?

Marko Mijatovic

unread,
Jan 10, 2010, 3:41:03 PM1/10/10
to
"Matt J " <mattja...@THISieee.spam> wrote in message <hht3p2$jq2$1...@fred.mathworks.com>...


I cant just type inv qr(A)!!!

Steven Lord

unread,
Jan 10, 2010, 9:15:38 PM1/10/10
to

"Marko Mijatovic" <telek...@gmail.com> wrote in message
news:hide0v$gee$1...@fred.mathworks.com...

How did you do this for LU? You took advantage of the fact that A = L*U,
right? How are A, Q, and R related? Can you do something similar?

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


Matt J

unread,
Jan 11, 2010, 4:06:03 AM1/11/10
to
"Marko Mijatovic" <telek...@gmail.com> wrote in message <hide0v$gee$1...@fred.mathworks.com>...

> "Matt J " <mattja...@THISieee.spam> wrote in message <hht3p2$jq2$1...@fred.mathworks.com>...
> > "Marko Mijatovic" <telek...@gmail.com> wrote in message <hht1jo$1oh$1...@fred.mathworks.com>...

> I cant just type inv qr(A)!!!

To quote your original post, you said you were "just missing matlab code with QR factorization..."

This makes it sounds like the problem you were having is that you did not know how to obtain the QR factorization using MATLAB.

Since the qr() function does this, and if you understand that, it is not clear what further help you were hoping to get from us...

Oleg Komarov

unread,
Jan 11, 2010, 5:10:21 AM1/11/10
to
"Matt J "
> > I cant just type inv qr(A)!!!
>
> To quote your original post, you said you were "just missing matlab code with QR factorization..."
>
> This makes it sounds like the problem you were having is that you did not know how to obtain the QR factorization using MATLAB.
>
> Since the qr() function does this, and if you understand that, it is not clear what further help you were hoping to get from us...

I think he wants to know how, in specific, is achieved the QR decomposition. Since in MATLAB it's a builtin fcn, the code isn't available.
I suggest to look for 'householder reflection' in wikipedia and 'Numerical Computing' by Cleve Moler (MATLAB chief scientist): http://www.mathworks.com/moler/

Oleg

John D'Errico

unread,
Jan 11, 2010, 6:20:06 AM1/11/10
to
"Matt J " <mattja...@THISieee.spam> wrote in message <hieplr$2ih$1...@fred.mathworks.com>...

No, I think he does not understand what a qr does.
or how to use the result. He cannot simply type
inv(LU(A)) either and get the results that he would
need.

It is time to go back to the books. A QR is a matrix
factorization. Regardless, he does not want to EVER
compute inv on the results of any of these operators.
For example, he wants to learn how to compute the
inverse of Q, WITHOUT the application of inv. Then
he must use \ (backslash) to deal with R.

If it is a question of wanting to program the QR
itself, then it really is time to return to the books,
as we will not write that code for him, even though
it is not that difficult to write.

John

Oleg Komarov

unread,
Jan 11, 2010, 7:40:21 AM1/11/10
to
"John D'Errico"
> If it is a question of wanting to program the QR
> itself, then it really is time to return to the books,
> as we will not write that code for him, even though
> it is not that difficult to write.
>
> John
John,
I don't have a really strong maths background. Can you suggest any good math reference on matrix factorization where the subject is explained in a step by step approach (possibly with examples)?

I have read something on Cleve's book (see above). I find it quite useful but I can't tell if something more detailed and simpler exists...

Thanks

Oleg

John D'Errico

unread,
Jan 11, 2010, 9:44:04 AM1/11/10
to
"Oleg Komarov" <oleg.k...@hotmail.it> wrote in message <hif67k$e52$1...@fred.mathworks.com>...

I'm not sure what you are looking for. This seems to
give a reasonable explanation of what is necessary, but
I have the feeling that you want more.

http://en.wikipedia.org/wiki/Householder_transformation

A QR is simply a sequence of householder transformations,
used to generate an upper triangular result.

So I would suggest that you write a function that forms
and applies ONE householder transformation to a matrix.
Then just call it in a loop. As you kill off what is in one
column of A, you build up Q at the same time, starting
from an identity matrix. When A is finally upper triangular,
then Q is done too.

John

Oleg Komarov

unread,
Jan 11, 2010, 10:53:04 AM1/11/10
to
John D'Errico,

> I'm not sure what you are looking for. This seems to
> give a reasonable explanation of what is necessary, but
> I have the feeling that you want more.

Yes, i want more :).
I already read the wiki page but I feel a little confused.
I was looking for something that explains linear systems with a more general approach (like Cleve's book but with stronger mathematical background, but maybe better reference is hard to find if not to attend a course in mathematics).
Any advice on a good textbook that starts from a to z (as we say in Italy) will be appreciated.

Thanks
Oleg

Marko Mijatovic

unread,
Jan 12, 2010, 2:55:15 PM1/12/10
to
"Oleg Komarov" <oleg.k...@hotmail.it> wrote in message <hifhh0$4uu$1...@fred.mathworks.com>...

from regular quadratic matrix A to calculate A ^ -1 so as to solve AX = I so that n times apply solution with the help of QR-factorization (ie Ax1 = e1, x1 first column of the matrix X )..... QR faktorization is needed only once

Pat Finder

unread,
Jan 13, 2010, 1:01:21 AM1/13/10
to
"Oleg Komarov" <oleg.k...@hotmail.it> wrote in message <hieted$40j$1...@fred.mathworks.com>...
I recommend you buy Cleve's book. It is great. There is a new revision, and he discusses the importance of the Householder transform.

Marko Mijatovic

unread,
Jan 14, 2010, 1:39:05 PM1/14/10
to
I have a pseudo code, only I dont know how to write this part in MATLAB
for i from 1 to n
-----> this part is most important
A xi = ei (x1 should be added in the first column of the matrix A ^ -1, and e1 = [1 0 0 .....] etc. ..
I am interested in how to put that 1 is the i-site in the vector ei)

ie I am interested in how to generate ei with loop (e1, e2, e3, e4, e5 ,......)
do you now understand what I need............

Andy

unread,
Jan 14, 2010, 1:46:02 PM1/14/10
to
> ie I am interested in how to generate ei with loop (e1, e2, e3, e4, e5 ,......)
> do you now understand what I need............

for i=1:n
ei=zeros(1,n);
ei(i)=1;
% etc.
end

Or, if you want to keep the ei around (rather than overwriting one variable called ei):

e=eye(n);
for i=1:n
% note: ei=e(i,:)
% etc.
end

Marko Mijatovic

unread,
Jan 14, 2010, 4:27:05 PM1/14/10
to
"Andy " <theori...@gmail.com> wrote in message <hinopa$f4q$1...@fred.mathworks.com>...


thank you......

0 new messages