Ask Your Question

Hartmut Monien's profile - activity

2023-07-20 16:50:15 +0100 received badge  Popular Question (source)
2022-08-10 18:29:01 +0100 received badge  Notable Question (source)
2022-04-04 15:55:45 +0100 asked a question laurent series

laurent series Is the number of terms of a Laurent series fixed? E.g. P.<t> = LaurentSeriesRing(QQ) 1/P([1 for t

2018-09-22 09:49:31 +0100 received badge  Famous Question (source)
2015-09-08 15:33:22 +0100 asked a question cython convert mpc_t to ComplexNumber

I wish to return the result of a calculation done in Cython with the result of mpc_t to ComplexNumber

from sage.libs.mpc cimport *

cpdef f():   
    cdef mpc_t z   
    mpc_init2(z, 1024)   
    mpc_set_ui(z, 11, MPC_RNDNN)  
    # how to convert the result to a ComplexNumber with the corresponding precision???   
    return ?

This should return ComplexNumber(7,0) with precision 1024 bits. What is the correct spell?

The real counterpart just works fine:

from sage.rings.real_mpfr cimport RealNumber
from sage.rings.real_mpfr import RealField

cpdef g():
    cdef RealNumber my_number = RealField(128)(5)
    mpfr_mul_ui(my_number.value, my_number.value, 17, MPFR_RNDN)
    return my_number

returns 85.000000000000000000000000000000000000 as it should.

2014-09-30 20:16:48 +0100 received badge  Notable Question (source)
2014-09-29 21:05:39 +0100 asked a question passing options to superclass method

I would like to modify the plot code of a plot attribute in a derived class

class Foo(Bar):
     def plot(self, **options):
         super(Foo, self).plot(options)

This does not seem to work. What is the right way to pass the options?

2013-08-28 12:21:24 +0100 received badge  Popular Question (source)
2013-05-03 09:45:43 +0100 received badge  Popular Question (source)
2011-10-14 00:47:27 +0100 asked a question pickling extension classes

What is the right way to pickle a cython extension class? Consider the example

cdef class Stuff:
 def __init__(self):


a = Stuff()
a == loads(dumps(a))

gives the result False because the address of the new object generated by loads is different from the original object a.

2011-07-15 03:47:47 +0100 received badge  Editor (source)
2011-07-14 17:57:09 +0100 received badge  Student (source)
2011-07-14 17:07:05 +0100 asked a question cython stl class

sage complains about importing the following spyx file:

from libcpp.vector cimport vector as vec

cdef test_vector(): 
   cdef vec[int] vect 
   cdef int i 
   for i in range(10): 
   for i in range(10): 
       print vect[i]

I have no problem translating a pyx file with the same contents with cython and generating a module with test_vector ... . What is the right way to access the stl cpp vector class in a pyx file?