3 Star 0 Fork 1

Gitee 极速下载/isl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://repo.or.cz/isl.git
克隆/下载
isl_val_imath.c 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
#include <isl_val_private.h>
/* Return a reference to an isl_val representing the unsigned
* integer value stored in the "n" chunks of size "size" at "chunks".
* The least significant chunk is assumed to be stored first.
*/
__isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx, size_t n,
size_t size, const void *chunks)
{
isl_val *v;
v = isl_val_alloc(ctx);
if (!v)
return NULL;
impz_import(v->n, n, -1, size, 0, 0, chunks);
isl_int_set_si(v->d, 1);
return v;
}
/* Store a representation of the absolute value of the numerator of "v"
* in terms of chunks of size "size" at "chunks".
* The least significant chunk is stored first.
* The number of chunks in the result can be obtained by calling
* isl_val_n_abs_num_chunks. The user is responsible for allocating
* enough memory to store the results.
*
* In the special case of a zero value, isl_val_n_abs_num_chunks will
* return one, while impz_export will not fill in any chunks. We therefore
* do it ourselves.
*/
isl_stat isl_val_get_abs_num_chunks(__isl_keep isl_val *v, size_t size,
void *chunks)
{
if (!v || !chunks)
return isl_stat_error;
if (!isl_val_is_rat(v))
isl_die(isl_val_get_ctx(v), isl_error_invalid,
"expecting rational value", return isl_stat_error);
impz_export(chunks, NULL, -1, size, 0, 0, v->n);
if (isl_val_is_zero(v))
memset(chunks, 0, size);
return isl_stat_ok;
}
/* Return the number of chunks of size "size" required to
* store the absolute value of the numerator of "v".
*/
isl_size isl_val_n_abs_num_chunks(__isl_keep isl_val *v, size_t size)
{
if (!v)
return isl_size_error;
if (!isl_val_is_rat(v))
isl_die(isl_val_get_ctx(v), isl_error_invalid,
"expecting rational value", return isl_size_error);
size *= 8;
return (impz_sizeinbase(v->n, 2) + size - 1) / size;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/mirrors/isl.git
git@gitee.com:mirrors/isl.git
mirrors
isl
isl
master

搜索帮助