4

I want to compute a matrix $M_{pq}$, for which the calculation of each coefficients $M_{pq} = f(p,q)$ is an expensive function. I know that my matrix is hermitian, so that $M_{qp} = M_{pq}^{*}$. As a consequence, I only need to compute roughly one half of the matrix coefficients to determine entirely the matrix $M$. Once I performed the expensive calculation of determining the list

halfM = Table[f[p,q],{p,1,n},{q,p,n}];

I then have all the information needed to reconstruct the full matrix $M$.

My question is then :

How would you then build-up the matrix $M$ ensuring that no other calculations are performed ? What could be the best way to operate on the lists in order to construct $M$ ?

jibe
  • 852
  • 6
  • 12

1 Answers1

6

You can pad missed elements and add a transposed matrix

M = # + ConjugateTranspose@UpperTriangularize[#, 1] &@PadLeft@halfM;

M // MatrixForm

enter image description here

ybeltukov
  • 43,673
  • 5
  • 108
  • 212