On Oct 21, 2008, at 10:17 PM, pong wrote:
Thanks to both Dan and William. However, Dan's result puzzled me.
Aren't they suggested that the for loop is faster?
Here is what I got:
sage: timeit('list(2*vector([random() for j in range(10)]))')
625 loops, best of 3: 332 µs per loop
sage:
On Tue, 21 Oct 2008 at 07:50AM -0700, pong wrote:
I wrote two list tests:
def test1():
for k in range(10^3):
v=[2*random() for j in range(10)]
else: pass
def test2():
for k in range(10^3):
v=list(2*vector([random() for j in range(10)]))
On Tue, Oct 21, 2008 at 4:09 PM, Dan Drake [EMAIL PROTECTED] wrote:
On Tue, 21 Oct 2008 at 07:50AM -0700, pong wrote:
I wrote two list tests:
def test1():
for k in range(10^3):
v=[2*random() for j in range(10)]
else: pass
def test2():
for k in range(10^3):
Thanks to both Dan and William. However, Dan's result puzzled me.
Aren't they suggested that the for loop is faster?
Here is what I got:
sage: timeit('list(2*vector([random() for j in range(10)]))')
625 loops, best of 3: 332 µs per loop
sage: timeit('[2*random() for j in range(10)]')
125 loops,
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
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
Yes, that's what I got. Maybe because I'm only using SAGE 3.1.1 or
there is something wrong with the installation.
sage: vector([k for k in range(10)])
---
TypeError
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
William Stein 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
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
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]
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?
I guess it's not a big deal since
12 matches
Mail list logo