/* File for generic tests.
Copyright (C) INRIA, 2008, 2009, 2010, 2011
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)))
/* functions with one input, one output */
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, MPC_PREC_RE (rop),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPC_PREC_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);
MPC_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);
MPC_OUT (rop);
printf ("%s quadruple precision gives ", function->name);
MPC_OUT (rop4);
printf ("and is rounded to ");
MPC_OUT (rop4rnd);
exit (1);
}
static void
tgeneric_cc_c (mpc_function *function, mpc_ptr op, mpc_ptr rop1, mpc_ptr rop2,
mpc_ptr rop14, mpc_ptr rop24, mpc_ptr rop14rnd, mpc_ptr rop24rnd,
mpc_rnd_t rnd1, mpc_rnd_t rnd2)
{
/* same as the previous function, but for mpc functions computing two
results from one argument */
known_signs_t ks = {1, 1};
function->pointer.CC_C (rop14, rop24, op, rnd1, rnd2);
function->pointer.CC_C (rop1, rop2, op, rnd1, rnd2);
if ( MPFR_CAN_ROUND (MPC_RE (rop14), 1, MPC_PREC_RE (rop1),
MPC_RND_RE (rnd1))
&& MPFR_CAN_ROUND (MPC_IM (rop14), 1, MPC_PREC_IM (rop1),
MPC_RND_IM (rnd1))
&& MPFR_CAN_ROUND (MPC_RE (rop24), 1, MPC_PREC_RE (rop2),
MPC_RND_RE (rnd2))
&& MPFR_CAN_ROUND (MPC_IM (rop24), 1, MPC_PREC_IM (rop2),
MPC_RND_IM (rnd2))) {
mpc_set (rop14rnd, rop14, rnd1);
mpc_set (rop24rnd, rop24, rnd2);
}
else
return;
if (!same_mpc_value (rop1, rop14rnd, ks)) {
/* rounding failed for first result */
printf ("Rounding might be incorrect for the first result of %s at\n", function->name);
MPC_OUT (op);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd1)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd1)));
printf ("\n%s gives ", function->name);
MPC_OUT (rop1);
printf ("%s quadruple precision gives ", function->name);
MPC_OUT (rop14);
printf ("and is rounded to ");
MPC_OUT (rop14rnd);
exit (1);
}
else if (!same_mpc_value (rop2, rop24rnd, ks)) {
/* rounding failed for second result */
printf ("Rounding might be incorrect for the second result of %s at\n", function->name);
MPC_OUT (op);
printf ("with rounding mode (%s, %s)",
mpfr_print_rnd_mode (MPC_RND_RE (rnd2)),
mpfr_print_rnd_mode (MPC_RND_IM (rnd2)));
printf ("\n%s gives ", function->name);
MPC_OUT (rop2);
printf ("%s quadruple precision gives ", function->name);
MPC_OUT (rop24);
printf ("and is rounded to ");
MPC_OUT (rop24rnd);
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_get_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);
MPC_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, MPC_PREC_RE (rop),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPC_PREC_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);
MPC_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);
MPC_OUT (rop);
printf ("%s quadruple precision gives ", function->name);
MPC_OUT (rop4);
printf ("and is rounded to ");
MPC_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, MPC_PREC_RE (rop),
MPC_RND_RE (rnd))
&& MPFR_CAN_ROUND (MPC_IM (rop4), 1, MPC_PREC_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);
MPC_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);
MPC_OUT (rop);
printf ("%s quadruple precision gives ", function->name);
MPC_OUT (rop4);
printf ("and is rounded to
没有合适的资源?快使用搜索试试~ 我知道了~
mpc-0.9.tar
4星 · 超过85%的资源 需积分: 33 95 下载量 26 浏览量
2012-08-10
20:02:38
上传
评论
收藏 553KB GZ 举报
温馨提示
共220个文件
c:140个
dat:37个
m4:8个
安装GCC需要用的编译软件,了空间撒反对了看见爱上水井坊大陆架卡萨东方丽景。
资源推荐
资源详情
资源评论
收起资源包目录
mpc-0.9.tar (220个子文件)
configure.ac 7KB
Makefile.am 1KB
Makefile.am 914B
Makefile.am 249B
Makefile.am 102B
AUTHORS 127B
tgeneric.c 40KB
read_data.c 27KB
pow.c 21KB
mul.c 17KB
sin_cos.c 15KB
div.c 14KB
tset.c 13KB
atan.c 12KB
sqrt.c 11KB
tan.c 9KB
sqr.c 8KB
asin.c 8KB
acos.c 8KB
ttan.c 7KB
tmul.c 6KB
tio_str.c 6KB
tsqr.c 6KB
exp.c 6KB
inp_str.c 6KB
pow_ui.c 5KB
fma.c 5KB
log.c 5KB
memory.c 5KB
get_str.c 5KB
random.c 5KB
tstrtoc.c 4KB
logging.c 4KB
tcosh.c 4KB
tpow_ui.c 4KB
tdiv.c 3KB
norm.c 3KB
set_x.c 3KB
tpow_si.c 3KB
tui_div.c 3KB
tmul_i.c 3KB
mul_i.c 2KB
acosh.c 2KB
set_x_x.c 2KB
strtoc.c 2KB
tcos.c 2KB
tprec.c 2KB
tadd_fr.c 2KB
tget_version.c 2KB
tadd_si.c 2KB
tadd.c 2KB
tanh.c 2KB
sinh.c 2KB
asinh.c 2KB
comparisons.c 2KB
tadd_ui.c 2KB
pow_z.c 2KB
atanh.c 2KB
tpow_d.c 1KB
mem.c 1KB
mul_fr.c 1KB
tatanh.c 1KB
tacosh.c 1KB
tasinh.c 1KB
out_str.c 1KB
treimref.c 1KB
get.c 1KB
proj.c 1KB
div_fr.c 1KB
ui_ui_sub.c 1KB
fr_sub.c 1KB
pow_ld.c 1KB
pow_d.c 1KB
fr_div.c 1KB
sub_fr.c 1KB
pow_fr.c 1KB
set_str.c 1KB
tpow_fr.c 1KB
sub_ui.c 1KB
add_ui.c 1KB
add_fr.c 1KB
add.c 1KB
tpow_z.c 1KB
ui_div.c 1KB
mul_ui.c 1KB
div_ui.c 1KB
add_si.c 1KB
tpow_ld.c 1KB
mul_si.c 1KB
mul_2exp.c 1KB
div_2exp.c 1KB
cosh.c 1KB
cmp_si_si.c 1KB
sub.c 1KB
set.c 1KB
conj.c 1KB
uceil_log2.c 1KB
neg.c 1KB
pow_si.c 1KB
cmp.c 1KB
共 220 条
- 1
- 2
- 3
yang0826
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页