• Support PF! Buy your school textbooks, materials and every day products Here!

Decomposing A into L and U (matrices)

  • Thread starter physicsCU
  • Start date
  • #1
202
1
I need to write a program to take A and make the lower and upper triangular matrices for it.

My idea is to use if statements, since what I am doing is setting U(i,j) equal to A(i,j) if i <= j and U(i,j) = 0 if i > j

For L(i,j), its equal to A(i,j) if i > j, 1 if i = j and 0 if i < j.

Any ideas how to do this? I am stumped on how to get the i and j parts working.
 

Answers and Replies

  • #2
FredGarvin
Science Advisor
5,066
8
I guess it depends on what language. If it were fortran (it's been a long time) I'd say you have to do a nested for...next loop.

For i=1 to #_of_colums
For j=1 to #_of_rows
Blah blah blah
Next j
Next i
 
  • #3
202
1
this is matlab, sorry.

i came to the same conclusion, but i guess i will have to do a nested for loop. I hate those. Oh well.

I think this will work, I will try to write the program today, but two other labs are due soon as well.
 
  • #4
202
1
Just wanted to update that I wrote the program the way we both thought of, and it worked the right way right off the bat!!!

That is a first for me i think!!!

Overall its a quick little loop and I would be willing to share it once my lab is turned in.
 
  • #5
FredGarvin
Science Advisor
5,066
8
Sweeeeeeeeeettt.
 

Related Threads on Decomposing A into L and U (matrices)

Replies
7
Views
2K
  • Last Post
Replies
4
Views
632
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
14
Views
1K
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
7
Views
1K
  • Last Post
Replies
1
Views
1K
Replies
13
Views
2K
Replies
0
Views
3K
  • Last Post
Replies
3
Views
3K
Top