ibayer / fastFM

fastFM: A Library for Factorization Machines
http://ibayer.github.io/fastFM
Other
1.07k stars 206 forks source link

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

Open ibayer opened 7 years ago

ibayer commented 7 years ago

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:

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

[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