version 1.3, 2003/11/16 13:48:08 |
version 1.6, 2013/10/18 01:28:52 |
|
|
/* $OpenXM: OpenXM/src/ox_ntl/ntlconv.cpp,v 1.2 2003/11/15 09:06:20 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" |
|
|
|
|
ZZ_to_cmo_zz(const ZZ &z) |
ZZ_to_cmo_zz(const ZZ &z) |
{ |
{ |
cmo_zz *c; |
cmo_zz *c; |
char *ptr; |
const char *ptr; |
|
|
ostrstream sout; |
std::ostringstream sout; |
sout << z << '\0'; |
sout << z << '\0'; |
ptr = sout.str(); |
std::string tmp = sout.str(); |
|
ptr = tmp.c_str(); |
|
|
BLOCK_NEW_CMO(); |
BLOCK_NEW_CMO(); |
c = new_cmo_zz_set_string(ptr); |
c = new_cmo_zz_set_string((char*)ptr); |
UNBLOCK_NEW_CMO(); |
UNBLOCK_NEW_CMO(); |
|
|
delete [] ptr; |
|
|
|
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 315 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 346 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 355 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 393 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 500 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: |
{ |
{ |