Next version of alglib.spkg (and some thoughts about debugging)

8 views
Skip to first unread message

Sergey Bochkanov

unread,
Aug 9, 2010, 4:42:16 AM8/9/10
to sage-...@googlegroups.com
Hello!

New version of ALGLIB spkg is released. It can be downloaded from
http://www.alglib.net/share/2010-08-09-alglib-for-sage/

New version of spkg:
* compiles under OS X, SPARC/Solaris, Linux
* was tested wuth 2.7 and 3.1.2 branches of Python
* includes patch by Carl Witty which allows to use Sage
matrices/vectors as algorithm inputs (results, however, are still
returned as Python lists)


Known issues with new spkg:

New spkg works when called from Sage, but for some unknown reason
spkg-check fails on my system with following traceback:

> Traceback (most recent call last):
> File "check.py", line 1, in <module>
> from alglib import _alglib
> File "/SAGE/sage-4.5.1/spkg/build/alglib-0.1/src/alglib/__init__.py", line 15, in <module>
> import alglib._alglib
> File "/SAGE/sage-4.5.1/spkg/build/alglib-0.1/src/alglib/_alglib.py", line 19, in <module>
> from sage.matrix.all import is_Matrix
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/matrix/all.py", line 1, in <module>
> from matrix_space import MatrixSpace, is_MatrixSpace
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/matrix/matrix_space.py", line 33, in <module>
> import matrix
> File "matrix.pyx", line 1, in init sage.matrix.matrix (sage/matrix/matrix.c:1757)
> File "matrix2.pyx", line 2, in init sage.matrix.matrix2 (sage/matrix/matrix2.c:44380)
> File "matrix1.pyx", line 1, in init sage.matrix.matrix1 (sage/matrix/matrix1.c:10941)
> File "matrix0.pyx", line 32, in init sage.matrix.matrix0 (sage/matrix/matrix0.c:23440)
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/modules/free_module.py", > line 159, idule> import free_module_element
> File "free_module_element.pyx", line 111, in init sage.modules.free_module_element (sage/modules/free_module_element.c:23489)
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/rings/arith.py", line 19, in <module>
> from sage.rings.rational_field import QQ
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/rings/rational_field.py", line 52, in <module>
> import rational
> File "rational.pyx", line 70, in init sage.rings.rational (sage/rings/rational.c:23826)
> File "real_mpfr.pyx", line 1, in init sage.rings.real_mpfr (sage/rings/real_mpfr.c:29200)
> File "complex_number.pxd", line 8, in init sage.libs.mpmath.utils (sage/libs/mpmath/utils.c:5378)
> File "complex_double.pxd", line 13, in init sage.rings.complex_number (sage/rings/complex_number.c:15877)
> File "complex_double.pyx", line 95, in init sage.rings.complex_double (sage/rings/complex_double.c:14319)
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/rings/complex_field.py", line 86, in ComplexField
> C = ComplexField_class(prec)
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/rings/complex_field.py", line 184, in __init__
> ParentWithGens.__init__(self, self._real_field(), ('I',), False, category = Fields())
> File "/SAGE/sage-4.5.1/local/lib/python2.6/site-packages/sage/rings/complex_field.py", line 237, in _real_field
> self.__real_field = real_mpfr.RealField(self._prec)
> File "real_mpfr.pyx", line 267, in sage.rings.real_mpfr.RealField (sage/rings/real_mpfr.c:3640)
> TypeError: 'NoneType' object is unsubscriptable

It is somehow connected to patch by Carl Witty which adds ability to
work with Sage matrices/vectors. This patch works OK when package is
used from Sage. But when we run test suite from spkg-check with
"python check.py", it fails at the "from sage.matrix.all import
is_Matrix". Does someone have any idea?

Some thought about debugging:

First, I want to thank William Stein for access to t2.math and
bsd.math, which allowed me to test ALGLIB under OS X and
SPARC/Solaris. I also want to thank David Kirkby for access to HP-UX
box with PA-RISC CPU and for his help during debugging.

Access to this hardware was very important because it allowed me to
catch two bugs. One of them was alignment bug, totally invisible under
Intel, but 100% blocker ("SEGV: bus error") under SPARC which has
stricter alignment requirements. Another bug was related to the NAN
detection: again, under Intel (and SPARC!) it was just hard-to-trigger
minor bug (actually, it went unnoticed), but it leaded to crash under
PA-RISC which has slightly different NAN representation.

I telling you this story so you can learn from my experience: the more
diverse environment you use to test your software, the more bugs you
will catch.

--
With best regards,
Sergey mailto:sergey.b...@alglib.net

Carl Witty

unread,
Aug 9, 2010, 11:58:12 AM8/9/10
to sage-...@googlegroups.com
On Mon, Aug 9, 2010 at 1:42 AM, Sergey Bochkanov
<sergey.b...@alglib.net> wrote:
> It  is  somehow connected to patch by Carl Witty which adds ability to
> work  with  Sage matrices/vectors. This patch works OK when package is
> used  from  Sage.  But  when  we  run  test suite from spkg-check with
> "python  check.py",  it  fails  at  the  "from  sage.matrix.all import
> is_Matrix". Does someone have any idea?

Unfortunately, you can't import only part of the Sage library; you
have to import the whole thing first, to make sure it's all
initialized correctly. (I consider this a bug, but it's a
low-priority one because the workaround is easy.)

Add this line at the top of check.py:

import sage.all

Carl

Sergey Bochkanov

unread,
Aug 9, 2010, 12:42:51 PM8/9/10
to Carl Witty
Hello, Carl.

You wrote 9 августа 2010 г., 19:58:12:
> Add this line at the top of check.py:
> import sage.all

Thanks!

I've added it on top of _alglib.py because
a) check.py, as every other file, explicitly imports _alglib.py
b) I prefer to modify one file instead of two

Apparently, it works now. Modified archive is uploaded to the same
location as original one -
http://www.alglib.net/share/2010-08-09-alglib-for-sage/

If you want, you can test it with your installation of Sage.

Reply all
Reply to author
Forward
0 new messages