4
$\begingroup$

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

$\endgroup$

1 Answer 1

6
$\begingroup$

You can pad missed elements and add a transposed matrix

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

M // MatrixForm

enter image description here

$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$
    – jibe
    Jan 12, 2015 at 10:50
  • $\begingroup$ @jibe In that case, this post should be a useful starting point. $\endgroup$ Jan 12, 2015 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.