Question posted on the net
please help me with simple to apply function that will construct symmetric matrix from given just a half matrix with diagonal. Eg: From: 1 0 0 0 2 3 0 0 4 9 5 0 2 2 3 4 To give: 1 2 4 2 2 3 9 2 4 9 5 3 2 2 3 4
Many answers were given, below is my answer, and I also show how to do it in Matlab
Mathematica a = {{1, 0, 0, 0}, {2, 3, 0, 0}, {4, 9, 5, 0}, {2, 2, 3, 4}}; Transpose[LowerTriangularize[a, -1]] + a
|
{{1, 2, 4, 2}, {2, 3, 9, 2}, {4, 9, 5, 3}, {2, 2, 3, 4} } |
Maple A:=Matrix([[1,0,0,0],[2,3,0,0],[4,9,5,0],[2,2,3,4]]); B:=ArrayTools:-LowerTriangle(A,-1); A:=A+B^%T;
|
[[1,2,4,2], [2,3,9,2], [4,9,5,3], [2,2,3,4]] |