On Mon, Oct 20, 2008 at 2:24 PM, pong <[EMAIL PROTECTED]> wrote:
>
> Yes, that's what I got. Maybe because I'm only using SAGE 3.1.1 or
> there is something wrong with the installation.

I bet that's the case.  You should maybe upgrade.  We'll be posting
binaries soon.

William

>
> sage: vector([k for k in range(10)])
> -----------------------------------------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call
> last)
>
> /home/pong/sage/<ipython console> in <module>()
>
> /home/pong/sage/free_module_element.pyx in
> sage.modules.free_module_element.vector (sage/modules/
> free_module_element.c:2376)()
>
> /home/pong/sage/free_module_element.pyx in
> sage.modules.free_module_element.prepare (sage/modules/
> free_module_element.c:2622)()
>
> TypeError: unable to find a common ring for all elements
>
>
> On Oct 20, 2:09 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
>> On Mon, Oct 20, 2008 at 2:06 PM, pong <[EMAIL PROTECTED]> wrote:
>>
>> > Thanks Marshall. I have thought about that as well.
>> > Since I want to optimize time. I want to see if your method is faster
>> > then a for loop. However, I run into something puzzling:
>>
>> > vector( [k for k in range(10)]) results in an error. Sage compliant
>> > about
>>
>> > TypeError: unable to find a common ring for all elements
>>
>> I get
>>
>> sage: vector( [k for k in range(10)])
>> (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
>>
>> Are you sure that's what you typed?
>>
>>
>>
>>
>>
>> > But if you check each element of the list, I got <type 'int'>
>>
>> > So why SAGE is complaining?
>>
>> > On Oct 19, 7:27 am, Marshall Hampton <[EMAIL PROTECTED]> wrote:
>> >> Another option is to convert your list to a vector, and then convert
>> >> it back.  This is more awkward for a single operation but if you are
>> >> doing lots of vector addition and scalar multiplication it can be the
>> >> way to go.
>> >> I.e. you can do:
>>
>> >> sage: a = [3,4]
>> >> sage: a = list(2*vector(a))
>> >> sage: a
>> >> [6, 8]
>>
>> >> -M. Hampton
>>
>> >> On Oct 19, 1:15 am, Robert Bradshaw <[EMAIL PROTECTED]>
>> >> wrote:
>>
>> >> > On Oct 18, 2008, at 10:14 PM, Alex Ghitza wrote:
>>
>> >> > > Hmmm.  As far as I know you can use _ as a placeholder for a
>> >> > > variable, and it's meant for this kind of use (where you don't
>> >> > > really want to introduce a new variable name).  It's strange that
>> >> > > it doesn't work for you.  Can you post the error message that you get?
>>
>> >> > Actually, _ is an actual variable, though personally I find it a bit
>> >> > harder to read than a normal letter. The one special thing about it
>> >> > (in ipython at least) is that it constantly gets reassigned to the
>> >> > last returned value, e.g.
>>
>> >> > sage: 1+2
>> >> > 3
>> >> > sage: _
>> >> > 3
>>
>> >> > - Robert
>>
>> --
>> William Stein
>> Associate Professor of Mathematics
>> University of Washingtonhttp://wstein.org
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to