[sage-combinat-devel] Re: Track ticket 9651

2010-09-19 Thread Christian Stump
Salut!

  It is not yet in the queue. If that makes your life simpler, you are
  welcome to add it there.

 This patch does not apply cleanly. I have tried out-of-the-box
 sage-4.5.3.rc0, sage-4.5.2 and sage-4.5.2 with the combinat queue
 installed.

I don't have much experience with the combinat queue but I finally
managed (many thanks to Sebastian L. for his patient help on Friday!)
to upload a version of the dictionary addition. I applied the new
version and everything works well (seeing it with my naive eyes) - if
there are still problems please let me know (maybe together with an
explanation how to solve them).

Best, Christian

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-de...@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



[sage-combinat-devel] #8327 Implement the universal cyclotomic field, using Zumbroich basis

2010-09-19 Thread Christian Stump
Hi,

after Sebastian's explanations how to push things to the combinat
queue (thanks again), I pushed a first version of the universal
cyclotomic field. If anyone has some time, it would be nice to get
some feedback what runs smoothly and where is still work to be done...

You get the universal cyclotomic field with UCF and any root of unity
by E(n) or E(n,k) for E(n)^k. Everything else should be self-
explaining, if it is not I should change it.

Best, Christian

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-de...@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



Re: [sage-devel] Re: Please explain _pari_ and _pari_init_

2010-09-19 Thread Jeroen Demeyer
On 2010-08-20 00:59, Simon King wrote:
 But how is the representation created in the first place? That's the
 job of the method X._foo_init_. It is supposed to return a string that
 yields a representation of X when evaluated in foo. If X._foo_init_ is
 not there, X._interface_init_ is called, which by default returns
 repr(X) (which often makes sense, but of course not always).

But this does not explain why _foo_init_ should return a STRING
(clearly, this is often a bad idea).

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Please explain _pari_ and _pari_init_

2010-09-19 Thread Jeroen Demeyer
It also seems that the Gp interface uses _pari_init_(), what's up with that?

Jeroen.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: Improvement of numerical integration routines

2010-09-19 Thread rjf
Any program that computes a quadrature by evaluating the integral at
selected points cannot provide
a rigorous error bound.  I don't know what a rigorous error estimate
is, unless it is an
estimate of what might be a rigorous bound.  And thus not rigorous at
all, since the
estimate might be wrong.

A nasty function:f(x) :=  if member(x,evaluation_point_set) then 0
else 1.
integrate(f,a,b)  should be b-a.  The numerical integration program
returns 0.

There are SO many programs to do numerical quadrature, and some of
them are
quite good and free.  Some are not free (e.g. NIntegrate in
Mathematica).
The real issue is not writing the program, but figuring out which
program to use and
how to set up the parameters to make it work best.  I doubt that
providing
arbitrary-precision floats as a foundation will help solve all the
issues, though
a version of Gaussian quadrature or Clenshaw-Curtis using bigfloats
would
not be hard to do.  See http://www.cs.berkeley.edu/~fateman/papers/quad.pdf
for program listings of a few quadrature routines using maxima and
bigfloats.


 See what NIntegrate does, and think about
whether you want to do that.

RJF



On Sep 17, 1:45 pm, Fredrik Johansson fredrik.johans...@gmail.com
wrote:
 On Fri, Sep 17, 2010 at 12:48 AM, maldun dom...@gmx.net wrote:
  Do you see the problems?! These are caused by the high oscillation,
  but we get no warning.
  If you use scipy you would get the following:

 It is possible to get an error estimate back from mpmath, as follows:

 sage: mpmath.quad(lambda a: mpmath.exp(a)*mpmath.sin(1000*a),
 [0,mpmath.pi], error=True)
 (mpf('-0.71920642950258207'), mpf('1.0'))
 sage: mpmath.quad(lambda a: mpmath.exp(a)*mpmath.sin(1000*a),
 [0,mpmath.pi], maxdegree=15, error=True)
 (mpf('-0.022140670492108779'), mpf('1.0e-37'))

 Currently it doesn't seem to work with mpmath.call (because
 mpmath_to_sage doesn't know what to do with a tuple).

 The error estimates are also somewhat bogus (in both examples above --
 the first value has been capped to 1.0, if I remember correctly what
 the code does, and the second is an extrapolate of the quadrature
 error alone and clearly doesn't account for the arithmetic error). But
 it should be sufficient to correctly detect a problem and signal a
 warning in the Sage wrapper code in typical cases.

 I'm currently working on rewriting the integration code in mpmath to
 handle error estimates more rigorously and flexibly. This will work
 much better in a future version of mpmath.

 Fredrik

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] memory leak or some other weirdness

