Exploiting symmetry in multidimensional arrays
Show older comments
Dear all, In a symmetric matrix A of size [n,n], for two indices i and j such that 1<=i<=n and 1<=j<=n we have that A(i,j)=A(j,i). Suppose I know A(i,j) for i>=j how can I efficiently set A(j,i)?
More generally, if I have a hypercube A of size n^m, how can I, on the basis of A(i1,i2,...,im) with i1>=i2>=i3....>=im, set all A for all permutations of i1,i2,...,im instead of recalculating the entry for each permutation.
Thanks,
Accepted Answer
More Answers (1)
Roger Stafford
on 13 Jul 2014
For a 2D array it's easy:
B = tril(A,-1)
A = B+B.'+diag(A);
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!