Rafael wrote: > Hello, > > I would like to pick out individual eigenvectors of a matrix, and then > be able to manipulate them as vectors. I tried the following: > > ---------------------------------------------------------------------- > | Sage Version 3.2, Release Date: 2008-11-20 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > > sage: m=matrix([[1,2,2],[2,1,2],[2,2,1]]);m > > [1 2 2] > [2 1 2] > [2 2 1] > sage: es = m.eigenvectors_right();es > > [(5, [ > (1, 1, 1) > ], 1), (-1, [ > (1, 0, -1), > (0, 1, -1) > ], 2)] > sage: eval, evec, degen = es[0];evec > > [ > (1, 1, 1) > ] > > But if I try to act with the matrix m on the eigenvector evec, there > is a problem: > > sage: m*evec > --------------------------------------------------------------------------- > TypeError Traceback (most recent call > last) > > /Users/rafael/<ipython console> in <module>() > > /Applications/sage-3.2/local/lib/python2.5/site-packages/sage/ > structure/element.so in sage.structure.element.Matrix.__mul__ (sage/ > structure/element.c:11189)() > > /Applications/sage-3.2/local/lib/python2.5/site-packages/sage/ > structure/coerce.so in > sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/ > coerce.c:5782)() > > TypeError: unsupported operand parent(s) for '*': 'Full MatrixSpace of > 3 by 3 dense matrices over Integer Ring' and 'Category of sequences in > Vector space of degree 3 and dimension 1 over Rational Field > User basis matrix: > [1 1 1]' > > On the other hand, the following does work: > > sage: w=vector([1, 1, 1]);w > (1, 1, 1) > sage: m*w > (5, 5, 5) > > So it seems I need to convert evec, which is a sequence, to a vector. > Is there a way to do this (other than retyping as above)?
If you just want a list of eigenvectors, you could also use eigenmatrix_right, which might provide easier access that is similar to the eigenvector functions in Matlab or Mathematica: sage: m=matrix([[1,2,2],[2,1,2],[2,2,1]]);m [1 2 2] [2 1 2] [2 2 1] sage: D,P = m.eigenmatrix_right() sage: D [ 5 0 0] [ 0 -1 0] [ 0 0 -1] sage: P [ 1 1 0] [ 1 0 1] [ 1 -1 -1] sage: m*P.column(0) (5, 5, 5) sage: m*P.column(1) (-1, 0, 1) sage: type(P.column(0)) <type 'sage.modules.vector_rational_dense.Vector_rational_dense'> Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---