I have a Numpy matrix, for example, numpy.matrix([[-1, 2],[1, -2]], dtype='int'). I want to get its integer-valued eigenvectors, if any; for example, numpy.array([[-1], [1]]) for the above matrix. What Numpy returns are eigenvectors in floating numbers, scaled to have unit length.
One can do this in Sage, where one can specify the field (i.e., data type) of the matrix and operations done on the matrix will respect the field one specifies.
Any idea of how to do this nicely in Python? Many thanks in advance.
I am personally content with the following solution: I called
sagein Python and letsagecompute what I want.sage, being math-oriented, is rather versatile in computations involving fields other than reals.Below is my script
compute_intarrs.pyand it requiressagebe installed. Be aware it is a little slow.Result:
In [1]: %run compute_intarrs.py[array([1, 1])]