I have a matrix X
and use it to compute the square matrix in MATLAB: S=X*X'
. I need to find only off-diagonal elements of S
.
I understand how to do this for the diagonal: sum(X.*X,1)
. Is there the similar way to find off-diagonal elements by vectorization?
S=X*X'
you get the off-diagonal and the diagonal entries. IfX
hasn
rows, avoiding to compute the diagonal terms would only saven
terms out ofn^2
in total. You could save an additional factor of2
due to symmetry. Is it worth it? What size is your matrix? – Luis Mendo