[81ef98]: inst / test_hyperg.m  Maximize  Restore  History

Download this file

153 lines (138 with data), 4.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
## Copyright (C) 2008 Raymond E. Rogers
##
## 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 3 of the License, or
## 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, see .
#
#
# Testing initialization/header for special functions
# Octave format
# It is intended to read test_hyperg.c from the GNU GSL hyperg test file
# and use the test lines. If you don't want to duplicate thier
# errors, comment out the bad tests with //
# Compare test_hyperg.c vs. test_hyperg_corr.c
#
# R. Rogers v1, testing only hyperg_1F1 and hyperg_U in double
# KummerM and KummerU
# Some array verification is done; since I messed it up once.
global GSL_DBL_EPSILON= 2.2204460492503131e-16
global GSL_SQRT_DBL_EPSILON= 1.4901161193847656e-08
global TEST_TOL0= (2.0*GSL_DBL_EPSILON)
global TEST_TOL1= (16.0*GSL_DBL_EPSILON)
global TEST_TOL2= (256.0*GSL_DBL_EPSILON)
global TEST_TOL3= (2048.0*GSL_DBL_EPSILON)
global TEST_TOL4= (16384.0*GSL_DBL_EPSILON)
global TEST_TOL5= (131072.0*GSL_DBL_EPSILON)
global TEST_TOL6= (1048576.0*GSL_DBL_EPSILON)
global TEST_SQRT_TOL0= (2.0*GSL_SQRT_DBL_EPSILON)
global TEST_SNGL= (1.0e-06)
global TEST_SF_INCONS= 1
global TEST_SF_ERRNEG= 2
global TEST_SF_TOLBAD= 4
global TEST_SF_RETBAD= 8
global TEST_SF_ERRBAD= 16
global TEST_SF_ERRBIG= 32
global TEST_SF_EXPBAD= 64
global TEST_FACTOR= 100
function res=READ_TEST_SF_hyperg_Kummer(input_name)
global GSL_DBL_EPSILON
global GSL_SQRT_DBL_EPSILON
global TEST_TOL0
global TEST_TOL1
global TEST_TOL2
global TEST_TOL3
global TEST_TOL4
global TEST_TOL5
global TEST_TOL6
global TEST_SQRT_TOL0
global TEST_SNGL
global TEST_SF_INCONS
global TEST_SF_ERRNEG
global TEST_SF_TOLBAD
global TEST_SF_RETBAD
global TEST_SF_ERRBAD
global TEST_SF_ERRBIG
global TEST_SF_EXPBAD
global TEST_FACTOR
[source_id,source_msg]=fopen(input_name,"r","native")
while (! feof(source_id))
do
input_line=fgetl(source_id);
until( index(input_line,"//") == 0);
str_p=index(input_line,"hyperg_1F1_e");
if (str_p != 0)
# Take it apart
string_split=split(input_line,",");
arg1=str2double(substr(string_split(3,:),3));
arg2=str2double(string_split(4,:));
arg3=str2double(string_split(5,:));
val=str2double(string_split(7,:));
tol=eval(string_split(8,:));
[ret,err]=hyperg_1F1(arg1,arg2,arg3);
# This is to prevent extanious stops on some errors
if ret==NaN
ret=Inf
endif
if (abs((ret-val)/val)<tol*TEST_FACTOR)
printf("\n Passed KummerM: %e %e %e ",arg1,arg2,arg3)
else
printf("\n Failed KummerM: %s\n value=%e, computed=%e, tol=%e, returned error=%e ",input_line,val,ret,tol,err)
printf("\n error %e", abs((ret-val)/val))
endif
endif
str_p=index(input_line,"hyperg_U_e");
if (str_p != 0)
# Take it apart
string_split=split(input_line,",");
arg1=str2double(substr(string_split(3,:),3));
arg2=str2double(string_split(4,:));
arg3=str2double(string_split(5,:));
val=str2double(string_split(7,:));
tol=eval(string_split(8,:));
[ret,err]=hyperg_U(arg1,arg2,arg3);
# This is to prevent extanious stops on some errors
if ret==NaN
ret=Inf
endif
if (abs((ret-val)/val)<tol*TEST_FACTOR)
printf("\n Passed KummerU: %e %e %e ",arg1,arg2,arg3)
else
printf("\n Failed KummerU: %s\n value=%e, computed=%e, tol=%e, returned error=%e ",input_line,val,ret,tol,err)
printf("\n error %e", abs((ret-val)/val))
endif
endif
endwhile
fclose(source_id);
#lets do some array tests
disp("\n array tests")
mat1=[1,2]
disp("\n hyperg_1F1(1,1,mat1)")
hyperg_1F1(1,1,mat1)
disp("\n hyperg_1F1(1,mat1,1) ")
hyperg_1F1(1,mat1,1)
disp("\n hyperg_1F1(mat1,1,1)")
hyperg_1F1(mat1,1,1)
disp("\n hyperg_1F1(mat1,mat1,mat1) ")
hyperg_1F1(mat1,mat1,mat1)
disp("\n hyperg_U(1,1,mat1)")
hyperg_U(1,1,mat1)
disp("\n hyperg_U(1,mat1,1)")
hyperg_U(1,mat1,1)
disp("\n hyperg_U(mat1,1,1)")
hyperg_U(mat1,1,1)
disp("\n hyperg_U(mat1,mat1,mat1)")
hyperg_U(mat1,mat1,mat1)
res="";
end
#file_name=input("file name: ","s")
file_name="test_hyperg_corr.c"
READ_TEST_SF_hyperg_Kummer(file_name);

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks