Combine upper, lower, and diagonal matrix?

In summary, the conversation discusses the best approach for solving a matrix that is a combination of diagonal, upper, and lower matrices. The use of MATLAB for matrix work is mentioned. There is a question about solving the upper and lower triangles separately and then combining them, as well as a question about the possibility of solving the matrix quicker if all three diagonals were the same. There is also a request for clarification on the use of an "x" in the example and the meaning of "solving" a matrix.
  • #1
1
0
If you have a matrix that is a combination of a diagonal, upper, and lower matrix - what is the best way to solve it? (I use MATLAB for matrix work)

Example:
5 1 0 0 x1 1
-1 5 1 0 x2 2
0 -1 5 1 x3 3
0 0 -1 5 x4 4

Is it possible to solve the upper triangle and lower triangle and then combine them?
Would it be possible to solve it quicker if the all three diagonals were the same (as above)?
 
Physics news on Phys.org
  • #2
I can't understand the example you have written. What does an "x" denote?

What do you mean by "solve" a matrix? Please clarify your example and I think someone will be able to help you.
 

1. How do I combine upper, lower, and diagonal matrices?

To combine upper, lower, and diagonal matrices, you can use the np.vstack() and np.hstack() functions in numpy. The np.vstack() function stacks arrays in sequence vertically, while the np.hstack() function stacks arrays in sequence horizontally. By using these functions, you can combine the matrices into one larger matrix.

2. Can I combine upper, lower, and diagonal matrices of different sizes?

Yes, you can combine matrices of different sizes as long as the number of columns in the upper and lower matrices match. The diagonal matrix can have any number of rows, as long as it is a column vector.

3. How do I combine a diagonal matrix with a non-square matrix?

You can use the np.diag() function to create a diagonal matrix from a given vector. Then, you can use the np.hstack() function to combine the diagonal matrix with the non-square matrix by stacking them horizontally.

4. Is it possible to combine more than three matrices using this method?

Yes, you can combine any number of matrices using the np.vstack() and np.hstack() functions. Simply pass in all the matrices as arguments in the order you want them to be stacked.

5. Can I combine matrices of different data types?

Yes, you can combine matrices of different data types as long as they are compatible. For example, you can combine a matrix of integers with a matrix of floats, but you cannot combine a matrix of strings with a matrix of integers. The resulting combined matrix will have the data type of the most precise matrix.

Suggested for: Combine upper, lower, and diagonal matrix?

Replies
5
Views
936
Replies
6
Views
222
Replies
24
Views
359
Replies
3
Views
947
Replies
5
Views
915
Replies
4
Views
658
Replies
4
Views
991
Replies
3
Views
909
Replies
7
Views
343
Back
Top