I'm writing an eigensolver and I'm trying to generate a guess for the next iteration in the solve that is orthogonal to to all known eigenvectors calculated thus far. This means that if I have only one eigenvector, that is say 2 million entries long, I need to generate a vector orthogonal to it. I don't think Gram Schmidt works here because I don't have a set of vectors to orthogonalize. What I have is a single vector, in the first eigensolve, and I need to generate another that is orthogonal.


So, in summary: given one vector, create from nothing another vector which is orthogonal to it. The method must support $N$-dimensional vectors (where $N$ could be millions).


I should add that writing a generalized cross product algorithm is not appealing. I'd prefer another way.



Find an $N$-dimensional vector orthogonal to a given vector
Suppose the vector is $(x\_1,x\_2,\dots)$. The following algorithm should work:


1. If $x\_1=0$ then take $(1,0,0,\dots)$.
2. If $x\_1$ is non-zero and $x\_2=0$ then take $(0,1,0,0,\dots)$.
3. If $x\_1$ and $x\_2$ are non-zero then take $(-x\_2,x\_1,0,0,\dots)$


