COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### matrix inverse using qr decomposition

• Follow

```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
```
 0

```"Marko Mijatovic" <telekineza@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
```
 -1

```"Marko Mijatovic" <telekineza@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?
```
 0

```"John D'Errico" <woodchips@rochester.rr.com> wrote in message <hhrevm\$2h7\$1@fred.mathworks.com>...
> "Marko Mijatovic" <telekineza@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

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....
```
 1
Reply telekineza (3) 1/4/2010 3:31:04 PM

```"Marko Mijatovic" <telekineza@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?
```
 -1

```"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hht3p2\$jq2\$1@fred.mathworks.com>...
> "Marko Mijatovic" <telekineza@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?

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

```"Marko Mijatovic" <telekineza@gmail.com> wrote in message
news:hide0v\$gee\$1@fred.mathworks.com...
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message
> <hht3p2\$jq2\$1@fred.mathworks.com>...
>> "Marko Mijatovic" <telekineza@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?
>
>
> I cant just type inv qr(A)!!!

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
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

```
 1

```"Marko Mijatovic" <telekineza@gmail.com> wrote in message <hide0v\$gee\$1@fred.mathworks.com>...
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hht3p2\$jq2\$1@fred.mathworks.com>...
> > "Marko Mijatovic" <telekineza@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...
```
 0

```"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
```
 1

```"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hieplr\$2ih\$1@fred.mathworks.com>...
> "Marko Mijatovic" <telekineza@gmail.com> wrote in message <hide0v\$gee\$1@fred.mathworks.com>...
> > "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hht3p2\$jq2\$1@fred.mathworks.com>...
> > > "Marko Mijatovic" <telekineza@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...

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
as we will not write that code for him, even though
it is not that difficult to write.

John
```
 -1

```"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
```
 0

```"Oleg Komarov" <oleg.komarov@hotmail.it> wrote in message <hif67k\$e52\$1@fred.mathworks.com>...
> "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...
>

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
```
 0

```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
```
 0

```"Oleg Komarov" <oleg.komarov@hotmail.it> wrote in message <hifhh0\$4uu\$1@fred.mathworks.com>...
> 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

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
```
 0

```"Oleg Komarov" <oleg.komarov@hotmail.it> wrote in message <hieted\$40j\$1@fred.mathworks.com>...
> "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
I recommend you buy Cleve's book. It is great.  There is a new revision, and he discusses the importance of the Householder transform.
```
 0
Reply pfinder (20) 1/13/2010 6:01:21 AM

```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............
```
 0
Reply telekineza (3) 1/14/2010 6:39:05 PM

```> 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
```
 0
Reply theorigamist (208) 1/14/2010 6:46:02 PM

```"Andy " <theorigamist@gmail.com> wrote in message <hinopa\$f4q\$1@fred.mathworks.com>...
> > 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

thank you......
```
 0
Reply telekineza (3) 1/14/2010 9:27:05 PM

17 Replies
754 Views

Similiar Articles:

7/23/2012 8:08:22 PM