=================================================================== RCS file: /home/cvs/OpenXM/src/ox_ntl/ntl.cpp,v retrieving revision 1.4 retrieving revision 1.7 diff -u -p -r1.4 -r1.7 --- OpenXM/src/ox_ntl/ntl.cpp 2003/11/17 12:04:20 1.4 +++ OpenXM/src/ox_ntl/ntl.cpp 2013/10/18 01:28:52 1.7 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/ox_ntl/ntl.cpp,v 1.3 2003/11/15 09:06:20 iwane Exp $ */ +/* $OpenXM: OpenXM/src/ox_ntl/ntl.cpp,v 1.6 2008/09/19 10:55:40 iwane Exp $ */ #include #include @@ -24,26 +24,34 @@ : [2,[[x-1,1],[x^4+x^3+x^2+x+1,1],[x+1,2],[x^2-x+1,2]]] * ****************************************************************************/ -cmo * -ntl_fctr(cmo **arg, int argc) +oxstack_node * +ntl_fctr(oxstack_node **arg, int argc) { - cmo *poly = arg[0]; + oxstack_node *p = arg[0]; + cmo *poly = p->c; cmo_indeterminate *x; + cmo *err; ZZX f; int ret; + char emss[25] = "Invalid Parameter(#)"; + char emst[25] = "Invalid Parameter(type)"; if (argc != 1) { - return ((cmo *)new_cmo_error2((cmo *)new_cmo_string("Invalid Parameter(#)"))); + err = ((cmo *)new_cmo_error2((cmo *)new_cmo_string(emss))); + p = oxstack_node_init(err); + return (p); } ret = cmo_to_ZZX(f, poly, x); if (ret != NTL_SUCCESS) { /* format error */ - return ((cmo *)new_cmo_error2((cmo *)new_cmo_string("Invalid Parameter(type)"))); + err = (cmo *)new_cmo_error2((cmo *)new_cmo_string(emst)); + p = oxstack_node_init(err); + return (p); } #if __NTL_PRINT - cout << "input: " << f << endl; + std::cout << "input: " << f << std::endl; #endif cmon_factors_t *factors = new_cmon_factors(); @@ -52,11 +60,13 @@ ntl_fctr(cmo **arg, int argc) factor(*factors->cont, *factors->f, f); #if __NTL_PRINT - cout << "fctr : " << *factors->f << endl; + std::cout << "fctr : " << *factors->f << std::endl; #endif + p = oxstack_node_init(NULL); + p->p = factors; - return ((cmo *)factors); + return (p); } /**************************************************************************** @@ -71,39 +81,48 @@ ntl_fctr(cmo **arg, int argc) : [2,[[x-1,1],[x^4+x^3+x^2+x+1,1],[x+1,2],[x^2-x+1,2]]] * ****************************************************************************/ -cmo * -ntl_lll(cmo **arg, int argc) +oxstack_node * +ntl_lll(oxstack_node **arg, int argc) { - cmo *poly = arg[0]; - cmo_indeterminate *x; + oxstack_node *p = arg[0]; + cmo *err; ZZX f; int ret; cmon_mat_zz_t *mat; + char emss[25] = "Invalid Parameter(#)"; + char emst[25] = "Invalid Parameter(type)"; if (argc != 1) { - return ((cmo *)new_cmo_error2((cmo *)new_cmo_string("Invalid Parameter(#)"))); + err = ((cmo *)new_cmo_error2((cmo *)new_cmo_string(emss))); + p = oxstack_node_init(err); + return (p); } mat = new_cmon_mat_zz(); - ret = cmo_to_mat_zz(*mat->mat, arg[0]); + ret = cmo_to_mat_zz(*mat->mat, p->c); if (ret != NTL_SUCCESS) { delete_cmon_mat_zz(mat); /* format error */ - return ((cmo *)new_cmo_error2((cmo *)new_cmo_string("Invalid Parameter(type)"))); + err = ((cmo *)new_cmo_error2((cmo *)new_cmo_string(emst))); + p = oxstack_node_init(err); + return (p); } #if __NTL_PRINT - cout << "input: " << (*mat->mat) << endl; + std::cout << "input: " << (*mat->mat) << std::endl; #endif ZZ det2; - long rd = LLL(det2, *mat->mat); + mat_ZZ U; #if __NTL_PRINT - cout << "output: " << (*mat->mat) << endl; + std::cout << "output: " << (*mat->mat) << std::endl; + std::cout << U <p = mat; + return (p); } @@ -112,8 +131,6 @@ ntl_lll(cmo **arg, int argc) #include #include -#include -#include "gmp.h" void ntl_free(void *ptr, size_t size) {} @@ -148,27 +165,36 @@ main(int argc, char *argv[]) #endif { - cmo_zz *n; - istrstream istr("[3 -3 -6]"); ZZ cont; ZZX fac; vec_pair_ZZX_long facs; - cmo_indeterminate *x = new_cmo_indeterminate((cmo *)new_cmo_string("x")); - istr >> fac; +// char xx[2] = "x"; +// cmo_indeterminate *x = new_cmo_indeterminate((cmo *)new_cmo_string(xx)); +// std::istringstream istr("[3 -3 -6]"); +// istr >> fac; + + SetCoeff(fac, 0, 3); + SetCoeff(fac, 1, -3); + SetCoeff(fac, 2, -6); + + factor(cont, facs, fac); // mpz_clear(ppp->mpz); +} + +if (0) { mp_set_memory_functions(GC_malloc, ntl_realloc, ntl_free); for (int i = 0;; i++) { - cmon_factors_t *mat = new_cmon_factors(cont, facs, x); - cmo *aaa = convert_cmon((cmo *)mat); - delete_cmon((cmo *)mat); +// cmon_factors_t *mat = new_cmon_factors(cont, facs, x); +// cmo *aaa = convert_cmon((cmo *)mat); +// delete_cmon((cmo *)mat); if (i % 1000 == 0) { - printf("GC-counts: %d, size: %u\n", GC_gc_no, GC_get_heap_size()); + printf("GC-counts: %lu, size: %u\n", GC_gc_no, GC_get_heap_size()); GC_gcollect(); usleep(1); }