- 注册时间
- 2010-10-22
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 2292
- 在线时间
- 小时
|
发表于 2011-2-24 16:37:47
|
显示全部楼层
7# 没——问题
从gmp.h的代码片段- #ifdef __GMP_SHORT_LIMB
- typedef unsigned int mp_limb_t;
- typedef int mp_limb_signed_t;
- #else
- #ifdef _LONG_LONG_LIMB
- typedef unsigned long long int mp_limb_t;
- typedef long long int mp_limb_signed_t;
- #else
- typedef unsigned long int mp_limb_t;
- typedef long int mp_limb_signed_t;
- #endif
- #endif
- typedef unsigned long int mp_bitcnt_t;
-
- /* For reference, note that the name __mpz_struct gets into C++ mangled
- function names, which means although the "__" suggests an internal, we
- must leave this name for binary compatibility. */
- typedef struct
- {
- int _mp_alloc; /* Number of *limbs* allocated and pointed
- to by the _mp_d field. */
- int _mp_size; /* abs(_mp_size) is the number of limbs the
- last field points to. If _mp_size is
- negative this is a negative number. */
- mp_limb_t *_mp_d; /* Pointer to the limbs. */
- } __mpz_struct;
-
- #endif /* __GNU_MP__ */
-
-
- typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */
- typedef __mpz_struct mpz_t[1];
复制代码 可以看出定义: mpz_t a,b,c;
就是定义结构体类型的指针变量。
内存管理通过三个函数malloc(), realloc(),free()
__mpz_struct结构体中,_mp_d为数据块指针,_mp_alloc为分配的数据块大小,_mp_size为实际有效数据大小和正负空信息。
init(); 根据_mp_alloc大小(初始化为1)通过malloc()分配空间,并赋块指针给_mp_d,并置_mp_size=0
mpn为通用模块(给mpz,mpf,mpq调用),mpz为整形大数模块,mpf为浮点大数模块,mpq为有理大数模块。 |
|