2010-09-19 Thread David Harvey
Consider the following script, which saves a p-adic matrix and then
repeatedly loads it into a list:

==
from time import time

K = Qp(13, 10)
M = Matrix(K, [[K.random_element() for j in range(200)] for k in range(200)])
M.save(thing.sobj)

L = []
for i in range(40):
last = time()
L.append(load(thing.sobj))
now = time()
print took %.2f seconds % (now - last)
last = now

==

Here is typical output for sage 4.5.3, AMD linux:

==

took 0.21 seconds
took 0.21 seconds
took 0.39 seconds
took 0.21 seconds
took 0.44 seconds
took 0.21 seconds
took 0.48 seconds
took 0.21 seconds
took 0.21 seconds
took 0.51 seconds
took 0.21 seconds
took 0.56 seconds
took 0.21 seconds
took 0.60 seconds
took 0.21 seconds
took 0.21 seconds
took 0.64 seconds
took 0.20 seconds
took 0.69 seconds
took 0.20 seconds
took 0.73 seconds
took 0.20 seconds
took 0.21 seconds
took 0.77 seconds
took 0.21 seconds
took 0.81 seconds
took 0.20 seconds
took 0.86 seconds
took 0.21 seconds
took 0.21 seconds
took 0.89 seconds
took 0.20 seconds
took 0.94 seconds
took 0.20 seconds
took 0.98 seconds
took 0.20 seconds
took 0.21 seconds
took 1.02 seconds
took 0.20 seconds
took 1.07 seconds

==

About half of them are 0.2 seconds, but the rest keep getting longer and
longer, apparently the increase is linear in the number of iterations.
This smells like some kind of weird leak, but I'm not sure. Any thoughts?

david


-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Two doctest-failures on a competely clean Sage 4.5.3 compilation

2010-09-19 Thread Mitesh Patel
On 09/18/2010 05:39 AM, Johan S. R. Nielsen wrote:
 I downloaded the Sage 4.5.3 source, compiled everything and ran a
 doctest (./sage -testall) immediately afterwards. I guess everything
 should run smoothly, but surprisingly, there were two failures:
 
 -
 sage -t  devel/sage/sage/misc/explain_pickle.py
 **
 File /home/jsrn/local/sage/sage-4.5.3/devel/sage/sage/misc/
 explain_pickle.py, line 968:
 sage: test_pickle(u'hi\u1234\U00012345')
 Exception raised:
 Traceback (most recent call last):
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/ncadoctest.py,
 line 1231, in run_one_test
 self.run_one_example(test, example, filename, compileflags)
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/
 sagedoctest.py, line 38, in run_one_example
 OrigDocTestRunner.run_one_example(self, test, example,
 filename, compileflags)
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/ncadoctest.py,
 line 1172, in run_one_example
 compileflags, 1) in test.globs
   File doctest __main__.example_32[3], line 1, in module
 test_pickle(u'hi\u1234\U00012345')###line 968:
 sage: test_pickle(u'hi\u1234\U00012345')
   File /home/jsrn/local/sage/sage-4.5.3/local/lib/python/site-
 packages/sage/misc/explain_pickle.py, line 2678, in test_pickle
 p = dumps(p, compress=False)
   File sage_object.pyx, line 787, in
 sage.structure.sage_object.dumps (sage/structure/sage_object.c:8242)
   File sage_object.pyx, line 970, in
 sage.structure.sage_object.picklejar (sage/structure/sage_object.c:
 9771)
 UnicodeEncodeError: 'ascii' codec can't encode characters in
 position 2-3: ordinal not in range(128)
 **
 1 items had failures:
