move versin() and coversin() code

Moved versin() and coversin() to bottom of functions in func.c
(however the builtin function list remains sorted).

Created a historical trig functions section for cmath.h and qmath.h.

Moved cal/test3500.cal to cal/test9300.cal to make room
for future trip tests going from test 3427 thru 3599.
This commit is contained in:
Landon Curt Noll
2023-09-01 23:53:30 -07:00
parent 7398fbb2e9
commit 20ce75a06d
6 changed files with 137 additions and 119 deletions

View File

@@ -120,7 +120,7 @@ V=@:
# #
# Please use: # Please use:
# #
# make calc_files_list # make clobber >/dev/null && make calc_files_list
# #
# to keep this list in nice sorted order. # to keep this list in nice sorted order.
# #
@@ -137,10 +137,10 @@ CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
smallfactors.cal solve.cal specialfunctions.cal splitbits.cal \ smallfactors.cal solve.cal specialfunctions.cal splitbits.cal \
statistics.cal strings.cal sumsq.cal sumtimes.cal surd.cal \ statistics.cal strings.cal sumsq.cal sumtimes.cal surd.cal \
test1700.cal test2300.cal test2600.cal test2700.cal test3100.cal \ test1700.cal test2300.cal test2600.cal test2700.cal test3100.cal \
test3300.cal test3400.cal test3500.cal test4000.cal test4100.cal \ test3300.cal test3400.cal test4000.cal test4100.cal test4600.cal \
test4600.cal test5100.cal test5200.cal test8400.cal test8500.cal \ test5100.cal test5200.cal test8400.cal test8500.cal test8600.cal \
test8600.cal test8900.cal toomcook.cal unitfrac.cal varargs.cal \ test8900.cal test9300.cal toomcook.cal unitfrac.cal varargs.cal \
xx_print.cal zeta2.cal w2f.cal xx_print.cal zeta2.cal
# These calc files are now obsolete and are removed by the install rule. # These calc files are now obsolete and are removed by the install rule.
# #

View File

