Ask Your Question
1

c++ cython in the notebook

asked 2013-02-27 18:34:01 +0200

ohanar gravatar image

I recently wanted to cimport sage.rings.number_field.number_field_element_quadratic from the a cython cell in notebook, but was met with gcc compilation errors. This is because that file is a c++ module.

So I am wondering, is there is a way to use the c++ functionality of cython from within a notebook cell?

edit retag flag offensive close merge delete

Comments

1) How did you install Sage? (compiling from source, downloading a binary, on a notebook server) 2) Do you have a c++ compiler installed on your system?

benjaminfjones gravatar imagebenjaminfjones ( 2013-02-27 23:03:05 +0200 )edit

Compiled from source (which implies that I have a c++ compiler), I just never really use the notebook interface.

ohanar gravatar imageohanar ( 2013-03-05 03:41:35 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2013-02-28 09:21:01 +0200

updated 2013-02-28 09:24:03 +0200

On my installation, in a notebook cell:

%cython
cimport sage.rings.number_field.number_field_element_quadratic

yields

[...]code_sage4_spyx_0.c:644:14: error: field ‘__pyx___numerator’ has incomplete type
[...]code_sage4_spyx_0.c:645:13: error: field ‘__pyx___denominator’ has incomplete type
[...]code_sage4_spyx_0.c:1090:13: error: field ‘x’ has incomplete type
[...]code_sage4_spyx_0.c:1356:14: error: field ‘x’ has incomplete type
error: command 'gcc' failed with exit status 1

but adding the magic commentbelow (see http://wiki.sagemath.org/faq) makes gcc quite happy:

%cython
#clang c++
cimport sage.rings.number_field.number_field_element_quadratic
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-02-27 18:34:01 +0200

Seen: 540 times

Last updated: Feb 28 '13