/* File for generic tests.
Copyright (C) 2008, 2009 Philippe Th\'eveny, Andreas Enge, Paul Zimmermann
This file is part of the MPC Library.
The MPC Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The MPC Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the MPC Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/* #include <stdlib.h> */
#include "mpc-tests.h"
/* Warning: unlike the MPFR macro (defined in mpfr-impl.h), this one returns
true when b is singular */
#define MPFR_CAN_ROUND(b,err,prec,rnd) \
(mpfr_zero_p (b) || mpfr_inf_p (b) \
|| mpfr_can_round (b, (long)mpfr_get_prec (b) - (err), (rnd), \
GMP_RNDZ, (prec) + ((rnd)==GMP_RNDN)))
static void
tgeneric_cc (mpc_function *function, mpc_ptr op, mpc_ptr rop,
mpc_ptr rop4, mpc_ptr rop4rnd, mpc_rnd_t rnd)
{
known_signs_t ks = {1, 1};
/* We compute the result with four times the precision and check whether the
rounding is correct. Error reports in this part of the algorithm might
still be wrong, though, since there are two consecutive roundings (but we
try to avoid them). */
function->pointer.CC (rop4, op, rnd);
function->pointer.CC (rop, op, rnd);
/* can't use the mpfr_can_round function when argument is singular,
use a custom macro instead. */
if (MPFR_CAN_ROUND (MPC_RE (rop4), 1, MPFR_PREC (MPC_RE (rop)),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPFR_PREC (MPC_IM (rop)),
MPC_RND_IM (rnd)))
mpc_set (rop4rnd, rop4, rnd);
else
/* avoid double rounding error */
return;
if (same_mpc_value (rop, rop4rnd, ks))
return;
/* rounding failed */
printf ("Rounding in %s might be incorrect for\n", function->name);
OUT (op);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd)));
printf ("\n%s gives ", function->name);
OUT (rop);
printf ("%s quadruple precision gives ", function->name);
OUT (rop4);
printf ("and is rounded to ");
OUT (rop4rnd);
exit (1);
}
static void
tgeneric_fc (mpc_function *function, mpc_ptr op, mpfr_ptr rop,
mpfr_ptr rop4, mpfr_ptr rop4rnd, mpfr_rnd_t rnd)
{
function->pointer.FC (rop4, op, rnd);
function->pointer.FC (rop, op, rnd);
if (MPFR_CAN_ROUND (rop4, 1, MPFR_PREC (rop), rnd))
mpfr_set (rop4rnd, rop4, rnd);
else
return;
if (same_mpfr_value (rop, rop4rnd, 1))
return;
printf ("Rounding in %s might be incorrect for\n", function->name);
OUT (op);
printf ("with rounding mode %s", mpfr_print_rnd_mode (rnd));
printf ("\n%s gives ", function->name);
MPFR_OUT (rop);
printf ("%s quadruple precision gives ", function->name);
MPFR_OUT (rop4);
printf ("and is rounded to ");
MPFR_OUT (rop4rnd);
exit (1);
}
static void
tgeneric_cfc (mpc_function *function, mpfr_ptr op1, mpc_ptr op2,
mpc_ptr rop, mpc_ptr rop4, mpc_ptr rop4rnd, mpc_rnd_t rnd)
{
known_signs_t ks = {1, 1};
function->pointer.CFC (rop4, op1, op2, rnd);
function->pointer.CFC (rop, op1, op2, rnd);
if (MPFR_CAN_ROUND (MPC_RE (rop4), 1, MPFR_PREC (MPC_RE (rop)),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPFR_PREC (MPC_IM (rop)),
MPC_RND_IM (rnd)))
mpc_set (rop4rnd, rop4, rnd);
else
return;
if (same_mpc_value (rop, rop4rnd, ks))
return;
printf ("Rounding in %s might be incorrect for\n", function->name);
MPFR_OUT (op1);
OUT (op2);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd)));
printf ("\n%s gives ", function->name);
OUT (rop);
printf ("%s quadruple precision gives ", function->name);
OUT (rop4);
printf ("and is rounded to ");
OUT (rop4rnd);
exit (1);
}
static void
tgeneric_ccf (mpc_function *function, mpc_ptr op1, mpfr_ptr op2,
mpc_ptr rop, mpc_ptr rop4, mpc_ptr rop4rnd, mpc_rnd_t rnd)
{
known_signs_t ks = {1, 1};
function->pointer.CCF (rop4, op1, op2, rnd);
function->pointer.CCF (rop, op1, op2, rnd);
if (MPFR_CAN_ROUND (MPC_RE (rop4), 1, MPFR_PREC (MPC_RE (rop)),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPFR_PREC (MPC_IM (rop)),
MPC_RND_IM (rnd)))
mpc_set (rop4rnd, rop4, rnd);
else
return;
if (same_mpc_value (rop, rop4rnd, ks))
return;
printf ("Rounding in %s might be incorrect for\n", function->name);
OUT (op1);
MPFR_OUT (op2);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd)));
printf ("\n%s gives ", function->name);
OUT (rop);
printf ("%s quadruple precision gives ", function->name);
OUT (rop4);
printf ("and is rounded to ");
OUT (rop4rnd);
exit (1);
}
static void
tgeneric_ccc (mpc_function *function, mpc_ptr op1, mpc_ptr op2,
mpc_ptr rop, mpc_ptr rop4, mpc_ptr rop4rnd, mpc_rnd_t rnd)
{
known_signs_t ks = {1, 1};
/* We compute the result with four times the precision and check whether the
rounding is correct. Error reports in this part of the algorithm might
still be wrong, though, since there are two consecutive roundings (but we
try to avoid them). */
function->pointer.CCC (rop4, op1, op2, rnd);
function->pointer.CCC (rop, op1, op2, rnd);
/* can't use mpfr_can_round when argument is singular */
if (MPFR_CAN_ROUND (MPC_RE (rop4), 1, MPFR_PREC (MPC_RE (rop)),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPFR_PREC (MPC_IM (rop)),
MPC_RND_IM (rnd)))
mpc_set (rop4rnd, rop4, rnd);
else
/* avoid double rounding error */
return;
if (same_mpc_value (rop, rop4rnd, ks))
return;
/* rounding failed */
printf ("Rounding in %s might be incorrect for\n", function->name);
OUT (op1);
OUT (op2);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd)));
printf ("\n%s gives ", function->name);
OUT (rop);
printf ("%s quadruple precision gives ", function->name);
OUT (rop4);
printf ("and is rounded to ");
OUT (rop4rnd);
exit (1);
}
static void
tgeneric_ccu (mpc_function *function, mpc_ptr op1, unsigned long int op2,
mpc_ptr rop, mpc_ptr rop4, mpc_ptr rop4rnd, mpc_rnd_t rnd)
{
known_signs_t ks = {1, 1};
function->pointer.CCU (rop4, op1, op2, rnd);
function->pointer.CCU (rop, op1, op2, rnd);
if (MPFR_CAN_ROUND (MPC_RE (rop4), 1, MPFR_PREC (MPC_RE (rop)),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPFR_PREC (MPC_IM (rop)),
MPC_RND_IM (rnd)))
mpc_set (rop4rnd, rop4, rnd);
else
return;
if (same_mpc_value (rop, rop4rnd, ks))
return;
printf ("Rounding in %s might be incorrect for\n", function->name);
OUT (op1);
printf ("op2=%lu\n", op2);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd)),
没有合适的资源?快使用搜索试试~ 我知道了~
mpc-0.8.1.tar.gz
5星 · 超过95%的资源 需积分: 46 312 下载量 20 浏览量
2011-12-10
22:08:29
上传
评论 1
收藏 532KB GZ 举报
温馨提示
共205个文件
c:134个
dat:35个
in:5个
mpc-0.8.1.tar.gz 用于linux gcc 升级
资源推荐
资源详情
资源评论
收起资源包目录
mpc-0.8.1.tar.gz (205个子文件)
configure.ac 5KB
Makefile.am 1KB
Makefile.am 864B
Makefile.am 168B
Makefile.am 102B
AUTHORS 200B
tgeneric.c 30KB
pow.c 24KB
read_data.c 21KB
mul.c 16KB
div.c 14KB
tset.c 12KB
atan.c 12KB
sqr.c 9KB
tan.c 8KB
tsqr.c 8KB
asin.c 8KB
acos.c 8KB
sqrt.c 7KB
ttan.c 7KB
cos.c 7KB
tmul.c 7KB
tio_str.c 6KB
exp.c 6KB
inp_str.c 6KB
sin.c 5KB
log.c 5KB
memory.c 5KB
get_str.c 5KB
random.c 4KB
tstrtoc.c 4KB
tcosh.c 4KB
tdiv.c 3KB
tui_div.c 3KB
norm.c 3KB
tmul_i.c 3KB
set_x.c 3KB
mul_i.c 3KB
set_x_x.c 2KB
acosh.c 2KB
strtoc.c 2KB
tcos.c 2KB
tprec.c 2KB
tadd_fr.c 2KB
sinh.c 2KB
tanh.c 2KB
asinh.c 2KB
tadd.c 2KB
comparisons.c 2KB
tget_version.c 2KB
tadd_ui.c 2KB
atanh.c 2KB
tpow_d.c 2KB
mem.c 1KB
mul_fr.c 1KB
tatanh.c 1KB
tacosh.c 1KB
tasinh.c 1KB
out_str.c 1KB
treimref.c 1KB
proj.c 1KB
div_fr.c 1KB
fr_div.c 1KB
fr_sub.c 1KB
pow_ld.c 1KB
ui_ui_sub.c 1KB
pow_d.c 1KB
add_ui.c 1KB
sub_ui.c 1KB
add_fr.c 1KB
sub_fr.c 1KB
set_str.c 1KB
add.c 1KB
pow_fr.c 1KB
tpow_fr.c 1KB
ui_div.c 1KB
mul_ui.c 1KB
div_ui.c 1KB
pow_ui.c 1KB
tpow_z.c 1KB
pow_z.c 1KB
mul_2exp.c 1KB
div_2exp.c 1KB
pow_si.c 1KB
sub.c 1KB
mul_si.c 1KB
cosh.c 1KB
cmp_si_si.c 1KB
set.c 1KB
tpow_ld.c 1KB
conj.c 1KB
tpow_ui.c 1KB
tpow_si.c 1KB
uceil_log2.c 1KB
neg.c 1KB
cmp.c 1KB
abs.c 1KB
urandom.c 1KB
get_prec2.c 1KB
get_prec.c 1KB
共 205 条
- 1
- 2
- 3
cxl13699995604
- 粉丝: 2
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 我分享个魔兽内存修改器
- Python毕业设计基于Django的网易云数据分析可视化大屏系统的设计与实现+使用说明+全部资料(优秀项目).zip
- Python毕业设计基于Django的网易云数据分析可视化大屏系统的设计与实现+使用说明+全部资料(高分项目).zip
- JavaScript实现的鼠标手势
- 人工兔优化算法ARO MATLAB源码, 应用案例为函数极值求解以及优化svm进行分类,代码注释详细,可结合自身需求进行应用
- 人才网站设计-asp.net+sql-(系统源码)
- asp.net+sql人才网站设计-含系统源码
- C#应用的用户配置窗体方案
- python实现绘制爱心图形的代码
- JAVAWEB项目-校园订餐系统项目源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页