I'm working on helping my friend create code to perform the Overlap Dirac Operator and have come across one part that I'm not sure what to do.

I need to compute the Eigenvalues and corresponding Eigenvectors for a hermitian matrix (my test is for n=4) so that I can implement a matrix sign function $epsilon(M) = U * epsilon(A) * U^*$ where $U$ is an eigenvector matrix, $U^*$ is the complex transpose of $U$, and $epsilon(A)$ is a matrix with the signs of eigenvalues of $M$ on it's diagonal.

Any resources or help on existing algorithms/libraries to solve this (or at least make close approximations) would be appreciated. My target programming language is Scala.

  • $\begingroup$ Welcome to Computational Science Phillip. I've updated your question with the MathJax mark-up I think you intended, but could you check to make sure I haven't missinterpreted what you meant. $\endgroup$
    – Mark Booth
    Jan 25, 2013 at 0:52
  • $\begingroup$ I think the description of $epsilon(A)$ as vector $lambda * I$ is not correct, since this would inevitably be vector $lambda$. Instead something like a diagonal matrix with those signed entries is probably meant. $\endgroup$
    – hardmath
    Jan 25, 2013 at 3:14
  • $\begingroup$ I think that my description might've just been poor to begin with. I'm new to this material. What I mean is that $epsilon(M) = U*epsilon(A)*U^*$ where $epsilon(A)$ is a matrix with the signs of eigenvalues of $M$ on the diagonal. $\endgroup$ Jan 25, 2013 at 3:51
  • $\begingroup$ The subroutine you are looking for should work only for $n=4$ or also for $n>4$? $\endgroup$
    – Stefano M
    Jan 25, 2013 at 9:13
  • $\begingroup$ Why aren't you just computing the eigenvalue decomposition and then set $\epsilon(A)=diag(sign\lambda_i)$ where $\lambda_i$ are the eigenvalues? $\endgroup$ Jan 25, 2013 at 14:15

1 Answer 1


Sorry I delayed so long to answer this question, but I wanted to answer this question in case someone else has a problem

I found a solution to this problem by using the jBLAS library (http://mikiobraun.github.io/jblas/)

To calculate the sign function $epsilon(M) = U * epsilon(A) * U^\dagger$, if you have an existing matrix matrixR in jBlas:

val eigenvecs = Eigen.eigenvectors(matrixR)
val lambda = new DoubleMatrix(4,4, math.signum(eigenvecs(1).get(0,0).real),0,0,0,
  0,0,0,math.signum(eigenvecs(1).get(3,3).real)) //can be extended to larger matrices
val epsilon = eigenvecs(0).real.mmul(lambda).mmul(eigenvecs(0).real.transpose) //where epsilon = epsilon(M)

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.