# Generating orthonormal eigenspace(s) for a real, non-symmetric, matrix

I have a real matrix, $A$, which is not necessarily symmetric, for which I wish to determine the following:

The real eigenspace(s) corresponding to all the real eigenvalues expressed as orthonormal eigenvectors.

The approach I've taken is to split the problem into two cases:

1. non-degenerate eigenvalue

Sometimes my eigenvalue solver produces a complex eigenvector. Is there always a real eigenvector that corresponds to this (real) eigenvalue? If not how can I check? And in the case that a real eigenvector does exist is there a general procedure to generate it?

2. degenerate eigenvalues

In this case I capture all the eigenvectors corresponding to the same eigenvalue to form an eigenspace. Again, sometimes these vectors are complex. In this case I presume it is not the case that I can always generate a corresponding real eigenspace. Is there a procedure to generate a real (sub)space from my original eigenspace?

To give an example:

$A = \left( \begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -1 \end{array} \right)$, $\lambda_i=(1, 1, -1)$, $v = \left( \begin{array}{ccc} 1 & 1 & 0 \\ \imath & -\imath & 0 \\ 0 & 0 & 1 \end{array} \right)$ (column eigenvectors).

The eigenspace corresponding to $\lambda = 1$ can be expressed as $\left( \begin{array}{ccc} 1 & 0 \\ 0 & 1 \end{array} \right)$ but for some reason my eigenvalue solver gives me back a complex eigenspace which is why I need a procedure to test and move back into real space (ideally orthonormalising if necessary).

-