It is hard to help if you don't post the whole session. What is m?
What are you trying to create, a set containing some matrices?
In Sage you can only form sets of objects if the are "immutable",
which is a Python concept. That is to do with the way that set
elements are managed, via so-called hash functions. But when you
construct a matrix in Sage is is "mutable", i.e. you can change its
elements.
So if you want a set containing matrices you have to make the
immutable first. Like this:
sage: m=Matrix([[1,2],[3,4]])
sage: MatList=[m^i for i in range(5)]
sage: for mi in MatList: mi.set_immutable()
....:
sage: MatSet = Set(MatList)
sage: MatSet
{[1 2]
[3 4], [199 290]
[435 634], [1 0]
[0 1], [ 7 10]
[15 22], [ 37 54]
[ 81 118]}
(not very beautiful, but it is a set of matrices).
I'm only guessing, but I bet that for what you are trying to do, using
a list of matrices (such as I constructed above, called MatList) will
do what you need.
John Cremona
2008/6/10 cesarnda <[EMAIL PROTECTED]>:
>
> I want to create a matrices set but I get the following error if I use
> the Set command:
> sage: setMat = Set(m)
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call
> last)
>
> /home/cesarnda/<ipython console> in <module>()
>
> /home/cesarnda/Sage/sage-3.0.2-debian32-intelx86-i686-Linux/local/lib/
> python2.5/site-packages/sage/sets/set.py in Set(X)
> 76
> 77 if isinstance(X, Element):
> ---> 78 raise TypeError, "Element has no defined underlying
> set"
> 79 elif isinstance(X, (list, tuple, set, frozenset)):
> 80 return Set_object_enumerated(frozenset(X))
>
> TypeError: Element has no defined underlying set
>
> and if I use the set command I get:
> sage: setMat = set(m)
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call
> last)
>
> /home/cesarnda/<ipython console> in <module>()
>
> /home/cesarnda/free_module_element.pyx in
> sage.modules.free_module_element.FreeModuleElement.__hash__ (sage/
> modules/free_module_element.c:2570)()
>
> TypeError: mutable vectors are unhasheable
>
> How can I solve this problem?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---