1 of   4 in __main__.example_32
 ***Test Failed*** 1 failures.
 For whitespace errors, see the file /home/jsrn/.sage//
 tmp/.doctest_explain_pickle.py
 --
 
 
 and
 
 --
 sage -t  devel/sage/sage/combinat/iet/reduced.py
 **
 File /home/jsrn/local/sage/sage-4.5.3/devel/sage/sage/combinat/iet/
 reduced.py, line 89:
 sage: loads(dumps(p)) == p
 Exception raised:
 Traceback (most recent call last):
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/ncadoctest.py,
 line 1231, in run_one_test
 self.run_one_example(test, example, filename, compileflags)
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/
 sagedoctest.py, line 38, in run_one_example
 OrigDocTestRunner.run_one_example(self, test, example,
 filename, compileflags)
   File /home/jsrn/local/sage/sage-4.5.3/local/bin/ncadoctest.py,
 line 1172, in run_one_example
 compileflags, 1) in test.globs
   File doctest __main__.example_2[4], line 1, in module
 loads(dumps(p)) == p###line 89:
 sage: loads(dumps(p)) == p
   File sage_object.pyx, line 787, in
 sage.structure.sage_object.dumps (sage/structure/sage_object.c:8242)
   File sage_object.pyx, line 970, in
 sage.structure.sage_object.picklejar (sage/structure/sage_object.c:
 9771)
   File sage_object.pyx, line 101, in
 sage.structure.sage_object.SageObject.__repr__ (sage/structure/
 sage_object.c:1370)
   File /home/jsrn/local/sage/sage-4.5.3/local/lib/python/site-
 packages/sage/combinat/iet/template.py, line 305, in _repr_
 return str(f(*self._repr_options))
   File /home/jsrn/local/sage/sage-4.5.3/local/lib/python/site-
 packages/sage/combinat/iet/template.py, line 351, in str
 l = self.list()
   File /home/jsrn/local/sage/sage-4.5.3/local/lib/python/site-
 packages/sage/combinat/iet/reduced.py, line 512, in list
 a0 = map(self._alphabet.unrank, range(0,len(self)))
 AttributeError: 'NoneType' object has no attribute 'unrank'
 **
 1 items had failures:
1 of  12 in __main__.example_2
 ***Test Failed*** 1 failures.
 -
 
 Can anyone explain this? Should there be created Tracs for fixing it,
 or am I missing something?
 I am running Ubuntu 10.4, 64bit on a Thinkpad t410 with Intel i7
 quadcore processor.


Just to check: What happens if you rerun these tests?

$ cd SAGE_ROOT
$ ./sage -t  devel/sage/sage/misc/explain_pickle.py
$ ./sage -t  devel/sage/sage/combinat/iet/reduced.py

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread dmharvey

On Sep 19, 6:25 pm, David Harvey dmhar...@cims.nyu.edu wrote:
 Consider the following script, which saves a p-adic matrix and then
 repeatedly loads it into a list:

The same thing happens on sage 4.5.2 on mac OS.

I also tried using a different ring, i.e. with

K = Integers(13^10)
M = Matrix(K, [[K.random_element() for j in range(200)] for k in
range(200)])
M.save(thing.sobj)

The same thing apparently happens, not quite as obvious but still
there:

took 1.08 seconds
took 1.08 seconds
took 1.01 seconds
took 1.11 seconds
took 1.01 seconds
took 1.14 seconds
took 1.01 seconds
took 1.01 seconds
took 1.14 seconds
took 1.01 seconds
took 1.16 seconds
took 1.01 seconds
took 1.17 seconds
took 1.02 seconds
took 1.02 seconds
took 1.19 seconds
took 1.02 seconds
took 1.20 seconds
took 1.02 seconds
took 1.22 seconds
took 1.02 seconds
took 1.02 seconds
took 1.24 seconds
took 1.01 seconds
took 1.25 seconds
took 1.01 seconds
took 1.26 seconds
took 1.02 seconds
took 1.02 seconds
took 1.28 seconds
took 1.03 seconds
took 1.29 seconds
took 1.03 seconds
took 1.31 seconds
took 1.02 seconds
took 1.02 seconds
took 1.32 seconds
took 1.02 seconds
took 1.34 seconds
took 1.02 seconds

