# Calculate efficiently an expensive hermitian matrix

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$ ?

## 1 Answer

You can pad missed elements and add a transposed matrix

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

M // MatrixForm


• Thank you. I knew it was doable, but didn't know PadLeft. I am also always really impressed by the shortened syntax you used, which is not yet in my reach
– jibe
Commented Jan 12, 2015 at 10:50
• @jibe In that case, this post should be a useful starting point. Commented Jan 12, 2015 at 14:19