From: Roman G. <rom...@gm...> - 2005-06-22 12:10:52
|
Hi Implementing a C API for a Python extension is one of the more obscure programming tasks IMHO. To expose additional pysparse functions using the C API the spmatrix_api.h needs to be extended. This is however an tedious and error prone task. I wrote a simple Python script to generate spmatrix_api.h. You can play around with this script if you want. (see attached file) Cheers -- Roman On 6/22/05, Dominique Orban <dom...@gm...> wrote: > On 6/22/05, Roman Geus <rom...@gm...> wrote: > > Hi Dominique > > > > Sorry for not replying. I actually forgot to register myself for this l= ist > > :-/ > > > > > Hello, > > > > > > I am linking my C code to PySparse and would like to create a CSR > > > matrix using newCSRMatObject. I don"t see why the prototype for that > > > function does not appear in the headers unless SPMATRIX_MODULE is > > > #define"d. > > > > > If I #define SPMATRIX_MODULE before #include-ing csr_mat.h, I obtain > > > tons of warning and error messages. > > > > newCSRMatObject() is not supposed to be visible outside of pysparse. > > > > > Why not have newCSRMatObject"s prototype in spmatrix_api.h like, e.g.= , > > > newLLMatObject? Same for newSSSMatObject. > > > > Since there is no way to create CSR and SSS matrices, other than > > building an LL matrix first and then converting it, I don't really see > > any benefit in exposing these functions. Am I missing something? >=20 > Hello Roman, >=20 > There may not be any benefits from Python. However, from C, you could > obviously create instances of CSR and SSS matrices without the > overhead of first creating an ll_mat and then converting it (which > takes some time when the matrices get large). If you know in advance > that you're going to create a matrix that will not be modified (in my > case: the factors of a system) but that you will use (eg for > backsolves), it would be nice to be able to skip the overhead of > creating an ll_mat. >=20 > I see it as a limitation of PySparse right now because my C kernel > isn't able to call directly other low-level language subroutines that > expect CSR or SSS matrices. Instead, I must take the long route > through ll_mat land and that has time and computational consequences. >=20 > I am not sure how to expose those functions though as tweaking the > source code produces lots of errors and warnings. I must not be > tweaking right. >=20 > Dominique > |