Commit Graph

584 Commits

Author SHA1 Message Date
Landon Curt Noll
4c65986502 improve inverse trigonometric help files 2023-09-11 15:34:12 -07:00
Landon Curt Noll
81eb6eac11 update which calc error codes are unused
In calcerr.tbl, error codes that are no longer
used start their error message with "UNUSED ERROR:".
2023-09-10 23:20:39 -07:00
Landon Curt Noll
bf730f5518 add cmappr() and missing complex tan, cot, sec, csc in liblcac
Added complex multiple approximation function to commath.c so
that users of libcalc may directly round complex number to
nearest multiple of a given real number:

    E_FUNC COMPLEX *cmappr(COMPLEX *c, NUMBER *e, long rnd, bool cfree);

For example:

    COMPLEX *c;             /* complex number to round to nearest epsilon */
    NUMBER *eps;            /* epsilon rounding precision */
    COMPLEX *res;           /* c rounded to nearest epsilon */
    long rnd = 24L;         /* a common rounding mode */
    bool ok_to_free;        /* true ==> free c, false ==> do not free c */

    ...

    res = cmappr(c, eps, ok_to_free);

The complex trigonometric functions tan, cot, sec, csc were implemented
in func.c as calls to complex sin and complex cos.  We added the
direct calls to comfunc.c so that users of libcalc may
call them directly:

    E_FUNC COMPLEX *c_tan(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_sec(COMPLEX *c, NUMBER *eps);
    E_FUNC COMPLEX *c_cot(COMPLEX *c, NUMBER *eps);
2023-09-10 22:54:50 -07:00
Landon Curt Noll
a722b5cca7 update major trigonometric help files and regression tests
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

Expanded the calc regression test suite test 34dd to test various
real and complex values for sin, cos, tan, cot, sec, csc.
2023-09-10 16:33:31 -07:00
Landon Curt Noll
78d536140f fix rand pseudo-random number generator
Fixed more documentation and code comments that referred to the old
additive 55 (a55) shuffle pseudo-random number generator.  We have
been using the subtractive 100 shuffle pseudo-random number generator
in place of the additive 55 generator for a while now.
2023-09-10 15:10:40 -07:00
Landon Curt Noll
8caa8d8635 update cal/README and cal/Makefile
Updated the cal/README to reflect the new names
of the calc regression test suite files.

Updated cal/Makefile to remove, when installing,
old names for calc regression test suite files.

Added missing getpgid_tmp to .gitignore.
2023-09-08 12:33:50 -07:00
Landon Curt Noll
d8603d3980 rename regression test calc resource files
To make the meaning a bit more clear in cal/regress.cal, we have
renamed the following test calc resource files that are related to
the calc regression test suite:

cal/test1700.cal -> cal/test8000.read.cal
cal/test2300.cal -> cal/test2300.obj_incdec.cal
cal/test2600.cal -> cal/test2600.numfunc.cal
cal/test2700.cal -> cal/test2700.isqrt.cal
cal/test3100.cal -> cal/test3100.matobj.cal
cal/test3400.cal -> cal/test3400.trig.cal
cal/test4000.cal -> cal/test4000.ptest.cal
cal/test4100.cal -> cal/test4100.redc.cal
cal/test4600.cal -> cal/test4600.fileop.cal
cal/test5100.cal -> cal/test5100.newdecl.cal
cal/test5200.cal -> cal/test5200.globstat.cal
cal/test8400.cal -> cal/test8400.quit.cal
cal/test8500.cal -> cal/test8500.divmod.cal
cal/test8600.cal -> cal/test8600.maxargs.cal
cal/set8700.cal -> cal/test8700.dotest.cal
cal/test8900.cal -> cal/test8900.special.cal
cal/test9300.cal -> cal/test9300.frem.cal

Added to test 94dd, read of a number of new calc resource files
that are not already read as a result of the calc regression test suite.
2023-09-08 12:15:04 -07:00
Landon Curt Noll
3fd55f0431 improve the cal/regress.cal regress test suite structure
Improve comments about use of the ${CALC_ENV} Makefile variable.
Noted in Makefile.cal where and how the ${CALC_ENV} is used.
Use ${CALC_ENV} Makefile variable were needed.

Modified regression test cal/regress.cal: in some cases test numbers
were adjusted.  Add comments indicate which test numbers apply to
which code.  Indicated where there is room for new tests.
Expanded the end of test numbers from 9999 to  99999.
2023-09-07 22:11:36 -07:00
Landon Curt Noll
b67e20881a fix historical trigonometric functions for values of 0
Fixed how the historical trigonometric functions call
the underlying trigonometric functions.  This fixes a
number of issues where the function for values of 0.

Updated cal/regress.cal to test historical trigonometric functions
at the  0 value.
2023-09-06 18:02:46 -07:00
Landon Curt Noll
c153ac08b9 add covercos, acovercos, haversin, ahaversin to help Makefile 2023-09-06 01:01:36 -07:00
Landon Curt Noll
fdbf53d7e8 add vercos(), avercos(), covercos(), acovercos()
Improved trig help files.

Added new vercos(x, [,eps]) for versed cosine and covercos(x, [,eps])
for inverse versed cosine.

Added new avercos(x, [,eps]) for inverse versed cosine and acovercos(x, [,eps])
for inverse coversed cosine.
2023-09-06 00:52:37 -07:00
Landon Curt Noll
ea5b5e0b53 fix aversin() and acoversin() to not modify args 2023-09-05 22:27:14 -07:00
Landon Curt Noll
3abedd6713 fix aversin() and acoversin()
In cases where the real value to the inverse versed sine and the
inverse coversed sine function produces a complex value, the
conversion from real to complex was incorrect.

Added c_to_q(COMPLEX *c, bool cfree) to make is easier to convert
a COMPLEX value that is real (imag part is 0) into a NUMBER and
optionally free the COMPLEX value.

The func.c code now uses c_to_q().

NOTE: There is a XXX bug marked in the f_aversin() and f_acoversin()
that still needs to be fixed.
2023-09-05 16:09:22 -07:00
Landon Curt Noll
ed112997a7 improve output of make prep and the #! line of update_ver 2023-09-03 23:50:23 -07:00
Landon Curt Noll
86f1d9e029 add new aversin and acoversin builtin functions.
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
from the local directory, and with reading of the startup scripts
disabled.

Changed "make prep" to perform various tests that are used to
help verify that calc is ready for a release.

Added Makefile testing rule testfuncsort to check for the sort
of the builtin function list.  Changed the order that builtin
functions are listed by "show builtin" and the help/builtin to
match the sorting of "LANG=C LC_ALL=C sort -d -u".
2023-09-03 23:37:09 -07:00
Landon Curt Noll
8edff80826 improve comments for versed sine and coversed sine functions 2023-09-02 23:10:24 -07:00
Landon Curt Noll
b55d41c221 change cal/wf2.cal to cal/write2file.cal
Also fixed Makefile typo.
2023-09-02 21:14:54 -07:00
Landon Curt Noll
df11a211c9 add write2file.cal for an example of how to do file I/O 2023-09-02 21:13:36 -07:00
Landon Curt Noll
20ce75a06d 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.
2023-09-01 23:53:30 -07:00
Landon Curt Noll
7398fbb2e9 rename vercos to coversin
The code to compute 1 - sin(x) belongs to coversin, not vercos.
2023-09-01 23:26:26 -07:00
Landon Curt Noll
b0a48a2b70 add new versin and vercos builtin functions
Added new versin(x, [,eps]) for versed sine and vercos(x, [,eps])
for versed cosine.

Updated trig help files.
2023-09-01 17:38:14 -07:00
Landon Curt Noll
1c839dfede add logn and error checking for invalue eps and epsilon values
Add new logn(x, n [,eps]) builtin to compute logarithms to base n.

Verify that eps arguments (error tolerance arguments that override
the default epsilon value) to builtin functions have proper values.
Previously the eps argument had little to no value checks for
many builtin functions.

Document in help files for builtin functions that take eps arguments,
the LIMIT range for such eps values.
2023-08-31 22:33:41 -07:00
Landon Curt Noll
4787199462 improve check for invalid epsilon
We added check_epsilon(NUMBER *q) so that later, builtin
functions can check the eps value as well.
2023-08-31 03:32:49 -07:00
Landon Curt Noll
b95a62c14e fix setting an invalid epsilon
Setting an invalid epsilon via the epsilon(value) or confiv("epsilon",
value) triggers an error.  The epsilon value must be: 0 < epsilon < 1.
2023-08-31 03:20:38 -07:00
Landon Curt Noll
e021e2130f add calv 3 wish to value.h 2023-08-31 02:15:51 -07:00
Landon Curt Noll
94d4c1ad64 fix Makefile use of ${EXT} for hsrc intermediates
Also improve .gitignore sort comment.  Sort generic excluded patterns
and added *.exe plus library exclusions.
2023-08-31 02:14:56 -07:00
Landon Curt Noll
5659ddbc4e remove CALC2_COMPAT symbol in source code
Removed CALC2_COMPAT in favor of ckecking if MAJOR_VER < 3.

The sign element in a ZVALUE is now of type SIGN, which is either
SB32 when MAJOR_VER < 3, or a bool otherwise.

The len element in a ZVALUE is of type LEN.  LEN type is SB32 when
MAJOR_VER < 3, or a uintptr_t otherwise.

Noted version.h symbols in README.RELEASE instead of CALC2_COMPAT.

Improve .gitignore.  Add excludes of hsrc temporary and test
programs.  Added note about how the list is sorted.
Moved the generic excludes to the top.
2023-08-31 02:02:40 -07:00
Landon Curt Noll
faa93bf085 add calc v3 wishlist for v_type to become an enum 2023-08-31 01:06:55 -07:00
Landon Curt Noll
0d2d5e3df3 add comment about turning off optimizer in .lldbinit 2023-08-31 01:02:21 -07:00
Landon Curt Noll
969e72b5c6 add .lldbinit improve debug comment in Makefile.local 2023-08-31 00:05:49 -07:00
Landon Curt Noll
4dbc4dfe9a add qispowerof2() to qfunc.c, improve log2() code
Change zispowerof2() interaface to take a FULL ptr as the 2nd arg:
zispowerof2(ZVALUE z, FULL *log2).

Added qispowerof2(NUMBER *q, NUMBER **qlog2) to qfunc.c.

Change log2() builtin to use the new qispowerof2() internal interface.

Update LIBRARY to reflect the new zispowerof2() internal interface
and the new qispowerof2() internal interface.
2023-08-27 23:50:44 -07:00
Landon Curt Noll
4e5fcc8812 add log2(x [,eps]) builtin function
Added log2(x [,eps]) builtin function.  When x is an integer
power of 2, log2(x) will return an integer, otherwise it will
return the equivalent of ln(x)/ln(2).
2023-08-27 19:02:37 -07:00
Landon Curt Noll
56c568060a updated ver_calc command line
Removed `-R release_file` and `-r release_file` command
line options from `ver_calc`.  Add `-h` option.  Updated
comments in "README.RELEASE", which serves as the contents
of the calc command "help release".
2023-08-27 16:18:12 -07:00
Landon Curt Noll
61206172f1 add NULL pre firewall to ZVALUE code
The z*.c functions that take pointers that cannot be NULL are checked
for NULL pointers at the beginning of the function.

While calc is not known to pass bogus NULL pointers to ZVALUE related
code, libcalc could be called by external code that might do so by
mistake.  If that happens, math_error() is called with the name of
the function and the name of the arg that was NULL.
2023-08-23 15:46:46 -07:00
Landon Curt Noll
0bb66cff74 change int.h to check MAJOR_VER < 3 when CHK_C is undefined
The int.h will trigger an error when CHK_C is undefined and MAJOR_VER
>= 3.  Improved the int.h error message in this case.

Added some comments and C integers to int.h.
2023-08-23 14:53:15 -07:00
Landon Curt Noll
0353aba275 add int.h
Added int.h as a centeral place for calc integer types and integer macros.

Currently zmath.c includes int.h but does not yet use it.

Added missing ptr type checks to chk_c.c.
2023-08-22 22:37:08 -07:00
Landon Curt Noll
2d5339fc51 update make chk_c rule to form status.chk_c.h
The make chk_c file also forms status.chk_c.h which either
defines CHK_C when the C compiler and select include files
appear to meet calc requirements, or undefines CHK_C
when it does not.
2023-08-21 20:18:30 -07:00
Landon Curt Noll
6abdd8ef3f restore old fake boolean typedef when no <stdbool.h> 2023-08-21 04:05:24 -07:00
Landon Curt Noll
8c6d2b2e07 improve comment about use of += in Makefile.local 2023-08-21 03:59:03 -07:00
Landon Curt Noll
999ad61a78 fix bool.h dependency on have_stdbool.h, make depend 2023-08-21 03:51:28 -07:00
Landon Curt Noll
1cf05b660c add missing min and max checks to chk_c.c 2023-08-21 03:30:31 -07:00
Landon Curt Noll
4fddf82106 add C compiler and C include checks for calc
Fixed have_statfs optional executable file extension ${EXT{ in
the ${UTIL_PROGS} make variable.

Prevented the "fake boolean value" when <stdbool.h> is missing,
from complicating C compilers post c17 standard.

Test if <stdint.h> exists and set HAVE_STDINT_H accordingly
in have_stdint.h.  Added HAVE_STDINT_H to allow one to force
this value.

Test if <inttypes.h> exists and set HAVE_INTTYPES_H accordingly
in have_inttypes.h.  Added HAVE_INTTYPES_H to allow one to force
this value.

Added c_chk.c to check the compiler and C include for calc
requirements.  If you are unable to compile this program, or
if this program when compiles does not exit 0, then your C
compiler and/or C include fails to meet calc requirements.
Compilers that are at least c99 MUST be able to compile this
program such that when run will exit 0.

The "make hsrc" file will attempt to compile and run c_chk and
will warn if the C compiler and/or C include fails to meet
calc requirements.  The "make debug" system will run c_chk -c
to print information about the C compiler and C include.
Currently failure to compile cc_chk.c or c_chk exiting non-0
will just print "WARNING!!" strings to stderr.
2023-08-21 03:10:39 -07:00
Landon Curt Noll
b0aa949ad5 simplify booleans when <stdbool.h> header file is missing 2023-08-19 22:02:16 -07:00
Landon Curt Noll
3c18e6e25b changed C source to use C booleans with backward compatibility
Fix "Under source code control" date for new version.h file.

Sorted the order of symbols printed by "make env".

Test if <stdbool.h> exists and set HAVE_STDBOOL_H accordingly
in have_stdbool.h.  Added HAVE_STDBOOL_H to allow one to force
this value.

Added "bool.h" include file to support use of boolean symbols,
true and false for pre-c99 C compilers.  The "bool.h" include
file defines TRUE as true, FALSE as false, and BOOL as bool:
for backward compatibility.

The sign in a ZVALUE is now of type SIGN, whcih is either
SB32 when CALC2_COMPAT is defined, or a bool.

Replaced in C source, TRUE with true, FALSE with false, and
BOOL with bool.
2023-08-19 19:20:32 -07:00
Landon Curt Noll
e18b715f3f fix function decls for stringrel() and stringcaserel() 2023-08-19 18:20:15 -07:00
Landon Curt Noll
a0687079f4 fix MAXDATA for non-CALC2_COMPAT small pointer case 2023-08-19 17:34:55 -07:00
Landon Curt Noll
91c0c99a2c add CALC2_COMPAT and version.h
Moved calc version definition from version.c to version.h.
Added CALC2_COMPAT, that when defined attempts to maintain calc
version 2 compatibility.  When MAJOR_VER <= 2, CALC2_COMPAT is
defined.  This is anticipation for a future calc version 3 code.
2023-08-19 17:32:42 -07:00
Landon Curt Noll
a7597cdf6f improve use of fposval.h.def warning in Makefile
When `./fposval` fails to form `fposval.h` and
the fallback file `fposval.h.def` is used, issue
a suggestion for how to see the `./fposval` failure.
2023-08-19 16:22:07 -07:00
Landon Curt Noll
4b5c0e7574 fix format of examples in help/log2 and help/logn 2023-08-19 14:14:52 -07:00
Landon Curt Noll
f60a1d6bc5 add PTR_LEN and PTR_BITS to longbits.h
Added PTR_LEN (length of a pointer) and PTR_BITS (bit length
of a pointer) to longbits.h.
2023-08-19 12:53:31 -07:00