Python — How can I find the square matrix of a lower triangular numpy matrix? (with a symmetrical upper triangle)
Posted
by
Dana Gray
on Stack Overflow
See other posts from Stack Overflow
or by Dana Gray
Published on 2013-06-30T22:17:03Z
Indexed on
2013/06/30
22:21 UTC
Read the original article
Hit count: 425
I generated a lower triangular matrix, and I want to complete the matrix using the values in the lower triangular matrix to form a square matrix, symmetrical around the diagonal zeros.
lower_triangle = numpy.array([
[0,0,0,0],
[1,0,0,0],
[2,3,0,0],
[4,5,6,0]])
I want to generate the following complete matrix, maintaining the zero diagonal:
complete_matrix = numpy.array([
[0, 1, 2, 4],
[1, 0, 3, 5],
[2, 3, 0, 6],
[4, 5, 6, 0]])
Thanks.
© Stack Overflow or respective owner