A partial answer is that somehow the elements of the spectrum are
being created as elements of QQbar, and must have high degree, so pari
is (behind the scenes) trying to compare algebraic numbers of high
degree, which is hard as it involves creating number fields of high
degree.  It seems computationally hard to test if an element of QQbar
is positive, which is what you are doing.

What is the degree of the elements of the spectrum which cause the problem?

Does anyone know why QQbar is being used here?

John

On 24 September 2012 21:18, Jernej Azarija <azi.std...@gmail.com> wrote:
> Consider the following program that computes the spectrum and chromatic
> number of a graph:
>
> for g in graphs.nauty_geng(str(7)):
>     s = g.spectrum()
>     g.chromatic_number()
>
> This works quickly and like a charm. Now consider the following program that
> computes something related to the spectrum and chromatic number:
>
> for g in graphs.nauty_geng(str(7)):
>     s = g.spectrum()
>     sp = sum([el**2 for el in s if el > 0])
>     sm = sum([el**2 for el in s if el < 0])
>
>     if sm != 0 and not (sp/sm+1 <= g.chromatic_number()):
>         print g.graph6_string()
>
> The program gets stuck in computing something for a long time and in the end
> it dies trying to allocate a ~7GB pari stack:
>
>   File "minw.py", line 9, in <module>
>     if sm != _sage_const_0  and not (sp/sm+_sage_const_1  <=
> g.chromatic_number()):
>   File "element.pyx", line 902, in
> sage.structure.element.Element.__richcmp__ (sage/structure/element.c:8480)
>   File "element.pyx", line 847, in sage.structure.element.Element._richcmp
> (sage/structure/element.c:7930)
>   File "element.pyx", line 829, in sage.structure.element.Element._richcmp_
> (sage/structure/element.c:7659)
>   File "element.pyx", line 874, in sage.structure.element.Element._richcmp
> (sage/structure/element.c:8342)
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3755, in __cmp__
>     rcmp = cmp(self.real(), other.real())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 4395, in __cmp__
>     return self._sub_(other).sign()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 4611, in sign
>     return self.sign()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 4614, in sign
>     self.exactify()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3466, in exactify
>     self._set_descr(self._descr.exactify())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 7591, in exactify
>     left.exactify()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3466, in exactify
>     self._set_descr(self._descr.exactify())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 7334, in exactify
>     arg.exactify()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3466, in exactify
>     self._set_descr(self._descr.exactify())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 7591, in exactify
>     left.exactify()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3466, in exactify
>     self._set_descr(self._descr.exactify())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 7591, in exactify
>     left.exactify()
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 3466, in exactify
>     self._set_descr(self._descr.exactify())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 7593, in exactify
>     gen = left._exact_field().union(right._exact_field())
>   File
> "/home/azi/sage-5.3.rc1/local/lib/python2.7/site-packages/sage/rings/qqbar.py",
> line 2276, in union
>     newpol, self_pol, k = pari_nf.rnfequation(my_factor, 1)
>   File "gen.pyx", line 10412, in sage.libs.pari.gen._pari_trap
> (sage/libs/pari/gen.c:54794)
>   File "gen.pyx", line 9718, in sage.libs.pari.gen.PariInstance.allocatemem
> (sage/libs/pari/gen.c:50859)
>   File "gen.pyx", line 10233, in sage.libs.pari.gen.init_stack
> (sage/libs/pari/gen.c:53888)
> MemoryError: Unable to allocate 65536000000 bytes memory for PARI.
>
>
> What exactly is going on? From what I've checked into the sources I do not
> see what is causing this issue? Am I doing something stupid in the second
> sage program or is this some kind of Sage-Pari bug?
>
> Best,
>
> Jernej
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To post to this group, send email to sage-devel@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-devel+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
>
>

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


Reply via email to