@@ -3566,17 +3566,20 @@ print '051: parsed test_trig()';
/* /*
* test_frem - tests of the functions frem, fcnt, gcdrem * test_frem - tests of the functions frem, fcnt, gcdrem
*
* NOTE: We haved test3500 to test9300. We parse this code here,
* however we execute this code as a 9300 test.
*/ */
read -once "test3500"; read -once "test9300";
print '052: read -once test3500'; print '052: read -once test9300';
/**/ /**/
define test_frem() define test_frem()
{ {
local tnum; /* test number */ local tnum; /* test number */
print '3500: Beginning test_frem'; print '9300: Beginning test_frem';
tnum = test3500(1, 3501, 200, 61); tnum = test9300(1, 9301, 200, 61);
print tnum: ': Ending test_frem'; print tnum: ': Ending test_frem';
} }
@@ -8085,8 +8088,6 @@ return test_det();
print; print;
return test_trig(); return test_trig();
print; print;
return test_frem();
print;
return test_error(); return test_error();
print; print;
return test_param(); return test_param();
@@ -8867,6 +8868,15 @@ print '9100: parsed test_functions3()';
print; print;
return test_functions3(); return test_functions3();
/*
* test_frem - tests of the functions frem, fcnt, gcdrem
*
* NOTE: We haved test3500 to test9300. We parse this code here,
* however we execute this code as a 9300 test.
*/
print;
return test_frem();
/* /*
* read various calc resource files * read various calc resource files

View File

@@ -1,7 +1,7 @@
/* /*
* test3500 - 3500 series of the regress.cal test suite * test9300 - 9300 series of the regress.cal test suite
* *
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll * Copyright (C) 1999,2023 Ernest Bowen and Landon Curt Noll
* *
* Primary author: Ernest Bowen * Primary author: Ernest Bowen
* *
@@ -255,16 +255,16 @@ define testh(str,n,N,verbose)
} }
/* /*
* test3500 - perform all of the above tests a bunch of times * test9300 - perform all of the above tests a bunch of times
*/ */
define test3500(verbose, tnum, n, N) define test9300(verbose, tnum, n, N)
{ {
/* set test parameters */ /* set test parameters */
if (isnull(verbose)) { if (isnull(verbose)) {
verbose = defaultverbose; verbose = defaultverbose;
} }
if (isnull(tnum)) { if (isnull(tnum)) {
tnum = 3501; /* default test number */ tnum = 9301; /* default test number */
} }
if (isnull(n)) { if (isnull(n)) {
n = 200; n = 200;
@@ -276,7 +276,7 @@ define test3500(verbose, tnum, n, N)
/* /*
* test a lot of stuff * test a lot of stuff
*/ */
srand(3500e3500); srand(9300e9300);
err += testf(strcat(str(tnum++), ": frem/fcnt"), n, verbose); err += testf(strcat(str(tnum++), ": frem/fcnt"), n, verbose);
err += testg(strcat(str(tnum++), ": gcdrem"), n, verbose); err += testg(strcat(str(tnum++), ": gcdrem"), n, verbose);
err += testh(strcat(str(tnum++),": gcdrem #2"), n, N, verbose); err += testh(strcat(str(tnum++),": gcdrem #2"), n, N, verbose);

View File

@@ -118,6 +118,10 @@ E_FUNC COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);
/*
* historical trig functions
*/
E_FUNC COMPLEX *c_versin(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_versin(COMPLEX *c, NUMBER *epsilon);
E_FUNC COMPLEX *c_coversin(COMPLEX *c, NUMBER *epsilon); E_FUNC COMPLEX *c_coversin(COMPLEX *c, NUMBER *epsilon);

204
func.c
View File

@@ -3486,108 +3486,6 @@ f_csch(int count, VALUE **vals)
} }
S_FUNC VALUE
f_versin(int count, VALUE **vals)
{
VALUE result;
COMPLEX *c;
NUMBER *eps;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/*
* set error tolerance for builtin function
*
* Use eps VALUE arg if given and value is in a valid range.
*/
eps = conf->epsilon;
if (count == 2) {
if (verify_eps(vals[1]) == false) {
return error_value(E_VERSIN1);
}
eps = vals[1]->v_num;
}
/*
* compute sine to a given error tolerance
*/
switch (vals[0]->v_type) {
case V_NUM:
result.v_num = qversin(vals[0]->v_num, eps);
result.v_type = V_NUM;
break;
case V_COM:
c = c_versin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_VERSIN3);
}
result.v_com = c;
result.v_type = V_COM;
if (cisreal(c)) {
result.v_num = qlink(c->real);
result.v_type = V_NUM;
comfree(c);
}
break;
default:
return error_value(E_VERSIN2);
}
return result;
}
S_FUNC VALUE
f_coversin(int count, VALUE **vals)
{
VALUE result;
COMPLEX *c;
NUMBER *eps;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/*
* set error tolerance for builtin function
*
* Use eps VALUE arg if given and value is in a valid range.
*/
eps = conf->epsilon;
if (count == 2) {
if (verify_eps(vals[1]) == false) {
return error_value(E_COVERSIN1);
}
eps = vals[1]->v_num;
}
/*
* compute cosinr to a given error tolerance
*/
switch (vals[0]->v_type) {
case V_NUM:
result.v_num = qcoversin(vals[0]->v_num, eps);
result.v_type = V_NUM;
break;
case V_COM:
c = c_coversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_COVERSIN3);
}
result.v_com = c;
result.v_type = V_COM;
if (cisreal(c)) {
result.v_num = qlink(c->real);
result.v_type = V_NUM;
comfree(c);
}
break;
default:
return error_value(E_COVERSIN2);
}
return result;
}
S_FUNC VALUE S_FUNC VALUE
f_atan(int count, VALUE **vals) f_atan(int count, VALUE **vals)
{ {
@@ -10716,6 +10614,108 @@ f_version(void)
} }
S_FUNC VALUE
f_versin(int count, VALUE **vals)
{
VALUE result;
COMPLEX *c;
NUMBER *eps;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/*
* set error tolerance for builtin function
*
* Use eps VALUE arg if given and value is in a valid range.
*/
eps = conf->epsilon;
if (count == 2) {
if (verify_eps(vals[1]) == false) {
return error_value(E_VERSIN1);
}
eps = vals[1]->v_num;
}
/*
* compute sine to a given error tolerance
*/
switch (vals[0]->v_type) {
case V_NUM:
result.v_num = qversin(vals[0]->v_num, eps);
result.v_type = V_NUM;
break;
case V_COM:
c = c_versin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_VERSIN3);
}
result.v_com = c;
result.v_type = V_COM;
if (cisreal(c)) {
result.v_num = qlink(c->real);
result.v_type = V_NUM;
comfree(c);
}
break;
default:
return error_value(E_VERSIN2);
}
return result;
}
S_FUNC VALUE
f_coversin(int count, VALUE **vals)
{
VALUE result;
COMPLEX *c;
NUMBER *eps;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
/*
* set error tolerance for builtin function
*
* Use eps VALUE arg if given and value is in a valid range.
*/
eps = conf->epsilon;
if (count == 2) {
if (verify_eps(vals[1]) == false) {
return error_value(E_COVERSIN1);
}
eps = vals[1]->v_num;
}
/*
* compute cosinr to a given error tolerance
*/
switch (vals[0]->v_type) {
case V_NUM:
result.v_num = qcoversin(vals[0]->v_num, eps);
result.v_type = V_NUM;
break;
case V_COM:
c = c_coversin(vals[0]->v_com, eps);
if (c == NULL) {
return error_value(E_COVERSIN3);
}
result.v_com = c;
result.v_type = V_COM;
if (cisreal(c)) {
result.v_num = qlink(c->real);
result.v_type = V_NUM;
comfree(c);
}
break;
default:
return error_value(E_COVERSIN2);
}
return result;
}
#endif /* !FUNCLIST */ #endif /* !FUNCLIST */

View File

@@ -222,6 +222,10 @@ E_FUNC NUMBER *qbern(ZVALUE z);
E_FUNC void qfreebern(void); E_FUNC void qfreebern(void);
E_FUNC NUMBER *qeuler(ZVALUE z); E_FUNC NUMBER *qeuler(ZVALUE z);
E_FUNC void qfreeeuler(void); E_FUNC void qfreeeuler(void);
/*
* historical trig functions
*/
E_FUNC NUMBER *qversin(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qversin(NUMBER *q, NUMBER *epsilon);
E_FUNC NUMBER *qcoversin(NUMBER *q, NUMBER *epsilon); E_FUNC NUMBER *qcoversin(NUMBER *q, NUMBER *epsilon);