15 #define mpz_isNeg(A) ((A)->_mp_size<0)
20 #include <sys/types.h>
37 if (
mpz_isNeg(n->z)) { *d+=8; mpz_neg(n->z,n->z); }
41 mpz_export(
s,&
l,-1,
sizeof(mp_limb_t),0,0,n->z);
43 s+=
l*
sizeof(mp_limb_t);
48 mpz_export(
s,&
l,-1,
sizeof(mp_limb_t),0,0,n->n);
50 s+=
l*
sizeof(mp_limb_t);
78 mpz_realloc2((*n)->z,
l*
sizeof(mp_limb_t)*8);
79 mpz_import((*n)->z,
l,-1,
sizeof(mp_limb_t),0,0,
s);
80 if (neg) mpz_neg((*n)->z,(*n)->z);
81 s+=
l*
sizeof(mp_limb_t);
87 mpz_init2((*n)->n,
l*
sizeof(mp_limb_t)*8);
88 mpz_import((*n)->n,
l,-1,
sizeof(mp_limb_t),0,0,
s);
89 s+=
l*
sizeof(mp_limb_t);
108 ll+=
l*
sizeof(mp_limb_t);
114 ll+=
l*
sizeof(mp_limb_t);
116 ll+=
l*
sizeof(mp_limb_t);
126 memcpy(
s,
m->exp,r->ExpL_Size*
sizeof(
long));
127 s+=r->ExpL_Size*
sizeof(long);
135 memcpy((*m)->exp,
s,r->ExpL_Size*
sizeof(
long));
136 s+=r->ExpL_Size*
sizeof(long);
143 ll+=r->ExpL_Size*
sizeof(long);
166 static char*
get_poly(
char *
s,
int &ind, poly *
p,
const ring r)
174 for(
long i=0;
i<
l;
i++)
187 long l=SIZEOF_LONG*2;
198 int cnt=0;
int rw=0;
int cl=0;
200 for(
int j=rl-1;
j>=0;
j--)
204 if (xx[
j]->
nrows >rw) rw=xx[
j]->nrows;
209 WerrorS(
"format mismatch in CRT");
213 if ((cpus==1) || (2*cpus>=cnt))
219 int parent_pid=getpid();
224 for(
int i=cnt-1;
i>=0;
i--)
228 for(
int i=cpus;
i>=0;
i--)
234 for (
int i=0;
i<cpus;
i++)
239 if (parent_pid!=getpid())
241 number *
x=(number *)
omAlloc(rl*
sizeof(number));
242 poly *
p=(poly *)
omAlloc(rl*
sizeof(poly));
248 int ind=queue->dequeue();
254 for(
int j=rl-1;
j>=0;
j--)
265 char *
s=(
char*)msg->str();
267 rqueue->enqueue(msg);
277 msg=rqueue->dequeue();
278 char *
s=(
char*)msg->str();
306 int parent_pid=getpid();
311 for(
int i=cnt-1;
i>=0;
i--)
315 for(
int i=cpus;
i>=0;
i--)
321 for (
int i=0;
i<cpus;
i++)
326 if (parent_pid!=getpid())
330 int ind=queue->dequeue();
339 char *
s=(
char*)msg->str();
341 rqueue->enqueue(msg);
351 msg=rqueue->dequeue();
352 char *
s=(
char*)msg->str();
374 printf(
"size: %d\n",ll);
376 printf(
"send len: %d\n",(
int)(
s-
buf));
378 for(
int i=0;
i<=ll/SIZEOF_LONG;
i++) printf(
"%ld ",d[
i]);
382 printf(
"read len: %d\n",(
int)(
s-
buf));
383 Print(
":index: %d\n",ll);
const CanonicalForm CFMap CFMap & N
const CanonicalForm int s
void WerrorS(const char *s)
static void * feOptValue(feOptIndex opt)
ideal id_Farey(ideal x, number N, const ring r)
static char * get_number(char *s, number *n)
static char * get_poly(char *s, int &ind, poly *p, const ring r)
static long size_poly(poly p, const ring r)
static char * send_poly(char *s, int ind, poly p, const ring r)
ideal id_Farey_0(ideal x, number N, const ring r)
static long size_number(number n)
static char * send_mon(char *s, poly m, const ring r)
ideal id_ChineseRemainder_0(ideal *xx, number *q, int rl, const ring r)
static char * send_number(char *s, number n)
static char * get_mon(char *s, poly *m, const ring r)
static long size_mon(poly m, const ring r)
poly p_ChineseRemainder(poly *xx, mpz_ptr *x, mpz_ptr *q, int rl, mpz_ptr *C, const ring R)
static void vmem_deinit()
static VRef< VString > vstring(const char *s)
static Status vmem_init()
poly p_Farey(poly p, number N, const ring r)
void p_Write(poly p, ring lmRing, ring tailRing)
static poly pReverse(poly p)
static unsigned pLength(poly a)
static poly p_Init(const ring r, omBin bin)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatiblity layer for legacy polynomial operations (over currRing)
int status int void * buf
ideal idInit(int idsize, int rank)
initialise an ideal / module
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)