I think this is a bug:
sage: vector(range(3))
TypeError: unable to find a common ring for all elements
since this does work:
sage: vector(srange(3))
(0, 1, 2)
The difference is that the elements of range(3) are python ints while
the elements of srange(3) are Sage Integers.
It also works if you specify the coordinate ring:
sage: vector(RR,range(3))
(0.000000000000000, 1.00000000000000, 2.00000000000000)
sage: vector(ZZ,range(3))
(0, 1, 2)
The problem lies in the function prepare() in
sage/modules/free_module_element.pyx, since Sequence(range(3)) has
universe <type 'int'> and is_Ring() fails on that.
The fix would therefore appear to be to test for the case where the
universe is <type 'int'>
and change it to ZZ.
The second issue is just that after w=range(3), w is a python list,
and for lists, multiplying by 2 just repeats the list. Similarly
sage: range(3) + range(3)
[0, 1, 2, 0, 1, 2]
If you want to do mathematical operations such as scalar
multiplcation, convert to a vector.
(You could also do [2*i for i in range(3)], but I don't think you like
that construction.)
I have CC's this to sage-devel so that the bug will be fixed (if
people agree with me that i is a bug).
John Cremona
2008/8/28 Stan Schymanski <schy...@gmail.com>: