# How to get eigenvectors of Hamiltonian in OpenFermion

In OpenFermion you can create a Hamiltonian in terms of creation and annihilation pretty easily: ham = ((FermionOperator('1^ 1', .5)) + (FermionOperator('2^ 2', .25)))

And getting the eigenvalues of the Hamiltonian is pretty straightforward as well: vals = eigenspectrum(ham)

But I don't understand how to get the eigenvectors of the Hamiltonian. FermionOperator doesn't return a numpy object so I can't use usual linear algebra libraries. What am I missing?

sparse_mat = openfermion.get_sparse_operator(ham, n_qubits=n) # type: scipy.sparse.csr_matrix

Then w will contain the eigenvalues and the columns of v will contain the eigenvectors. Setting the n_qubits=n parameter will result in a matrix that gets padded up to $$2^n \times 2^n$$ which is important if you're going to do further matrix manipulations or algebra involving the matrix representing your Hamiltonian.
And of course, for efficiency reasons you may choose not to cast the sparse operator to a numpy array but then you will end up using sparse matrix functions from scipy, for example scipy.sparse.linalg.eigsh to find some subset of eigenvalues/eigenvectors of a sparse matrix.