Decomposing A into L and U (matrices)

  • Thread starter Thread starter physicsCU
  • Start date Start date
  • Tags Tags
    Matrices
Click For Summary

Discussion Overview

The discussion revolves around the process of decomposing a matrix A into its lower triangular matrix L and upper triangular matrix U. The focus is on programming techniques to achieve this decomposition, specifically in the context of MATLAB.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant proposes using if statements to define the elements of U and L based on their positions relative to the indices i and j.
  • Another participant suggests that a nested loop structure would be necessary for implementation, particularly in a programming language like Fortran.
  • A later reply clarifies that the programming is being done in MATLAB and expresses a preference against nested loops.
  • One participant reports successfully writing the program as initially planned, indicating that it functioned correctly on the first attempt.
  • Another participant expresses enthusiasm about the successful implementation.

Areas of Agreement / Disagreement

Participants generally agree on the approach to decompose the matrix using nested loops, although there is some variation in language preference and personal feelings about using such loops. The discussion remains focused on programming rather than theoretical aspects of matrix decomposition.

Contextual Notes

Participants do not delve into the mathematical theory behind matrix decomposition, focusing instead on the practical programming aspects. There are no detailed discussions on potential edge cases or limitations of the proposed methods.

Who May Find This Useful

This discussion may be useful for individuals learning matrix decomposition techniques in programming, particularly in MATLAB, as well as those seeking practical coding solutions for similar problems.

physicsCU
Messages
198
Reaction score
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.
 
Physics news on Phys.org
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
 
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.
 
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.
 
Sweeeeeeeeeettt.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
19
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K