/* specfunc/test_sf.c
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Gerard Jungman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Author: G. Jungman */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_ieee_utils.h>
#include <gsl/gsl_test.h>
#include <gsl/gsl_sf.h>
#include "test_sf.h"
double
test_sf_frac_diff(double x1, double x2)
{
if(x1 == 0.0 && x2 == 0.0) {
return 0.0;
}
else if(x1 <= DBL_MAX && x2 <= DBL_MAX && (x1 + x2 != 0.0)) {
return fabs((x1-x2)/(x1+x2));
}
else {
return 1.0;
}
}
/* Check a result against a given value and tolerance.
*/
int
test_sf_check_result(char * message_buff, gsl_sf_result r, double val, double tol)
{
int s = 0;
double f = test_sf_frac_diff(val, r.val);
if(fabs(val - r.val) > 2.0*r.err) s |= TEST_SF_INCONS;
if(r.err < 0.0) s |= TEST_SF_ERRNEG;
if(f > tol) s |= TEST_SF_TOLBAD;
if(s != 0) {
char buff[2048];
sprintf(buff, " expected: %20.16g\n", val);
strcat(message_buff, buff);
sprintf(buff, " obtained: %20.16g %20.16g %g\n", r.val, r.err, r.err/(fabs(r.val) + r.err));
strcat(message_buff, buff);
sprintf(buff, " fracdiff: %20.16g\n", f);
strcat(message_buff, buff);
}
if(s & TEST_SF_INCONS) {
strcat(message_buff, " value/expected not consistent within reported error\n");
}
if(s & TEST_SF_ERRNEG) {
strcat(message_buff, " reported error negative\n");
}
if(s & TEST_SF_TOLBAD) {
strcat(message_buff, " value not within tolerance of expected value\n");
}
return s;
}
int
test_sf_check_val(char * message_buff, double rval, double val, double tol)
{
int s = 0;
double f = test_sf_frac_diff(val, rval);
if(f > tol) s |= TEST_SF_TOLBAD;
if(s != 0) {
char buff[2048];
sprintf(buff, " expected: %20.16g\n", val);
strcat(message_buff, buff);
sprintf(buff, " obtained: %20.16g\n", rval);
strcat(message_buff, buff);
sprintf(buff, " fracdiff: %20.16g\n", f);
strcat(message_buff, buff);
}
if(s & TEST_SF_TOLBAD) {
strcat(message_buff, " value not within tolerance of expected value\n");
}
return s;
}
/* Relax the condition on the agreement and on the usefulness
* of the error estimate.
*/
int
test_sf_check_result_relax(char * message_buff, gsl_sf_result r, double val, double tol)
{
int s = 0;
double f = test_sf_frac_diff(val, r.val);
if(f > GSL_MAX_DBL(TEST_SNGL,tol)) s |= TEST_SF_INCONS;
if(r.err < 0.0) s |= TEST_SF_ERRNEG;
if(f > tol) s |= TEST_SF_TOLBAD;
if(s != 0) {
char buff[2048];
sprintf(buff, " expected: %20.16g\n", val);
strcat(message_buff, buff);
sprintf(buff, " obtained: %20.16g %20.16g %g\n", r.val, r.err, r.err/(fabs(r.val) + r.err));
strcat(message_buff, buff);
sprintf(buff, " fracdiff: %20.16g\n", f);
strcat(message_buff, buff);
}
if(s & TEST_SF_INCONS) {
strcat(message_buff, " value/expected not consistent MAX(tol,SINGLE_PREC)\n");
}
if(s & TEST_SF_ERRNEG) {
strcat(message_buff, " reported error negative\n");
}
if(s & TEST_SF_TOLBAD) {
strcat(message_buff, " value not within tolerance of expected value\n");
}
return s;
}
/* Check a return value.
*/
int
test_sf_check_return(char * message_buff, int val_return, int expected_return)
{
if(val_return != expected_return) {
char buff[256];
sprintf(buff, " unexpected return code: %d\n", val_return);
strcat(message_buff, buff);
return TEST_SF_RETBAD;
}
else {
return 0;
}
}
int
test_sf (gsl_sf_result r, double val_in, double tol, int status,
int expect_return, const char * desc)
{
char message_buff[4096];
int local_s = 0;
message_buff[0] = '\0';
local_s |= test_sf_check_result(message_buff, r, val_in, tol);
local_s |= test_sf_check_return(message_buff, status, expect_return);
gsl_test(local_s, desc);
if(local_s != 0) {
/* printf(" %s %d\n", __FILE__, __LINE__); */
printf("%s", message_buff);
printf(" %22.18g %22.18g\n", r.val, r.err);
}
return local_s;
}
int
test_sf_val (double val, double val_in, double tol, const char * desc)
{
char message_buff[4096];
int local_s = 0;
message_buff[0] = '\0';
local_s |= test_sf_check_val(message_buff, val, val_in, tol);
gsl_test(local_s, desc);
if(local_s != 0) {
/* printf(" %s %d\n", __FILE__, __LINE__); */
printf("%s", message_buff);
printf(" %22.18g\n", val);
}
return local_s;
}
int
test_sf_rlx (gsl_sf_result r, double val_in, double tol, int status,
int expect_return, const char * desc)
{
char message_buff[4096];
int local_s = 0;
message_buff[0] = '\0';
local_s |= test_sf_check_result_relax(message_buff, r, val_in, tol);
local_s |= test_sf_check_return(message_buff, status, expect_return);
gsl_test(local_s, desc);
if(local_s != 0) {
/* printf(" %s %d\n", __FILE__, __LINE__); */
printf("%s", message_buff);
printf(" %22.18g %22.18g\n", r.val, r.err);
}
return local_s;
}
int
test_sf_2 (gsl_sf_result r1, double val1, double tol1,
gsl_sf_result r2, double val2, double tol2,
int status, int expect_return, const char * desc)
{
char message_buff[4096];
int local_s = 0;
message_buff[0] = '\0';
local_s |= test_sf_check_result(message_buff, r1, val1, tol1);
local_s |= test_sf_check_result(message_buff, r2, val2, tol2);
local_s |= test_sf_check_return(message_buff, status, expect_return);
gsl_test(local_s, desc);
if(local_s != 0) {
/* printf(" %s %d\n", __FILE__, __LINE__); */
printf("%s", message_buff);
printf(" %22.18g %22.18g\n", r1.val, r1.err);
printf(" %22.18g %22.18g\n", r2.val, r2.err);
}
return local_s;
}
int
test_sf_sgn (gsl_sf_result r, double sgn, double val_in, double tol, double expect_sgn, int status,
int expect_return, const char * desc)
{
char message_buff[4096];
gsl_sf_result local_r;
int local_s = 0;
message_buff[0] = '\0';
local_r.val = sgn;
local_r.err = 0.0;
local_s |= test_sf_check_result(message_buff, r, val_in, tol);
local_s |= test_sf_check_result(message_buff, local_r, expect_sgn, 0.0);
local_s |= test_sf_check_return(message_buff, status, expect_return);
gsl_test(local_s, desc);
if(local_s != 0) {
/* printf(" %s %d\n", __FILE__, __LINE__); */
printf("%s", message_buff);
printf(" %22.18g %22.18g\n", r.val, r.err);
}
return local_s;
}
int test_clausen(void)
{
gsl_sf_result r;
int s = 0;
TEST_SF(s, gsl_sf_clausen_e, (M_PI/20.0, &r), 0.4478882448133546, TEST_TOL0, GSL_SUCCESS);
TEST_SF(s, gsl_sf_clausen_e, (M_PI/6.0, &r), 0.8643791310538927, TEST_TOL0, GSL_SUCCESS);
TEST_SF(s, gsl_sf_clausen_e, (M_PI/3.0, &r), 1.0149416064096535, TEST_TOL0, GSL_SUCCESS);
TEST_SF(s, gsl_sf_clausen_e, ( 2.0*M_PI + M_PI/3.0, &r), 1.0149416064096535, TEST_TOL0, GSL_SUCCESS);
TEST_SF(s, gsl_sf_clausen_e, (100.0*M_PI + M_PI/3.0, &r), 1.0149416064096535, TEST_TOL0, GSL_SUCCESS);
return s;
}
int test_coupling(void)
{
gsl_sf_result r;
int s = 0;
TEST_SF(s, gsl_sf_coupling_3j_e, (0, 1, 1, 0, 1, -1, &r), sqrt(1.0/2.0), TEST_TOL0, GSL_SUCCESS);
没有合适的资源?快使用搜索试试~ 我知道了~
specfunc_C++特殊函数
共131个文件
c:83个
h:43个
todo:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 9 浏览量
2022-09-19
12:30:48
上传
评论
收藏 374KB ZIP 举报
温馨提示
多个常用的特殊函数的例子
资源推荐
资源详情
资源评论
收起资源包目录
specfunc_C++特殊函数 (131个子文件)
Makefile.am 2KB
test_sf.c 86KB
gamma.c 58KB
hyperg_1F1.c 57KB
hyperg_U.c 43KB
legendre_con.c 42KB
test_hyperg.c 38KB
coulomb.c 38KB
test_bessel.c 37KB
test_legendre.c 34KB
fermi_dirac.c 34KB
bessel_olver.c 31KB
bessel_zero.c 28KB
hyperg_2F1.c 26KB
bessel.c 26KB
zeta.c 24KB
airy_der.c 23KB
airy.c 23KB
legendre_poly.c 20KB
trig.c 19KB
psi.c 18KB
legendre_H3d.c 17KB
test_gamma.c 17KB
exp.c 15KB
ellint.c 15KB
test_coulomb.c 15KB
gamma_inc.c 14KB
dilog.c 14KB
coupling.c 14KB
airy_zero.c 13KB
poch.c 13KB
expint.c 13KB
transport.c 12KB
erfc.c 11KB
bessel_j.c 10KB
sinint.c 10KB
legendre_Qn.c 9KB
dawson.c 9KB
debye.c 9KB
laguerre.c 9KB
test_airy.c 9KB
hyperg.c 8KB
bessel_i.c 8KB
bessel_y.c 7KB
log.c 7KB
synchrotron.c 7KB
bessel_Kn.c 6KB
bessel_I1.c 6KB
bessel_In.c 6KB
bessel_temme.c 6KB
bessel_k.c 6KB
lambert.c 6KB
bessel_I0.c 6KB
bessel_K1.c 6KB
bessel_K0.c 5KB
bessel_Yn.c 5KB
test_dilog.c 5KB
beta_inc.c 5KB
hyperg_0F1.c 5KB
gegenbauer.c 5KB
bessel_Jnu.c 5KB
bessel_Jn.c 5KB
bessel_Knu.c 5KB
bessel_amp_phase.c 5KB
bessel_sequence.c 4KB
bessel_Y1.c 4KB
beta.c 4KB
shint.c 4KB
coulomb_bound.c 4KB
bessel_J1.c 3KB
bessel_Y0.c 3KB
expint3.c 3KB
bessel_Ynu.c 3KB
bessel_Inu.c 3KB
bessel_J0.c 3KB
atanint.c 3KB
elljac.c 3KB
clausen.c 3KB
elementary.c 2KB
result.c 2KB
pow_int.c 2KB
hyperg_2F0.c 2KB
cheb_eval_mode.c 680B
cheb_eval.c 656B
ChangeLog 10KB
gsl_sf_bessel.h 14KB
gsl_sf_legendre.h 8KB
recurse.h 8KB
gsl_sf_gamma.h 7KB
gsl_sf_hyperg.h 4KB
gsl_sf_exp.h 4KB
gsl_sf_coulomb.h 4KB
gsl_sf_coupling.h 4KB
gsl_sf_trig.h 4KB
gsl_sf_ellint.h 4KB
test_sf.h 4KB
gsl_sf_expint.h 4KB
gsl_sf_airy.h 4KB
gsl_sf_fermi_dirac.h 3KB
bessel.h 3KB
共 131 条
- 1
- 2
资源评论
weixin_42651887
- 粉丝: 76
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功