version 1.33, 2005/03/03 07:25:17 |
version 1.37, 2014/04/07 04:00:10 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.32 2005/03/03 06:38:15 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.36 2013/10/20 15:29:12 iwane Exp $ */ |
|
|
/* |
/* |
This module includes functions for sending/receiveng CMO's. |
This module includes functions for sending/receiveng CMO's. |
Line 210 static cmo_zz* receive_cmo_zz(OXFILE *oxfp) |
|
Line 210 static cmo_zz* receive_cmo_zz(OXFILE *oxfp) |
|
|
|
static cmo_qq* receive_cmo_qq(OXFILE *oxfp) |
static cmo_qq* receive_cmo_qq(OXFILE *oxfp) |
{ |
{ |
cmo_qq* c = new_cmo_qq_noinit(); |
mpz_t num, den; |
c->num = receive_cmo(oxfp); |
mpz_init(num); |
c->den = receive_cmo(oxfp); |
mpz_init(den); |
return c; |
receive_mpz(oxfp, num); |
|
receive_mpz(oxfp, den); |
|
return new_cmo_qq_set_mpz(num, den); |
} |
} |
|
|
static cmo_zero* receive_cmo_zero(OXFILE *oxfp) |
static cmo_zero* receive_cmo_zero(OXFILE *oxfp) |
Line 385 cmo *receive_cmo_tag(OXFILE *oxfp, int tag) |
|
Line 387 cmo *receive_cmo_tag(OXFILE *oxfp, int tag) |
|
static void receive_mpz(OXFILE *oxfp, mpz_ptr mpz) |
static void receive_mpz(OXFILE *oxfp, mpz_ptr mpz) |
{ |
{ |
int i; |
int i; |
|
int n = sizeof(mpz->_mp_d[0]) / sizeof(int); |
int size = receive_int32(oxfp); |
int size = receive_int32(oxfp); |
int len = abs(size); |
int len = abs(size); |
resize_mpz(mpz, size); |
int *ptr; |
|
if (n == 1) { |
|
resize_mpz(mpz, size); |
|
} else if (size >= 0) { |
|
resize_mpz(mpz, (size+1) / n); |
|
} else { |
|
resize_mpz(mpz, (size-1) / n); |
|
} |
|
|
|
ptr = (int *)mpz->_mp_d; |
for(i=0; i<len; i++) { |
for(i=0; i<len; i++) { |
mpz->_mp_d[i] = receive_int32(oxfp); |
ptr[i] = receive_int32(oxfp); |
} |
} |
} |
} |
|
|
Line 605 static int send_cmo_zz(OXFILE *oxfp, cmo_zz* c) |
|
Line 616 static int send_cmo_zz(OXFILE *oxfp, cmo_zz* c) |
|
|
|
static int send_cmo_qq(OXFILE *oxfp, cmo_qq* c) |
static int send_cmo_qq(OXFILE *oxfp, cmo_qq* c) |
{ |
{ |
send_cmo(oxfp, c->num); |
send_mpz(oxfp, mpq_numref(c->mpq)); |
send_cmo(oxfp, c->den); |
send_mpz(oxfp, mpq_denref(c->mpq)); |
return 0; |
return 0; |
} |
} |
|
|
Line 703 void send_cmo(OXFILE *oxfp, cmo* c) |
|
Line 714 void send_cmo(OXFILE *oxfp, cmo* c) |
|
static int send_mpz(OXFILE *oxfp, mpz_ptr mpz) |
static int send_mpz(OXFILE *oxfp, mpz_ptr mpz) |
{ |
{ |
int i; |
int i; |
int len = abs(mpz->_mp_size); |
int n = sizeof(mpz->_mp_d[0]) / sizeof(int); |
send_int32(oxfp, mpz->_mp_size); |
int len = abs(mpz->_mp_size) * n; |
|
int *ptr = (int *)mpz->_mp_d; |
|
int size; |
|
send_int32(oxfp, mpz->_mp_size * n); |
|
if (len > 0 && ptr[len-1] == 0) { |
|
len--; |
|
} |
|
size = mpz->_mp_size < 0 ? -len : len; |
|
send_int32(oxfp, size); |
for(i=0; i<len; i++) { |
for(i=0; i<len; i++) { |
send_int32(oxfp, mpz->_mp_d[i]); |
send_int32(oxfp, ptr[i]); |
} |
} |
return 0; |
return 0; |
} |
} |