First time here? Check out the FAQ!

Ask Your Question
1

c++ cython in the notebook

asked 12 years ago

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?

Preview: (hide)

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 ( 12 years ago )

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

ohanar gravatar imageohanar ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

updated 12 years ago

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
Preview: (hide)
link

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: 12 years ago

Seen: 630 times

Last updated: Feb 28 '13