Exploiting symmetry in multidimensional arrays
Ältere Kommentare anzeigen
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,
Akzeptierte Antwort
Weitere Antworten (1)
Roger Stafford
am 13 Jul. 2014
For a 2D array it's easy:
B = tril(A,-1)
A = B+B.'+diag(A);
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!