Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Simplify C header (ffm.h) #88

Open
5 tasks
ibayer opened this issue Jan 17, 2017 · 0 comments
Open
5 tasks

[WIP] Simplify C header (ffm.h) #88

ibayer opened this issue Jan 17, 2017 · 0 comments

Comments

@ibayer
Copy link
Owner

ibayer commented Jan 17, 2017

The refactoring from issue #85 has to be completed first.

Motivation:

A lot of complicated code is required in fastFM/ffm.pyx to wrap the
c structs cs_di and ffm_param (see fastFM/cff.pxd).

Basically the fastFM-core header fastFM-core/include/ffm.h should be refactored using ADTs [1] (for cs_di and ffm_param) so that the C lib can be call as suggested here.

Overview:

(fastFM-core): Forward declare the struts and provide factory function in order to remove
implementation details from fastFM-core/include/ffm.h (see [0,1] for an example).

(fastFM): Adapt fastFM/ffm.pyx and fastFM/cff.pxd to the new ffm.h header.

1 Refactor C Interface:

  • (fastFM-core) Add C constructor for the structs cs_di, ffm_param.

in ffm.h


extern cs_di* InitSparseMatrix (... );
extern void DeleteSparseMatrix(cs_di* m);

extern ffm_param* CreateParam(...);
extern void DeleteParam(ffm_param *p);

the implementation goes into ffm.c

2 Use new C Interface:

3 Clean Up

  • (fastFM/fastFM-core) Drop the now unused struct from fastFM/cff.pxd and ffm.h.

[0] slide 15 http://www.slideshare.net/StefanusDuToit/cpp-con-2014-hourglass-interfaces-for-c-apis
[1] http://inst.eecs.berkeley.edu/~selfpace/studyguide/9C.sg/Output/ADTs.in.C.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant