version 1.2, 2003/11/15 09:06:20 |
version 1.6, 2013/10/18 01:28:52 |
|
|
/* $OpenXM: OpenXM/src/ox_ntl/ntlconv.cpp,v 1.1 2003/11/08 12:34:00 iwane Exp $ */ |
/* $OpenXM: OpenXM/src/ox_ntl/ntlconv.cpp,v 1.5 2003/11/27 14:19:50 iwane Exp $ */ |
|
|
#include <NTL/ZZX.h> |
#include <NTL/ZZX.h> |
#include <NTL/mat_ZZ.h> |
#include <NTL/mat_ZZ.h> |
|
|
#include <strstream> |
#include <sstream> |
|
#include <string> |
|
#include <string.h> |
|
|
#include "ntl.h" |
#include "ntl.h" |
|
|
|
|
#define __NTL_PRINT (1) |
#define __NTL_PRINT (1) |
#endif |
#endif |
|
|
|
/*==========================================================================* |
|
* Block interrupt input |
|
*==========================================================================*/ |
#define BLOCK_NEW_CMO() BLOCK_INPUT() |
#define BLOCK_NEW_CMO() BLOCK_INPUT() |
#define UNBLOCK_NEW_CMO() UNBLOCK_INPUT() |
#define UNBLOCK_NEW_CMO() UNBLOCK_INPUT() |
|
|
|
|
ZZ_to_cmo_zz(const ZZ &z) |
ZZ_to_cmo_zz(const ZZ &z) |
{ |
{ |
cmo_zz *c; |
cmo_zz *c; |
|
const char *ptr; |
|
|
ostrstream sout; |
std::ostringstream sout; |
sout << z << '\0'; |
sout << z << '\0'; |
|
std::string tmp = sout.str(); |
|
ptr = tmp.c_str(); |
|
|
BLOCK_NEW_CMO(); |
BLOCK_NEW_CMO(); |
c = new_cmo_zz_set_string(sout.str()); |
c = new_cmo_zz_set_string((char*)ptr); |
UNBLOCK_NEW_CMO(); |
UNBLOCK_NEW_CMO(); |
|
|
return (c); |
return (c); |
} |
} |
|
|
|
|
mat_zz_to_cmo(mat_ZZ &mat) |
mat_zz_to_cmo(mat_ZZ &mat) |
{ |
{ |
cmo_list *list; |
cmo_list *list; |
int ret; |
|
|
|
cmo_zz *zz; |
cmo_zz *zz; |
int row, col; |
int row, col; |
Line 308 cmo_to_mat_zz(mat_ZZ &mat, cmo *m) |
|
Line 315 cmo_to_mat_zz(mat_ZZ &mat, cmo *m) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************** |
/**************************************************************************** |
* convert cmo to ZZX which is polynomial in Z[x] |
* convert cmo to ZZX which is polynomial in Z[x] |
* |
* |
Line 339 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
Line 340 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
return (NTL_FAILURE); |
return (NTL_FAILURE); |
} |
} |
{ |
{ |
istrstream sin(str, strlen(str)); |
std::istringstream sin(str); |
sin >> f; |
sin >> f; |
} |
} |
break; |
break; |
Line 348 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
Line 349 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
cmo_recursive_polynomial *rec = (cmo_recursive_polynomial *)m; |
cmo_recursive_polynomial *rec = (cmo_recursive_polynomial *)m; |
cmo_polynomial_in_one_variable *poly = (cmo_polynomial_in_one_variable *)rec->coef; |
cmo_polynomial_in_one_variable *poly = (cmo_polynomial_in_one_variable *)rec->coef; |
cell *el; |
cell *el; |
int len; |
|
|
|
if (poly->tag != CMO_POLYNOMIAL_IN_ONE_VARIABLE) { |
if (poly->tag != CMO_POLYNOMIAL_IN_ONE_VARIABLE) { |
return (NTL_FAILURE); |
return (NTL_FAILURE); |
} |
} |
|
|
el = list_first((cmo_list *)poly); |
el = list_first((cmo_list *)poly); |
len = list_length((cmo_list *)poly); |
|
|
|
f = 0; |
f = 0; |
|
|
Line 386 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
Line 385 cmo_to_ZZX(ZZX &f, cmo *m, cmo_indeterminate *&x) |
|
return (NTL_SUCCESS); |
return (NTL_SUCCESS); |
} |
} |
|
|
|
|
|
|
/**************************************************************************** |
/**************************************************************************** |
* convert polynomial in Z[x] to cmo_recursive_polynomial |
* convert polynomial in Z[x] to cmo_recursive_polynomial |
* |
* |
Line 493 vec_pair_ZZX_long_to_cmo(vec_pair_ZZX_long &factors, c |
|
Line 494 vec_pair_ZZX_long_to_cmo(vec_pair_ZZX_long &factors, c |
|
cmo * |
cmo * |
convert_cmon(cmo *p) |
convert_cmon(cmo *p) |
{ |
{ |
|
|
switch (p->tag) { |
switch (p->tag) { |
case CMON_ZZ: |
case CMON_ZZ: |
{ |
{ |