That's great, thanks a lot!
Stan
Martin Albrecht wrote:
>> Could you give an example of how to convert a list (e.g. [1,2,3,4]) to a
>> vector (e.g. (1,2,3,4) and back again? That would help me a lot.
>>
>
> sage: l = [1,2,3,4]
> sage: v = vector(ZZ,l); v
> (1, 2, 3, 4)
> sage: list(v) # lis
> Could you give an example of how to convert a list (e.g. [1,2,3,4]) to a
> vector (e.g. (1,2,3,4) and back again? That would help me a lot.
sage: l = [1,2,3,4]
sage: v = vector(ZZ,l); v
(1, 2, 3, 4)
sage: list(v) # list of ZZs
[1, 2, 3, 4]
sage: map(int, list(v)) # list of ints
[1, 2, 3, 4]
Ch
Hi John,
Thanks a lot for your help.
John Cremona wrote:
> 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.)
>
Could you give an example of how to conver
There are two separate things going on here.
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 sran