For matrices over ZZ it doesn't seem to happen though. This suggests
it is a bug in the generic matrix load() code.

david

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread dmharvey
On Sep 19, 9:12 pm, dmharvey dmhar...@cims.nyu.edu wrote:

 For matrices over ZZ it doesn't seem to happen though. This suggests
 it is a bug in the generic matrix load() code.

Curiouser and curiouser it has nothing to do with matrices. Even
doing this causes the problem:

K = Integers(13^10)
M = [[K.random_element() for j in range(200)] for k in range(200)]
save(M, thing.sobj)

But if I use just Integers of the same size it doesn't happen.

david

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread dmharvey

On Sep 19, 9:28 pm, dmharvey dmhar...@cims.nyu.edu wrote:

 Curiouser and curiouser it has nothing to do with matrices. Even
 doing this causes the problem:

 K = Integers(13^10)
 M = [[K.random_element() for j in range(200)] for k in range(200)]
 save(M, thing.sobj)

I have just discovered the following remarkable

THEOREM:

The code

K = Integers(N)
M = [[K.random_element() for j in range(200)] for k in range(200)]
save(M, thing.sobj)

leads to the bug IF AND ONLY IF N = 500.

Moreover, it is about 50x faster to load the matrix if N  500.

WTF??

david

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


Re: [sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread Mitesh Patel
On 09/19/2010 08:45 PM, dmharvey wrote:
 On Sep 19, 9:28 pm, dmharvey dmhar...@cims.nyu.edu wrote:
 Curiouser and curiouser it has nothing to do with matrices. Even
 doing this causes the problem:

 K = Integers(13^10)
 M = [[K.random_element() for j in range(200)] for k in range(200)]
 save(M, thing.sobj)
 
 I have just discovered the following remarkable
 
 THEOREM:
 
 The code
 
 K = Integers(N)
 M = [[K.random_element() for j in range(200)] for k in range(200)]
 save(M, thing.sobj)
 
 leads to the bug IF AND ONLY IF N = 500.
 
 Moreover, it is about 50x faster to load the matrix if N  500.
 
 WTF??

Possibly very naive question: What happens to the times if you disable
automatic garbage collection:

import gc
gc.disable()

?

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread dmharvey


On Sep 19, 10:03 pm, Mitesh Patel qed...@gmail.com wrote:

 Possibly very naive question: What happens to the times if you disable
 automatic garbage collection:

 import gc
 gc.disable()

 ?

Interesting clue yes that gets rid of the increasing times. So do
you think the garbage collection has some kind of stupid quadratic
time algorithm?

There is still a 50x difference between Integers(499) and
Integers(500).

It's difficult to tell if there's an actual leak, since of course the
memory usage keeps increasing as I load more and more copies of the
data.

david

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org


[sage-devel] Re: memory leak or some other weirdness

2010-09-19 Thread dmharvey

On Sep 19, 10:20 pm, dmharvey dmhar...@cims.nyu.edu wrote:
 On Sep 19, 10:03 pm, Mitesh Patel qed...@gmail.com wrote:

  Possibly very naive question: What happens to the times if you disable
  automatic garbage collection:

  import gc
  gc.disable()

  ?

 Interesting clue yes that gets rid of the increasing times. So do
 you think the garbage collection has some kind of stupid quadratic
 time algorithm?

Ah perhaps the garbage collector has to scan through all extant
objects every now and then, looking for reference loops etc? So this
would happen in ANY program that has large numbers of small objects
lying around? I've never thought much about garbage collection before.

david

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org