/* InterFace to Lisp routines, using foreign-function interface. This accesses the NTL factoring of polynomials (ZZX) routine. It should also serve as an example of how to program similar more complicated pieces than described in LispWins3.cpp . */ #include #include #include #include #include #include #include #include #include #include NTL_START_IMPL //ZZX is NTL's name for polynomials in one variable (X) over // the arbitrary precision integers (ZZ). /* Here is the function we want to call... void factor(ZZ& c, vec_pair_ZZX_long& factors, const ZZX& f, long verbose=0, long bnd=0); */ //To interface with this program, see loadntl.cl. We // have to set up some buffers in lisp to hold the answers. extern "C" __declspec(dllexport) long LFactorPoly(ZZX * f, ZZX** ans, long* muls, ZZ* c ) {long bnd=0,verbose=0,size, i; vec_pair_ZZX_long * foo= new vec_pair_ZZX_long(); factor(* c, *foo, *f,verbose,bnd); //Call NTL Factoring size=(*foo).length(); // how many factors have we found? for (i=0; i