mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
add half trigonometric functions
Fixed SEE ALSO typo in help randperm. Added the following new trigonometric functions: haversin(x [,eps]) half versed trigonometric sine hacoversin(x [,eps]) half coversed trigonometric sine havercos(x [,eps]) half versed trigonometric cosine hacovercos(x [,eps]) half coversed trigonometric cosine ahaversin(x [,eps]) inverse half versed trigonometric sine ahacoversin(x [,eps]) inverse half coversed trigonometric sine ahavercos(x [,eps]) inverse half versed trigonometric cosine ahacovercos(x [,eps]) inverse half coversed trigonometric cosine Fixed calc regression test 42dd to set the display value back to 20. Added test 95dd and test9500.trigeq.cal to the calc regression test suite to perform extensive test of trigonometric functions. Fix and improve recently comments and variable names added new trigonometric functions in comfunc.c, func.c, qtrans.c.
This commit is contained in:
50
CHANGES
50
CHANGES
@@ -99,15 +99,6 @@ The following are the changes from calc version 2.14.3.5 to date:
|
||||
Document in help files for builtin functions that take eps arguments,
|
||||
the LIMIT range for such eps values.
|
||||
|
||||
Added new versin(x, [,eps]) for versed sine and coversin(x, [,eps])
|
||||
for inverse versed sine.
|
||||
|
||||
Added new aversin(x, [,eps]) for inverse versed sine and acoversin(x, [,eps])
|
||||
for inverse coversed sine.
|
||||
|
||||
Improved trig function help files to reference use of complex arguments
|
||||
that while supported were not documented.
|
||||
|
||||
Removed old Makefile testing rules for make dbx and make gdb.
|
||||
|
||||
Improved "make run" to execute calccalc using shared libraries
|
||||
@@ -176,14 +167,15 @@ The following are the changes from calc version 2.14.3.5 to date:
|
||||
number generator in place of the additive 55 generator for a
|
||||
while now.
|
||||
|
||||
Improved help files for sin, cos, tan, cot, sec, csc. In case
|
||||
of tan, cot, sec, csc corrected help file was corrected to
|
||||
indicate that complex arguments are allowed. This was a help
|
||||
file oversight from long ago when those trigonometric functions
|
||||
were expanded to include complex arguments.
|
||||
Improved help files trigonometric functions. They were corrected
|
||||
to indicate that complex arguments are allowed: an oversight
|
||||
from long ago when those trigonometric functions were expanded
|
||||
to include complex arguments. The EXAMPLE sections were expanded
|
||||
and made consistent, where applicable, across the trigonometric
|
||||
help files. Documented libcalc functions in the SEE ALSO sections.
|
||||
|
||||
Expanded the calc regression test suite test 34dd to test various
|
||||
real and complex values for sin, cos, tan, cot, sec, csc.
|
||||
real and complex values for trigonometric functions.
|
||||
|
||||
Added complex multiple approximation function to commath.c so
|
||||
that users of libcalc may directly round complex number to
|
||||
@@ -338,10 +330,36 @@ The following are the changes from calc version 2.14.3.5 to date:
|
||||
verify that the errnum calc computation error codes and their
|
||||
E_STRING values have not changed.
|
||||
|
||||
Improve the ciarify of calc regression suite (regress.cal) to mostly
|
||||
Improve the clarity of calc regression suite (regress.cal) to mostly
|
||||
use E_STRING errsym instead of numeric errnum values for error()
|
||||
and errno() related tests.
|
||||
|
||||
Fixed SEE ALSO typo in help randperm.
|
||||
|
||||
Added the following new trigonometric functions:
|
||||
|
||||
versin(x [,eps]) versed trigonometric sine
|
||||
coversin(x [,eps]) coversed trigonometric sine
|
||||
vercos(x [,eps]) versed trigonometric cosine
|
||||
covercos(x [,eps]) coversed trigonometric cosine
|
||||
aversin(x [,eps]) inverse versed trigonometric sine
|
||||
acoversin(x [,eps]) inverse coversed trigonometric sine
|
||||
avercos(x [,eps]) inverse versed trigonometric cosine
|
||||
acovercos(x [,eps]) inverse coversed trigonometric cosine
|
||||
haversin(x [,eps]) half versed trigonometric sine
|
||||
hacoversin(x [,eps]) half coversed trigonometric sine
|
||||
havercos(x [,eps]) half versed trigonometric cosine
|
||||
hacovercos(x [,eps]) half coversed trigonometric cosine
|
||||
ahaversin(x [,eps]) inverse half versed trigonometric sine
|
||||
ahacoversin(x [,eps]) inverse half coversed trigonometric sine
|
||||
ahavercos(x [,eps]) inverse half versed trigonometric cosine
|
||||
ahacovercos(x [,eps]) inverse half coversed trigonometric cosine
|
||||
|
||||
Fixed calc regression test 42dd to set the display value back to 20.
|
||||
|
||||
Added test 95dd and test9500.trigeq.cal to the calc regression test
|
||||
suite to perform extensive test of trigonometric functions.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.14.3.4 to 2.14.3.5:
|
||||
|
||||
|
2
Makefile
2
Makefile
@@ -3103,7 +3103,7 @@ testfuncsort: ./calc${EXT}
|
||||
@${RM} -f func.show func.sort
|
||||
@${CALC_ENV} ./calc${EXT} -d -u show builtin | grep '^[A-Za-z0-9]' > func.show
|
||||
@${CALC_ENV} ./calc${EXT} -d -u show builtin | grep '^[A-Za-z0-9]' | LANG=C LC_ALL=C ${SORT} -d -u > func.sort
|
||||
@-if ! cmp -s func.show func.sort; then \
|
||||
@if ! cmp -s func.show func.sort; then \
|
||||
echo 1>&2; \
|
||||
echo "ERROR: builtins[] arrray in func.c is not in dictionary sorted order" 1>&2; \
|
||||
echo 1>&2; \
|
||||
|
@@ -141,8 +141,9 @@ CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
|
||||
test4100.redc.cal test4600.fileop.cal test5100.newdecl.cal \
|
||||
test5200.globstat.cal test8000.read.cal test8400.quit.cal \
|
||||
test8500.divmod.cal test8600.maxargs.cal test8700.dotest.cal \
|
||||
test8900.special.cal test9300.frem.cal toomcook.cal unitfrac.cal \
|
||||
varargs.cal write2file.cal xx_print.cal zeta2.cal
|
||||
test8900.special.cal test9300.frem.cal test9500.trigeq.cal \
|
||||
toomcook.cal unitfrac.cal varargs.cal write2file.cal xx_print.cal \
|
||||
zeta2.cal
|
||||
|
||||
# These calc files are now obsolete and are removed by the install rule.
|
||||
#
|
||||
|
148
cal/regress.cal
148
cal/regress.cal
@@ -89,7 +89,7 @@ define vrfy(test, str)
|
||||
++prob;
|
||||
}
|
||||
if (test != 1) {
|
||||
print '**** Non-true result (' : test : '): ' : str;
|
||||
print '**** Non-true result:', str;
|
||||
++prob;
|
||||
} else {
|
||||
print str;
|
||||
@@ -3877,6 +3877,114 @@ define test_trig()
|
||||
strcat(str(tnum++),
|
||||
': round(acovercos(2 + 3i, 1e-10), 10) == 0.3076036495+1.8641615442i'));
|
||||
|
||||
/* test half versed trigonometric sine */
|
||||
vrfy(haversin(0, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': haversin(0, 1e-10) == 0'));
|
||||
vrfy(round(haversin(0.2, 1e-10), 10) == 0.0099667111,
|
||||
strcat(str(tnum++),
|
||||
': round(haversin(0.2, 1e-10), 10) == 0.0099667111'));
|
||||
vrfy(round(haversin(3/7, 1e-10), 10) == 0.0452198242,
|
||||
strcat(str(tnum++),
|
||||
': round(haversin(3/7, 1e-10), 10) == 0.0452198242'));
|
||||
vrfy(round(haversin(-31, 1e-10), 10) == 0.0426288211,
|
||||
strcat(str(tnum++),
|
||||
': round(haversin(-31, 1e-10), 10) == 0.0426288211'));
|
||||
vrfy(haversin(pi/3, 1e-10) == 0.25,
|
||||
strcat(str(tnum++), ': haversin(pi/3, 1e-10) == 0.25'));
|
||||
vrfy(haversin(pi/2, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': haversin(pi/2, 1e-10) == 0.5'));
|
||||
vrfy(haversin(pi, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': haversin(pi, 1e-10) == 1'));
|
||||
vrfy(haversin(3*pi/2, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': haversin(3*pi/2, 1e-10) == 0.5'));
|
||||
vrfy(round(haversin(1, 1e-10), 10) == 0.229848847,
|
||||
strcat(str(tnum++),
|
||||
': round(haversin(1, 1e-10), 10) == 0.229848847'));
|
||||
vrfy(round(haversin(2 + 3i, 1e-10), 10) == 2.5948128455+4.5546139469i,
|
||||
strcat(str(tnum++),
|
||||
': round(haversin(2 + 3i, 1e-10), 10) == 2.5948128455+4.5546139469i'));
|
||||
|
||||
/* test half coversed trigonometric sine */
|
||||
vrfy(hacoversin(0, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': hacoversin(0, 1e-10) == 0.5'));
|
||||
vrfy(round(hacoversin(0.2, 1e-10), 10) == 0.4006653346,
|
||||
strcat(str(tnum++),
|
||||
': round(hacoversin(0.2, 1e-10), 10) == 0.4006653346'));
|
||||
vrfy(round(hacoversin(3/7, 1e-10), 10) == 0.2922140725,
|
||||
strcat(str(tnum++),
|
||||
': round(hacoversin(3/7, 1e-10), 10) == 0.2922140725'));
|
||||
vrfy(round(hacoversin(-31, 1e-10), 10) == 0.2979811774,
|
||||
strcat(str(tnum++),
|
||||
': round(hacoversin(-31, 1e-10), 10) == 0.2979811774'));
|
||||
vrfy(hacoversin(pi/6, 1e-10) == 0.25,
|
||||
strcat(str(tnum++), ': hacoversin(pi/6, 1e-10) == 0.25'));
|
||||
vrfy(hacoversin(pi/2, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': hacoversin(pi/2, 1e-10) == 0'));
|
||||
vrfy(hacoversin(pi, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': hacoversin(pi, 1e-10) == 0.5'));
|
||||
vrfy(hacoversin(3*pi/2, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': hacoversin(3*pi/2, 1e-10) == 1'));
|
||||
vrfy(round(hacoversin(1, 1e-10), 10) == 0.0792645076,
|
||||
strcat(str(tnum++),
|
||||
': round(hacoversin(1, 1e-10), 10) == 0.0792645076'));
|
||||
vrfy(round(hacoversin(2 + 3i, 1e-10), 10) == -4.0772495734+2.08445348i,
|
||||
strcat(str(tnum++),
|
||||
': round(hacoversin(2 + 3i, 1e-10), 10) == -4.0772495734+2.08445348i'));
|
||||
|
||||
/* test half versed trigonometric cosine */
|
||||
vrfy(havercos(0, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': havercos(0, 1e-10) == 1'));
|
||||
vrfy(round(havercos(0.2, 1e-10), 10) == 0.9900332889,
|
||||
strcat(str(tnum++),
|
||||
': round(havercos(0.2, 1e-10), 10) == 0.9900332889'));
|
||||
vrfy(round(havercos(3/7, 1e-10), 10) == 0.9547801758,
|
||||
strcat(str(tnum++),
|
||||
': round(havercos(3/7, 1e-10), 10) == 0.9547801758'));
|
||||
vrfy(round(havercos(-31, 1e-10), 10) == 0.9573711789,
|
||||
strcat(str(tnum++),
|
||||
': round(havercos(-31, 1e-10), 10) == 0.9573711789'));
|
||||
vrfy(havercos(pi/3, 1e-10) == 0.75,
|
||||
strcat(str(tnum++), ': havercos(pi/3, 1e-10) == 0.75'));
|
||||
vrfy(havercos(pi/2, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': havercos(pi/2, 1e-10) == 0.5'));
|
||||
vrfy(havercos(pi, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': havercos(pi, 1e-10) == 0'));
|
||||
vrfy(havercos(3*pi/2, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': havercos(3*pi/2, 1e-10) == 0.5'));
|
||||
vrfy(round(havercos(1, 1e-10), 10) == 0.770151153,
|
||||
strcat(str(tnum++),
|
||||
': round(havercos(1, 1e-10), 10) == 0.770151153'));
|
||||
vrfy(round(havercos(2 + 3i, 1e-10), 10) == -1.5948128455-4.5546139469i,
|
||||
strcat(str(tnum++),
|
||||
': round(havercos(2 + 3i, 1e-10), 10) == -1.5948128455-4.5546139469i'));
|
||||
|
||||
/* test half coversed trigonometric cosine */
|
||||
vrfy(hacovercos(0, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': hacovercos(0, 1e-10) == 0.5'));
|
||||
vrfy(round(hacovercos(0.2, 1e-10), 10) == 0.5993346654,
|
||||
strcat(str(tnum++),
|
||||
': round(hacovercos(0.2, 1e-10), 10) == 0.5993346654'));
|
||||
vrfy(round(hacovercos(3/7, 1e-10), 10) == 0.7077859275,
|
||||
strcat(str(tnum++),
|
||||
': round(hacovercos(3/7, 1e-10), 10) == 0.7077859275'));
|
||||
vrfy(round(hacovercos(-31, 1e-10), 10) == 0.7020188226,
|
||||
strcat(str(tnum++),
|
||||
': round(hacovercos(-31, 1e-10), 10) == 0.7020188226'));
|
||||
vrfy(hacovercos(pi/6, 1e-10) == 0.75,
|
||||
strcat(str(tnum++), ': hacovercos(pi/6, 1e-10) == 0.75'));
|
||||
vrfy(hacovercos(pi/2, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': hacovercos(pi/2, 1e-10) == 1'));
|
||||
vrfy(hacovercos(pi, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': hacovercos(pi, 1e-10) == 0.5'));
|
||||
vrfy(hacovercos(3*pi/2, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': hacovercos(3*pi/2, 1e-10) == 0'));
|
||||
vrfy(round(hacovercos(1, 1e-10), 10) == 0.9207354924,
|
||||
strcat(str(tnum++),
|
||||
': round(hacovercos(1, 1e-10), 10) == 0.9207354924'));
|
||||
vrfy(round(hacovercos(2 + 3i, 1e-10), 10) == 5.0772495734-2.08445348i,
|
||||
strcat(str(tnum++),
|
||||
': round(hacovercos(2 + 3i, 1e-10), 10) == 5.0772495734-2.08445348i'));
|
||||
|
||||
print strcat(str(tnum++), ': Ending test_trig');
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
@@ -4413,8 +4521,10 @@ define test_fileops()
|
||||
print '4280: x = rm("junk4200")';
|
||||
x = rm("tmp4200");
|
||||
print '4281: x = rm("tmp4200")';
|
||||
x = config("display", 20);
|
||||
print '4282: x = config("display", 20)';
|
||||
|
||||
print '4282: Ending test_fileops';
|
||||
print '4283: Ending test_fileops';
|
||||
}
|
||||
print '071: parsed test_fileops()';
|
||||
|
||||
@@ -9767,9 +9877,29 @@ print '9484: skipping read -once zeta2 - will be read via test8900.special';
|
||||
print '9485: Ending read of selected calc resource files';
|
||||
|
||||
|
||||
/* ********************************************************* */
|
||||
/* NOTE: ==> Reserved for more read tests 9500-9599 here <== */
|
||||
/* ********************************************************* */
|
||||
/*
|
||||
* test 95dd: read test9500.trigeq, test of trigonometric identities
|
||||
*/
|
||||
print;
|
||||
print '9500: Starting trigonometric identities test set';
|
||||
epsilon(1e-20),;
|
||||
print '9501: epsilon(1e-20)';
|
||||
read -once test9500.trigeq;
|
||||
print '9502: read -once test9500.trigeq';
|
||||
vrfy(verify_tan(9503) == 0, '9503: verify_tan(9503) == 0');
|
||||
vrfy(verify_cot(9504) == 0, '9504: verify_cot(9504) == 0');
|
||||
vrfy(verify_sec(9505) == 0, '9505: verify_sec(9505) == 0');
|
||||
vrfy(verify_csc(9506) == 0, '9506: verify_csc(9506) == 0');
|
||||
vrfy(verify_versin(9507) == 0, '9507: verify_versin(9507) == 0');
|
||||
vrfy(verify_coversin(9508) == 0, '9508: verify_coversin(9508) == 0');
|
||||
vrfy(verify_vercos(9509) == 0, '9509: verify_vercos(9509) == 0');
|
||||
vrfy(verify_covercos(9510) == 0, '9510: verify_covercos(9510) == 0');
|
||||
vrfy(verify_haversin(9511) == 0, '9511: verify_haversin(9511) == 0');
|
||||
vrfy(verify_hacoversin(9512) == 0, '9512: verify_hacoversin(9512) == 0');
|
||||
vrfy(verify_havercos(9513) == 0, '9513: verify_havercos(9513) == 0');
|
||||
vrfy(verify_hacovercos(9514) == 0, '9514: verify_hacovercos(9514) == 0');
|
||||
|
||||
print '9515: Ending trigonometric identities test set';
|
||||
|
||||
|
||||
/*
|
||||
@@ -9790,6 +9920,8 @@ print '9607: u_glob as both static and parameter';
|
||||
vrfy(config("redecl_warn",1)==0, '9608: config("redecl_warn",1)==0');
|
||||
vrfy(config("dupvar_warn",1)==0, '9609: config("dupvar_warn",1)==0');
|
||||
|
||||
print '9610: Ending test of dupvar_warn and redecl_warn config parameters';
|
||||
|
||||
|
||||
/* *********************************************** */
|
||||
/* NOTE: ==> Room for new tests 9700-9899 here <== */
|
||||
@@ -10511,6 +10643,12 @@ vrfy_errsym(10553, 10553, "E_ERRSYM_2");
|
||||
vrfy_errsym(10554, 10554, "E_ERRSYM_3");
|
||||
vrfy_errsym(10555, 10555, "E_ERRSYM_4");
|
||||
vrfy_errsym(10556, 10556, "E_ERRSYM_5");
|
||||
vrfy_errsym(10557, 10557, "E_HAVERSIN_1");
|
||||
vrfy_errsym(10558, 10558, "E_HAVERSIN_2");
|
||||
vrfy_errsym(10559, 10559, "E_HAVERSIN_3");
|
||||
vrfy_errsym(10560, 10560, "E_AHAVERSIN_1");
|
||||
vrfy_errsym(10561, 10561, "E_AHAVERSIN_2");
|
||||
vrfy_errsym(10562, 10562, "E_AHAVERSIN_3");
|
||||
|
||||
/* ************************************************************** */
|
||||
/* NOTE: Reserve thru test 10998 for calc computation error codes */
|
||||
|
1126
cal/test9500.trigeq.cal
Normal file
1126
cal/test9500.trigeq.cal
Normal file
File diff suppressed because it is too large
Load Diff
8
cmath.h
8
cmath.h
@@ -136,6 +136,14 @@ E_FUNC COMPLEX *c_vercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_avercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_covercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_acovercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_haversin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_ahaversin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_hacoversin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_ahacoversin(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_havercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_ahavercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_hacovercos(COMPLEX *c, NUMBER *epsilon);
|
||||
E_FUNC COMPLEX *c_ahacovercos(COMPLEX *c, NUMBER *epsilon);
|
||||
|
||||
|
||||
|
||||
|
474
comfunc.c
474
comfunc.c
@@ -1648,7 +1648,7 @@ c_ilog(COMPLEX *c, ZVALUE base)
|
||||
|
||||
|
||||
/*
|
||||
* c_versin - versed sine for COMPLEX values
|
||||
* c_versin - COMPLEX valued versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1684,13 +1684,13 @@ c_versin(COMPLEX *c, NUMBER *epsilon)
|
||||
*/
|
||||
ctmp = c_cos(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex cos for complex versin");
|
||||
math_error("Failed to compute complex cosine for complex versin");
|
||||
not_reached();
|
||||
}
|
||||
r = c_sub(&_cone_, ctmp);
|
||||
|
||||
/*
|
||||
* return complex 1 - cos(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
comfree(ctmp);
|
||||
return r;
|
||||
@@ -1698,7 +1698,7 @@ c_versin(COMPLEX *c, NUMBER *epsilon)
|
||||
|
||||
|
||||
/*
|
||||
* c_aversin - inverse versed sine for COMPLEX values
|
||||
* c_aversin - COMPLEX valued inverse versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1715,7 +1715,7 @@ COMPLEX *
|
||||
c_aversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *x; /* argument to inverse trig function */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -1732,19 +1732,19 @@ c_aversin(COMPLEX *c, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x = c_sub(&_cone_, c);
|
||||
r = c_acos(x, epsilon);
|
||||
comfree(x);
|
||||
ctmp = c_sub(&_cone_, c);
|
||||
r = c_acos(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex acos(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_coversin - coversed sine for COMPLEX values
|
||||
* c_coversin - COMPLEX valued coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1780,21 +1780,21 @@ c_coversin(COMPLEX *c, NUMBER *epsilon)
|
||||
*/
|
||||
ctmp = c_sin(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex sin for complex coversin");
|
||||
math_error("Failed to compute complex sine for complex coversin");
|
||||
not_reached();
|
||||
}
|
||||
r = c_sub(&_cone_, ctmp);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex 1 - sin(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
comfree(ctmp);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_acoversin - inverse versed sine for COMPLEX values
|
||||
* c_acoversin - COMPLEX valued inverse coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1811,7 +1811,7 @@ COMPLEX *
|
||||
c_acoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *x; /* argument to inverse trig function */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -1828,19 +1828,19 @@ c_acoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x = c_sub(&_cone_, c);
|
||||
r = c_asin(x, epsilon);
|
||||
comfree(x);
|
||||
ctmp = c_sub(&_cone_, c);
|
||||
r = c_asin(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex asin(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_vercos - versed sine for COMPLEX values
|
||||
* c_vercos - COMPLEX valued versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1876,21 +1876,21 @@ c_vercos(COMPLEX *c, NUMBER *epsilon)
|
||||
*/
|
||||
ctmp = c_cos(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex cos for complex vercos");
|
||||
math_error("Failed to compute complex cosine for complex vercos");
|
||||
not_reached();
|
||||
}
|
||||
r = c_add(&_cone_, ctmp);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex 1 + cos(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
comfree(ctmp);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_avercos - inverse versed sine for COMPLEX values
|
||||
* c_avercos - COMPLEX valued inverse versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1907,7 +1907,7 @@ COMPLEX *
|
||||
c_avercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *x; /* argument to inverse trig function */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -1924,19 +1924,19 @@ c_avercos(COMPLEX *c, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x = c_sub(c, &_cone_);
|
||||
r = c_acos(x, epsilon);
|
||||
comfree(x);
|
||||
ctmp = c_sub(c, &_cone_);
|
||||
r = c_acos(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex acos(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_covercos - coversed sine for COMPLEX values
|
||||
* c_covercos - COMPLEX valued coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1972,21 +1972,21 @@ c_covercos(COMPLEX *c, NUMBER *epsilon)
|
||||
*/
|
||||
ctmp = c_sin(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex sin for complex covercos");
|
||||
math_error("Failed to compute complex sine for complex covercos");
|
||||
not_reached();
|
||||
}
|
||||
r = c_add(&_cone_, ctmp);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex 1 + sin(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
comfree(ctmp);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_acovercos - inverse versed sine for COMPLEX values
|
||||
* c_acovercos - COMPLEX valued inverse coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2003,7 +2003,7 @@ COMPLEX *
|
||||
c_acovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *x; /* argument to inverse trig function */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2020,12 +2020,408 @@ c_acovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x = c_sub(c, &_cone_);
|
||||
r = c_asin(x, epsilon);
|
||||
comfree(x);
|
||||
ctmp = c_sub(c, &_cone_);
|
||||
r = c_asin(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return complex asin(x - 1)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_haversin - COMPLEX valued half versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* haversin(x) = versin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_haversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* return COMPLEX value */
|
||||
COMPLEX *ctmp; /* complex cos(c) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex trig function value
|
||||
*/
|
||||
ctmp = c_versin(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex versed sine for complex haversin");
|
||||
not_reached();
|
||||
}
|
||||
r = c_divq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_ahaversin - COMPLEX valued inverse half versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahaversin(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_ahaversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
COMPLEX *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x2 = c_mulq(c, &_qtwo_);
|
||||
ctmp = c_sub(&_cone_, x2);
|
||||
comfree(x2);
|
||||
r = c_acos(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_hacoversin - COMPLEX valued half coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* hacoversin(x) = coversin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_hacoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* return COMPLEX value */
|
||||
COMPLEX *ctmp; /* complex sin(c) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex trig function value
|
||||
*/
|
||||
ctmp = c_coversin(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex coversed sine for complex hacoversin");
|
||||
not_reached();
|
||||
}
|
||||
r = c_divq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_ahacoversin - COMPLEX valued inverse half coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacoversin(x) = asin(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_ahacoversin(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
COMPLEX *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x2 = c_mulq(c, &_qtwo_);
|
||||
ctmp = c_sub(&_cone_, x2);
|
||||
comfree(x2);
|
||||
r = c_asin(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_havercos - COMPLEX valued half coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* havercos(x) = vercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_havercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* return COMPLEX value */
|
||||
COMPLEX *ctmp; /* complex sin(c) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex trig function value
|
||||
*/
|
||||
ctmp = c_vercos(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex versed cosine for complex havercos");
|
||||
not_reached();
|
||||
}
|
||||
r = c_divq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_ahavercos - COMPLEX valued inverse half coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahavercos(x) = acos(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_ahavercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
COMPLEX *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x2 = c_mulq(c, &_qtwo_);
|
||||
ctmp = c_sub(&_cone_, x2);
|
||||
comfree(x2);
|
||||
r = c_acos(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_hacovercos - COMPLEX valued half coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* hacovercos(x) = covercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_hacovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* return COMPLEX value */
|
||||
COMPLEX *ctmp; /* complex sin(c) */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex trig function value
|
||||
*/
|
||||
ctmp = c_covercos(c, epsilon);
|
||||
if (ctmp == NULL) {
|
||||
math_error("Failed to compute complex coversed cosine for complex hacovercos");
|
||||
not_reached();
|
||||
}
|
||||
r = c_divq(ctmp, &_qtwo_);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* c_ahacovercos - COMPLEX valued inverse half coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacovercos(x) = asin(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q complex value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* complex value result of trig function on q with error epsilon
|
||||
*/
|
||||
COMPLEX *
|
||||
c_ahacovercos(COMPLEX *c, NUMBER *epsilon)
|
||||
{
|
||||
COMPLEX *r; /* inverse trig value result */
|
||||
COMPLEX *ctmp; /* argument to inverse trig function */
|
||||
COMPLEX *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (c == NULL) {
|
||||
math_error("%s: c is NULL", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate complex inverse trig function value
|
||||
*/
|
||||
x2 = c_mulq(c, &_qtwo_);
|
||||
ctmp = c_sub(&_cone_, x2);
|
||||
comfree(x2);
|
||||
r = c_asin(ctmp, epsilon);
|
||||
comfree(ctmp);
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return r;
|
||||
}
|
||||
|
24
errtbl.c
24
errtbl.c
@@ -705,6 +705,30 @@ CONST struct errtbl error_table[] = {
|
||||
{ 10554, "E_ERRSYM_3", "String argument is not a valid E_STRING for errsym" },
|
||||
{ 10555, "E_ERRSYM_4", "Numeric argument is not an integer for errsym" },
|
||||
{ 10556, "E_ERRSYM_5", "Unable to create a valid E_STRING from the errnum for errsym" },
|
||||
{ 10557, "E_HAVERSIN_1", "Bad epsilon for haversin" },
|
||||
{ 10558, "E_HAVERSIN_2", "Bad first argument for haversin" },
|
||||
{ 10559, "E_HAVERSIN_3", "Too-large im(argument) for haversin" },
|
||||
{ 10560, "E_AHAVERSIN_1", "Bad epsilon for ahaversin" },
|
||||
{ 10561, "E_AHAVERSIN_2", "Bad first argument for ahaversin" },
|
||||
{ 10562, "E_AHAVERSIN_3", "Too-large im(argument) for ahaversin" },
|
||||
{ 10563, "E_HACOVERSIN_1", "Bad epsilon for hacoversin" },
|
||||
{ 10564, "E_HACOVERSIN_2", "Bad first argument for hacoversin" },
|
||||
{ 10565, "E_HACOVERSIN_3", "Too-large im(argument) for hacoversin" },
|
||||
{ 10566, "E_AHACOVERSIN_1", "Bad epsilon for ahacoversin" },
|
||||
{ 10567, "E_AHACOVERSIN_2", "Bad first argument for achaoversin" },
|
||||
{ 10568, "E_AHACOVERSIN_3", "Too-large im(argument) for ahacoversin" },
|
||||
{ 10569, "E_HAVERCOS_1", "Bad epsilon for havercos" },
|
||||
{ 10570, "E_HAVERCOS_2", "Bad first argument for havercos" },
|
||||
{ 10571, "E_HAVERCOS_3", "Too-large im(argument) for havercos" },
|
||||
{ 10572, "E_AHAVERCOS_1", "Bad epsilon for ahavercos" },
|
||||
{ 10573, "E_AHAVERCOS_2", "Bad first argument for ahavercos" },
|
||||
{ 10574, "E_AHAVERCOS_3", "Too-large im(argument) for ahavercos" },
|
||||
{ 10575, "E_HACOVERCOS_1", "Bad epsilon for hacovercos" },
|
||||
{ 10576, "E_HACOVERCOS_2", "Bad first argument for hacovercos" },
|
||||
{ 10577, "E_HACOVERCOS_3", "Too-large im(argument) for hacovercos" },
|
||||
{ 10578, "E_AHACOVERCOS_1", "Bad epsilon for ahacovercos" },
|
||||
{ 10579, "E_AHACOVERCOS_2", "Bad first argument for achaovercos" },
|
||||
{ 10580, "E_AHACOVERCOS_3", "Too-large im(argument) for ahacovercos" },
|
||||
/* IMPORTANT NOTE: add new entries above here and be sure their errnum numeric value is consecutive! */
|
||||
|
||||
/* The next NULL entry must be last */
|
||||
|
600
func.c
600
func.c
@@ -10821,7 +10821,7 @@ f_version(void)
|
||||
|
||||
|
||||
/*
|
||||
* f_versin - versed sine
|
||||
* f_versin - versed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_versin(int count, VALUE **vals)
|
||||
@@ -10878,7 +10878,7 @@ f_versin(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_aversin - inverse versed sine
|
||||
* f_aversin - inverse versed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_aversin(int count, VALUE **vals)
|
||||
@@ -10910,7 +10910,7 @@ f_aversin(int count, VALUE **vals)
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real triv function */
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qaversin_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
@@ -10961,7 +10961,7 @@ f_aversin(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_coversin - coversed sine
|
||||
* f_coversin - coversed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_coversin(int count, VALUE **vals)
|
||||
@@ -11018,7 +11018,7 @@ f_coversin(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_acoversin - inverse coversed sine
|
||||
* f_acoversin - inverse coversed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_acoversin(int count, VALUE **vals)
|
||||
@@ -11050,7 +11050,7 @@ f_acoversin(int count, VALUE **vals)
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real triv function */
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacoversin_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
@@ -11101,7 +11101,7 @@ f_acoversin(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_vercos - versed cosine
|
||||
* f_vercos - versed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_vercos(int count, VALUE **vals)
|
||||
@@ -11158,7 +11158,7 @@ f_vercos(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_avercos - inverse versed cosine
|
||||
* f_avercos - inverse versed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_avercos(int count, VALUE **vals)
|
||||
@@ -11190,7 +11190,7 @@ f_avercos(int count, VALUE **vals)
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real triv function */
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qavercos_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
@@ -11241,7 +11241,7 @@ f_avercos(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_covercos - coversed cosine
|
||||
* f_covercos - coversed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_covercos(int count, VALUE **vals)
|
||||
@@ -11298,7 +11298,7 @@ f_covercos(int count, VALUE **vals)
|
||||
|
||||
|
||||
/*
|
||||
* f_acovercos - inverse coversed cosine
|
||||
* f_acovercos - inverse coversed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_acovercos(int count, VALUE **vals)
|
||||
@@ -11330,7 +11330,7 @@ f_acovercos(int count, VALUE **vals)
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real triv function */
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacovercos_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
@@ -11380,6 +11380,566 @@ f_acovercos(int count, VALUE **vals)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_haversin - half versed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_haversin(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_HAVERSIN_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute trig function to a given error tolerance
|
||||
*/
|
||||
switch (vals[0]->v_type) {
|
||||
case V_NUM:
|
||||
result.v_num = qhaversin(vals[0]->v_num, eps);
|
||||
result.v_type = V_NUM;
|
||||
break;
|
||||
case V_COM:
|
||||
c = c_haversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_HAVERSIN_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return error_value(E_HAVERSIN_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_ahaversin - inverse half versed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_ahaversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
|
||||
/* 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_AHAVERSIN_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute inverse trig function to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahaversin_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
*/
|
||||
if (result.v_num != NULL) {
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* case: trig function returned NULL - need to try COMPLEX trig function
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahaversin(arg1.v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHAVERSIN_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
*/
|
||||
return error_value(E_AHAVERSIN_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_hacoversin - half coversed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_hacoversin(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_HACOVERSIN_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute trig function to a given error tolerance
|
||||
*/
|
||||
switch (vals[0]->v_type) {
|
||||
case V_NUM:
|
||||
result.v_num = qhacoversin(vals[0]->v_num, eps);
|
||||
result.v_type = V_NUM;
|
||||
break;
|
||||
case V_COM:
|
||||
c = c_hacoversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_HACOVERSIN_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return error_value(E_HACOVERSIN_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_ahacoversin - inverse half coversed trigonometric sine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_ahacoversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
|
||||
/* 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_AHACOVERSIN_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute inverse trig function to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahacoversin_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
*/
|
||||
if (result.v_num != NULL) {
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* case: trig function returned NULL - need to try COMPLEX trig function
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahacoversin(arg1.v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHACOVERSIN_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
*/
|
||||
return error_value(E_AHACOVERSIN_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_havercos - half versed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_havercos(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_HAVERCOS_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute trig function to a given error tolerance
|
||||
*/
|
||||
switch (vals[0]->v_type) {
|
||||
case V_NUM:
|
||||
result.v_num = qhavercos(vals[0]->v_num, eps);
|
||||
result.v_type = V_NUM;
|
||||
break;
|
||||
case V_COM:
|
||||
c = c_havercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_HAVERCOS_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return error_value(E_HAVERCOS_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_ahavercos - inverse half versed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_ahavercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
|
||||
/* 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_AHAVERCOS_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute inverse trig function to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahavercos_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
*/
|
||||
if (result.v_num != NULL) {
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* case: trig function returned NULL - need to try COMPLEX trig function
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahavercos(arg1.v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHAVERCOS_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
*/
|
||||
return error_value(E_AHAVERCOS_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_hacovercos - half coversed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_hacovercos(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_HACOVERCOS_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute trig function to a given error tolerance
|
||||
*/
|
||||
switch (vals[0]->v_type) {
|
||||
case V_NUM:
|
||||
result.v_num = qhacovercos(vals[0]->v_num, eps);
|
||||
result.v_type = V_NUM;
|
||||
break;
|
||||
case V_COM:
|
||||
c = c_hacovercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_HACOVERCOS_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return error_value(E_HACOVERCOS_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* f_ahacovercos - inverse half coversed trigonometric cosine
|
||||
*/
|
||||
S_FUNC VALUE
|
||||
f_ahacovercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
|
||||
/* 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_AHACOVERCOS_1);
|
||||
}
|
||||
eps = vals[1]->v_num;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute inverse trig function to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahacovercos_or_NULL(arg1.v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
*/
|
||||
if (result.v_num != NULL) {
|
||||
result.v_type = V_NUM;
|
||||
|
||||
/*
|
||||
* case: trig function returned NULL - need to try COMPLEX trig function
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahacovercos(arg1.v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHACOVERCOS_3);
|
||||
}
|
||||
result.v_com = c;
|
||||
result.v_type = V_COM;
|
||||
|
||||
/*
|
||||
* case: complex trig function returned real, convert result to NUMBER
|
||||
*/
|
||||
if (cisreal(c)) {
|
||||
result.v_num = c_to_q(c, true);
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
*/
|
||||
return error_value(E_AHACOVERCOS_2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif /* !FUNCLIST */
|
||||
|
||||
|
||||
@@ -11442,6 +12002,14 @@ STATIC CONST struct builtin builtins[] = {
|
||||
"inverse csch of a within accuracy b"},
|
||||
{"agd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_agd},
|
||||
"inverse Gudermannian function"},
|
||||
{"ahacovercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahacovercos},
|
||||
"inverse half coversed cosine of a within accuracy b"},
|
||||
{"ahacoversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahacoversin},
|
||||
"inverse half coversed sine of a within accuracy b"},
|
||||
{"ahavercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahavercos},
|
||||
"inverse half versed cosine of a within accuracy b"},
|
||||
{"ahaversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ahaversin},
|
||||
"inverse half versed sine of a within accuracy b"},
|
||||
{"append", 1, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_listappend},
|
||||
"append values to end of list"},
|
||||
{"appr", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_appr},
|
||||
@@ -11693,9 +12261,17 @@ STATIC CONST struct builtin builtins[] = {
|
||||
"convert a to b hours, c min, rounding type d\n"},
|
||||
{"h2hms", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_h2hms},
|
||||
"convert a to b hours, c min, d sec, rounding type e\n"},
|
||||
{"hacovercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hacovercos},
|
||||
"half coversed cosine of value a within accuracy b"},
|
||||
{"hacoversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hacoversin},
|
||||
"half coversed sine of value a within accuracy b"},
|
||||
{"hash", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hash},
|
||||
"return non-negative hash value for one or\n"
|
||||
"\t\t\tmore values"},
|
||||
{"havercos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_havercos},
|
||||
"half versed cosine of value a within accuracy b"},
|
||||
{"haversin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_haversin},
|
||||
"half versed sine of value a within accuracy b"},
|
||||
{"head", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_head},
|
||||
"return list of specified number at head of a list"},
|
||||
{"highbit", 1, 1, 0, OP_HIGHBIT, {.null = NULL}, {.null = NULL},
|
||||
|
@@ -44,9 +44,9 @@ LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
comp, fact, rand, perm
|
||||
comb, fact, rand, perm
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
## Copyright (C) 1999-2006,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
13
qmath.h
13
qmath.h
@@ -238,7 +238,18 @@ E_FUNC NUMBER *qavercos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qcovercos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacovercos_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qacovercos(NUMBER *q, NUMBER *epsilon);
|
||||
|
||||
E_FUNC NUMBER *qhaversin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahaversin_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahaversin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qhacoversin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahacoversin_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahacoversin(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qhavercos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahavercos_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahavercos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qhacovercos(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahacovercos_or_NULL(NUMBER *q, NUMBER *epsilon);
|
||||
E_FUNC NUMBER *qahacovercos(NUMBER *q, NUMBER *epsilon);
|
||||
|
||||
/*
|
||||
* pseudo-seed generator
|
||||
|
725
qtrans.c
725
qtrans.c
@@ -1979,7 +1979,7 @@ qacoth(NUMBER *q, NUMBER *epsilon)
|
||||
|
||||
|
||||
/*
|
||||
* qversin - versed sine for NUMBER values
|
||||
* qversin - versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -1995,8 +1995,8 @@ qacoth(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *
|
||||
qversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res;
|
||||
NUMBER *cos;
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2013,19 +2013,19 @@ qversin(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
cos = qcos(q, epsilon);
|
||||
res = qsub(&_qone_, cos);
|
||||
qfree(cos);
|
||||
qtmp = qcos(q, epsilon);
|
||||
res = qsub(&_qone_, qtmp);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return 1 - cos(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qaversin_or_NULL - inverse versed sine for NUMBER values
|
||||
* qaversin_or_NULL - return NULL or non-complex inverse versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2047,7 +2047,7 @@ NUMBER *
|
||||
qaversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *x; /* argument to inverse trig function */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2064,22 +2064,22 @@ qaversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x = qsub(&_qone_, q);
|
||||
res = qacos(x, epsilon);
|
||||
qfree(x);
|
||||
qtmp = qsub(&_qone_, q);
|
||||
res = qacos(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return acos(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qaversin - inverse versed sine for NUMBER values
|
||||
* qaversin - non-complex inverse versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2114,19 +2114,19 @@ qaversin(NUMBER *q, NUMBER *epsilon)
|
||||
*/
|
||||
res = qaversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse cos for aversin");
|
||||
math_error("cannot compute inverse cosine for aversin");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return acos(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qcoversin - coversed sine for NUMBER values
|
||||
* qcoversin - coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2142,7 +2142,8 @@ qaversin(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *
|
||||
qcoversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *sin, *res;
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2159,19 +2160,19 @@ qcoversin(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
sin = qsin(q, epsilon);
|
||||
res = qsub(&_qone_, sin);
|
||||
qfree(sin);
|
||||
qtmp = qsin(q, epsilon);
|
||||
res = qsub(&_qone_, qtmp);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return 1 - sin(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacoversin_or_NULL - inverse coversed sine for NUMBER values
|
||||
* qacoversin_or_NULL - return NULL or non-complex inverse coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2196,7 +2197,7 @@ NUMBER *
|
||||
qacoversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *x; /* argument to inverse trig function */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2213,22 +2214,22 @@ qacoversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x = qsub(&_qone_, q);
|
||||
res = qasin(x, epsilon);
|
||||
qfree(x);
|
||||
qtmp = qsub(&_qone_, q);
|
||||
res = qasin(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return asin(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacoversin - inverse coversed sine for NUMBER values
|
||||
* qacoversin - non-complex inverse coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2263,19 +2264,19 @@ qacoversin(NUMBER *q, NUMBER *epsilon)
|
||||
*/
|
||||
res = qacoversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse sin for acoversin");
|
||||
math_error("cannot compute inverse sine for acoversin");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return asin(1 - x)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qvercos - versed sine for NUMBER values
|
||||
* qvercos - versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2291,7 +2292,8 @@ qacoversin(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *
|
||||
qvercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *cos, *res;
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2308,19 +2310,19 @@ qvercos(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
cos = qcos(q, epsilon);
|
||||
res = qqadd(&_qone_, cos);
|
||||
qfree(cos);
|
||||
qtmp = qcos(q, epsilon);
|
||||
res = qqadd(&_qone_, qtmp);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return 1 + cos(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qavercos_or_NULL - inverse versed sine for NUMBER values
|
||||
* qavercos_or_NULL - return NULL or non-complex inverse versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2342,7 +2344,7 @@ NUMBER *
|
||||
qavercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *x; /* argument to inverse trig function */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2359,22 +2361,22 @@ qavercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x = qsub(q, &_qone_);
|
||||
res = qacos(x, epsilon);
|
||||
qfree(x);
|
||||
qtmp = qsub(q, &_qone_);
|
||||
res = qacos(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return acos(x - 1)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qavercos - inverse versed sine for NUMBER values
|
||||
* qavercos - non-complex inverse versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2409,19 +2411,19 @@ qavercos(NUMBER *q, NUMBER *epsilon)
|
||||
*/
|
||||
res = qavercos_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse cos for avercos");
|
||||
math_error("cannot compute inverse cosine for avercos");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return acos(x - 1)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qcovercos - coversed sine for NUMBER values
|
||||
* qcovercos - coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2437,7 +2439,8 @@ qavercos(NUMBER *q, NUMBER *epsilon)
|
||||
NUMBER *
|
||||
qcovercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *sin, *res;
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2454,19 +2457,19 @@ qcovercos(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
sin = qsin(q, epsilon);
|
||||
res = qqadd(&_qone_, sin);
|
||||
qfree(sin);
|
||||
qtmp = qsin(q, epsilon);
|
||||
res = qqadd(&_qone_, qtmp);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return 1 + sin(x)
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacovercos_or_NULL - inverse coversed sine for NUMBER values
|
||||
* qacovercos_or_NULL - return NULL or non-complex inverse coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2491,7 +2494,7 @@ NUMBER *
|
||||
qacovercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *x; /* argument to inverse trig function */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
@@ -2508,22 +2511,22 @@ qacovercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x = qsub(&_qone_, q);
|
||||
res = qasin(x, epsilon);
|
||||
qfree(x);
|
||||
qtmp = qsub(&_qone_, q);
|
||||
res = qasin(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return asin(x - 1)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qacovercos - inverse coversed sine for NUMBER values
|
||||
* qacovercos - non-complex inverse coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
@@ -2558,12 +2561,612 @@ qacovercos(NUMBER *q, NUMBER *epsilon)
|
||||
*/
|
||||
res = qacovercos_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse sin for acovercos");
|
||||
math_error("cannot compute inverse sine for acovercos");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return asin(x - 1)
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qhaversin - half versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* haversin(x) = versin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qhaversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
qtmp = qversin(q, epsilon);
|
||||
res = qdivi(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahaversin_or_NULL - return NULL or non-complex inverse half versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahaversin(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* != NULL ==> real value result of trig function on q with error epsilon,
|
||||
* NULL ==> trig function value cannot be expressed as a NUMBER
|
||||
*
|
||||
* NOTE: If this function returns NULL, consider calling the equivalent
|
||||
* COMPLEX function from comfunc.c. See the help file for the
|
||||
* related builtin for details.
|
||||
*/
|
||||
NUMBER *
|
||||
qahaversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
NUMBER *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x2 = qmuli(q, 2);
|
||||
qtmp = qsub(&_qone_, x2);
|
||||
qfree(x2);
|
||||
res = qacos(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahaversin - non-complex inverse half versed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahaversin(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qahaversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
res = qahaversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse cosine for ahaversin");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qhacoversin - coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* hacoversin((x) = coversin(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qhacoversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
qtmp = qcoversin(q, epsilon);
|
||||
res = qdivi(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahacoversin_or_NULL - return NULL or non-complex inverse coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacoversin(x) = asin(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*
|
||||
* returns:
|
||||
* != NULL ==> real value result of trig function on q with error epsilon,
|
||||
* NULL ==> trig function value cannot be expressed as a NUMBER
|
||||
*
|
||||
* NOTE: If this function returns NULL, consider calling the equivalent
|
||||
* COMPLEX function from comfunc.c. See the help file for the
|
||||
* related builtin for details.
|
||||
*/
|
||||
NUMBER *
|
||||
qahacoversin_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
qtmp = qsub(&_qone_, q);
|
||||
res = qasin(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahacoversin - non-complex inverse coversed trigonometric sine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacoversin(x) = asin(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qahacoversin(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
res = qahacoversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse sine for ahacoversin");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qhavercos - half versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* havercos(x) = vercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qhavercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
qtmp = qvercos(q, epsilon);
|
||||
res = qdivi(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahavercos_or_NULL - return NULL or non-complex inverse half versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahavercos(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* != NULL ==> real value result of trig function on q with error epsilon,
|
||||
* NULL ==> trig function value cannot be expressed as a NUMBER
|
||||
*
|
||||
* NOTE: If this function returns NULL, consider calling the equivalent
|
||||
* COMPLEX function from comfunc.c. See the help file for the
|
||||
* related builtin for details.
|
||||
*/
|
||||
NUMBER *
|
||||
qahavercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
NUMBER *x2; /* twice x */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
x2 = qmuli(q, 2);
|
||||
qtmp = qsub(&_qone_, x2);
|
||||
qfree(x2);
|
||||
res = qacos(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahavercos - non-complex inverse half versed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahavercos(x) = acos(1 - 2*x)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qahavercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
res = qahaversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse cocosine for ahavercos");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qhacovercos - half coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* hacovercos((x) = covercos(x) / 2
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qhacovercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate trig function value
|
||||
*/
|
||||
qtmp = qcovercos(q, epsilon);
|
||||
res = qdivi(qtmp, 2);
|
||||
qfree(qtmp);
|
||||
|
||||
/*
|
||||
* return trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahacovercos_or_NULL - return NULL or non-complex inverse half coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacovercos(x) = acos(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*
|
||||
* returns:
|
||||
* != NULL ==> real value result of trig function on q with error epsilon,
|
||||
* NULL ==> trig function value cannot be expressed as a NUMBER
|
||||
*
|
||||
* NOTE: If this function returns NULL, consider calling the equivalent
|
||||
* COMPLEX function from comfunc.c. See the help file for the
|
||||
* related builtin for details.
|
||||
*/
|
||||
NUMBER *
|
||||
qahacovercos_or_NULL(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
NUMBER *qtmp; /* argument to inverse trig function */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
qtmp = qsub(&_qone_, q);
|
||||
res = qacos(qtmp, epsilon);
|
||||
qfree(qtmp);
|
||||
if (res == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* qahacovercos - non-complex inverse half coversed trigonometric cosine
|
||||
*
|
||||
* This uses the formula:
|
||||
*
|
||||
* ahacovercos(x) = acos(2*x - 1)
|
||||
*
|
||||
* given:
|
||||
* q real value to pass to the trig function
|
||||
* epsilon error tolerance / precision for trig calculation
|
||||
*
|
||||
* returns:
|
||||
* real value result of trig function on q with error epsilon
|
||||
*/
|
||||
NUMBER *
|
||||
qahacovercos(NUMBER *q, NUMBER *epsilon)
|
||||
{
|
||||
NUMBER *res; /* inverse trig value result */
|
||||
|
||||
/*
|
||||
* firewall
|
||||
*/
|
||||
if (q == NULL) {
|
||||
math_error("q is NULL for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
if (check_epsilon(epsilon) == false) {
|
||||
math_error("Invalid epsilon arg for %s", __func__);
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate inverse trig function value
|
||||
*/
|
||||
res = qahacoversin_or_NULL(q, epsilon);
|
||||
if (res == NULL) {
|
||||
math_error("cannot compute inverse cosine for ahacovercos");
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* return inverse trigonometric result
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user