add config("triground") to trigonometric function rounding

The config("triground") controls rounding for the following
trigonometric and hyperbolic functions:

    sin, cos, tan, cot, sec, csc
    asin, acos, atan, acot, asec, acsc
    versin, coversin, vercos, covercos
    aversin, acoversin, avercos, acovercos
    haversin, hacoversin, havercos, hacovercos
    ahaversin, hacoversin, havercos, ahacovercos
    exsec, aexsec, excsc, aexcsc
    crd, acrd
    cas, cis
    sinh, cosh, tanh, coth, sech, csch
    asinh, acosh, atanh, acoth, asech, acsch

In addition to taking a complex root (such as via the power
function on a complex value), "triground" is used for:

    exp, polar

For the above mentioned functions, the rounding mode used to
round the result to the nearest epsilon value is controlled by,
and defaults to:

    config("triground", 24)

As with other config options, the call returns the previous mode,
without a 2nd argument, returns the current mode without changing it:

    config("triground")

Improved "SEE ALSO" for the hyperbolic function help files.
This commit is contained in:
Landon Curt Noll
2023-10-03 20:31:13 -07:00
parent fec9712b9a
commit db582d6e34
22 changed files with 177 additions and 63 deletions

View File

@@ -106,6 +106,7 @@ NAMETYPE configs[] = {
{"cfsim", CONFIG_CFSIM},
{"outround", CONFIG_OUTROUND},
{"round", CONFIG_ROUND},
{"triground", CONFIG_TRIGROUND},
{"leadzero", CONFIG_LEADZERO},
{"fullzero", CONFIG_FULLZERO},
{"maxscan", CONFIG_MAXSCAN},
@@ -167,6 +168,7 @@ CONFIG oldstd = { /* backward compatible standard configuration */
8, /* cfsim() default rounding mode */
2, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
24, /* trigonometric and hyperbolic function rounding mode */
false, /* true ==> print leading 0 before decimal pt */
0, /* true ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
@@ -230,6 +232,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */
8, /* cfsim() default rounding mode */
24, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
24, /* trigonometric and hyperbolic function rounding mode */
true, /* true ==> print leading 0 before decimal pt */
0, /* true ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
@@ -761,6 +764,14 @@ setconfig(int type, VALUE *vp)
conf->round = len;
break;
case CONFIG_TRIGROUND:
if (getlen(vp, &len)) {
math_error("Illegal value for triground");
not_reached();
}
conf->triground = len;
break;
case CONFIG_LEADZERO:
if (vp->v_type == V_NUM) {
q = vp->v_num;
@@ -1308,6 +1319,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
i = cfg->round;
break;
case CONFIG_TRIGROUND:
i = cfg->triground;
break;
case CONFIG_LEADZERO:
i = (cfg->leadzero ? 1 : 0);
break;
@@ -1512,6 +1527,7 @@ config_cmp(CONFIG *cfg1, CONFIG *cfg2)
cfg1->cfsim != cfg2->cfsim ||
cfg1->outround != cfg2->outround ||
cfg1->round != cfg2->round ||
cfg1->triground != cfg2->triground ||
cfg1->leadzero != cfg2->leadzero ||
cfg1->fullzero != cfg2->fullzero ||
cfg1->maxscancount != cfg2->maxscancount ||