Given a square matrix Z, return a symmetric matrix S = Z + Zᵀ - diag(Z) (so S[i,j] == S[j,i]).
Z
S = Z + Zᵀ - diag(Z)
S[i,j] == S[j,i]
Input
[[0 1 2] [3 4 5] [6 7 8]]
Output
[[ 0 4 8] [ 4 4 12] [ 8 12 8]]
This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.
solve(...)