On Tuesday, 25 September 2012 15:31:09 UTC+8, Dima Pasechnik wrote: > > As suggested below, it might work if you replace the line > s = g.spectrum() > with > s = [AA(xx) for xx in g.spectrum()] > This still doesn't really work, but s = [RR(xx) for xx in g.spectrum()]
does. You'd also need to weaken your inequality a bit to account for numerical noise (RR by default has 53-bit mantissa). Doing sp/sm+1.01 instead of sp/sm+1 produces a list of 94 graphs. How to make this robust is another question. HTH, Dmitrii > making all the eigenvalues real (as they should be, as you generate > undirected graphs) > > On Tuesday, 25 September 2012 04:18:03 UTC+8, Jernej Azarija 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.