Re: [sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread Vincent Delecroix
Anyway, you should also return the size of the allocated block. It might be more standard to use slong my_function(mpfr_ptr * answer, mpfr_ptr coeffs, slong length) where the output would be the size of the allocated block at "*answer". Don't you have a reasonable bound on the size of the resu

[sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread mmarco
Thanks for the hint. Compiling in plain python complained about some missing header files. Adding them to the include path seemed to solve the problem for now. El domingo, 5 de febrero de 2017, 13:25:48 (UTC+1), Volker Braun escribió: > > On Sunday, February 5, 2017 at 11:38:25 AM UTC+1, mmarco

Re: [sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread mmarco
I see. One problem here is that I don't know in advance the size of the returned list, so the allocation should happen in the c++ library side. So I am guessing the way around it is to return a pointer to the mpfr_ptr. Right? El domingo, 5 de febrero de 2017, 11:43:54 (UTC+1), vdelecroix escrib

[sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread Volker Braun
On Sunday, February 5, 2017 at 11:38:25 AM UTC+1, mmarco wrote: > > cdef extern from "my_library.h": > mpfr_t* my_function (mpfr_t *_coef) > That isn't exactly idiomatic C++, but ok /home/mmarco/sage/local/lib/python2.7/site-packages/IPython/core/ultratb.pyc > in is_recursion_error(etype,

Re: [sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread Vincent Delecroix
If you want to be complient with GMP/MPFR/FLINT you should change the signature of mpfr_t* my_function (mpfr_t *_coef) to void my_function(mfpr_ptr result, mpfr_ptr input, slong len) And such function should not do any allocation at all. Le 05/02/2017 à 11:40, Vincent Delecroix a écr

Re: [sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread Vincent Delecroix
If you had a look at the code I provided you can check that what you did is very wrong. mpfr_t is already an array. The type "mpfr_t * x" make no sense at all. Le 05/02/2017 à 11:38, mmarco a écrit : I am afraid I didn't explain my problem well enough. My problem is not to write c++ code with

[sage-devel] Re: What is the right way to deal with mpfr_t arrays/vectors/lists in cython?

2017-02-05 Thread mmarco
I am afraid I didn't explain my problem well enough. My problem is not to write c++ code with mpfr. That is solved It is also not to call c++ libraries from cython code that involves plain mpfr numbers. That is also solved. My problem is to do so with functions that involve *arrays *(or lists, or