| version 1.6, 2008/09/19 10:55:40 |
version 1.7, 2013/10/18 01:28:52 |
|
|
| /* $OpenXM: OpenXM/src/ox_ntl/ntl.cpp,v 1.5 2004/07/04 02:31:51 iwane Exp $ */ |
/* $OpenXM: OpenXM/src/ox_ntl/ntl.cpp,v 1.6 2008/09/19 10:55:40 iwane Exp $ */ |
| |
|
| #include <NTL/ZZXFactoring.h> |
#include <NTL/ZZXFactoring.h> |
| #include <NTL/LLL.h> |
#include <NTL/LLL.h> |
| Line 33 ntl_fctr(oxstack_node **arg, int argc) |
|
| Line 33 ntl_fctr(oxstack_node **arg, int argc) |
|
| cmo *err; |
cmo *err; |
| ZZX f; |
ZZX f; |
| int ret; |
int ret; |
| |
char emss[25] = "Invalid Parameter(#)"; |
| |
char emst[25] = "Invalid Parameter(type)"; |
| |
|
| if (argc != 1) { |
if (argc != 1) { |
| err = ((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); |
p = oxstack_node_init(err); |
| return (p); |
return (p); |
| } |
} |
| Line 43 ntl_fctr(oxstack_node **arg, int argc) |
|
| Line 45 ntl_fctr(oxstack_node **arg, int argc) |
|
| ret = cmo_to_ZZX(f, poly, x); |
ret = cmo_to_ZZX(f, poly, x); |
| if (ret != NTL_SUCCESS) { |
if (ret != NTL_SUCCESS) { |
| /* format error */ |
/* format error */ |
| err = (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); |
p = oxstack_node_init(err); |
| return (p); |
return (p); |
| } |
} |
| |
|
| #if __NTL_PRINT |
#if __NTL_PRINT |
| cout << "input: " << f << endl; |
std::cout << "input: " << f << std::endl; |
| #endif |
#endif |
| |
|
| cmon_factors_t *factors = new_cmon_factors(); |
cmon_factors_t *factors = new_cmon_factors(); |
| Line 58 ntl_fctr(oxstack_node **arg, int argc) |
|
| Line 60 ntl_fctr(oxstack_node **arg, int argc) |
|
| factor(*factors->cont, *factors->f, f); |
factor(*factors->cont, *factors->f, f); |
| |
|
| #if __NTL_PRINT |
#if __NTL_PRINT |
| cout << "fctr : " << *factors->f << endl; |
std::cout << "fctr : " << *factors->f << std::endl; |
| #endif |
#endif |
| |
|
| p = oxstack_node_init(NULL); |
p = oxstack_node_init(NULL); |
| Line 87 ntl_lll(oxstack_node **arg, int argc) |
|
| Line 89 ntl_lll(oxstack_node **arg, int argc) |
|
| ZZX f; |
ZZX f; |
| int ret; |
int ret; |
| cmon_mat_zz_t *mat; |
cmon_mat_zz_t *mat; |
| |
char emss[25] = "Invalid Parameter(#)"; |
| |
char emst[25] = "Invalid Parameter(type)"; |
| |
|
| if (argc != 1) { |
if (argc != 1) { |
| err = ((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); |
p = oxstack_node_init(err); |
| return (p); |
return (p); |
| } |
} |
| Line 99 ntl_lll(oxstack_node **arg, int argc) |
|
| Line 103 ntl_lll(oxstack_node **arg, int argc) |
|
| if (ret != NTL_SUCCESS) { |
if (ret != NTL_SUCCESS) { |
| delete_cmon_mat_zz(mat); |
delete_cmon_mat_zz(mat); |
| /* format error */ |
/* format error */ |
| err = ((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); |
p = oxstack_node_init(err); |
| return (p); |
return (p); |
| } |
} |
| |
|
| #if __NTL_PRINT |
#if __NTL_PRINT |
| cout << "input: " << (*mat->mat) << endl; |
std::cout << "input: " << (*mat->mat) << std::endl; |
| #endif |
#endif |
| |
|
| ZZ det2; |
ZZ det2; |
| mat_ZZ U; |
mat_ZZ U; |
| |
|
| #if __NTL_PRINT |
#if __NTL_PRINT |
| cout << "output: " << (*mat->mat) << endl; |
std::cout << "output: " << (*mat->mat) << std::endl; |
| cout << U << endl; |
std::cout << U <<std:: endl; |
| #endif |
#endif |
| |
|
| p = oxstack_node_init(NULL); |
p = oxstack_node_init(NULL); |
| Line 127 ntl_lll(oxstack_node **arg, int argc) |
|
| Line 131 ntl_lll(oxstack_node **arg, int argc) |
|
| |
|
| #include <unistd.h> |
#include <unistd.h> |
| #include <gc/gc.h> |
#include <gc/gc.h> |
| #include <strstream> |
|
| #include "gmp.h" |
|
| |
|
| void ntl_free(void *ptr, size_t size) {} |
void ntl_free(void *ptr, size_t size) {} |
| |
|
| Line 163 main(int argc, char *argv[]) |
|
| Line 165 main(int argc, char *argv[]) |
|
| #endif |
#endif |
| |
|
| { |
{ |
| cmo_zz *n; |
|
| |
|
| istrstream istr("[3 -3 -6]"); |
|
| ZZ cont; |
ZZ cont; |
| ZZX fac; |
ZZX fac; |
| vec_pair_ZZX_long facs; |
vec_pair_ZZX_long facs; |
| cmo_indeterminate *x = new_cmo_indeterminate((cmo *)new_cmo_string("x")); |
// char xx[2] = "x"; |
| istr >> fac; |
// 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); |
factor(cont, facs, fac); |
| |
|
| // mpz_clear(ppp->mpz); |
// mpz_clear(ppp->mpz); |
| |
} |
| |
|
| |
if (0) { |
| mp_set_memory_functions(GC_malloc, ntl_realloc, ntl_free); |
mp_set_memory_functions(GC_malloc, ntl_realloc, ntl_free); |
| for (int i = 0;; i++) { |
for (int i = 0;; i++) { |
| |
|
| cmon_factors_t *mat = new_cmon_factors(cont, facs, x); |
// cmon_factors_t *mat = new_cmon_factors(cont, facs, x); |
| cmo *aaa = convert_cmon((cmo *)mat); |
// cmo *aaa = convert_cmon((cmo *)mat); |
| delete_cmon((cmo *)mat); |
// delete_cmon((cmo *)mat); |
| |
|
| if (i % 1000 == 0) { |
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(); |
GC_gcollect(); |
| usleep(1); |
usleep(1); |
| } |
} |