Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing a pointer to a struct in cython
    primarykey
    data
    text
    <p>I'm attempting to write a cython interface to the complex version of the MUMPS solver (zmumps). I'm running into some problems as I have no previous experience with either C or cython. Following the example of the <a href="https://github.com/bfroehle/pymumps" rel="nofollow">pymumps package</a> I was able to get the real version of the code (dmumps) to work. </p> <p>I believe that my problem are the pointers to the ZMUMPS_COMPLEX structures. For the </p> <p>So far I have the following (lifted heavily from <a href="https://github.com/bfroehle/pymumps" rel="nofollow">pymumps</a>):</p> <p><strong>zmumps_c.pxd:</strong></p> <pre><code>from libc.string cimport strncpy cdef extern from "mumps_c_types.h": ctypedef struct ZMUMPS_COMPLEX "ZMUMPS_COMPLEX": double r double i cdef extern from "zmumps_c.h": ctypedef int MUMPS_INT ctypedef struct c_ZMUMPS_STRUC_C "ZMUMPS_STRUC_C": MUMPS_INT sym, par, job MUMPS_INT comm_fortran # Fortran communicator MUMPS_INT n # Assembled entry MUMPS_INT nz MUMPS_INT *irn MUMPS_INT *jcn ZMUMPS_COMPLEX *a # RHS and statistics ZMUMPS_COMPLEX *rhs MUMPS_INT infog[40] void c_zmumps_c "zmumps_c" (c_ZMUMPS_STRUC_C *) </code></pre> <p><strong>zmumps_c.pyx</strong></p> <pre><code>cdef class ZMUMPS_STRUC_C: cdef c_ZMUMPS_STRUC_C ob property sym: def __get__(self): return self.ob.sym def __set__(self, value): self.ob.sym = value property par: def __get__(self): return self.ob.par def __set__(self, value): self.ob.par = value property job: def __get__(self): return self.ob.job def __set__(self, value): self.ob.job = value property comm_fortran: def __get__(self): return self.ob.comm_fortran def __set__(self, value): self.ob.comm_fortran = value property n: def __get__(self): return self.ob.n def __set__(self, value): self.ob.n = value property nz: def __get__(self): return self.ob.nz def __set__(self, value): self.ob.nz = value property irn: def __get__(self): return &lt;long&gt; self.ob.irn def __set__(self, long value): self.ob.irn = &lt;MUMPS_INT*&gt; value property jcn: def __get__(self): return &lt;long&gt; self.ob.jcn def __set__(self, long value): self.ob.jcn = &lt;MUMPS_INT*&gt; value property a: def __get__(self): return &lt;long&gt; self.ob.a def __set__(self, long value): self.ob.a = &lt;ZMUMPS_COMPLEX*&gt; value property rhs: def __get__(self): return &lt;long&gt; self.ob.rhs def __set__(self, long value): self.ob.rhs = &lt;ZMUMPS_COMPLEX*&gt; value property infog: def __get__(self): cdef MUMPS_INT[:] view = self.ob.infog return view def zmumps_c(ZMUMPS_STRUC_C s not None): c_zmumps_c(&amp;s.ob) </code></pre> <p>In my python code I'm able to set the irn and jcn using</p> <pre><code>import zmumps_c import numpy as np MUMPS_STRUC_C = staticmethod(zmumps_c.ZMUMPS_STRUC_C) id = MUMPS_STRUC_C() x = np.r_[1:10] id.irn = x.__array_interface__['data'][0] </code></pre> <p>However, I have no idea how to set the values of a or rhs. Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload