mirror of
https://github.com/lcn2/calc.git
synced 2025-08-22 01:23:28 +03:00
Compare commits
158 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e0cd9bb3db | ||
|
f0f6171354 | ||
|
94861cc6d2 | ||
|
286233e28f | ||
|
99ac7836aa | ||
|
6c0c8e0ef6 | ||
|
8aa5f140bf | ||
|
2fcb9a5995 | ||
|
8b018b697d | ||
|
0e269ecd67 | ||
|
a640bc4656 | ||
|
62a95499ef | ||
|
9e92d4a35a | ||
|
459c07b121 | ||
|
ada15fdabc | ||
|
d5de36841a | ||
|
cf419fb329 | ||
|
abf39b34b6 | ||
|
552252371f | ||
|
7570010a04 | ||
|
a9ee753dc6 | ||
|
ca5a81122a | ||
|
554cd97145 | ||
|
806606f284 | ||
|
7c0ebc5887 | ||
|
45665f94a7 | ||
|
cd736fdbd4 | ||
|
f753884008 | ||
|
1d9a4941ce | ||
|
5bde797ba4 | ||
|
ecba35fc26 | ||
|
a4f8f367c3 | ||
|
41b11ab785 | ||
|
3d33c6c6f4 | ||
|
dbd8926022 | ||
|
f7f110b686 | ||
|
ebf065dcb8 | ||
|
6bc0747a71 | ||
|
04861939fc | ||
|
ca0aaa0c3a | ||
|
f5d5319a51 | ||
|
263b8a78ef | ||
|
3c866367c6 | ||
|
09d7080547 | ||
|
f480c8c5df | ||
|
a230431a3b | ||
|
eaec46982d | ||
|
a86d629982 | ||
|
bcbc0cb766 | ||
|
ac0d84eef8 | ||
|
9b4580d861 | ||
|
2085361df1 | ||
|
bf4657c138 | ||
|
1b5636afed | ||
|
7eba99ac29 | ||
|
de6474bf28 | ||
|
55bc690cd1 | ||
|
6dc62c1ab7 | ||
|
0aca07d278 | ||
|
1ab3b2c313 | ||
|
64e2c6a262 | ||
|
eac02835ed | ||
|
33657bb2cc | ||
|
8af0b351ae | ||
|
3260f90a73 | ||
|
b7e15195f9 | ||
|
c02725f036 | ||
|
507fe026e5 | ||
|
486f4c5626 | ||
|
91991bb729 | ||
|
71a116ca6f | ||
|
8b7e01f426 | ||
|
229345ade8 | ||
|
0f902b95cf | ||
|
8684e1be9c | ||
|
ae3a6129b2 | ||
|
2c72570b8d | ||
|
41803b878e | ||
|
a8be58becb | ||
|
067afc140a | ||
|
41128fada9 | ||
|
f5fae012f9 | ||
|
3d25fb30cb | ||
|
8374586275 | ||
|
68c2edf610 | ||
|
d58a55a1ed | ||
|
ccfa797b68 | ||
|
0f030f0759 | ||
|
af59b9dab2 | ||
|
fa173cd9aa | ||
|
1f8269c0e2 | ||
|
51462b8612 | ||
|
9b69648921 | ||
|
c5e416c41f | ||
|
37ad43c7fd | ||
|
a877cb52c0 | ||
|
4bec694df3 | ||
|
4870a7a164 | ||
|
84ccb37bc3 | ||
|
29c6e9325f | ||
|
81a4a4f828 | ||
|
1cdb5172d8 | ||
|
54a7a3f7bc | ||
|
2ea77e6151 | ||
|
5cfa6199e5 | ||
|
da6ccc146f | ||
|
fcfe237375 | ||
|
5fb3db4558 | ||
|
c8705c1198 | ||
|
0558bafcb6 | ||
|
f58277f53d | ||
|
e555a718c0 | ||
|
b29fcf2dd5 | ||
|
4f86703843 | ||
|
07d8bf0f3e | ||
|
b4cd692bae | ||
|
83c898cc2b | ||
|
c585d7aa78 | ||
|
f42a003d04 | ||
|
8da0471f07 | ||
|
1c20261b93 | ||
|
aeb9a9d473 | ||
|
66883b390d | ||
|
ea533659ce | ||
|
9e81971f25 | ||
|
cbbd866535 | ||
|
bf23f82c29 | ||
|
ec5c584785 | ||
|
6bbb8c0e42 | ||
|
438554b0ed | ||
|
61ba4bc5c8 | ||
|
0145883396 | ||
|
f91bfaab70 | ||
|
36ab4fdc1b | ||
|
1cd89398ad | ||
|
bd3a381783 | ||
|
618f42c960 | ||
|
1363b58060 | ||
|
2c659f40ff | ||
|
4c243a69fe | ||
|
f80eee7a09 | ||
|
a044b9325b | ||
|
c028ea478f | ||
|
62bdba6d22 | ||
|
4d9511243c | ||
|
188fd372ea | ||
|
44ffb0eec9 | ||
|
beb13bf89f | ||
|
a31078bbec | ||
|
7ae4f4009c | ||
|
40fc854006 | ||
|
8dd7a3cd2a | ||
|
2726ae9d23 | ||
|
d25186fc52 | ||
|
28d1e35362 | ||
|
1ae2f953d3 | ||
|
ed4b56d1ec | ||
|
cc2f6f7b85 |
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ master ]
|
||||||
|
schedule:
|
||||||
|
- cron: '41 1 * * 6'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'cpp' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
107
.gitignore
vendored
Normal file
107
.gitignore
vendored
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# files and directories created during the building of calc and other Makefile actions
|
||||||
|
#
|
||||||
|
# NOTE: While many of these might be part of a released calc tarball, they are
|
||||||
|
# not consider development source. Some other file(s) and/or programs
|
||||||
|
# generate these files.
|
||||||
|
#
|
||||||
|
.dynamic
|
||||||
|
.hsrc
|
||||||
|
Makefile.simple
|
||||||
|
NOTES
|
||||||
|
align32.h
|
||||||
|
args.h
|
||||||
|
cal/.all
|
||||||
|
calc
|
||||||
|
calc.1
|
||||||
|
calc.usage
|
||||||
|
calcerr.c
|
||||||
|
calcerr.h
|
||||||
|
conf.h
|
||||||
|
cscript/.all
|
||||||
|
cscript/4dsphere
|
||||||
|
cscript/README
|
||||||
|
cscript/fproduct
|
||||||
|
cscript/mersenne
|
||||||
|
cscript/piforever
|
||||||
|
cscript/plus
|
||||||
|
cscript/powerterm
|
||||||
|
cscript/simple
|
||||||
|
cscript/square
|
||||||
|
custom/.all
|
||||||
|
custom/Makefile.simple
|
||||||
|
custom/libcustcalc*
|
||||||
|
endian
|
||||||
|
endian_calc.h
|
||||||
|
fposval.h
|
||||||
|
have_ban_pragma.h
|
||||||
|
have_const.h
|
||||||
|
have_fpos.h
|
||||||
|
have_fpos_pos.h
|
||||||
|
have_getpgid.h
|
||||||
|
have_getprid.h
|
||||||
|
have_getsid.h
|
||||||
|
have_gettime.h
|
||||||
|
have_memmv.h
|
||||||
|
have_newstr.h
|
||||||
|
have_offscl.h
|
||||||
|
have_posscl.h
|
||||||
|
have_rusage.h
|
||||||
|
have_stdlib.h
|
||||||
|
have_stdvs
|
||||||
|
have_strdup.h
|
||||||
|
have_string.h
|
||||||
|
have_strlcat.h
|
||||||
|
have_strlcpy.h
|
||||||
|
have_times.h
|
||||||
|
have_uid_t.h
|
||||||
|
have_unistd.h
|
||||||
|
have_unused.h
|
||||||
|
have_urandom.h
|
||||||
|
have_ustat.h
|
||||||
|
help/.all
|
||||||
|
help/COPYING
|
||||||
|
help/COPYING-LGPL
|
||||||
|
help/binding
|
||||||
|
help/bindings
|
||||||
|
help/bug
|
||||||
|
help/bugs
|
||||||
|
help/builtin
|
||||||
|
help/change
|
||||||
|
help/changes
|
||||||
|
help/contrib
|
||||||
|
help/copy
|
||||||
|
help/cscript
|
||||||
|
help/custom_cal
|
||||||
|
help/errorcode
|
||||||
|
help/errorcodes
|
||||||
|
help/full
|
||||||
|
help/funclist
|
||||||
|
help/funclist.c
|
||||||
|
help/libcalc
|
||||||
|
help/man
|
||||||
|
help/new_custom
|
||||||
|
help/question
|
||||||
|
help/questions
|
||||||
|
help/resource
|
||||||
|
help/type
|
||||||
|
help/usage
|
||||||
|
libcalc*
|
||||||
|
libcustcalc*
|
||||||
|
longbits
|
||||||
|
longbits.h
|
||||||
|
sample_many
|
||||||
|
sample_rand
|
||||||
|
tags
|
||||||
|
terminal.h
|
||||||
|
ver_calc
|
||||||
|
|
||||||
|
# other commonly excluded patterns
|
||||||
|
#
|
||||||
|
*~
|
||||||
|
*.BAK
|
||||||
|
core*
|
||||||
|
.DS_Store
|
||||||
|
*.dSYM/
|
||||||
|
*.[oa]
|
||||||
|
.*.swp
|
||||||
|
*,v
|
139
BUGS
139
BUGS
@@ -1,12 +1,12 @@
|
|||||||
If you notice something wrong, strange or broken, try rereading:
|
If you notice something wrong, strange or broken, try rereading:
|
||||||
|
|
||||||
README.FIRST
|
README.FIRST
|
||||||
HOWTO.INSTALL
|
HOWTO.INSTALL
|
||||||
BUGS (this file)
|
BUGS (this file)
|
||||||
|
|
||||||
If that does not help, cd to the calc source directory and try:
|
If that does not help, cd to the calc source directory and try:
|
||||||
|
|
||||||
make check
|
make check
|
||||||
|
|
||||||
Look at the end of the output, it should say something like:
|
Look at the end of the output, it should say something like:
|
||||||
|
|
||||||
@@ -15,70 +15,113 @@ Look at the end of the output, it should say something like:
|
|||||||
|
|
||||||
If it does not, then something is really broken!
|
If it does not, then something is really broken!
|
||||||
|
|
||||||
|
To be sure that your version of calc is up to date, check out:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-mirror.html
|
||||||
|
|
||||||
If you made and modifications to calc beyond the simple Makefile
|
If you made and modifications to calc beyond the simple Makefile
|
||||||
configuration, try backing them out and see if things get better.
|
configuration, try backing them out and see if things get better.
|
||||||
|
|
||||||
To be sure that your version of calc is up to date, check out:
|
If you have tried all of the above and things still are not right,
|
||||||
|
then it may be time to send in a bug report.
|
||||||
http://www.isthe.com/chongo/tech/comp/calc/calc-download.html
|
|
||||||
|
|
||||||
The calc web site is located at:
|
|
||||||
|
|
||||||
http://www.isthe.com/chongo/tech/comp/calc/index.html
|
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
If you have tried all of the above and things still are not right,
|
The BEST WAY TO SEND IN A BUG REPORT is via calc GitHub issue URL:
|
||||||
then it may be time to send in a bug report. You can send bug
|
|
||||||
and bug fixes reports to:
|
|
||||||
|
|
||||||
calc-bugs at asthe dot com
|
https://github.com/lcn2/calc/issues
|
||||||
|
|
||||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
If you see an existing issue that matches your problem, look
|
||||||
[[ NOTE: The EMail address uses 'asthe', the web site URL uses 'isthe' ]]
|
over the notes and if needed, add your own observation,
|
||||||
|
even if you just add to an existing issue:
|
||||||
|
|
||||||
Your subject must contain the words:
|
I have this issue too
|
||||||
|
|
||||||
calc bug report
|
If you don't see your issue addressed, then on the above
|
||||||
|
GitHub web page, click on this button:
|
||||||
|
|
||||||
You may have additional words in your subject line.
|
((New Issue))
|
||||||
|
|
||||||
When you send your report, please include the following information:
|
=-=
|
||||||
|
|
||||||
* a description of the problem
|
If you prefer to not use GitHub, then you
|
||||||
* the version of calc you are using (if you cannot get calc
|
may send bug and bug fixes reports to:
|
||||||
to run, then send us the 4 #define lines from version.c)
|
|
||||||
* if you modified calc from an official patch, send me the mods you made
|
|
||||||
* the type of system you were using
|
|
||||||
* the type of compiler you were using
|
|
||||||
* any compiler warnings or errors that you saw
|
|
||||||
* cd to the calc source directory, and type:
|
|
||||||
|
|
||||||
make debug > debug.out 2>&1 (sh, ksh, bash users)
|
calc-bugrept-mail at asthe dot com
|
||||||
make debug >& debug.out (csh, tcsh users)
|
|
||||||
|
|
||||||
and send the contents of the 'debug.out' file.
|
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||||
|
|
||||||
Stack traces from core dumps are useful to send as well.
|
NOTE: This replaces the old calc-bugs at asthe dot com address.
|
||||||
|
|
||||||
Fell free to use the above address to send in big fixes (in the form
|
PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line:
|
||||||
|
|
||||||
|
calc bug report
|
||||||
|
|
||||||
|
You may add additional words to your subject line.
|
||||||
|
|
||||||
|
Suggestion:
|
||||||
|
|
||||||
|
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||||
|
may change so verify you have the current info by visiting:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html
|
||||||
|
|
||||||
|
IMPORTANT:
|
||||||
|
|
||||||
|
PLEASE use the above SPECIAL PHRASE somewhere in the Subject line or
|
||||||
|
the mail system won't deliver your Email message.
|
||||||
|
|
||||||
|
Keep in mind that the best way to report on a calc bug is
|
||||||
|
via the above mentioned calc GitHub issue URL.
|
||||||
|
|
||||||
|
Please be patient as we cannot always respond to Email messages quickly.
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
|
When you send your report, via the calc GitHub issue URL or Email,
|
||||||
|
please include the following information:
|
||||||
|
|
||||||
|
* A description of the problem
|
||||||
|
|
||||||
|
* Version of calc you are using
|
||||||
|
|
||||||
|
If you cannot compile calc, then look at version.c
|
||||||
|
and report the #define that start with:
|
||||||
|
|
||||||
|
#define MAJOR_VER
|
||||||
|
#define MINOR_VER
|
||||||
|
#define MAJOR_PATCH
|
||||||
|
#define MINOR_PATCH
|
||||||
|
|
||||||
|
* If you modified calc from an official patch,
|
||||||
|
send us the mods you made
|
||||||
|
|
||||||
|
* Type and version of the operating system
|
||||||
|
|
||||||
|
* Type and version of compiler
|
||||||
|
|
||||||
|
* Send us all compiler warnings or errors you find
|
||||||
|
|
||||||
|
* If calc dumped core, try to send us a core dump stack trace
|
||||||
|
|
||||||
|
* cd to the calc source directory, and send the contents
|
||||||
|
of debug.out produced by this command:
|
||||||
|
|
||||||
|
make debug > debug.out 2>&1
|
||||||
|
|
||||||
|
Fell free to use the above address to send in bug fixes (in the form
|
||||||
of a context diff patch).
|
of a context diff patch).
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
Known bugs:
|
Known bugs in calc:
|
||||||
|
|
||||||
|
The output of the alg_config.cal resource file is bogus.
|
||||||
|
We would welcome a replacement for this code.
|
||||||
|
|
||||||
We are sure some more bugs exist. When you find them, please let
|
We are sure some more bugs exist. When you find them, please let
|
||||||
us know! See the above for details on how to report and were to
|
us know! See the above for details on how to report and were to
|
||||||
EMail your bug reports and hopefully patches to fix them.
|
Email your bug reports and hopefully patches to fix them.
|
||||||
|
|
||||||
=-=
|
|
||||||
|
|
||||||
Problems that have known work-a-rounds:
|
|
||||||
|
|
||||||
* There is a bug in gcc v4.1.0 that causes calc to fail the regression
|
|
||||||
test. The work-a-round is to compile with gcc v4.1.1 or later. This
|
|
||||||
problems was observed on Fedora 5.
|
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
@@ -129,7 +172,9 @@ mis-features in calc:
|
|||||||
|
|
||||||
will not.
|
will not.
|
||||||
|
|
||||||
## Copyright (C) 1999-2013 Landon Curt Noll
|
=-=
|
||||||
|
|
||||||
|
## Copyright (C) 1999-2014,2021 Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -145,10 +190,6 @@ mis-features in calc:
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.2 $
|
|
||||||
## @(#) $Id: BUGS,v 30.2 2013/08/11 01:09:27 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/RCS/BUGS,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1994/03/18 14:06:13
|
## Under source code control: 1994/03/18 14:06:13
|
||||||
## File existed as early as: 1994
|
## File existed as early as: 1994
|
||||||
##
|
##
|
||||||
|
100
CONTRIB-CODE
Normal file
100
CONTRIB-CODE
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
Calc is open source. Contributions of code are welcome.
|
||||||
|
|
||||||
|
We welcome and encourage you to send us:
|
||||||
|
|
||||||
|
* calc resource files (cal/*.cal files)
|
||||||
|
* calc shell scripts (cscript/*.calc files)
|
||||||
|
* builtin functions that you have modified or written, i.e.:
|
||||||
|
assocfunc.c comfunc.c func.c func.h
|
||||||
|
listfunc.c matfunc.c qfunc.c zfunc.c
|
||||||
|
* custom functions that you have modified or written
|
||||||
|
* help files modified or written (help/*)
|
||||||
|
* Makefile improvements (Makefile, */Makefile)
|
||||||
|
* other source code modifications (*.c, *.h)
|
||||||
|
* etc. (* */* :) )
|
||||||
|
|
||||||
|
In order to consider integrating your code, we need:
|
||||||
|
|
||||||
|
* calc version you are working with (please try use the latest version)
|
||||||
|
* new help files or help file patches, if applicable (documentation)
|
||||||
|
* proposed text for the CHANGES file (brief description of what it does)
|
||||||
|
* regress.cal test patch as needed
|
||||||
|
* your source code and/or source code changes (:-))
|
||||||
|
|
||||||
|
If you add functionality to calc, please be sure to modify/patch/add
|
||||||
|
Makefiles, help files, cal/regress.cal test code as well.
|
||||||
|
Regression test cases are vital to maintaining calc's level
|
||||||
|
of correctness and helps us avoid code bug regression.
|
||||||
|
|
||||||
|
Please try to generate a patch against the most recent
|
||||||
|
version of calc, and if you use GitHub, the top of the
|
||||||
|
master branch:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc
|
||||||
|
|
||||||
|
The best way contribute to calc bug is to generate calc
|
||||||
|
GitHub pull request:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc/pulls
|
||||||
|
|
||||||
|
Your code needs to be contributed under either the 2.1 of the GNU
|
||||||
|
Lesser General Public License (LGPL 2.1) or in the public domain.
|
||||||
|
|
||||||
|
If you do not want to use calc GitHub, then send Email to:
|
||||||
|
|
||||||
|
calc-contrib-mail at asthe dot com
|
||||||
|
|
||||||
|
NOTE: Remove spaces and replace 'at' with @, 'dot' with .
|
||||||
|
|
||||||
|
You MUST use following SPECIAL PHRASE in your Email Subject line:
|
||||||
|
|
||||||
|
calc contribution
|
||||||
|
|
||||||
|
You may add additional words to your subject line.
|
||||||
|
|
||||||
|
Suggestion:
|
||||||
|
|
||||||
|
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||||
|
may change so verify you have the current info by visiting:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html
|
||||||
|
|
||||||
|
IMPORTANT: If your Email doesn't contain the above phrase,
|
||||||
|
then we WILL NOT SEE your Email.
|
||||||
|
|
||||||
|
PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line!
|
||||||
|
|
||||||
|
Keep in mind that the best way to report on a calc bug is to use
|
||||||
|
the above mentioned calc GitHub procedure.
|
||||||
|
|
||||||
|
Please be patient as we cannot always respond to Email messages quickly.
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
|
See also the calc wishlist by running the calc command:
|
||||||
|
|
||||||
|
; help wishlist
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
|
## Copyright (C) 1999,2014,2021 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
|
||||||
|
## as published by the Free Software Foundation.
|
||||||
|
##
|
||||||
|
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
|
## Public License for more details.
|
||||||
|
##
|
||||||
|
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
##
|
||||||
|
## Under source code control: 1997/03/09 16:33:22
|
||||||
|
## File existed as early as: 1997
|
||||||
|
##
|
||||||
|
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
|
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
48
COPYING
48
COPYING
@@ -6,16 +6,12 @@ This file is Copyrighted
|
|||||||
|
|
||||||
This file is covered under the following Copyright:
|
This file is covered under the following Copyright:
|
||||||
|
|
||||||
Copyright (C) 1999-2008 Landon Curt Noll
|
Copyright (C) 1999-2021 Landon Curt Noll
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
# @(#) $Revision: 30.4 $
|
|
||||||
# @(#) $Id: COPYING,v 30.4 2013/09/01 20:14:30 chongo Exp $
|
|
||||||
# @(#) $Source: /usr/local/src/bin/calc/RCS/COPYING,v $
|
|
||||||
|
|
||||||
-=-
|
-=-
|
||||||
|
|
||||||
Calc is covered by the GNU Lesser General Public License
|
Calc is covered by the GNU Lesser General Public License
|
||||||
@@ -53,48 +49,6 @@ Calc is covered by the GNU Lesser General Public License
|
|||||||
Boston, MA 02110-1301
|
Boston, MA 02110-1301
|
||||||
USA
|
USA
|
||||||
|
|
||||||
The contact addresses for calc is as follows:
|
|
||||||
|
|
||||||
Web: http://www.isthe.com/chongo/tech/comp/calc/email.html
|
|
||||||
|
|
||||||
To join the low volume calc mailing list. Send a EMail message to:
|
|
||||||
|
|
||||||
calc-tester-request at asthe dot com
|
|
||||||
|
|
||||||
Your subject must contain the words:
|
|
||||||
|
|
||||||
calc mailing list subscription
|
|
||||||
|
|
||||||
You may have additional words in your subject line.
|
|
||||||
|
|
||||||
Your message body (not the subject) should consist of:
|
|
||||||
|
|
||||||
subscribe calc-tester address
|
|
||||||
end
|
|
||||||
name your_full_name
|
|
||||||
|
|
||||||
where ``address'' is your EMail address and ``your_full_name'' is
|
|
||||||
your full name.
|
|
||||||
|
|
||||||
Feel free to follow the name line with additional EMail text as desired.
|
|
||||||
|
|
||||||
-=-
|
|
||||||
|
|
||||||
Calc bug reports and calc bug fixes should be sent to:
|
|
||||||
|
|
||||||
calc-bugs at asthe dot com
|
|
||||||
|
|
||||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
|
||||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
|
||||||
|
|
||||||
Your subject must contain the words:
|
|
||||||
|
|
||||||
calc bug report
|
|
||||||
|
|
||||||
You may have additional words in your subject line.
|
|
||||||
|
|
||||||
-=-
|
|
||||||
|
|
||||||
Calc's relationship to the GNU Lesser General Public License
|
Calc's relationship to the GNU Lesser General Public License
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
273
HOWTO.INSTALL
273
HOWTO.INSTALL
@@ -1,6 +1,18 @@
|
|||||||
|
|
||||||
|
IMPORTANT: Please see the section at the bottom of this file for
|
||||||
|
some important information on Makefiles used in calc.
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# IMPORTANT: DO NOT run GNU make in parallel mode!!! #
|
||||||
|
###################################################################
|
||||||
|
# Unfortunately due to the complex dependency issues between #
|
||||||
|
# Makefile, Makefile.ship and custom/Makefile, parallel GNU make #
|
||||||
|
# is NOT recommended. Sorry (tm Canada) :) #
|
||||||
|
###################################################################
|
||||||
|
|
||||||
Installing calc from the bzip2-ed tarball in 4 easy steps:
|
Installing calc from the bzip2-ed tarball in 4 easy steps:
|
||||||
|
|
||||||
0) If your platform supports i686 RPMs, you may want to go to:
|
(0) If your platform supports i686 RPMs, you may want to go to:
|
||||||
|
|
||||||
http://www.isthe.com/chongo/src/calc/
|
http://www.isthe.com/chongo/src/calc/
|
||||||
|
|
||||||
@@ -25,15 +37,25 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
cd /var/tmp
|
cd /var/tmp
|
||||||
bunzip2 -c /usr/src/redhat/SOURCES/calc-*.tar.bz2 | tar -xvf -
|
bunzip2 -c /usr/src/redhat/SOURCES/calc-*.tar.bz2 | tar -xvf -
|
||||||
|
|
||||||
1) Look at the makefile, and adjust it to suit your needs.
|
(1) Look at the makefile, and adjust it to suit your needs.
|
||||||
|
|
||||||
The top level Makefile and the custom/Makefile require a GNU
|
The top level Makefile and the custom/Makefile require a modern
|
||||||
Make (such as gmake) or an equivalently advanced make. On many
|
Make (such as gmake) or an equivalently advanced make. On many
|
||||||
targets, the default make is sufficent. On FreeBSD for example,
|
targets, the default make is sufficient. On FreeBSD for example,
|
||||||
one must use gmake instead of make.
|
probably want to use gmake instead of make.
|
||||||
|
|
||||||
If your target system does not have GNU Make (or equivalent), then
|
Some report that under macOS, one has to declare the target
|
||||||
you should try using the Makefile.simple and custom/Makefile.simple
|
to be Darwin. So for macOS, one might have to do:
|
||||||
|
|
||||||
|
# for macOS users only, force the target to be Darwin
|
||||||
|
#
|
||||||
|
make target=Darwin clobber
|
||||||
|
make target=Darwin all
|
||||||
|
make target=Darwin chk
|
||||||
|
make target=Darwin install
|
||||||
|
|
||||||
|
If your target system does not have a moderm Makefile (such as gmake),
|
||||||
|
then you should try using the Makefile.simple and custom/Makefile.simple
|
||||||
files:
|
files:
|
||||||
|
|
||||||
mv Makefile Makefile.gmake
|
mv Makefile Makefile.gmake
|
||||||
@@ -46,6 +68,14 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
values should work. If in doubt, follow the 'When in doubt'
|
values should work. If in doubt, follow the 'When in doubt'
|
||||||
suggestion.
|
suggestion.
|
||||||
|
|
||||||
|
If you are using a modern make (such as gmake), you may override
|
||||||
|
any values set in the Mkefile by adding them to Makefile.local
|
||||||
|
using the := directive. For example:
|
||||||
|
|
||||||
|
HAVE_STRING_H:= YES
|
||||||
|
HAVE_TIMES_H:= YES
|
||||||
|
SED:= /usr/local/bin/nsed
|
||||||
|
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
! If you are building under Windoz or a Windoz-like environment !
|
! If you are building under Windoz or a Windoz-like environment !
|
||||||
! (such as Cygwin or DJGPP), read the README.WINDOWS file. !
|
! (such as Cygwin or DJGPP), read the README.WINDOWS file. !
|
||||||
@@ -110,7 +140,7 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
found below, comment out the Linux set and comment in that
|
found below, comment out the Linux set and comment in that
|
||||||
set or edit the gcc set or the common cc set as needed.
|
set or edit the gcc set or the common cc set as needed.
|
||||||
|
|
||||||
You may want to change these Makrfile variables from their defaults:
|
You may want to change these Makefile variables from their defaults:
|
||||||
|
|
||||||
RANLIB
|
RANLIB
|
||||||
|
|
||||||
@@ -138,11 +168,11 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
|
|
||||||
Adjust other Makefile variables as needed.
|
Adjust other Makefile variables as needed.
|
||||||
|
|
||||||
2) build calc:
|
(2) build calc:
|
||||||
|
|
||||||
The top level Makefile and the custom/Makefile require a GNU
|
The top level Makefile and the custom/Makefile require a GNU
|
||||||
Make (such as gmake) or an equivalently advanced make. On many
|
Make (such as gmake) or an equivalently advanced make. On many
|
||||||
targets, the default make is sufficent. On FreeBSD for example,
|
targets, the default make is sufficient. On FreeBSD for example,
|
||||||
one must use gmake instead of make.
|
one must use gmake instead of make.
|
||||||
|
|
||||||
If your target system does not have GNU Make (or equivalent), then
|
If your target system does not have GNU Make (or equivalent), then
|
||||||
@@ -170,7 +200,7 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
make clobber
|
make clobber
|
||||||
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
|
make calc-dynamic-only BLD_TYPE=calc-dynamic-only
|
||||||
|
|
||||||
3) test calc:
|
(3) test calc:
|
||||||
|
|
||||||
make check
|
make check
|
||||||
|
|
||||||
@@ -181,14 +211,223 @@ Installing calc from the bzip2-ed tarball in 4 easy steps:
|
|||||||
|
|
||||||
make chk
|
make chk
|
||||||
|
|
||||||
4) install calc:
|
(4) install calc:
|
||||||
|
|
||||||
make install
|
make install
|
||||||
|
|
||||||
We suggest that you might want to read the README file and look at
|
We suggest that you might want to read the README.FIRST file and look at
|
||||||
the calc help subsystem. See the README file for details.
|
the calc help subsystem. See also the README.md file.
|
||||||
|
|
||||||
## Copyright (C) 1999-2007 Landon Curt Noll
|
=-=
|
||||||
|
|
||||||
|
On calc Makefiles:
|
||||||
|
|
||||||
|
How to tell the origin of of a Makefile:
|
||||||
|
|
||||||
|
The "# SRC: ... - ..." comment line near the top
|
||||||
|
of the file indicates the origin of this file.
|
||||||
|
In each segment below, we indicate what the SRC
|
||||||
|
comment like will read.
|
||||||
|
|
||||||
|
SHELL= ...
|
||||||
|
|
||||||
|
On some systems, /bin/sh is a rather reduced shell with
|
||||||
|
deprecated behavior.
|
||||||
|
|
||||||
|
If your system has a up to date, bash shell, then
|
||||||
|
you may wish to edit the Makefile to use:
|
||||||
|
|
||||||
|
SHELL= /bin/bash
|
||||||
|
|
||||||
|
On some systems such as macOS, the bash shell is very
|
||||||
|
far behind to the point where is cannot be depended on.
|
||||||
|
On such systems, the zsh may be a much better alternative
|
||||||
|
shell for this Makefile to use:
|
||||||
|
|
||||||
|
SHELL= /bin/zsh
|
||||||
|
|
||||||
|
Makefile
|
||||||
|
|
||||||
|
# SRC: Makefile - Our calc build environment
|
||||||
|
|
||||||
|
This is our internal Makefile that drives how we build calc.
|
||||||
|
For critical rules in Makefile.ship, there is a corresponding
|
||||||
|
rule in Makefile that calls ${MAKE} -f Makefile.ship with,
|
||||||
|
additional commands, args and Makefile variables. The ${XVAR}
|
||||||
|
Makefile variable, for example, is passed on each call to
|
||||||
|
${MAKE} -f Makefile.ship so that the environment and parameters of
|
||||||
|
Makefile.ship may be managed for our build environment.
|
||||||
|
|
||||||
|
This Makefile is used to make the calc rpm. In addition to these
|
||||||
|
comments, this Makefile differs from the non-rpm bzip2-ed tarball
|
||||||
|
source Makefile in at least the the following ways:
|
||||||
|
|
||||||
|
CCWERR= -Werror
|
||||||
|
USE_READLINE= -DUSE_READLINE
|
||||||
|
READLINE_LIB= -lreadline -lhistory -lncurses
|
||||||
|
|
||||||
|
If the Makefile is not suitable for you, then
|
||||||
|
you may wish to replace it with Makefile.ship:
|
||||||
|
|
||||||
|
mv -f -v Makefile.ship Makefile
|
||||||
|
|
||||||
|
This Makefile assumes you have a modern make command such as
|
||||||
|
the GNU make. See Makefile.simple comment below if you do not
|
||||||
|
have such a modern make command.
|
||||||
|
|
||||||
|
In packages such as RPMs, and the tar.bz2 source tarball,
|
||||||
|
Makefile contains the contents of Makefile.ship. If Makefile.ship
|
||||||
|
is missing it has likely moved to replace Makefile.
|
||||||
|
|
||||||
|
In the calc GitHub repo, Makefile is the calc build environment
|
||||||
|
and Makefile.ship is the top level Makefile:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc
|
||||||
|
|
||||||
|
Makefile.ship
|
||||||
|
|
||||||
|
# SRC: Makefile.ship - top level Makefile
|
||||||
|
|
||||||
|
This is the main top level Makefile.
|
||||||
|
|
||||||
|
In calc packages such as RPMs, and the tar.bz2 source tarball,
|
||||||
|
Makefile.ship has been moved into Makefile.
|
||||||
|
|
||||||
|
In the calc GitHub repo, Makefile is the calc build environment
|
||||||
|
and Makefile.ship is the top level Makefile:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc
|
||||||
|
|
||||||
|
The Makefile.simple rule of Makefile.ship, when forming the
|
||||||
|
Makefile.simple file, removes lines from Makefile.ship between
|
||||||
|
pairs of '#if 0' AND '#endif':
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
lines removed when forming Makefile.simple
|
||||||
|
...
|
||||||
|
lines removed when forming Makefile.simple
|
||||||
|
#endif
|
||||||
|
|
||||||
|
The '#if 0' AND '#endif' MUST be at the start of the line.
|
||||||
|
Any text after the '#if 0' OR '#endif' is ignored.
|
||||||
|
|
||||||
|
While they may look like a CPP directives, they are not. The
|
||||||
|
inline awk script of the Makefile.simple rule does NOT allow
|
||||||
|
them to nest:
|
||||||
|
|
||||||
|
#if 0 /* DO NOT DO THIS */
|
||||||
|
lines removed when forming Makefile.simple
|
||||||
|
...
|
||||||
|
#if 0 /* DO NOT DO THIS */
|
||||||
|
...
|
||||||
|
#endif /* DO NOT DO THIS */
|
||||||
|
...
|
||||||
|
#endif /* DO NOT DO THIS */
|
||||||
|
|
||||||
|
The custom/Makefile rule of Makefile.ship is used to form
|
||||||
|
the custom/Makefile. In particular the Makefile.ship lines:
|
||||||
|
|
||||||
|
# start of host target cut
|
||||||
|
... these go in between custom/Makefile.head and custom/Makefile.tail
|
||||||
|
# end of host target cut
|
||||||
|
|
||||||
|
Makefile.simple
|
||||||
|
|
||||||
|
# SRC: non-GNU Makefile via make -f Makefile.ship Makefile.simple
|
||||||
|
|
||||||
|
This is a non-GNU or simple Makefile designed for environments
|
||||||
|
that do not have a modern make command.
|
||||||
|
|
||||||
|
If you have a Makefile.simple file, use these commands to
|
||||||
|
form a Makefile:
|
||||||
|
|
||||||
|
if [ -f Makefile ]; then mv -f Makefile Makefile.orig; fi
|
||||||
|
cp Makefile.simple Makefile
|
||||||
|
|
||||||
|
The Makefile.simple rule from Makefile.ship is used to construct
|
||||||
|
this file from the contents of Makefile.ship.
|
||||||
|
|
||||||
|
In calc packages such as RPMs, and the tar.bz2 source the
|
||||||
|
Makefile.simple exists. In the calc GitHub repo:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc
|
||||||
|
|
||||||
|
this file does NOT exist and must be made via the Makefile.simple
|
||||||
|
make rule. Therefore, non-GNU and simple make commands are NOT
|
||||||
|
supported by the calc GitHub repo master branch. Instead, you
|
||||||
|
need to extract Makefile.simple from one of the calc tar.bz2
|
||||||
|
source tarball source from a calc source mirror:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-mirror.html
|
||||||
|
|
||||||
|
custom/Makefile.head
|
||||||
|
|
||||||
|
# SRC: custom/Makefile.head
|
||||||
|
|
||||||
|
This file forms the top part of the custom/Makefile.
|
||||||
|
|
||||||
|
custom/Makefile.tail
|
||||||
|
|
||||||
|
# SRC: custom/Makefile.tail
|
||||||
|
|
||||||
|
This file forms the bottom part of the custom/Makefile.
|
||||||
|
|
||||||
|
custom/Makefile
|
||||||
|
|
||||||
|
# SRC: Makefile via make -f Makefile custom/Makefile
|
||||||
|
|
||||||
|
This is the custom directory Makefile.
|
||||||
|
|
||||||
|
The custom/Makefile rule of Makefile.ship is used to form
|
||||||
|
the custom/Makefile. In particular the Makefile.ship lines:
|
||||||
|
|
||||||
|
# start of host target cut
|
||||||
|
... these go in between custom/Makefile.head and custom/Makefile.tail
|
||||||
|
# end of host target cut
|
||||||
|
|
||||||
|
NOTE: The clobber rule does not remove this file. - XXX
|
||||||
|
|
||||||
|
custom/Makefile.simple
|
||||||
|
|
||||||
|
# SRC: non-GNU Makefile via make -f Makefile custom/Makefile.simple
|
||||||
|
|
||||||
|
This is a non-GNU or simple Makefile for the custom directory
|
||||||
|
that is designed for environments that do not have a modern make
|
||||||
|
command.
|
||||||
|
|
||||||
|
In calc packages such as RPMs, and the tar.bz2 source the
|
||||||
|
Makefile.simple exists. In the calc GitHub repo:
|
||||||
|
|
||||||
|
https://github.com/lcn2/calc
|
||||||
|
|
||||||
|
this file does NOT exist and must be made via the
|
||||||
|
custom/Makefile.simple make rule. Therefore, non-GNU and simple
|
||||||
|
make commands are NOT supported by the calc GitHub repo master
|
||||||
|
branch. Instead, you need to extract custom/Makefile.simple
|
||||||
|
from one of the calc tar.bz2 source tarball source from a calc
|
||||||
|
source mirror:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-mirror.html
|
||||||
|
|
||||||
|
cal/Makefile
|
||||||
|
|
||||||
|
# SRC: cal/Makefile
|
||||||
|
|
||||||
|
The Makefile for the cal sub-directory.
|
||||||
|
|
||||||
|
cscript/Makefile
|
||||||
|
|
||||||
|
# SRC: cscript/Makefile
|
||||||
|
|
||||||
|
The Makefile for the cscript sub-directory.
|
||||||
|
|
||||||
|
help/Makefile
|
||||||
|
|
||||||
|
# SRC: help/Makefile
|
||||||
|
|
||||||
|
The Makefile for the help sub-directory.
|
||||||
|
|
||||||
|
## Copyright (C) 1999-2007,2021 Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -204,10 +443,6 @@ the calc help subsystem. See the README file for details.
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.6 $
|
|
||||||
## @(#) $Id: HOWTO.INSTALL,v 30.6 2007/10/16 12:22:22 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/RCS/HOWTO.INSTALL,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1999/09/27 20:48:44
|
## Under source code control: 1999/09/27 20:48:44
|
||||||
## File existed as early as: 1999
|
## File existed as early as: 1999
|
||||||
##
|
##
|
||||||
|
4
LIBRARY
4
LIBRARY
@@ -638,10 +638,6 @@ need call libcalc_call_me_last() only once.
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.1 $
|
|
||||||
## @(#) $Id: LIBRARY,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/RCS/LIBRARY,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1993/07/30 19:44:49
|
## Under source code control: 1993/07/30 19:44:49
|
||||||
## File existed as early as: 1993
|
## File existed as early as: 1993
|
||||||
##
|
##
|
||||||
|
1
Makefile.local
Normal file
1
Makefile.local
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Add below to override Makefile values (using :=) as in: HAVE_STRING_H:= YES
|
File diff suppressed because it is too large
Load Diff
54
QUESTIONS
Normal file
54
QUESTIONS
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
If you have a simple general question about calc, send Email to:
|
||||||
|
|
||||||
|
calc-quest-mail at asthe dot com
|
||||||
|
|
||||||
|
NOTE: Remove spaces and replace 'at' with @, and 'dot' with .
|
||||||
|
|
||||||
|
PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line:
|
||||||
|
|
||||||
|
calc question
|
||||||
|
|
||||||
|
You may add additional words to your subject line.
|
||||||
|
|
||||||
|
IMPORTANT: If your Email doesn't contain the above phrase,
|
||||||
|
then we WILL NOT SEE your Email.
|
||||||
|
|
||||||
|
PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line!
|
||||||
|
|
||||||
|
Suggestion:
|
||||||
|
|
||||||
|
From time to time, the Email address and Subject SPECIAL PHRASE
|
||||||
|
may change so verify you have the current info by visiting:
|
||||||
|
|
||||||
|
http://www.isthe.com/chongo/tech/comp/calc/calc-question.html
|
||||||
|
|
||||||
|
Please limit your questions to general questions about calc. We
|
||||||
|
cannot go into great detail in our answers, nor can we do your
|
||||||
|
homework, nor can we do much more than answer short general questions
|
||||||
|
about calc.
|
||||||
|
|
||||||
|
Please be patient as we cannot always respond to Email messages quickly.
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
|
## Copyright (C) 2021 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
|
||||||
|
## as published by the Free Software Foundation.
|
||||||
|
##
|
||||||
|
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
|
## Public License for more details.
|
||||||
|
##
|
||||||
|
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
##
|
||||||
|
## Under source code control: 2021/02/10 00:15:05
|
||||||
|
## File existed as early as: 2021
|
||||||
|
##
|
||||||
|
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
|
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -32,30 +32,30 @@ something that you type in.
|
|||||||
|
|
||||||
For list of help topics:
|
For list of help topics:
|
||||||
|
|
||||||
> help
|
; help
|
||||||
|
|
||||||
For overview of calc overview:
|
For overview of calc overview:
|
||||||
|
|
||||||
> help intro
|
; help intro
|
||||||
> help overview
|
; help overview
|
||||||
> help command
|
; help command
|
||||||
> help define
|
; help define
|
||||||
> help statement
|
; help statement
|
||||||
> help variable
|
; help variable
|
||||||
> help usage
|
; help usage
|
||||||
|
|
||||||
For list of builtin functions:
|
For list of builtin functions:
|
||||||
|
|
||||||
> help builtin
|
; help builtin
|
||||||
|
|
||||||
C programmers should note some unexpected differences in the calc syntax:
|
C programmers should note some unexpected differences in the calc syntax:
|
||||||
|
|
||||||
> help unexpected
|
; help unexpected
|
||||||
|
|
||||||
Calc is shipped with a standard collection of calc resource files.
|
Calc is shipped with a standard collection of calc resource files.
|
||||||
For a list of calc standard resource files see:
|
For a list of calc standard resource files see:
|
||||||
|
|
||||||
> help resource
|
; help resource
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
@@ -71,54 +71,33 @@ or run:
|
|||||||
|
|
||||||
for a wish/todo list. Code contributions are welcome.
|
for a wish/todo list. Code contributions are welcome.
|
||||||
|
|
||||||
=-=
|
-=-
|
||||||
|
|
||||||
To join the calc-tester mailing list. Send an EMail message to:
|
If you you notice something wrong, strange or broken, see the file:
|
||||||
|
|
||||||
calc-tester-request at asthe dot com
|
BUGS
|
||||||
|
|
||||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
or run:
|
||||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
|
||||||
|
|
||||||
Your subject must contain the words:
|
calc help bugs
|
||||||
|
|
||||||
calc mailing list subscription
|
for information about how to report a bug.
|
||||||
|
|
||||||
You may have additional words in your subject line.
|
-=-
|
||||||
|
|
||||||
Your message body (not the subject) should consist of:
|
If you have a general question about calc, see the file:
|
||||||
|
|
||||||
subscribe calc-tester address
|
QUESTIONS
|
||||||
end
|
|
||||||
name your_full_name
|
|
||||||
|
|
||||||
where ``address'' is your EMail address and ``your_full_name'' is
|
or run:
|
||||||
your full name.
|
|
||||||
|
|
||||||
Feel free to follow the name line with additional EMail text as desired.
|
calc help questions
|
||||||
|
|
||||||
=-=
|
for information about how to ask a question.
|
||||||
|
|
||||||
Send Calc bug and bug fixes to:
|
-=-
|
||||||
|
|
||||||
calc-bugs at asthe dot com
|
## Copyright (C) 1999,2014,2017,2021 Landon Curt Noll
|
||||||
|
|
||||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
|
||||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
|
||||||
|
|
||||||
but see the BUGS file first.
|
|
||||||
|
|
||||||
Your subject must contain the words:
|
|
||||||
|
|
||||||
calc bug report
|
|
||||||
|
|
||||||
You may have additional words in your subject line.
|
|
||||||
|
|
||||||
The calc web site is located at:
|
|
||||||
|
|
||||||
http://www.isthe.com/chongo/tech/comp/calc/
|
|
||||||
|
|
||||||
## Copyright (C) 1999 Landon Curt Noll
|
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## 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
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -134,10 +113,6 @@ The calc web site is located at:
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.1 $
|
|
||||||
## @(#) $Id: README,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/RCS/README,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1995/10/25 05:27:59
|
## Under source code control: 1995/10/25 05:27:59
|
||||||
## File existed as early as: 1995
|
## File existed as early as: 1995
|
||||||
##
|
##
|
@@ -1,4 +1,4 @@
|
|||||||
Dear calc user on a Windoz based system,
|
Dear calc user on a Windows based system,
|
||||||
|
|
||||||
See the HOWTO.INSTALL file for information on how to build and install calc.
|
See the HOWTO.INSTALL file for information on how to build and install calc.
|
||||||
See also the README file.
|
See also the README file.
|
||||||
@@ -10,6 +10,21 @@ NOTE: The main developers do not have access to a Windoz based platform.
|
|||||||
Of course you are welcome to send us any patches that fix your
|
Of course you are welcome to send us any patches that fix your
|
||||||
Windoz build environment.
|
Windoz build environment.
|
||||||
|
|
||||||
|
|
||||||
|
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||||
|
=-= compiling with Windows Subsystem for Linux (WSL) =-Cygwin =-=
|
||||||
|
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||||
|
|
||||||
|
It has been reported that calc version 2.12.6.4 has been successfully
|
||||||
|
compiled, installed and running on Windows 10 on 2018 Jan 21.
|
||||||
|
|
||||||
|
We were told:
|
||||||
|
|
||||||
|
"The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that
|
||||||
|
enables you to run native Linux command-line tools directly on Windows"
|
||||||
|
|
||||||
|
https://docs.microsoft.com/cs-cz/windows/wsl/about
|
||||||
|
|
||||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||||
=-= compiling with Cygwin =-=
|
=-= compiling with Cygwin =-=
|
||||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||||
@@ -111,7 +126,7 @@ recommends the following settings:
|
|||||||
CATDIR= /dev/env/DJDIR/man/cat1
|
CATDIR= /dev/env/DJDIR/man/cat1
|
||||||
NROFF= groff
|
NROFF= groff
|
||||||
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
CALCPATH= .;./cal;~/.cal;${CALC_SHAREDIR};${CUSTOMCALDIR}
|
||||||
CALCRC= ${CALC_SHAREDIR}/startup;~/.calcrc;./.calcinit
|
CALCRC= ./.calcinit;~/.calcrc;${CALC_SHAREDIR}/startup
|
||||||
CALCPAGER= less.exe -ci
|
CALCPAGER= less.exe -ci
|
||||||
DEBUG= -O2 -gstabs+ -DWINDOZ
|
DEBUG= -O2 -gstabs+ -DWINDOZ
|
||||||
|
|
||||||
@@ -142,10 +157,6 @@ the above Makefile list, follow the recommendation in the Makefile.
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.2 $
|
|
||||||
## @(#) $Id: README.WINDOWS,v 30.2 2009/03/14 02:29:31 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/RCS/README.WINDOWS,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 2001/02/25 14:00:05
|
## Under source code control: 2001/02/25 14:00:05
|
||||||
## File existed as early as: 2001
|
## File existed as early as: 2001
|
||||||
##
|
##
|
||||||
|
263
README.md
Normal file
263
README.md
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
# What is calc?
|
||||||
|
|
||||||
|
Calc is an interactive calculator which provides for easy large
|
||||||
|
numeric calculations, but which also can be easily programmed
|
||||||
|
for difficult or long calculations. It can accept a command line
|
||||||
|
argument, in which case it executes that single command and exits.
|
||||||
|
Otherwise, it enters interactive mode. In this mode, it accepts
|
||||||
|
commands one at a time, processes them, and displays the answers.
|
||||||
|
In the simplest case, commands are simply expressions which are
|
||||||
|
evaluated. For example, the following line can be input:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
3 * (4 + 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
and the calculator will print:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
15
|
||||||
|
```
|
||||||
|
|
||||||
|
Calc has the usual collection of arithmetic operators +, -, /, * as
|
||||||
|
well as ^ (exponentiation), % (modulus) and // (integer divide).
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
3 * 19^43 - 1
|
||||||
|
```
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
29075426613099201338473141505176993450849249622191102976
|
||||||
|
```
|
||||||
|
|
||||||
|
Notice that calc values can be very large. For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
2^23209-1
|
||||||
|
```
|
||||||
|
|
||||||
|
will print:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
402874115778988778181873329071 ... many digits ... 3779264511
|
||||||
|
```
|
||||||
|
|
||||||
|
The special '.' symbol (called dot), represents the result of the
|
||||||
|
last command expression, if any. This is of great use when a series
|
||||||
|
of partial results are calculated, or when the output mode is changed
|
||||||
|
and the last result needs to be redisplayed. For example, the above
|
||||||
|
result can be modified by typing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
. % (2^127-1)
|
||||||
|
```
|
||||||
|
|
||||||
|
and the calculator will print:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
47385033654019111249345128555354223304
|
||||||
|
```
|
||||||
|
|
||||||
|
For more complex calculations, variables can be used to save the
|
||||||
|
intermediate results. For example, the result of adding 7 to the
|
||||||
|
previous result can be saved by typing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curds = 15
|
||||||
|
whey = 7 + 2*curds
|
||||||
|
```
|
||||||
|
|
||||||
|
Functions can be used in expressions. There are a great number of
|
||||||
|
pre-defined functions. For example, the following will calculate
|
||||||
|
the factorial of the value of 'whey':
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fact(whey)
|
||||||
|
```
|
||||||
|
|
||||||
|
and the calculator prints:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
13763753091226345046315979581580902400000000
|
||||||
|
```
|
||||||
|
|
||||||
|
The calculator also knows about complex numbers, so that typing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
(2+3i) * (4-3i)
|
||||||
|
cos(.)
|
||||||
|
```
|
||||||
|
|
||||||
|
will print:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
17+6i
|
||||||
|
-55.50474777265624667147+193.9265235748927986537i
|
||||||
|
```
|
||||||
|
|
||||||
|
The calculator can calculate transcendental functions, and accept and
|
||||||
|
display numbers in real or exponential format. For example, typing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
config("display", 70),
|
||||||
|
epsilon(1e-70),
|
||||||
|
sin(1)
|
||||||
|
```
|
||||||
|
|
||||||
|
prints:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
0.8414709848078965066525023216302989996225630607983710656727517099919104
|
||||||
|
```
|
||||||
|
|
||||||
|
Calc can output values in terms of fractions, octal or hexadecimal.
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
config("mode", "fraction"),
|
||||||
|
(17/19)^23
|
||||||
|
print
|
||||||
|
base(16),
|
||||||
|
(19/17)^29
|
||||||
|
print
|
||||||
|
log(79.3i)
|
||||||
|
```
|
||||||
|
|
||||||
|
will print:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
19967568900859523802559065713/257829627945307727248226067259
|
||||||
|
|
||||||
|
0x9201e65bdbb801eaf403f657efcf863/0x5cd2e2a01291ffd73bee6aa7dcf7d1
|
||||||
|
|
||||||
|
0x17b5164ac24ee836bf/0xc7b7a8e3ef5fcf752+0x883eaf5adadd26be3/0xc7b7a8e3ef5fcf752i
|
||||||
|
```
|
||||||
|
|
||||||
|
All numbers are represented as fractions with arbitrarily large
|
||||||
|
numerators and denominators which are always reduced to lowest terms.
|
||||||
|
Real or exponential format numbers can be input and are converted
|
||||||
|
to the equivalent fraction. Hex, binary, or octal numbers can be
|
||||||
|
input by using numbers with leading '0x', '0b' or '0' characters.
|
||||||
|
Complex numbers can be input using a trailing 'i', as in '2+3i'.
|
||||||
|
Strings and characters are input by using single or double quotes.
|
||||||
|
|
||||||
|
Commands are statements in a C-like language, where each input
|
||||||
|
line is treated as the body of a procedure. Thus the command
|
||||||
|
line can contain variable declarations, expressions, labels,
|
||||||
|
conditional tests, and loops. Assignments to any variable name
|
||||||
|
will automatically define that name as a global variable. The
|
||||||
|
other important thing to know is that all non-assignment expressions
|
||||||
|
which are evaluated are automatically printed. Thus, you can evaluate
|
||||||
|
an expression's value by simply typing it in.
|
||||||
|
|
||||||
|
Many useful built-in mathematical functions are available. Use the:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help builtin
|
||||||
|
```
|
||||||
|
|
||||||
|
command to list them.
|
||||||
|
|
||||||
|
You can also define your own functions by using the 'define' keyword,
|
||||||
|
followed by a function declaration very similar to C.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
define f2(n)
|
||||||
|
{
|
||||||
|
local ans;
|
||||||
|
|
||||||
|
ans = 1;
|
||||||
|
while (n > 1)
|
||||||
|
ans *= (n -= 2);
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Thus the input:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
f2(79)
|
||||||
|
```
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
1009847364737869270905302433221592504062302663202724609375
|
||||||
|
```
|
||||||
|
|
||||||
|
Functions which only need to return a simple expression can be defined
|
||||||
|
using an equals sign, as in the example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
define sc(a,b) = a^3 + b^3
|
||||||
|
```
|
||||||
|
|
||||||
|
Thus the input:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sc(31, 61)
|
||||||
|
```
|
||||||
|
|
||||||
|
will produce:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
256772
|
||||||
|
```
|
||||||
|
|
||||||
|
Variables in functions can be defined as either 'global', 'local',
|
||||||
|
or 'static'. Global variables are common to all functions and the
|
||||||
|
command line, whereas local variables are unique to each function
|
||||||
|
level, and are destroyed when the function returns. Static variables
|
||||||
|
are scoped within single input files, or within functions, and are
|
||||||
|
never destroyed. Variables are not typed at definition time, but
|
||||||
|
dynamically change as they are used.
|
||||||
|
|
||||||
|
For more information about the calc language and features, try:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help overview
|
||||||
|
```
|
||||||
|
|
||||||
|
Calc has a help command that will produce information about
|
||||||
|
every builtin function, command as well as a number of other
|
||||||
|
aspects of calc usage. Try the command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help help
|
||||||
|
```
|
||||||
|
|
||||||
|
for and overview of the help system. The command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help builtin
|
||||||
|
```
|
||||||
|
|
||||||
|
provides information on built-in mathematical functions, whereas:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help asinh
|
||||||
|
```
|
||||||
|
|
||||||
|
will provides information a specific function. The following
|
||||||
|
help files:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help command
|
||||||
|
help define
|
||||||
|
help operator
|
||||||
|
help statement
|
||||||
|
help variable
|
||||||
|
```
|
||||||
|
|
||||||
|
provide a good overview of the calc language. If you are familiar
|
||||||
|
with C, you should also try:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
help unexpected
|
||||||
|
```
|
||||||
|
|
||||||
|
It contains information about differences between C and calc
|
||||||
|
that may surprise C programmers.
|
21
SECURITY.md
Normal file
21
SECURITY.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Use this section to tell people about which versions of your project are
|
||||||
|
currently being supported with security updates.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 5.1.x | :white_check_mark: |
|
||||||
|
| 5.0.x | :x: |
|
||||||
|
| 4.0.x | :white_check_mark: |
|
||||||
|
| < 4.0 | :x: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Use this section to tell people how to report a vulnerability.
|
||||||
|
|
||||||
|
Tell them where to go, how often they can expect to get an update on a
|
||||||
|
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||||
|
declined, etc.
|
10
addop.c
10
addop.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* addop - add opcodes to a function being compiled
|
* addop - add opcodes to a function being compiled
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
|
* Copyright (C) 1999-2007,2021 David I. Bell and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: addop.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/addop.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:48:10
|
* Under source code control: 1990/02/15 01:48:10
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
@@ -32,6 +28,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
|
#include "alloc.h"
|
||||||
#include "opcodes.h"
|
#include "opcodes.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include "func.h"
|
#include "func.h"
|
||||||
@@ -40,6 +37,9 @@
|
|||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
#define FUNCALLOCSIZE 20 /* reallocate size for functions */
|
#define FUNCALLOCSIZE 20 /* reallocate size for functions */
|
||||||
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
#define OPCODEALLOCSIZE 100 /* reallocate size for opcodes in functions */
|
||||||
|
|
||||||
|
10
align32.c
10
align32.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* align32 - determine if 32 bit accesses must be aligned
|
* align32 - determine if 32 bit accesses must be aligned
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: align32.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/align32.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/11/23 05:18:06
|
* Under source code control: 1995/11/23 05:18:06
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -38,6 +34,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
static void buserr(void); /* catch alignment errors */
|
static void buserr(void); /* catch alignment errors */
|
||||||
|
|
||||||
|
|
||||||
|
12
alloc.h
12
alloc.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* alloc - storage allocation and storage debug macros
|
* alloc - storage allocation and storage debug macros
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 David I. Bell
|
* Copyright (C) 1999-2007,2014 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.3 $
|
|
||||||
* @(#) $Id: alloc.h,v 30.3 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/alloc.h,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:48:29
|
* Under source code control: 1990/02/15 01:48:29
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
@@ -28,8 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__ALLOC_H__)
|
#if !defined(INCLUDE_ALLOC_H)
|
||||||
#define __ALLOC_H__
|
#define INCLUDE_ALLOC_H
|
||||||
|
|
||||||
|
|
||||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||||
@@ -92,4 +88,4 @@ E_FUNC int strcmp();
|
|||||||
E_FUNC void *memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n);
|
E_FUNC void *memmove(void *s1, CONST void *s2, MEMMOVE_SIZE_T n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !__ALLOC_H__ */
|
#endif /* !INCLUDE_ALLOC_H */
|
||||||
|
11
assocfunc.c
11
assocfunc.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* assocfunc - association table routines
|
* assocfunc - association table routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 David I. Bell
|
* Copyright (C) 1999-2007,2021 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: assocfunc.c,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/assocfunc.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1993/07/20 23:04:27
|
* Under source code control: 1993/07/20 23:04:27
|
||||||
* File existed as early as: 1993
|
* File existed as early as: 1993
|
||||||
*
|
*
|
||||||
@@ -40,6 +36,9 @@
|
|||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
#define MINHASHSIZE 31 /* minimum size of hash tables */
|
#define MINHASHSIZE 31 /* minimum size of hash tables */
|
||||||
#define GROWHASHSIZE 50 /* approximate growth for hash tables */
|
#define GROWHASHSIZE 50 /* approximate growth for hash tables */
|
||||||
#define CHAINLENGTH 10 /* desired number of elements on a hash chain */
|
#define CHAINLENGTH 10 /* desired number of elements on a hash chain */
|
||||||
@@ -83,7 +82,7 @@ associndex(ASSOC *ap, BOOL create, long dim, VALUE *indices)
|
|||||||
* so that we can first select the correct hash chain, and
|
* so that we can first select the correct hash chain, and
|
||||||
* also so we can quickly compare each element for a match.
|
* also so we can quickly compare each element for a match.
|
||||||
*/
|
*/
|
||||||
hash = FNV1_32_BASIS;
|
hash = QUICKHASH_BASIS;
|
||||||
for (i = 0; i < dim; i++)
|
for (i = 0; i < dim; i++)
|
||||||
hash = hashvalue(&indices[i], hash);
|
hash = hashvalue(&indices[i], hash);
|
||||||
|
|
||||||
|
180
banned.h
Normal file
180
banned.h
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* banned - optionally ban dqngerious functions
|
||||||
|
*
|
||||||
|
* Unless UNBAN is defined, this file will turn the use
|
||||||
|
* of certain dangerous functions into syntax errors.
|
||||||
|
*
|
||||||
|
* In the case of calc, we are motivated in part by the desire for
|
||||||
|
* calc to correctly calculate: even durings extremely long calculations.
|
||||||
|
*
|
||||||
|
* If UNBAN is NOT defined, then calling certain functions
|
||||||
|
* will result in a syntaxc error.
|
||||||
|
*
|
||||||
|
* If we define UNBAN, then the effect of this file is disabled.
|
||||||
|
*
|
||||||
|
* The banned.h attempts to ban the use of certain dangerous functions
|
||||||
|
* that, if improperly used, could compromise the computational integrity
|
||||||
|
* if calculations.
|
||||||
|
*
|
||||||
|
* In the case of calc, we are motivated in part by the desire for calc
|
||||||
|
* to correctly calculate: even durings extremely long calculations.
|
||||||
|
*
|
||||||
|
* If UNBAN is NOT defined, then calling certain functions
|
||||||
|
* will result in a call to a non-existent function (link error).
|
||||||
|
*
|
||||||
|
* While we do NOT encourage defining UNBAN, there may be
|
||||||
|
* a system / compiler environment where re-defining a
|
||||||
|
* function may lead to a fatal compiler complication.
|
||||||
|
* If that happens, consider compiling as:
|
||||||
|
*
|
||||||
|
* make clobber all chk CCBAN=-DUNBAN
|
||||||
|
*
|
||||||
|
* as see if this is a work-a-round.
|
||||||
|
*
|
||||||
|
* If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us!
|
||||||
|
* Please send us a bug report. See the file:
|
||||||
|
*
|
||||||
|
* BUGS
|
||||||
|
*
|
||||||
|
* or the URL:
|
||||||
|
*
|
||||||
|
* http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html
|
||||||
|
*
|
||||||
|
* for how to send us such a bug report.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 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
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* Under source code control: 2021/03/06 21:07:31
|
||||||
|
* File existed as early as: 2021
|
||||||
|
*
|
||||||
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(PRE_HAVE_BAN_PRAGMA_H)
|
||||||
|
#include "have_ban_pragma.h"
|
||||||
|
#endif /* ! PRE_HAVE_BAN_PRAGMA_H */
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(INCLUDE_BANNED_H)
|
||||||
|
#define INCLUDE_BANNED_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we define UNBAN, then the effect of this file is disabled.
|
||||||
|
*/
|
||||||
|
#if !defined(UNBAN)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In the spirit of:
|
||||||
|
*
|
||||||
|
* https://github.com/git/git/blob/master/banned.h
|
||||||
|
*
|
||||||
|
* we will ban the use of certain unsafe functions by turning
|
||||||
|
* then into function calls that do not exist.
|
||||||
|
*
|
||||||
|
* In the case of calc, we are motivated in part by the desire
|
||||||
|
* for calc to correctly calculate: even durings extremely long
|
||||||
|
* calculations.
|
||||||
|
*
|
||||||
|
* If UNBAN is NOT defined, then calling certain functions
|
||||||
|
* will result in a syntaxc error.
|
||||||
|
*
|
||||||
|
* Unlike the above URL, we suggest an alternative function.
|
||||||
|
* In many cases, additional logic is required to use the
|
||||||
|
* alternative function, we cannot simply replace one function
|
||||||
|
* with another.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, strcpy() can lead to buffer overflows.
|
||||||
|
* Use strlcpy() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef strcpy
|
||||||
|
#pragma GCC poison strcpy
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, strcat() can lead to buffer overflows.
|
||||||
|
* Use strlcat() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef strcat
|
||||||
|
#pragma GCC poison strcat
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, strncpy() can lead to buffer overflows.
|
||||||
|
* Use memccpy() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef strncpy
|
||||||
|
#pragma GCC poison strncpy
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, strncat() can lead to buffer overflows.
|
||||||
|
* Use memccpy() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef strncat
|
||||||
|
#pragma GCC poison strncat
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, sprintf() can lead to buffer overflows.
|
||||||
|
* Use snprintf() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef sprintf
|
||||||
|
#pragma GCC poison sprintf
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If one is not careful, vsprintf() can lead to buffer overflows.
|
||||||
|
* Use vsnprintf() instead.
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_PRAGMA_GCC_POSION)
|
||||||
|
#undef vsprintf
|
||||||
|
#pragma GCC poison vsprintf
|
||||||
|
#endif /* HAVE_PRAGMA_GCC_POSION */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX - As of 2021, functions such as:
|
||||||
|
*
|
||||||
|
* gmtime_s
|
||||||
|
* localtime_s
|
||||||
|
* ctime_s
|
||||||
|
* asctime_s
|
||||||
|
*
|
||||||
|
* are not universal. We cannot yet ban the following
|
||||||
|
* functions because we do not have a portable AND
|
||||||
|
* widely available alternative. Therefore we just
|
||||||
|
* have to be extra careful when using:
|
||||||
|
*
|
||||||
|
* gmtime
|
||||||
|
* localtime
|
||||||
|
* ctime
|
||||||
|
* ctime_r
|
||||||
|
* asctime
|
||||||
|
* asctime_r
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !UNBAN */
|
||||||
|
|
||||||
|
#endif /* !INCLUDE_BANNED_H */
|
12
blkcpy.c
12
blkcpy.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* blkcpy - general values and related routines used by the calculator
|
* blkcpy - general values and related routines used by the calculator
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007,2021 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: blkcpy.c,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/blkcpy.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/04/18 20:41:26
|
* Under source code control: 1997/04/18 20:41:26
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
@@ -33,12 +29,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "calc.h"
|
#include "calc.h"
|
||||||
|
#include "alloc.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "blkcpy.h"
|
#include "blkcpy.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copystod - copy num indexed items from source value to destination value
|
* copystod - copy num indexed items from source value to destination value
|
||||||
*
|
*
|
||||||
@@ -1044,7 +1044,7 @@ copyblk2num(BLOCK *sblk, long ssi, long num, NUMBER *dnum, long dsi,
|
|||||||
NUMBER *ret; /* cloned and modified numerator */
|
NUMBER *ret; /* cloned and modified numerator */
|
||||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||||
HALF *swapped; /* byte swapped input data */
|
HALF *swapped; /* byte swapped input data */
|
||||||
unsigned long halflen; /* length of the input ounded up to HALFs */
|
unsigned long halflen; /* length of the input rounded up to HALFs */
|
||||||
HALF *h; /* copy byteswap pointer */
|
HALF *h; /* copy byteswap pointer */
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
#endif
|
#endif
|
||||||
|
12
blkcpy.h
12
blkcpy.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* blkcpy - general values and related routines used by the calculator
|
* blkcpy - general values and related routines used by the calculator
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007,2014 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: blkcpy.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/blkcpy.h,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/04/18 20:41:25
|
* Under source code control: 1997/04/18 20:41:25
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
@@ -30,8 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__BLKCPY_H__)
|
#if !defined(INCLUDE_BLKCPY_H)
|
||||||
#define __BLKCPY_H__
|
#define INCLUDE_BLKCPY_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the main copy gateway function
|
* the main copy gateway function
|
||||||
@@ -59,4 +55,4 @@ E_FUNC int copystr2blk(STRING *, long, long, BLOCK *, long, BOOL);
|
|||||||
E_FUNC int copystr2file(STRING *, long, long, FILEID, long);
|
E_FUNC int copystr2file(STRING *, long, long, FILEID, long);
|
||||||
E_FUNC int copystr2str(STRING *, long, long, STRING *, long);
|
E_FUNC int copystr2str(STRING *, long, long, STRING *, long);
|
||||||
|
|
||||||
#endif /* !__BLKCPY_H__ */
|
#endif /* !INCLUDE_BLKCPY_H */
|
||||||
|
17
block.c
17
block.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* block - fixed, dynamic, fifo and circular memory blocks
|
* block - fixed, dynamic, fifo and circular memory blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007,2021 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: block.c,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/block.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/02/27 00:29:40
|
* Under source code control: 1997/02/27 00:29:40
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
@@ -32,6 +28,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "have_string.h"
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#include "alloc.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "zmath.h"
|
#include "zmath.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -40,6 +41,10 @@
|
|||||||
#include "str.h"
|
#include "str.h"
|
||||||
#include "calcerr.h"
|
#include "calcerr.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
#define NBLOCKCHUNK 16
|
#define NBLOCKCHUNK 16
|
||||||
|
|
||||||
STATIC long nblockcount = 0;
|
STATIC long nblockcount = 0;
|
||||||
@@ -295,7 +300,7 @@ blkrealloc(BLOCK *blk, int newlen, int newchunk)
|
|||||||
* Set the data length
|
* Set the data length
|
||||||
*
|
*
|
||||||
* We also know that the new block is not empty since we have
|
* We also know that the new block is not empty since we have
|
||||||
* already dealth with that case above.
|
* already dealt with that case above.
|
||||||
*
|
*
|
||||||
* After this section of code, limit and datalen will be
|
* After this section of code, limit and datalen will be
|
||||||
* correct in terms of the new type.
|
* correct in terms of the new type.
|
||||||
|
20
block.h
20
block.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* block - fixed, dynamic, fifo and circular memory blocks
|
* block - fixed, dynamic, fifo and circular memory blocks
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 Landon Curt Noll and Ernest Bowen
|
* Copyright (C) 1999-2007,2014,2021 Landon Curt Noll and Ernest Bowen
|
||||||
*
|
*
|
||||||
* Primary author: Landon Curt Noll
|
* Primary author: Landon Curt Noll
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: block.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/block.h,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/02/21 05:03:39
|
* Under source code control: 1997/02/21 05:03:39
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
@@ -31,8 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__BLOCK_H__)
|
#if !defined(INCLUDE_BLOCK_H)
|
||||||
#define __BLOCK_H__
|
#define INCLUDE_BLOCK_H
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -59,7 +55,7 @@
|
|||||||
* blkchunk defaults to BLK_CHUNKSIZE
|
* blkchunk defaults to BLK_CHUNKSIZE
|
||||||
*
|
*
|
||||||
* blkfree(x)
|
* blkfree(x)
|
||||||
* Reduce storage down to 0 octetes.
|
* Reduce storage down to 0 octets.
|
||||||
*
|
*
|
||||||
* size(x)
|
* size(x)
|
||||||
* The length of data stored in the block.
|
* The length of data stored in the block.
|
||||||
@@ -92,7 +88,7 @@
|
|||||||
* blkmove(dest, src, length [, dest_offset [, src_offset]])
|
* blkmove(dest, src, length [, dest_offset [, src_offset]])
|
||||||
* 0 <= length <= blksize(x)
|
* 0 <= length <= blksize(x)
|
||||||
* offset's are restricted in value by block type
|
* offset's are restricted in value by block type
|
||||||
* overlapping moves are handeled correctly
|
* overlapping moves are handled correctly
|
||||||
*
|
*
|
||||||
* blkccpy(dest, src, stopval, length [, dest_offset [, src_offset]])
|
* blkccpy(dest, src, stopval, length [, dest_offset [, src_offset]])
|
||||||
* 0 <= length <= blksize(x)
|
* 0 <= length <= blksize(x)
|
||||||
@@ -108,7 +104,7 @@
|
|||||||
* b = a*k for some integer k >= 1
|
* b = a*k for some integer k >= 1
|
||||||
*
|
*
|
||||||
* scatter(src, dest1, dest2 [, dest3 ] ...)
|
* scatter(src, dest1, dest2 [, dest3 ] ...)
|
||||||
* copy sucessive octets from src into dest1, dest2, ...
|
* copy successive octets from src into dest1, dest2, ...
|
||||||
* restarting with dest1 after end of list
|
* restarting with dest1 after end of list
|
||||||
* stops at end of src
|
* stops at end of src
|
||||||
*
|
*
|
||||||
@@ -188,7 +184,7 @@ EXTERN int blk_debug; /* 0 => debug off */
|
|||||||
/* length of data stored in a block */
|
/* length of data stored in a block */
|
||||||
#define blklen(blk) ((blk)->datalen)
|
#define blklen(blk) ((blk)->datalen)
|
||||||
|
|
||||||
/* block footpint in memory */
|
/* block footprint in memory */
|
||||||
#define blksizeof(blk) ((blk)->maxsize)
|
#define blksizeof(blk) ((blk)->maxsize)
|
||||||
|
|
||||||
/* block allocation chunk size */
|
/* block allocation chunk size */
|
||||||
@@ -222,4 +218,4 @@ E_FUNC int countnblocks(void);
|
|||||||
E_FUNC void shownblocks(void);
|
E_FUNC void shownblocks(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__BLOCK_H__ */
|
#endif /* !INCLUDE_BLOCK_H */
|
||||||
|
51
byteswap.c
51
byteswap.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* byteswap - byte swapping routines
|
* byteswap - byte swapping routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: byteswap.c,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/byteswap.c,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/10/11 04:44:01
|
* Under source code control: 1995/10/11 04:44:01
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -33,6 +29,9 @@
|
|||||||
#include "byteswap.h"
|
#include "byteswap.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "banned.h" /* include after system header <> includes */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* swap_b8_in_HALFs - swap 8 and if needed, 16 bits in an array of HALFs
|
* swap_b8_in_HALFs - swap 8 and if needed, 16 bits in an array of HALFs
|
||||||
*
|
*
|
||||||
@@ -81,7 +80,7 @@ swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a ZVALUE to swap
|
* src - pointer to a ZVALUE to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -127,8 +126,8 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* swap or copy the rest of the ZVALUE elements
|
* swap or copy the rest of the ZVALUE elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->len = (LEN)SWAP_B8_IN_LEN(&dest->len, &src->len);
|
SWAP_B8_IN_LEN(&dest->len, &src->len);
|
||||||
dest->sign = (BOOL)SWAP_B8_IN_BOOL(&dest->sign, &src->sign);
|
SWAP_B8_IN_BOOL(&dest->sign, &src->sign);
|
||||||
} else {
|
} else {
|
||||||
dest->len = src->len;
|
dest->len = src->len;
|
||||||
dest->sign = src->sign;
|
dest->sign = src->sign;
|
||||||
@@ -149,7 +148,7 @@ swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a NUMBER to swap
|
* src - pointer to a NUMBER to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -193,7 +192,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links);
|
SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
@@ -213,7 +212,7 @@ swap_b8_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a COMPLEX to swap
|
* src - pointer to a COMPLEX to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -257,7 +256,7 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_B8_IN_LONG(&dest->links, &src->links);
|
SWAP_B8_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
@@ -317,7 +316,7 @@ swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a ZVALUE to swap
|
* src - pointer to a ZVALUE to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -362,8 +361,8 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* swap or copy the rest of the ZVALUE elements
|
* swap or copy the rest of the ZVALUE elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->len = (LEN)SWAP_B16_IN_LEN(&dest->len, &src->len);
|
SWAP_B16_IN_LEN(&dest->len, &src->len);
|
||||||
dest->sign = (BOOL)SWAP_B16_IN_BOOL(&dest->sign, &src->sign);
|
SWAP_B16_IN_BOOL(&dest->sign, &src->sign);
|
||||||
} else {
|
} else {
|
||||||
dest->len = src->len;
|
dest->len = src->len;
|
||||||
dest->sign = src->sign;
|
dest->sign = src->sign;
|
||||||
@@ -384,7 +383,7 @@ swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a NUMBER to swap
|
* src - pointer to a NUMBER to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -428,7 +427,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links);
|
SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
@@ -448,7 +447,7 @@ swap_b16_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a COMPLEX to swap
|
* src - pointer to a COMPLEX to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -492,7 +491,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_B16_IN_LONG(&dest->links, &src->links);
|
SWAP_B16_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
@@ -512,7 +511,7 @@ swap_b16_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a ZVALUE to swap
|
* src - pointer to a ZVALUE to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -558,8 +557,8 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* swap or copy the rest of the ZVALUE elements
|
* swap or copy the rest of the ZVALUE elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->len = (LEN)SWAP_HALF_IN_LEN(&dest->len, &src->len);
|
SWAP_HALF_IN_LEN(&dest->len, &src->len);
|
||||||
dest->sign = (BOOL)SWAP_HALF_IN_BOOL(&dest->sign, &src->sign);
|
SWAP_HALF_IN_BOOL(&dest->sign, &src->sign);
|
||||||
} else {
|
} else {
|
||||||
dest->len = src->len;
|
dest->len = src->len;
|
||||||
dest->sign = src->sign;
|
dest->sign = src->sign;
|
||||||
@@ -580,7 +579,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a NUMBER to swap
|
* src - pointer to a NUMBER to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -624,7 +623,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links);
|
SWAP_HALF_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
@@ -644,7 +643,7 @@ swap_HALF_in_NUMBER(NUMBER *dest, NUMBER *src, BOOL all)
|
|||||||
* NULL to allocate the storage
|
* NULL to allocate the storage
|
||||||
* src - pointer to a COMPLEX to swap
|
* src - pointer to a COMPLEX to swap
|
||||||
* all - TRUE => swap every element, FALSE => swap only the
|
* all - TRUE => swap every element, FALSE => swap only the
|
||||||
* multiprecision storage
|
* multi-precision storage
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to where the swapped src has been put
|
* pointer to where the swapped src has been put
|
||||||
@@ -688,7 +687,7 @@ swap_HALF_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
|
|||||||
* swap or copy the rest of the NUMBER elements
|
* swap or copy the rest of the NUMBER elements
|
||||||
*/
|
*/
|
||||||
if (all) {
|
if (all) {
|
||||||
dest->links = (long)SWAP_HALF_IN_LONG(&dest->links,&src->links);
|
SWAP_HALF_IN_LONG(&dest->links, &src->links);
|
||||||
} else {
|
} else {
|
||||||
dest->links = src->links;
|
dest->links = src->links;
|
||||||
}
|
}
|
||||||
|
12
byteswap.h
12
byteswap.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* byteswap - byte swapping macros
|
* byteswap - byte swapping macros
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2014 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: byteswap.h,v 30.1 2007/03/16 11:09:46 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/RCS/byteswap.h,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/10/11 04:44:01
|
* Under source code control: 1995/10/11 04:44:01
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -29,8 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__BYTESWAP_H__)
|
#if !defined(INCLUDE_BYTESWAP_H)
|
||||||
#define __BYTESWAP_H__
|
#define INCLUDE_BYTESWAP_H
|
||||||
|
|
||||||
|
|
||||||
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
#if defined(CALC_SRC) /* if we are building from the calc source tree */
|
||||||
@@ -178,4 +174,4 @@
|
|||||||
#endif /* LONG_BITS == 64 */
|
#endif /* LONG_BITS == 64 */
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__BYTESWAP_H__ */
|
#endif /* !INCLUDE_BYTESWAP_H */
|
||||||
|
225
cal/Makefile
225
cal/Makefile
@@ -2,7 +2,15 @@
|
|||||||
#
|
#
|
||||||
# cal - makefile for calc standard resource files
|
# cal - makefile for calc standard resource files
|
||||||
#
|
#
|
||||||
# Copyright (C) 1999-2006 Landon Curt Noll
|
# Copyright (C) 1999-2006,2017,2021 Landon Curt Noll
|
||||||
|
#
|
||||||
|
# SRC: cal/Makefile
|
||||||
|
#
|
||||||
|
# The "# SRC: ... - ..." comment line above indicates
|
||||||
|
# the origin of this file.
|
||||||
|
#
|
||||||
|
# IMPORTANT: Please see the section on Makefiles near the
|
||||||
|
# bottom of the HOWTO.INSTALL file.
|
||||||
#
|
#
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
# 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
|
# the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -18,10 +26,6 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 30.10 $
|
|
||||||
# @(#) $Id: Makefile,v 30.10 2013/09/02 03:02:00 chongo Exp $
|
|
||||||
# @(#) $Source: /usr/local/src/bin/calc/cal/RCS/Makefile,v $
|
|
||||||
#
|
|
||||||
# Under source code control: 1991/07/21 05:00:54
|
# Under source code control: 1991/07/21 05:00:54
|
||||||
# File existed as early as: 1991
|
# File existed as early as: 1991
|
||||||
#
|
#
|
||||||
@@ -31,15 +35,64 @@
|
|||||||
# calculator by David I. Bell with help/mods from others
|
# calculator by David I. Bell with help/mods from others
|
||||||
# Makefile by Landon Curt Noll
|
# Makefile by Landon Curt Noll
|
||||||
|
|
||||||
# required vars
|
|
||||||
|
# The shell used by this Makefile
|
||||||
|
#
|
||||||
|
# On some systems, /bin/sh is a rather reduced shell with
|
||||||
|
# deprecated behavior.
|
||||||
|
#
|
||||||
|
# If your system has a up to date, bash shell, then
|
||||||
|
# you may wish to use:
|
||||||
|
#
|
||||||
|
# SHELL= /bin/bash
|
||||||
|
#
|
||||||
|
# On some systems such as macOS, the bash shell is very
|
||||||
|
# far behind to the point where is cannot be depended on.
|
||||||
|
# On such systems, the zsh may be a much better alternative
|
||||||
|
# shell for this Makefile to use:
|
||||||
|
#
|
||||||
|
# SHELL= /bin/zsh
|
||||||
#
|
#
|
||||||
SHELL= /bin/sh
|
SHELL= /bin/sh
|
||||||
|
#SHELL= /bin/bash
|
||||||
|
#SHELL= /bin/zsh
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
# Normally, the upper level makefile will set these values. We provide
|
# Normally, the upper level makefile will set these values. We provide
|
||||||
# a default here just in case you want to build from this directory.
|
# a default here just in case you want to build from this directory.
|
||||||
####
|
####
|
||||||
|
|
||||||
|
# PREFIX - Top level location for calc
|
||||||
|
#
|
||||||
|
# The PREFIX is often prepended to paths within calc and calc Makefiles.
|
||||||
|
#
|
||||||
|
# Starting with calc v2.13.0.1, nearly all Makefile places that used
|
||||||
|
# /usr/local now use ${PREFIX}. An exception is the olduninstall rule
|
||||||
|
# and, of course, this section. :-)
|
||||||
|
#
|
||||||
|
# NOTE: The ${PREFIX} is not the same as ${T}. The ${T} specifies
|
||||||
|
# a top level directory under which calc installs things.
|
||||||
|
# While usually ${T} is empty, it can be specific path
|
||||||
|
# as if calc where "chrooted" during an install.
|
||||||
|
# The ${PREFIX} value, during install, is a path between
|
||||||
|
# the top level ${T} install directory and the object
|
||||||
|
# such as an include file.
|
||||||
|
#
|
||||||
|
# NOTE: See also, ${T}, below.
|
||||||
|
#
|
||||||
|
# There are some paths that do NOT call under ${PREFIX}, such as
|
||||||
|
# ${CALCPATH}, that include paths not under ${PREFIX}, but those
|
||||||
|
# too are exceptions to this general rule.
|
||||||
|
#
|
||||||
|
# When in doubt, try:
|
||||||
|
#
|
||||||
|
# PREFIX= /usr/local
|
||||||
|
#
|
||||||
|
PREFIX= /usr/local
|
||||||
|
#PREFIX= /usr
|
||||||
|
#PREFIX= /usr/global
|
||||||
|
|
||||||
# Normally certain files depend on the Makefile. If the Makefile is
|
# Normally certain files depend on the Makefile. If the Makefile is
|
||||||
# changed, then certain steps should be redone. If MAKE_FILE is
|
# changed, then certain steps should be redone. If MAKE_FILE is
|
||||||
# set to Makefile, then these files will depend on Makefile. If
|
# set to Makefile, then these files will depend on Makefile. If
|
||||||
@@ -69,11 +122,11 @@ TOP_MAKE_FILE= Makefile
|
|||||||
# INCDIR= /usr/include
|
# INCDIR= /usr/include
|
||||||
#
|
#
|
||||||
|
|
||||||
#INCDIR= /usr/local/include
|
#INCDIR= ${PREFIX}/include
|
||||||
#INCDIR= /dev/env/DJDIR/include
|
#INCDIR= /dev/env/DJDIR/include
|
||||||
INCDIR= /usr/include
|
INCDIR= /usr/include
|
||||||
|
|
||||||
# where to install calc realted things
|
# where to install calc related things
|
||||||
#
|
#
|
||||||
# ${BINDIR} where to install calc binary files
|
# ${BINDIR} where to install calc binary files
|
||||||
# ${LIBDIR} where calc link library (*.a) files are installed
|
# ${LIBDIR} where calc link library (*.a) files are installed
|
||||||
@@ -95,15 +148,15 @@ INCDIR= /usr/include
|
|||||||
# LIBDIR= /usr/lib
|
# LIBDIR= /usr/lib
|
||||||
# CALC_SHAREDIR= /usr/share/calc
|
# CALC_SHAREDIR= /usr/share/calc
|
||||||
#
|
#
|
||||||
#BINDIR= /usr/local/bin
|
#BINDIR= ${PREFIX}/bin
|
||||||
#BINDIR= /dev/env/DJDIR/bin
|
#BINDIR= /dev/env/DJDIR/bin
|
||||||
BINDIR= /usr/bin
|
BINDIR= /usr/bin
|
||||||
|
|
||||||
#LIBDIR= /usr/local/lib
|
#LIBDIR= ${PREFIX}/lib
|
||||||
#LIBDIR= /dev/env/DJDIR/lib
|
#LIBDIR= /dev/env/DJDIR/lib
|
||||||
LIBDIR= /usr/lib
|
LIBDIR= /usr/lib
|
||||||
|
|
||||||
#CALC_SHAREDIR= /usr/local/lib/calc
|
#CALC_SHAREDIR= ${PREFIX}/lib/calc
|
||||||
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
||||||
CALC_SHAREDIR= /usr/share/calc
|
CALC_SHAREDIR= /usr/share/calc
|
||||||
|
|
||||||
@@ -161,55 +214,82 @@ T=
|
|||||||
|
|
||||||
# Makefile debug
|
# Makefile debug
|
||||||
#
|
#
|
||||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||||
# Q= echo internal makefile actions (debug / verbose mode)
|
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||||
|
#
|
||||||
|
# H=@: do not report hsrc file formation progress
|
||||||
|
# H=@ do echo hsrc file formation progress
|
||||||
|
#
|
||||||
|
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
|
||||||
|
# S= full ${CC} output during hsrc file formation
|
||||||
|
#
|
||||||
|
# E= 2>/dev/null slience command stderr during hsrc file formation
|
||||||
|
# E= full command stderr during hsrc file formation
|
||||||
|
#
|
||||||
|
# V=@: do not echo debug statements (quiet mode)
|
||||||
|
# V=@ do echo debug statements (debug / verbose mode)
|
||||||
#
|
#
|
||||||
#Q=
|
#Q=
|
||||||
Q=@
|
Q=@
|
||||||
|
#
|
||||||
|
S= >/dev/null 2>&1
|
||||||
|
#S=
|
||||||
|
#
|
||||||
|
E= 2>/dev/null
|
||||||
|
#E=
|
||||||
|
#
|
||||||
|
#H=@:
|
||||||
|
H=@
|
||||||
|
#
|
||||||
|
V=@:
|
||||||
|
#V=@
|
||||||
|
|
||||||
# standard tools
|
# standard tools
|
||||||
#
|
#
|
||||||
CHMOD= chmod
|
CHMOD= chmod
|
||||||
CMP= cmp
|
CMP= cmp
|
||||||
RM= rm
|
|
||||||
MKDIR= mkdir
|
|
||||||
RMDIR= rmdir
|
|
||||||
CP= cp
|
|
||||||
MV= mv
|
|
||||||
CO= co
|
CO= co
|
||||||
TRUE= true
|
CP= cp
|
||||||
TOUCH= touch
|
FMT= fmt
|
||||||
|
MKDIR= mkdir
|
||||||
|
MV= mv
|
||||||
|
RM= rm
|
||||||
|
RMDIR= rmdir
|
||||||
SED= sed
|
SED= sed
|
||||||
SORT= sort
|
SORT= sort
|
||||||
FMT= fmt
|
TOUCH= touch
|
||||||
|
TRUE= true
|
||||||
|
|
||||||
# The calc files to install
|
# The calc files to install
|
||||||
#
|
#
|
||||||
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
|
# This list is produced by the detaillist rule when no WARNINGS are detected.
|
||||||
#
|
#
|
||||||
# Please use:
|
# Please use:
|
||||||
#
|
#
|
||||||
# make calc_files_list
|
# make calc_files_list
|
||||||
#
|
#
|
||||||
# to keep this list in nice sorted order and to check that these
|
# to keep this list in nice sorted order.
|
||||||
# deailed help files are under RCS control.
|
|
||||||
#
|
#
|
||||||
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
|
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
|
||||||
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
|
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
|
||||||
constants.cal deg.cal dms.cal dotest.cal ellip.cal factorial.cal \
|
constants.cal deg.cal dms.cal dotest.cal ellip.cal factorial.cal \
|
||||||
factorial2.cal gvec.cal hello.cal hms.cal infinities.cal \
|
factorial2.cal gvec.cal hello.cal hms.cal infinities.cal intfile.cal \
|
||||||
intfile.cal intnum.cal lambertw.cal linear.cal lnseries.cal \
|
intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
|
||||||
lucas.cal lucas_chk.cal lucas_tbl.cal mersenne.cal mfactor.cal \
|
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal pell.cal \
|
||||||
mod.cal natnumset.cal pell.cal pi.cal pix.cal pollard.cal poly.cal \
|
pi.cal pix.cal pollard.cal poly.cal prompt.cal psqrt.cal qtime.cal \
|
||||||
prompt.cal psqrt.cal qtime.cal quat.cal randbitrun.cal randmprime.cal \
|
quat.cal randbitrun.cal randmprime.cal randombitrun.cal randomrun.cal \
|
||||||
randombitrun.cal randomrun.cal randrun.cal regress.cal repeat.cal \
|
randrun.cal regress.cal repeat.cal screen.cal seedrandom.cal \
|
||||||
screen.cal seedrandom.cal set8700.cal set8700.line smallfactors.cal \
|
set8700.cal set8700.line smallfactors.cal solve.cal \
|
||||||
solve.cal specialfunctions.cal statistics.cal strings.cal sumsq.cal \
|
specialfunctions.cal statistics.cal strings.cal sumsq.cal sumtimes.cal \
|
||||||
sumtimes.cal surd.cal test1700.cal test2300.cal test2600.cal \
|
surd.cal test1700.cal test2300.cal test2600.cal test2700.cal \
|
||||||
test2700.cal test3100.cal test3300.cal test3400.cal test3500.cal \
|
test3100.cal test3300.cal test3400.cal test3500.cal test4000.cal \
|
||||||
test4000.cal test4100.cal test4600.cal test5100.cal test5200.cal \
|
test4100.cal test4600.cal test5100.cal test5200.cal test8400.cal \
|
||||||
test8400.cal test8500.cal test8600.cal test8900.cal toomcook.cal \
|
test8500.cal test8600.cal test8900.cal toomcook.cal unitfrac.cal \
|
||||||
unitfrac.cal varargs.cal xx_print.cal zeta2.cal
|
varargs.cal xx_print.cal zeta2.cal
|
||||||
|
|
||||||
|
# These calc files are now obsolete and are removed by the install rule.
|
||||||
|
#
|
||||||
|
DEAD_CALC_FILES= lucas_tbl.cal
|
||||||
|
|
||||||
# These files are found (but not built) in the distribution
|
# These files are found (but not built) in the distribution
|
||||||
#
|
#
|
||||||
@@ -236,7 +316,7 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
|||||||
# sub-directory called calc/cal.
|
# sub-directory called calc/cal.
|
||||||
#
|
#
|
||||||
# NOTE: Due to bogus shells found on one common system we must have
|
# NOTE: Due to bogus shells found on one common system we must have
|
||||||
# an non-emoty else clause for every if condition. *sigh*
|
# an non-empty else clause for every if condition. *sigh*
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
|
||||||
@@ -261,19 +341,13 @@ calcliblist:
|
|||||||
#
|
#
|
||||||
calc_files_list:
|
calc_files_list:
|
||||||
${Q} -(find . -mindepth 1 -maxdepth 1 -type f -name '*.cal' -print | \
|
${Q} -(find . -mindepth 1 -maxdepth 1 -type f -name '*.cal' -print | \
|
||||||
while read i; do \
|
while read i; do \
|
||||||
if [ X"$$i" != X"/dev/null" ]; then \
|
echo $$i; \
|
||||||
if [ ! -f RCS/$$i,v ]; then \
|
done; \
|
||||||
echo "WARNING: $$i not under RCS control" 1>&2; \
|
echo '--first_line--'; \
|
||||||
else \
|
echo README; \
|
||||||
echo $$i; \
|
echo set8700.line; \
|
||||||
fi; \
|
echo bindings) | \
|
||||||
fi; \
|
|
||||||
done; \
|
|
||||||
echo '--first_line--'; \
|
|
||||||
echo README; \
|
|
||||||
echo set8700.line; \
|
|
||||||
echo bindings) | \
|
|
||||||
${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
|
${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
|
||||||
${SED} -e '1s/--first_line--/CALC_FILES=/' -e '2,$$s/^/ /' \
|
${SED} -e '1s/--first_line--/CALC_FILES=/' -e '2,$$s/^/ /' \
|
||||||
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
||||||
@@ -301,6 +375,23 @@ clean:
|
|||||||
|
|
||||||
clobber: clean
|
clobber: clean
|
||||||
${RM} -f .all
|
${RM} -f .all
|
||||||
|
-${Q} if [ -e .DS_Store ]; then \
|
||||||
|
echo ${RM} -rf .DS_Store; \
|
||||||
|
${RM} -rf .DS_Store; \
|
||||||
|
fi
|
||||||
|
-${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
||||||
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
|
continue; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "./$$i" ]; then \
|
||||||
|
echo "${RM} -f ./$$i"; \
|
||||||
|
${RM} -f ./$$i; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
# install everything
|
# install everything
|
||||||
#
|
#
|
||||||
@@ -308,8 +399,8 @@ clobber: clean
|
|||||||
#
|
#
|
||||||
install: all
|
install: all
|
||||||
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
||||||
echo ${MKDIR} ${T}${CALC_SHAREDIR}; \
|
echo ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
|
||||||
${MKDIR} ${T}${CALC_SHAREDIR}; \
|
${MKDIR} -p ${T}${CALC_SHAREDIR}; \
|
||||||
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
||||||
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||||
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
||||||
@@ -333,12 +424,38 @@ install: all
|
|||||||
echo "installed ${T}${CALC_SHAREDIR}/$$i"; \
|
echo "installed ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
||||||
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
|
continue; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "./$$i" ]; then \
|
||||||
|
echo "${RM} -f ./$$i"; \
|
||||||
|
${RM} -f ./$$i; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
# Try to remove everything that was installed
|
# Try to remove everything that was installed
|
||||||
#
|
#
|
||||||
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
||||||
#
|
#
|
||||||
uninstall:
|
uninstall:
|
||||||
|
- ${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
||||||
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
|
continue; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
||||||
|
fi; \
|
||||||
|
if [ -e "./$$i" ]; then \
|
||||||
|
echo "${RM} -f ./$$i"; \
|
||||||
|
${RM} -f ./$$i; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
-${Q} for i in ${CALC_FILES} /dev/null; do \
|
-${Q} for i in ${CALC_FILES} /dev/null; do \
|
||||||
if [ "$$i" = "/dev/null" ]; then \
|
if [ "$$i" = "/dev/null" ]; then \
|
||||||
continue; \
|
continue; \
|
||||||
@@ -348,7 +465,7 @@ uninstall:
|
|||||||
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
||||||
echo "cannot uninstall ${T}${CALC_SHAREDIR}/$$i"; \
|
echo "cannot uninstall ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
else \
|
else \
|
||||||
echo "uninstalled ${T}${CALC_SHAREDIR}/$$i"; \
|
echo "un-installed ${T}${CALC_SHAREDIR}/$$i"; \
|
||||||
fi; \
|
fi; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
77
cal/README
77
cal/README
@@ -14,9 +14,12 @@ For example:
|
|||||||
|
|
||||||
; read lucas
|
; read lucas
|
||||||
lucas(h,n) defined
|
lucas(h,n) defined
|
||||||
|
gen_u2(h,n,v1) defined
|
||||||
gen_u0(h,n,v1) defined
|
gen_u0(h,n,v1) defined
|
||||||
|
rodseth_xhn(x,h,n) defined
|
||||||
gen_v1(h,n) defined
|
gen_v1(h,n) defined
|
||||||
ldebug(funct,str) defined
|
ldebug(funct,str) defined
|
||||||
|
legacy_gen_v1(h,n) defined
|
||||||
|
|
||||||
will cause calc to load and execute the 'lucas.cal' resource file.
|
will cause calc to load and execute the 'lucas.cal' resource file.
|
||||||
Executing the resource file will cause several functions to be defined.
|
Executing the resource file will cause several functions to be defined.
|
||||||
@@ -35,12 +38,7 @@ Calc resource file files are provided because they serve as examples of
|
|||||||
how use the calc language, and/or because the authors thought them to
|
how use the calc language, and/or because the authors thought them to
|
||||||
be useful!
|
be useful!
|
||||||
|
|
||||||
If you write something that you think is useful, please send it to:
|
=-=
|
||||||
|
|
||||||
calc-contrib at asthe dot com
|
|
||||||
|
|
||||||
[[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
|
||||||
[[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
|
|
||||||
|
|
||||||
By convention, a resource file only defines and/or initializes functions,
|
By convention, a resource file only defines and/or initializes functions,
|
||||||
objects and variables. (The regress.cal and testxxx.cal regression test
|
objects and variables. (The regress.cal and testxxx.cal regression test
|
||||||
@@ -215,12 +213,12 @@ brentsolve.cal
|
|||||||
|
|
||||||
brentsolve(low, high,eps)
|
brentsolve(low, high,eps)
|
||||||
|
|
||||||
A root-finder implementwed with the Brent-Dekker trick.
|
A root-finder implemented with the Brent-Dekker trick.
|
||||||
|
|
||||||
brentsolve2(low, high,which,eps)
|
brentsolve2(low, high,which,eps)
|
||||||
|
|
||||||
The second function, brentsolve2(low, high,which,eps) has some lines
|
The second function, brentsolve2(low, high,which,eps) has some lines
|
||||||
added to make it easier to hardcode the name of the helper function
|
added to make it easier to hard-code the name of the helper function
|
||||||
different from the obligatory "f".
|
different from the obligatory "f".
|
||||||
|
|
||||||
See:
|
See:
|
||||||
@@ -394,7 +392,7 @@ factorial2.cal
|
|||||||
|
|
||||||
bigcatalan(n)
|
bigcatalan(n)
|
||||||
|
|
||||||
Calculates the n-th Catalan number for n large. It is usefull
|
Calculates the n-th Catalan number for n large. It is useful
|
||||||
above n~50,000 but defaults to the builtin function for smaller
|
above n~50,000 but defaults to the builtin function for smaller
|
||||||
values.Meant as a complete replacement for catalan(n) with only a
|
values.Meant as a complete replacement for catalan(n) with only a
|
||||||
very small overhead. See:
|
very small overhead. See:
|
||||||
@@ -435,9 +433,9 @@ factorial2.cal
|
|||||||
k = 0
|
k = 0
|
||||||
|
|
||||||
The other function stirling2caching(n,m) does it by way of the
|
The other function stirling2caching(n,m) does it by way of the
|
||||||
reccurence relation and keeps all earlier results. This function
|
re-occurrence relation and keeps all earlier results. This function
|
||||||
is much slower for computing a single value than stirling2(n,m) but
|
is much slower for computing a single value than stirling2(n,m) but
|
||||||
is very usefull if many Stirling numbers are needed, for example in
|
is very useful if many Stirling numbers are needed, for example in
|
||||||
a series. See:
|
a series. See:
|
||||||
|
|
||||||
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
|
http://en.wikipedia.org/wiki/Stirling_numbers_of_the_second_kind
|
||||||
@@ -548,7 +546,7 @@ infinities.cal
|
|||||||
pinf()
|
pinf()
|
||||||
|
|
||||||
The symbolic handling of infinities. Needed for intnum.cal but might be
|
The symbolic handling of infinities. Needed for intnum.cal but might be
|
||||||
usefull elsewhere, too.
|
useful elsewhere, too.
|
||||||
|
|
||||||
|
|
||||||
intfile.cal
|
intfile.cal
|
||||||
@@ -597,13 +595,13 @@ intnum.cal
|
|||||||
This file offers some methods for numerical integration. Implemented are
|
This file offers some methods for numerical integration. Implemented are
|
||||||
the Gauss-Legendre and the tanh-sinh quadrature.
|
the Gauss-Legendre and the tanh-sinh quadrature.
|
||||||
|
|
||||||
All functions are usefull to some extend but the main function for
|
All functions are useful to some extend but the main function for
|
||||||
quadrature is quad(), which is not much more than an abstraction layer.
|
quadrature is quad(), which is not much more than an abstraction layer.
|
||||||
|
|
||||||
The main workers are quadgl() for Gauss-legendre and quadts() for the
|
The main workers are quadgl() for Gauss-Legendre and quadts() for the
|
||||||
tanh-sinh quadrature. The limits of the integral can be anything in the
|
tanh-sinh quadrature. The limits of the integral can be anything in the
|
||||||
complex plane and the extended real line. The latter means that infinite
|
complex plane and the extended real line. The latter means that infinite
|
||||||
limits are supported by way of the smbolic infinities implemented in the
|
limits are supported by way of the symbolic infinities implemented in the
|
||||||
file infinities.cal (automatically linked in by intnum.cal).
|
file infinities.cal (automatically linked in by intnum.cal).
|
||||||
|
|
||||||
Integration in parts and contour is supported by the "points" argument
|
Integration in parts and contour is supported by the "points" argument
|
||||||
@@ -663,7 +661,7 @@ intnum.cal
|
|||||||
|
|
||||||
The quad*core functions do not offer anything fancy but the third parameter
|
The quad*core functions do not offer anything fancy but the third parameter
|
||||||
controls the so called "order" which is just the number of nodes computed.
|
controls the so called "order" which is just the number of nodes computed.
|
||||||
This can be quite usefull in some circumstances.
|
This can be quite useful in some circumstances.
|
||||||
|
|
||||||
; quadgldeletenodes()
|
; quadgldeletenodes()
|
||||||
; define f(x){ return exp(x);}
|
; define f(x){ return exp(x);}
|
||||||
@@ -725,7 +723,7 @@ lambertw.cal
|
|||||||
ProductLog[branch,z] with the tested values.
|
ProductLog[branch,z] with the tested values.
|
||||||
|
|
||||||
The series is only valid for the branches 0,-1, real z, converges
|
The series is only valid for the branches 0,-1, real z, converges
|
||||||
for values of z _very_ near the branchpoint -exp(-1) only, and must
|
for values of z _very_ near the branch-point -exp(-1) only, and must
|
||||||
be given the branches explicitly. See the code in lambertw.cal
|
be given the branches explicitly. See the code in lambertw.cal
|
||||||
for further information.
|
for further information.
|
||||||
|
|
||||||
@@ -748,7 +746,7 @@ lnseries.cal
|
|||||||
does so by computing the prime factorization of all of the number
|
does so by computing the prime factorization of all of the number
|
||||||
sequence 1,2,3...n, calculates the natural logarithms of the primes
|
sequence 1,2,3...n, calculates the natural logarithms of the primes
|
||||||
in 1,2,3...n and uses the above factorization to build the natural
|
in 1,2,3...n and uses the above factorization to build the natural
|
||||||
logarithms of the rest of the sequence by sadding the logarithms of
|
logarithms of the rest of the sequence by adding the logarithms of
|
||||||
the primes in the factorization. This is faster for high precision
|
the primes in the factorization. This is faster for high precision
|
||||||
of the logarithms and/or long sequences.
|
of the logarithms and/or long sequences.
|
||||||
|
|
||||||
@@ -760,7 +758,27 @@ lucas.cal
|
|||||||
|
|
||||||
lucas(h, n)
|
lucas(h, n)
|
||||||
|
|
||||||
Perform a primality test of h*2^n-1, with 1<=h<2*n.
|
Perform a primality test of h*2^n-1.
|
||||||
|
|
||||||
|
gen_u2(h, n, v1)
|
||||||
|
|
||||||
|
Generate u(2) for h*2^n-1. This function is used by lucas(h, n),
|
||||||
|
as the first term in the lucas sequence that is needed to
|
||||||
|
prove that h*2^n-1 is prime or not prime.
|
||||||
|
|
||||||
|
NOTE: Some call this term u(0). The function gen_u0(h, n, v1)
|
||||||
|
simply calls gen_u2(h, n, v1) for such people. :-)
|
||||||
|
|
||||||
|
gen_v1(h, v)
|
||||||
|
|
||||||
|
Generate v(1) for h*2^n-1. This function is used by lucas(h, n),
|
||||||
|
via the gen_u2(h, n, v1), to supply the 3rd argument to gen_u2.
|
||||||
|
|
||||||
|
legacy_gen_v1(h, n)
|
||||||
|
|
||||||
|
Generate v(1) for h*2^n-1 using the legacy Amdahl 6 method.
|
||||||
|
This function sometimes returns -1 for a few cases when
|
||||||
|
h is a multiple of 3. This function is NOT used by lucas(h, n).
|
||||||
|
|
||||||
|
|
||||||
lucas_chk.cal
|
lucas_chk.cal
|
||||||
@@ -773,11 +791,6 @@ lucas_chk.cal
|
|||||||
Used by regress.cal during the 2100 test set.
|
Used by regress.cal during the 2100 test set.
|
||||||
|
|
||||||
|
|
||||||
lucas_tbl.cal
|
|
||||||
|
|
||||||
Lucasian criteria for primality tables.
|
|
||||||
|
|
||||||
|
|
||||||
mersenne.cal
|
mersenne.cal
|
||||||
|
|
||||||
mersenne(p)
|
mersenne(p)
|
||||||
@@ -793,7 +806,7 @@ mfactor.cal
|
|||||||
at 2*start_k*n+1. Skips values that are multiples of primes <= p_elim.
|
at 2*start_k*n+1. Skips values that are multiples of primes <= p_elim.
|
||||||
By default, start_k == 1, rept_loop = 10000 and p_elim = 17.
|
By default, start_k == 1, rept_loop = 10000 and p_elim = 17.
|
||||||
|
|
||||||
The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and
|
The p_elim == 17 overhead takes ~3 minutes on an 200 MHz r4k CPU and
|
||||||
requires about ~13 Megs of memory. The p_elim == 13 overhead
|
requires about ~13 Megs of memory. The p_elim == 13 overhead
|
||||||
takes about 3 seconds and requires ~1.5 Megs of memory.
|
takes about 3 seconds and requires ~1.5 Megs of memory.
|
||||||
|
|
||||||
@@ -1304,7 +1317,7 @@ specialfunctions.cal
|
|||||||
http://en.wikipedia.org/wiki/Polygamma
|
http://en.wikipedia.org/wiki/Polygamma
|
||||||
http://dlmf.nist.gov/5
|
http://dlmf.nist.gov/5
|
||||||
|
|
||||||
for information on the n-th derivative ofthe Euler gamma function. This
|
for information on the n-th derivative of the Euler gamma function. This
|
||||||
function depends on the script zeta2.cal.
|
function depends on the script zeta2.cal.
|
||||||
|
|
||||||
|
|
||||||
@@ -1321,7 +1334,7 @@ specialfunctions.cal
|
|||||||
|
|
||||||
zeta(s)
|
zeta(s)
|
||||||
|
|
||||||
Calculates the value of the Rieman Zeta function at s. See:
|
Calculates the value of the Riemann Zeta function at s. See:
|
||||||
|
|
||||||
http://en.wikipedia.org/wiki/Riemann_zeta_function
|
http://en.wikipedia.org/wiki/Riemann_zeta_function
|
||||||
http://dlmf.nist.gov/25.2
|
http://dlmf.nist.gov/25.2
|
||||||
@@ -1340,7 +1353,7 @@ statistics.cal
|
|||||||
invbetainc(x,a,b)
|
invbetainc(x,a,b)
|
||||||
|
|
||||||
Computes the inverse of the regularized beta function. Does so the
|
Computes the inverse of the regularized beta function. Does so the
|
||||||
brute-force way wich makes it a bit slower.
|
brute-force way which makes it a bit slower.
|
||||||
|
|
||||||
betapdf(x,a,b)
|
betapdf(x,a,b)
|
||||||
betacdf(x,a,b)
|
betacdf(x,a,b)
|
||||||
@@ -1420,7 +1433,7 @@ sumtimes.cal
|
|||||||
Give the user CPU time for various ways of evaluating sums, sums of
|
Give the user CPU time for various ways of evaluating sums, sums of
|
||||||
squares, etc, for large lists and matrices. N is the size of
|
squares, etc, for large lists and matrices. N is the size of
|
||||||
the list or matrix to use. The doalltimes() function will run
|
the list or matrix to use. The doalltimes() function will run
|
||||||
all fo the sumtimes tests. For example:
|
all of the sumtimes tests. For example:
|
||||||
|
|
||||||
doalltimes(1e6);
|
doalltimes(1e6);
|
||||||
|
|
||||||
@@ -1766,7 +1779,7 @@ zeta2.cal
|
|||||||
for information on this special zeta function.
|
for information on this special zeta function.
|
||||||
|
|
||||||
|
|
||||||
## Copyright (C) 2000 David I. Bell and Landon Curt Noll
|
## Copyright (C) 2000,2014,2017,2021 David I. Bell and Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Primary author: Landon Curt Noll
|
## Primary author: Landon Curt Noll
|
||||||
##
|
##
|
||||||
@@ -1784,10 +1797,6 @@ zeta2.cal
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.8 $
|
|
||||||
## @(#) $Id: README,v 30.8 2013/09/02 01:46:05 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/cal/RCS/README,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1990/02/15 01:50:32
|
## Under source code control: 1990/02/15 01:50:32
|
||||||
## File existed as early as: before 1990
|
## File existed as early as: before 1990
|
||||||
##
|
##
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* alg_config - help determine optimal values for algorithm levels
|
* alg_config - help determine optimal values for algorithm levels
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006 Landon Curt Noll
|
* Copyright (C) 2006,2014,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: alg_config.cal,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/alg_config.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2006/06/07 14:10:11
|
* Under source code control: 2006/06/07 14:10:11
|
||||||
* File existed as early as: 2006
|
* File existed as early as: 2006
|
||||||
*
|
*
|
||||||
@@ -28,8 +24,37 @@
|
|||||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static test_time; /* try for this many seconds in loop test */
|
||||||
|
|
||||||
global test_time; /* try for this many seconds in loop test */
|
|
||||||
|
/*
|
||||||
|
* close_to_one - set to 1 if the ratio is close enough to 1
|
||||||
|
*
|
||||||
|
* given:
|
||||||
|
* ratio the ratio of time between two algorithms
|
||||||
|
*
|
||||||
|
* returns:
|
||||||
|
* 1 When ratio is near 1.0
|
||||||
|
* 0 otherwise
|
||||||
|
*
|
||||||
|
* We consider the range [0.995, 1.005] to be close enough to 1 to be call unity
|
||||||
|
* because of the precision of the CPU timing.
|
||||||
|
*/
|
||||||
|
define close_to_one(ratio)
|
||||||
|
{
|
||||||
|
/* firewall */
|
||||||
|
if (!isreal(ratio)) {
|
||||||
|
quit "close: 1st arg: must be a real number";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if the ratio is far from unity */
|
||||||
|
if ((ratio < 0.995) || (ratio > 1.005)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we are close to unity */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -143,7 +168,7 @@ define mul_loop(repeat, x)
|
|||||||
* len length in BASEB-bit words to multiply
|
* len length in BASEB-bit words to multiply
|
||||||
*
|
*
|
||||||
* return:
|
* return:
|
||||||
* ratio of (1st / 2nd) algorithm rate
|
* ratio of (1st / 2nd) algorithm rate.
|
||||||
*
|
*
|
||||||
* When want to determine a rate to a precision of 1 part in 1000.
|
* When want to determine a rate to a precision of 1 part in 1000.
|
||||||
* Most systems today return CPU time to at least 10 msec precision.
|
* Most systems today return CPU time to at least 10 msec precision.
|
||||||
@@ -166,6 +191,7 @@ define mul_ratio(len)
|
|||||||
local tover; /* est of time for loop overhead */
|
local tover; /* est of time for loop overhead */
|
||||||
local alg1_rate; /* loop rate of 1st algorithm */
|
local alg1_rate; /* loop rate of 1st algorithm */
|
||||||
local alg2_rate; /* loop rate of 2nd algorithm */
|
local alg2_rate; /* loop rate of 2nd algorithm */
|
||||||
|
local ret; /* return ratio, or 1.0 */
|
||||||
local i;
|
local i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -218,12 +244,12 @@ define mul_ratio(len)
|
|||||||
* determine the 1st algorithm rate
|
* determine the 1st algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg1 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
printf("\t will try alg1 %d loops\n", loops);
|
printf("\t will try alg1 %d loops\n", loops);
|
||||||
@@ -264,12 +290,12 @@ define mul_ratio(len)
|
|||||||
* determine the 2nd algorithm rate
|
* determine the 2nd algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg2 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
tlen = mul_loop(loops, &x);
|
tlen = mul_loop(loops, &x);
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
@@ -298,7 +324,12 @@ define mul_ratio(len)
|
|||||||
/*
|
/*
|
||||||
* return alg1 / alg2 rate ratio
|
* return alg1 / alg2 rate ratio
|
||||||
*/
|
*/
|
||||||
return (alg1_rate / alg2_rate);
|
ret = alg1_rate / alg2_rate;
|
||||||
|
if (config("user_debug") > 2) {
|
||||||
|
printf("\tprecise ratio is: %.f mul_ratio will return: %.3f\n",
|
||||||
|
alg1_rate / alg2_rate, ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,30 +351,40 @@ define best_mul2()
|
|||||||
{
|
{
|
||||||
local ratio; /* previously calculated alg1/alg2 ratio */
|
local ratio; /* previously calculated alg1/alg2 ratio */
|
||||||
local low; /* low loop value tested */
|
local low; /* low loop value tested */
|
||||||
local high; /* low loop value tested */
|
local high; /* high loop value tested */
|
||||||
|
local mid; /* between low and high */
|
||||||
|
local best_val; /* value found with ratio closest to unity */
|
||||||
|
local best_ratio; /* closest ratio found to unity */
|
||||||
local expand; /* how fast to expand the length */
|
local expand; /* how fast to expand the length */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup
|
* setup
|
||||||
*/
|
*/
|
||||||
test_time = 15.0;
|
printf("WARNING: This tool may not be computing the correct best value\n");
|
||||||
if (config("user_debug") > 0) {
|
test_time = 5.0;
|
||||||
printf("will start with loop test time of %d secs\n", test_time);
|
printf("The best_mul2() function will take a LONG time to run!\n");
|
||||||
|
printf("It is important that best_mul2() run on an otherwise idle host!\n");
|
||||||
|
if (config("user_debug") <= 0) {
|
||||||
|
printf("To monitor progress, set user_debug to 2: "
|
||||||
|
"config(\"user_debug\", 2)\n");
|
||||||
}
|
}
|
||||||
|
printf("Starting with loop test time of %d secs\n", test_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* firewall - must have a >1 ratio for the initial length
|
* firewall - must have a >1 ratio for the initial length
|
||||||
*/
|
*/
|
||||||
high = 16;
|
high = 8;
|
||||||
|
best_val = high;
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing multiply alg1/alg2 ratio for len = %d\n", high);
|
printf("testing multiply alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = mul_ratio(high);
|
ratio = mul_ratio(high);
|
||||||
|
best_ratio = ratio;
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" multiply alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" multiply alg1/alg2 ratio = %.6f\n", ratio);
|
||||||
}
|
}
|
||||||
if (ratio <= 1.0) {
|
if (ratio < 1.0) {
|
||||||
quit "best_mul2: tests imply config(\"mul2\") should be < 4";
|
quit "best_mul2: tests imply mul2 should be < 16, which seems bogus";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -351,12 +392,12 @@ define best_mul2()
|
|||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
/*
|
/*
|
||||||
* determine the paramters of the next ratio test
|
* determine the parameters of the next ratio test
|
||||||
*
|
*
|
||||||
* We will multiplicatively expand our test level until
|
* We will multiplicatively expand our test level until
|
||||||
* the ratio drops below 1.0.
|
* the ratio drops below 1.0.
|
||||||
*/
|
*/
|
||||||
expand = ((ratio >= 3.5) ? 16 : 2^round(ratio));
|
expand = 2;
|
||||||
low = high;
|
low = high;
|
||||||
high *= expand;
|
high *= expand;
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
@@ -368,20 +409,64 @@ define best_mul2()
|
|||||||
* determine the alg1/alg2 test ratio for this new length
|
* determine the alg1/alg2 test ratio for this new length
|
||||||
*/
|
*/
|
||||||
if (high >= 2^31) {
|
if (high >= 2^31) {
|
||||||
quit "best_mul2: tests imply config(\"mul2\") should be >= 2^31";
|
quit "best_mul2: test implies mul2 >= 2^31, which seems bogus";
|
||||||
}
|
}
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing multiply alg1/alg2 ratio for len = %d\n", high);
|
printf("testing multiply alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = mul_ratio(high);
|
ratio = mul_ratio(high);
|
||||||
if (config("user_debug") > 1) {
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
printf(" multiply alg1/alg2 ratio = %.3f\n", ratio);
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (ratio >= 1.0);
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" multiply alg1/alg2 ratio = %.6f\n", ratio);
|
||||||
|
}
|
||||||
|
} while (ratio > 1.0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we previously expanded more than by a factor of 2, then
|
||||||
|
* we may have jumped over the crossover point. So now
|
||||||
|
* drop down powers of two until the ratio is again >= 1.0
|
||||||
|
*/
|
||||||
|
if (expand > 2) {
|
||||||
|
do {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* contract by 2
|
||||||
|
*/
|
||||||
|
high /= 2;
|
||||||
|
low = high / 2;
|
||||||
|
if (config("user_debug") > 0) {
|
||||||
|
printf("re-testing multiply alg1/alg2 ratio for len = %d\n",
|
||||||
|
high);
|
||||||
|
}
|
||||||
|
ratio = mul_ratio(high);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio "
|
||||||
|
"to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" multiply alg1/alg2 ratio = %.6f\n", ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (ratio <= 1.0);
|
||||||
|
|
||||||
|
/* now that the ratio flipped again, use the previous range */
|
||||||
|
low = high;
|
||||||
|
high = high * 2;
|
||||||
|
}
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("alg1/alg2 ratio now < 1.0, starting binary search "
|
printf("Starting binary search between %d and %d\n", low, high);
|
||||||
"between %d and %d\n",
|
|
||||||
low, high);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -390,30 +475,54 @@ define best_mul2()
|
|||||||
while (low+1 < high) {
|
while (low+1 < high) {
|
||||||
|
|
||||||
/* try the mid-point */
|
/* try the mid-point */
|
||||||
|
mid = int((low+high)/2);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing multiply alg1/alg2 ratio for len = %d\n",
|
printf("testing multiply alg1/alg2 ratio for len = %d\n", mid);
|
||||||
int((low+high)/2));
|
}
|
||||||
|
ratio = mul_ratio(mid);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = mid;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ratio = mul_ratio(int((low+high)/2));
|
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" multiply alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" len %d multiply alg1/alg2 ratio = %.6f\n", mid, ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop search if near unity */
|
||||||
|
if (close_to_one(ratio)) {
|
||||||
|
low = mid;
|
||||||
|
high = mid;
|
||||||
|
if (config("user_debug") > 0) {
|
||||||
|
printf("\twe are close enough to unity ratio at: %d\n", mid);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bump lower range up if we went over */
|
/* bump lower range up if we went over */
|
||||||
if (ratio >= 1.0) {
|
if (ratio > 1.0) {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove low from %d up to %d\n",
|
printf("\tmove low from %d up to %d\n",
|
||||||
low, int((low+high)/2));
|
low, mid);
|
||||||
}
|
}
|
||||||
low = int((low+high)/2);
|
low = mid;
|
||||||
|
|
||||||
/* drop higher range down if we went under */
|
/* drop higher range down if we went under */
|
||||||
} else {
|
} else {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove high from %d down to %d\n",
|
printf("\tmove high from %d down to %d\n",
|
||||||
high, int((low+high)/2));
|
high, mid);
|
||||||
}
|
}
|
||||||
high = int((low+high)/2);
|
high = mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* report on test loop progress */
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf("\tsetting low: %d high: %d diff: %d\n",
|
||||||
|
low, high, high-low);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,10 +530,15 @@ define best_mul2()
|
|||||||
* return on the suggested config("mul2") value
|
* return on the suggested config("mul2") value
|
||||||
*/
|
*/
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("best value of config(\"mul2\") is %d\n",
|
printf("Best value for multiply is near %d\n", best_val);
|
||||||
(ratio >= 1.0) ? high : low);
|
printf("Best multiply alg1/alg2 ratio is: %.6f\n", best_ratio);
|
||||||
|
printf("We suggest placing this line in your .calcrc:\n");
|
||||||
|
printf("config(\"mul2\", %d),;\n", best_val);
|
||||||
|
printf("WARNING: It is believed that the output "
|
||||||
|
"of this resource file is bogus!\n");
|
||||||
|
printf("WARNING: You may NOT wish to follow the above suggestion.\n");
|
||||||
}
|
}
|
||||||
return ((ratio >= 1.0) ? high : low);
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -562,6 +676,7 @@ define sq_ratio(len)
|
|||||||
local tover; /* est of time for loop overhead */
|
local tover; /* est of time for loop overhead */
|
||||||
local alg1_rate; /* loop rate of 1st algorithm */
|
local alg1_rate; /* loop rate of 1st algorithm */
|
||||||
local alg2_rate; /* loop rate of 2nd algorithm */
|
local alg2_rate; /* loop rate of 2nd algorithm */
|
||||||
|
local ret; /* return ratio, or 1.0 */
|
||||||
local i;
|
local i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -614,12 +729,12 @@ define sq_ratio(len)
|
|||||||
* determine the 1st algorithm rate
|
* determine the 1st algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg1 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
tlen = sq_loop(loops, &x);
|
tlen = sq_loop(loops, &x);
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
@@ -657,12 +772,12 @@ define sq_ratio(len)
|
|||||||
* determine the 2nd algorithm rate
|
* determine the 2nd algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg2 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
tlen = sq_loop(loops, &x);
|
tlen = sq_loop(loops, &x);
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
@@ -691,7 +806,12 @@ define sq_ratio(len)
|
|||||||
/*
|
/*
|
||||||
* return alg1 / alg2 rate ratio
|
* return alg1 / alg2 rate ratio
|
||||||
*/
|
*/
|
||||||
return (alg1_rate / alg2_rate);
|
ret = alg1_rate / alg2_rate;
|
||||||
|
if (config("user_debug") > 2) {
|
||||||
|
printf("\tprecise ratio is: %.f sq_ratio will return: %.3f\n",
|
||||||
|
alg1_rate / alg2_rate, ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -713,30 +833,40 @@ define best_sq2()
|
|||||||
{
|
{
|
||||||
local ratio; /* previously calculated alg1/alg2 ratio */
|
local ratio; /* previously calculated alg1/alg2 ratio */
|
||||||
local low; /* low loop value tested */
|
local low; /* low loop value tested */
|
||||||
local high; /* low loop value tested */
|
local high; /* high loop value tested */
|
||||||
|
local mid; /* between low and high */
|
||||||
|
local best_val; /* value found with ratio closest to unity */
|
||||||
|
local best_ratio; /* closest ratio found to unity */
|
||||||
local expand; /* how fast to expand the length */
|
local expand; /* how fast to expand the length */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup
|
* setup
|
||||||
*/
|
*/
|
||||||
test_time = 15.0;
|
printf("WARNING: This tool may not be computing the correct best value\n");
|
||||||
if (config("user_debug") > 0) {
|
test_time = 5.0;
|
||||||
printf("will start with loop test time of %d secs\n", test_time);
|
printf("The best_sq2() function will take a LONG time to run!\n");
|
||||||
|
printf("It is important that best_sq2() run on an otherwise idle host!\n");
|
||||||
|
if (config("user_debug") <= 0) {
|
||||||
|
printf("To monitor progress, set user_debug to 2: "
|
||||||
|
"config(\"user_debug\", 2)\n");
|
||||||
}
|
}
|
||||||
|
printf("Starting with loop test time of %d secs\n", test_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* firewall - must have a >1 ratio for the initial length
|
* firewall - must have a >1 ratio for the initial length
|
||||||
*/
|
*/
|
||||||
high = 16;
|
high = 8;
|
||||||
|
best_val = high;
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing square alg1/alg2 ratio for len = %d\n", high);
|
printf("testing square alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = sq_ratio(high);
|
ratio = sq_ratio(high);
|
||||||
|
best_ratio = ratio;
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" square alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" square alg1/alg2 ratio = %.3f\n", ratio);
|
||||||
}
|
}
|
||||||
if (ratio <= 1.0) {
|
if (ratio < 1.0) {
|
||||||
quit "best_sq2: tests imply config(\"sq2\") should be < 4";
|
quit "best_sq2: test implies sq2 < 16, which seems bogus";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -744,37 +874,81 @@ define best_sq2()
|
|||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
/*
|
/*
|
||||||
* determine the paramters of the next ratio test
|
* determine the parameters of the next ratio test
|
||||||
*
|
*
|
||||||
* We will multiplicatively expand our test level until
|
* We will multiplicatively expand our test level until
|
||||||
* the ratio drops below 1.0.
|
* the ratio drops below 1.0.
|
||||||
*/
|
*/
|
||||||
expand = ((ratio >= 3.5) ? 16 : 2^round(ratio));
|
expand = 2;
|
||||||
low = high;
|
low = high;
|
||||||
high *= expand;
|
high *= expand;
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" expand the next test range by a factor of %d\n",
|
printf(" expand the next test range by a factor of %d\n",
|
||||||
expand);
|
expand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* determine the alg1/alg2 test ratio for this new length
|
* determine the alg1/alg2 test ratio for this new length
|
||||||
*/
|
*/
|
||||||
if (high >= 2^31) {
|
if (high >= 2^31) {
|
||||||
quit "best_sq2: tests imply config(\"sq2\") should be >= 2^31";
|
quit "best_sq2: tests imply sq2 >= 2^31, which seems bogus";
|
||||||
}
|
}
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing square alg1/alg2 ratio for len = %d\n", high);
|
printf("testing square alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = sq_ratio(high);
|
ratio = sq_ratio(high);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" square alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" square alg1/alg2 ratio = %.3f\n", ratio);
|
||||||
}
|
}
|
||||||
} while (ratio >= 1.0);
|
} while (ratio > 1.0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we previously expanded more than by a factor of 2, then
|
||||||
|
* we may have jumped over the crossover point. So now
|
||||||
|
* drop down powers of two until the ratio is again >= 1.0
|
||||||
|
*/
|
||||||
|
if (expand > 2) {
|
||||||
|
do {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* contract by 2
|
||||||
|
*/
|
||||||
|
high /= 2;
|
||||||
|
low = high / 2;
|
||||||
|
if (config("user_debug") > 0) {
|
||||||
|
printf("re-testing multiply alg1/alg2 ratio for len = %d\n",
|
||||||
|
high);
|
||||||
|
}
|
||||||
|
ratio = mul_ratio(high);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio "
|
||||||
|
"to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" multiply alg1/alg2 ratio = %.6f\n", ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (ratio <= 1.0);
|
||||||
|
|
||||||
|
/* now that the ratio flipped again, use the previous range */
|
||||||
|
low = high;
|
||||||
|
high = high * 2;
|
||||||
|
}
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("alg1/alg2 ratio now < 1.0, starting binary search "
|
printf("Starting binary search between %d and %d\n", low, high);
|
||||||
"between %d and %d\n",
|
|
||||||
low, high);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -783,41 +957,71 @@ define best_sq2()
|
|||||||
while (low+1 < high) {
|
while (low+1 < high) {
|
||||||
|
|
||||||
/* try the mid-point */
|
/* try the mid-point */
|
||||||
|
mid = int((low+high)/2);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing square alg1/alg2 ratio for len = %d\n",
|
printf("testing square alg1/alg2 ratio for len = %d\n", mid);
|
||||||
int((low+high)/2));
|
}
|
||||||
|
ratio = sq_ratio(mid);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = mid;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ratio = sq_ratio(int((low+high)/2));
|
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" square alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" len %d square alg1/alg2 ratio = %.6f\n", mid, ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop search if near unity */
|
||||||
|
if (close_to_one(ratio)) {
|
||||||
|
low = mid;
|
||||||
|
high = mid;
|
||||||
|
if (config("user_debug") > 0) {
|
||||||
|
printf("\twe are close enough to unity ratio at: %d\n", mid);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bump lower range up if we went over */
|
/* bump lower range up if we went over */
|
||||||
if (ratio >= 1.0) {
|
if (ratio > 1.0) {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove low from %d up to %d\n",
|
printf("\tmove low from %d up to %d\n",
|
||||||
low, int((low+high)/2));
|
low, mid);
|
||||||
}
|
}
|
||||||
low = int((low+high)/2);
|
low = mid;
|
||||||
|
|
||||||
/* drop higher range down if we went under */
|
/* drop higher range down if we went under */
|
||||||
} else {
|
} else {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove high from %d down to %d\n",
|
printf("\tmove high from %d down to %d\n",
|
||||||
high, int((low+high)/2));
|
high, mid);
|
||||||
}
|
}
|
||||||
high = int((low+high)/2);
|
high = mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* report on test loop progress */
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf("\tsetting low: %d high: %d diff: %d\n",
|
||||||
|
low, high, high-low);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return on the suggested config("sq2") value
|
* return on the suggested config("sq2") value
|
||||||
*/
|
*/
|
||||||
|
mid = int((low+high)/2);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("best value of config(\"sq2\") is %d\n",
|
printf("Best value for square is near %d\n", best_val);
|
||||||
(ratio >= 1.0) ? high : low);
|
printf("Best square alg1/alg2 ratio is: %.6f\n", best_ratio);
|
||||||
|
printf("We suggest placing this line in your .calcrc:\n");
|
||||||
|
printf("config(\"sq2\", %d),;\n", best_val);
|
||||||
|
printf("WARNING: It is believed that the output "
|
||||||
|
"of this resource file is bogus!\n");
|
||||||
|
printf("WARNING: You may NOT wish to follow the above suggestion.\n");
|
||||||
}
|
}
|
||||||
return ((ratio >= 1.0) ? high : low);
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -968,6 +1172,7 @@ define pow_ratio(len)
|
|||||||
local alg1_rate; /* loop rate of 1st algorithm */
|
local alg1_rate; /* loop rate of 1st algorithm */
|
||||||
local alg2_rate; /* loop rate of 2nd algorithm */
|
local alg2_rate; /* loop rate of 2nd algorithm */
|
||||||
local ex; /* exponent to use in pow_loop() */
|
local ex; /* exponent to use in pow_loop() */
|
||||||
|
local ret; /* return ratio, or 1.0 */
|
||||||
local i;
|
local i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -990,7 +1195,7 @@ define pow_ratio(len)
|
|||||||
/*
|
/*
|
||||||
* setup
|
* setup
|
||||||
*/
|
*/
|
||||||
ex = 5;
|
ex = 7;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize x, the values we will pmod
|
* initialize x, the values we will pmod
|
||||||
@@ -1026,12 +1231,12 @@ define pow_ratio(len)
|
|||||||
* determine the 1st algorithm rate
|
* determine the 1st algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg1 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
tlen = pow_loop(loops, &x, ex);
|
tlen = pow_loop(loops, &x, ex);
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
@@ -1070,12 +1275,12 @@ define pow_ratio(len)
|
|||||||
* determine the 2nd algorithm rate
|
* determine the 2nd algorithm rate
|
||||||
*/
|
*/
|
||||||
loops = max(1, ceil(loops * test_time / tlen));
|
loops = max(1, ceil(loops * test_time / tlen));
|
||||||
if (loops < 8) {
|
if (loops < 16) {
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" we must expand loop test time to more than %d secs\n",
|
printf(" we must expand alg2 loop test time to about %d secs\n",
|
||||||
ceil(test_time * (8 / loops)));
|
ceil(test_time * (16 / loops)));
|
||||||
}
|
}
|
||||||
loops = 8;
|
loops = 16;
|
||||||
}
|
}
|
||||||
tlen = pow_loop(loops, &x, ex);
|
tlen = pow_loop(loops, &x, ex);
|
||||||
if (config("user_debug") > 3) {
|
if (config("user_debug") > 3) {
|
||||||
@@ -1104,7 +1309,12 @@ define pow_ratio(len)
|
|||||||
/*
|
/*
|
||||||
* return alg1 / alg2 rate ratio
|
* return alg1 / alg2 rate ratio
|
||||||
*/
|
*/
|
||||||
return (alg1_rate / alg2_rate);
|
ret = alg1_rate / alg2_rate;
|
||||||
|
if (config("user_debug") > 2) {
|
||||||
|
printf("\tprecise ratio is: %.f pow_ratio will return: %.3f\n",
|
||||||
|
alg1_rate / alg2_rate, ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1126,33 +1336,51 @@ define best_pow2()
|
|||||||
{
|
{
|
||||||
local ratio; /* previously calculated alg1/alg2 ratio */
|
local ratio; /* previously calculated alg1/alg2 ratio */
|
||||||
local low; /* low loop value tested */
|
local low; /* low loop value tested */
|
||||||
local high; /* low loop value tested */
|
local high; /* high loop value tested */
|
||||||
|
local mid; /* between low and high */
|
||||||
|
local best_val; /* value found with ratio closest to unity */
|
||||||
|
local best_ratio; /* closest ratio found to unity */
|
||||||
local expand; /* how fast to expand the length */
|
local expand; /* how fast to expand the length */
|
||||||
local looped; /* 1 ==> we have expanded lengths before */
|
local looped; /* 1 ==> we have expanded lengths before */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup
|
* setup
|
||||||
*/
|
*/
|
||||||
test_time = 15.0;
|
printf("WARNING: This tool may not be computing the correct best value\n");
|
||||||
if (config("user_debug") > 0) {
|
test_time = 60.0;
|
||||||
printf("will start with loop test time of %d secs\n", test_time);
|
printf("The best_pow2() function will take a LONG time to run!\n");
|
||||||
|
printf("It is important that best_pow2() run on an otherwise idle host!\n");
|
||||||
|
if (config("user_debug") <= 0) {
|
||||||
|
printf("To monitor progress, set user_debug to 2: "
|
||||||
|
"config(\"user_debug\", 2)\n");
|
||||||
}
|
}
|
||||||
|
printf("Starting with loop test time of %d secs\n", test_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* firewall - must have a >1.02 ratio for the initial length
|
* firewall - must have a >1.02 ratio for the initial length
|
||||||
*
|
*
|
||||||
* We select 1.02 because of the precision of the CPU timing. We
|
* We select 1.02 because of the precision of the CPU timing. We
|
||||||
* want to firt move into an area where the 1st algoritm clearly
|
* want to first move into an area where the 1st algorithm clearly
|
||||||
* dominates.
|
* dominates.
|
||||||
*/
|
*/
|
||||||
low = 4;
|
low = 4;
|
||||||
high = 4;
|
high = 4;
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = 1e10; /* not a real value */
|
||||||
do {
|
do {
|
||||||
high *= 4;
|
high *= 4;
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing pmod alg1/alg2 ratio for len = %d\n", high);
|
printf("testing pmod alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = pow_ratio(high);
|
ratio = pow_ratio(high);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" pmod alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" pmod alg1/alg2 ratio = %.3f\n", ratio);
|
||||||
if (ratio > 1.0 && ratio <= 1.02) {
|
if (ratio > 1.0 && ratio <= 1.02) {
|
||||||
@@ -1171,7 +1399,7 @@ define best_pow2()
|
|||||||
looped = 0;
|
looped = 0;
|
||||||
do {
|
do {
|
||||||
/*
|
/*
|
||||||
* determine the paramters of the next ratio test
|
* determine the parameters of the next ratio test
|
||||||
*
|
*
|
||||||
* We will multiplicatively expand our test level until
|
* We will multiplicatively expand our test level until
|
||||||
* the ratio drops below 1.0.
|
* the ratio drops below 1.0.
|
||||||
@@ -1199,20 +1427,27 @@ define best_pow2()
|
|||||||
* determine the alg1/alg2 test ratio for this new length
|
* determine the alg1/alg2 test ratio for this new length
|
||||||
*/
|
*/
|
||||||
if (high >= 2^31) {
|
if (high >= 2^31) {
|
||||||
quit "best_pow2: tests imply config(\"pow2\") should be >= 2^31";
|
quit "best_pow2: test implies pow2 >= 2^31, which seems bogus";
|
||||||
}
|
}
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing pmod alg1/alg2 ratio for len = %d\n", high);
|
printf("testing pmod alg1/alg2 ratio for len = %d\n", high);
|
||||||
}
|
}
|
||||||
ratio = pow_ratio(high);
|
ratio = pow_ratio(high);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = high;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" pmod alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" pmod alg1/alg2 ratio = %.6f\n", ratio);
|
||||||
}
|
}
|
||||||
looped = 1;
|
looped = 1;
|
||||||
} while (ratio >= 1.0);
|
} while (ratio > 1.0);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("alg1/alg2 ratio now < 1.0, starting binary search "
|
printf("Starting binary search between %d and %d\n", low, high);
|
||||||
"between %d and %d\n", low, high);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1221,39 +1456,69 @@ define best_pow2()
|
|||||||
while (low+1 < high) {
|
while (low+1 < high) {
|
||||||
|
|
||||||
/* try the mid-point */
|
/* try the mid-point */
|
||||||
|
mid = int((low+high)/2);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("testing pmod alg1/alg2 ratio for len = %d\n",
|
printf("testing pow2 alg1/alg2 ratio for len = %d\n", mid);
|
||||||
int((low+high)/2));
|
}
|
||||||
|
ratio = pow_ratio(mid);
|
||||||
|
if (abs(ratio - 1.0) < abs(best_ratio - 1.0)) {
|
||||||
|
best_val = mid;
|
||||||
|
best_ratio = ratio;
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf(" len %d has a new closest ratio to unity: %.6f\n",
|
||||||
|
best_val, best_ratio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ratio = pow_ratio(int((low+high)/2));
|
|
||||||
if (config("user_debug") > 1) {
|
if (config("user_debug") > 1) {
|
||||||
printf(" pmod alg1/alg2 ratio = %.3f\n", ratio);
|
printf(" len %d pmod alg1/alg2 ratio = %.6f\n", mid, ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* stop search if near unity */
|
||||||
|
if (close_to_one(ratio)) {
|
||||||
|
low = mid;
|
||||||
|
high = mid;
|
||||||
|
if (config("user_debug") > 0) {
|
||||||
|
printf("\twe are close enough to unity ratio at: %d\n", mid);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bump lower range up if we went over */
|
/* bump lower range up if we went over */
|
||||||
if (ratio >= 1.0) {
|
if (ratio > 1.0) {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove low from %d up to %d\n",
|
printf("\tmove low from %d up to %d\n",
|
||||||
low, int((low+high)/2));
|
low, mid);
|
||||||
}
|
}
|
||||||
low = int((low+high)/2);
|
low = mid;
|
||||||
|
|
||||||
/* drop higher range down if we went under */
|
/* drop higher range down if we went under */
|
||||||
} else {
|
} else {
|
||||||
if (config("user_debug") > 2) {
|
if (config("user_debug") > 2) {
|
||||||
printf("\tmove high from %d down to %d\n",
|
printf("\tmove high from %d down to %d\n",
|
||||||
high, int((low+high)/2));
|
high, mid);
|
||||||
}
|
}
|
||||||
high = int((low+high)/2);
|
high = mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* report on test loop progress */
|
||||||
|
if (config("user_debug") > 1) {
|
||||||
|
printf("\tsetting low: %d high: %d diff: %d\n",
|
||||||
|
low, high, high-low);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return on the suggested config("pow2") value
|
* return on the suggested config("pow2") value
|
||||||
*/
|
*/
|
||||||
|
mid = int((low+high)/2);
|
||||||
if (config("user_debug") > 0) {
|
if (config("user_debug") > 0) {
|
||||||
printf("best value of config(\"pow2\") is %d\n",
|
printf("Best value for pmod is near %d\n", best_val);
|
||||||
(ratio >= 1.0) ? high : low);
|
printf("Best pmod alg1/alg2 ratio is: %.6f\n", best_ratio);
|
||||||
|
printf("We suggest placing this line in your .calcrc:\n");
|
||||||
|
printf("config(\"pow2\", %d),;\n", best_val);
|
||||||
|
printf("WARNING: It is believed that the output "
|
||||||
|
"of this resource file is bogus!\n");
|
||||||
|
printf("WARNING: You may NOT wish to follow the above suggestion.\n");
|
||||||
}
|
}
|
||||||
return ((ratio >= 1.0) ? high : low);
|
return mid;
|
||||||
}
|
}
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: beer.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/beer.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/11/13 13:21:05
|
* Under source code control: 1996/11/13 13:21:05
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* bernoulli - clculate the Nth Bernoulli number B(n)
|
* bernoulli - calculate the Nth Bernoulli number B(n)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000 David I. Bell and Landon Curt Noll
|
* Copyright (C) 2000,2021 David I. Bell and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: bernoulli.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/bernoulli.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/09/30 11:18:41
|
* Under source code control: 1991/09/30 11:18:41
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
@@ -30,9 +26,9 @@
|
|||||||
/*
|
/*
|
||||||
* Calculate the Nth Bernoulli number B(n).
|
* Calculate the Nth Bernoulli number B(n).
|
||||||
*
|
*
|
||||||
* NOTE: This is now a bulitin function.
|
* NOTE: This is now a builtin function.
|
||||||
*
|
*
|
||||||
* The non-buildin code used the following symbolic formula to calculate B(n):
|
* The non-builtin code used the following symbolic formula to calculate B(n):
|
||||||
*
|
*
|
||||||
* (b+1)^(n+1) - b^(n+1) = 0
|
* (b+1)^(n+1) - b^(n+1) = 0
|
||||||
*
|
*
|
||||||
@@ -46,7 +42,7 @@
|
|||||||
* B(3) = -(6*B(2) + 4*B(1) + 1) / 4
|
* B(3) = -(6*B(2) + 4*B(1) + 1) / 4
|
||||||
*
|
*
|
||||||
* The combinatorial factors in the expansion of the above formula are
|
* The combinatorial factors in the expansion of the above formula are
|
||||||
* calculated interatively, and we use the fact that B(2i+1) = 0 if i > 0.
|
* calculated interactively, and we use the fact that B(2i+1) = 0 if i > 0.
|
||||||
* Since all previous B(n)'s are needed to calculate a particular B(n), all
|
* Since all previous B(n)'s are needed to calculate a particular B(n), all
|
||||||
* values obtained are saved in an array for ease in repeated calculations.
|
* values obtained are saved in an array for ease in repeated calculations.
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* bernpoly - Bernoully polynomials B_n(z) for arbitrary n,z..
|
* bernpoly - Bernoulli polynomials B_n(z) for arbitrary n,z..
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: bernpoly.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/bernpoly.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: bigprime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/bigprime.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/05/22 21:56:32
|
* Under source code control: 1991/05/22 21:56:32
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
|
@@ -16,10 +16,6 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 30.1 $
|
|
||||||
# @(#) $Id: bindings,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
# @(#) $Source: /usr/local/src/bin/calc/cal/RCS/bindings,v $
|
|
||||||
#
|
|
||||||
# Under source code control: 1993/05/02 20:09:19
|
# Under source code control: 1993/05/02 20:09:19
|
||||||
# File existed as early as: 1993
|
# File existed as early as: 1993
|
||||||
#
|
#
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* brentsolve - Root finding with the Brent-Dekker trick
|
* brentsolve - Root finding with the Brent-Dekker trick
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: brentsolve.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/brentsolve.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
@@ -147,7 +143,7 @@ define brentsolve2(low, high,which,eps){
|
|||||||
|
|
||||||
switch(param(0)){
|
switch(param(0)){
|
||||||
case 0:
|
case 0:
|
||||||
case 1: return newerror("brentsolve2: not enough argments");
|
case 1: return newerror("brentsolve2: not enough arguments");
|
||||||
case 2: eps = epsilon(epsilon()*1e-2);
|
case 2: eps = epsilon(epsilon()*1e-2);
|
||||||
which = 0;break;
|
which = 0;break;
|
||||||
case 3: eps = epsilon(epsilon()*1e-2);break;
|
case 3: eps = epsilon(epsilon()*1e-2);break;
|
||||||
|
14
cal/chi.cal
14
cal/chi.cal
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* chi - chi^2 probabilities with degrees of freedom for null hypothesis
|
* chi - chi^2 probabilities with degrees of freedom for null hypothesis
|
||||||
*
|
*
|
||||||
* Copyright (C) 2001 Landon Curt Noll
|
* Copyright (C) 2001,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: chi.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/chi.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2001/03/27 14:10:11
|
* Under source code control: 2001/03/27 14:10:11
|
||||||
* File existed as early as: 2001
|
* File existed as early as: 2001
|
||||||
*
|
*
|
||||||
@@ -55,7 +51,7 @@ define Z(x, eps_term)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* P(x[, eps]) asymtotic P(x) expansion for x>0 to an given epsilon error term
|
* P(x[, eps]) asymptotic P(x) expansion for x>0 to an given epsilon error term
|
||||||
*
|
*
|
||||||
* NOTE: If eps is omitted, the stored epsilon value is used.
|
* NOTE: If eps is omitted, the stored epsilon value is used.
|
||||||
*
|
*
|
||||||
@@ -103,7 +99,7 @@ define P(x, eps_term)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* aproximate sum(n=0; n < infinity){x^(2*n+1)/(1*3*5*...(2*n+1)}
|
* approximate sum(n=0; n < infinity){x^(2*n+1)/(1*3*5*...(2*n+1)}
|
||||||
*/
|
*/
|
||||||
x2 = x*x;
|
x2 = x*x;
|
||||||
x_term = x;
|
x_term = x;
|
||||||
@@ -134,7 +130,7 @@ define P(x, eps_term)
|
|||||||
*
|
*
|
||||||
* The chi_prob() function does not work well with odd degrees of freedom.
|
* The chi_prob() function does not work well with odd degrees of freedom.
|
||||||
* It is reasonable with even degrees of freedom, although one must give
|
* It is reasonable with even degrees of freedom, although one must give
|
||||||
* a sifficently small error term as the degress gets large (>100).
|
* a sufficiently small error term as the degrees gets large (>100).
|
||||||
*
|
*
|
||||||
* NOTE: This function does not work well with odd degrees of freedom.
|
* NOTE: This function does not work well with odd degrees of freedom.
|
||||||
* Can somebody help / find a bug / provide a better method of
|
* Can somebody help / find a bug / provide a better method of
|
||||||
@@ -190,7 +186,7 @@ define chi_prob(chi_sq, v, eps_term)
|
|||||||
local r; /* index in finite sum */
|
local r; /* index in finite sum */
|
||||||
local r_lim; /* limit value for r */
|
local r_lim; /* limit value for r */
|
||||||
local s; /* sum */
|
local s; /* sum */
|
||||||
local d; /* demoninator (2*4*6*... or 1*3*5...) */
|
local d; /* denominator (2*4*6*... or 1*3*5...) */
|
||||||
local chi_term; /* chi_sq^r */
|
local chi_term; /* chi_sq^r */
|
||||||
local ret; /* return value */
|
local ret; /* return value */
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* chrem - chinese remainder theorem/problem solver
|
* chrem - Chinese remainder theorem/problem solver
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: Ernest Bowen
|
* Primary author: Ernest Bowen
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: chrem.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/chrem.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1992/09/26 01:00:47
|
* Under source code control: 1992/09/26 01:00:47
|
||||||
* File existed as early as: 1992
|
* File existed as early as: 1992
|
||||||
*
|
*
|
||||||
@@ -30,7 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When possible, chrem finds solutions for x of a set of congruences
|
* When possible, chrem finds solutions for x of a set of congruence
|
||||||
* of the form:
|
* of the form:
|
||||||
*
|
*
|
||||||
* x = r1 (mod m1)
|
* x = r1 (mod m1)
|
||||||
@@ -39,7 +35,7 @@
|
|||||||
*
|
*
|
||||||
* where the residues r1, r2, ... and the moduli m1, m2, ... are
|
* where the residues r1, r2, ... and the moduli m1, m2, ... are
|
||||||
* given integers. The Chinese remainder theorem states that if
|
* given integers. The Chinese remainder theorem states that if
|
||||||
* m1, m2, ... are relatively prime in pairs, the above congruences
|
* m1, m2, ... are relatively prime in pairs, the above congruence
|
||||||
* have a unique solution modulo m1 * m2 * ... If m1, m2, ...
|
* have a unique solution modulo m1 * m2 * ... If m1, m2, ...
|
||||||
* are not relatively prime in pairs, it is possible that no solution
|
* are not relatively prime in pairs, it is possible that no solution
|
||||||
* exists. If solutions exist, the general solution is expressible as:
|
* exists. If solutions exist, the general solution is expressible as:
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: constants.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/constants.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: deg.cal,v 30.2 2010/09/02 06:01:14 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/deg.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:33
|
* Under source code control: 1990/02/15 01:50:33
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
30
cal/dms.cal
30
cal/dms.cal
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* dms - calculate in degrees, minutes, and seconds (based on deg)
|
* dms - calculate in degrees, minutes, and seconds (based on deg)
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999,2010 David I. Bell and Landon Curt Noll
|
* Copyright (C) 1999,2010,2021 David I. Bell and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: dms.cal,v 30.2 2010/09/02 06:14:16 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/dms.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:33
|
* Under source code control: 1990/02/15 01:50:33
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
@@ -57,7 +53,7 @@ define dms_add(a, b)
|
|||||||
{
|
{
|
||||||
local obj dms ans; /* return value */
|
local obj dms ans; /* return value */
|
||||||
|
|
||||||
/* initalize value to 1st arg */
|
/* initialize value to 1st arg */
|
||||||
if (istype(a, ans)) {
|
if (istype(a, ans)) {
|
||||||
/* 1st arg is dms object, load it */
|
/* 1st arg is dms object, load it */
|
||||||
ans.deg = a.deg;
|
ans.deg = a.deg;
|
||||||
@@ -114,7 +110,7 @@ define dms_sub(a, b)
|
|||||||
{
|
{
|
||||||
local obj dms ans; /* return value */
|
local obj dms ans; /* return value */
|
||||||
|
|
||||||
/* initalize value to 1st arg */
|
/* initialize value to 1st arg */
|
||||||
if (istype(a, ans)) {
|
if (istype(a, ans)) {
|
||||||
/* 1st arg is dms object, load it */
|
/* 1st arg is dms object, load it */
|
||||||
ans.deg = a.deg;
|
ans.deg = a.deg;
|
||||||
@@ -356,24 +352,8 @@ define fixdms(a)
|
|||||||
quit "attempt to fix a non dms object";
|
quit "attempt to fix a non dms object";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force minutes to be intergral */
|
/* use builtin d2dms function */
|
||||||
a.min += frac(a.deg) * 60;
|
d2dms(a.deg + a.min/60 + a.sec/3600, a.deg, a.min, a.sec),;
|
||||||
a.deg = int(a.deg);
|
|
||||||
|
|
||||||
/* force degrees to be intergral */
|
|
||||||
a.sec += frac(a.min) * 60;
|
|
||||||
a.min = int(a.min);
|
|
||||||
|
|
||||||
/* carry excess seconds into minutes */
|
|
||||||
a.min += a.sec // 60;
|
|
||||||
a.sec %= 60;
|
|
||||||
|
|
||||||
/* carry excess minutes into degrees */
|
|
||||||
a.deg += a.min // 60;
|
|
||||||
a.min %= 60;
|
|
||||||
|
|
||||||
/* round degrees :-) */
|
|
||||||
a.deg %= 360;
|
|
||||||
|
|
||||||
/* return normalized result */
|
/* return normalized result */
|
||||||
return a;
|
return a;
|
||||||
|
@@ -8,18 +8,14 @@
|
|||||||
* copyright this dotest_code.
|
* copyright this dotest_code.
|
||||||
*
|
*
|
||||||
* ERNEST BOWEN AND LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
* ERNEST BOWEN AND LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
|
||||||
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
|
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
|
||||||
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
||||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||||
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: dotest.cal,v 30.2 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/dotest.cal,v $
|
|
||||||
*
|
|
||||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||||
*
|
*
|
||||||
* Under source dotest_code control: 2006/03/08 05:54:09
|
* Under source dotest_code control: 2006/03/08 05:54:09
|
||||||
@@ -177,7 +173,7 @@ define dotest(dotest_file, dotest_code = 0, dotest_maxcond = -1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* preppare to return to the caller environment
|
* prepare to return to the caller environment
|
||||||
*
|
*
|
||||||
* We increase the caller's error count by the number
|
* We increase the caller's error count by the number
|
||||||
* of line tests that failed, not the number of internal
|
* of line tests that failed, not the number of internal
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: ellip.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/ellip.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:33
|
* Under source code control: 1990/02/15 01:50:33
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: factorial.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/factorial.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* factorial2 - implementation of different factorial related functions
|
* factorial2 - implementation of different factorial related functions
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: factorial2.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/factorial2.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
@@ -285,10 +281,10 @@ define __CZ__multiply_factored_factorial(matrix,stop){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compute binomial coeficients n!/(k!(n-k)!)
|
Compute binomial coefficients n!/(k!(n-k)!)
|
||||||
|
|
||||||
One of the rare cases where a formula once meant to ease manual computation
|
One of the rare cases where a formula once meant to ease manual computation
|
||||||
is actually the (aymptotically) fastest way to do it (in July 2013) for
|
is actually the (asymptotically) fastest way to do it (in July 2013) for
|
||||||
the extreme case binomial(2N,N) but for a high price, the memory
|
the extreme case binomial(2N,N) but for a high price, the memory
|
||||||
needed is pi(N)--theoretically.
|
needed is pi(N)--theoretically.
|
||||||
*/
|
*/
|
||||||
@@ -630,7 +626,7 @@ define subfactorialrecursive(n){
|
|||||||
return n * subfactorialrecursive(n-1) + (-1)^n;
|
return n * subfactorialrecursive(n-1) + (-1)^n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is, quite amusingely, faster than the very same algorithm in
|
/* This is, quite amusingly, faster than the very same algorithm in
|
||||||
PARI/GP + GMP*/
|
PARI/GP + GMP*/
|
||||||
define subfactorialiterative(n){
|
define subfactorialiterative(n){
|
||||||
local k temp1 temp2 ret;
|
local k temp1 temp2 ret;
|
||||||
|
@@ -8,10 +8,6 @@
|
|||||||
* operation "function" must be first; calc doesn't care how many more
|
* operation "function" must be first; calc doesn't care how many more
|
||||||
* arguments there actually are.
|
* arguments there actually are.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.3 $
|
|
||||||
* @(#) $Id: gvec.cal,v 30.3 2011/05/23 23:00:55 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/gvec.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2011/03/31 17:54:55
|
* Under source code control: 2011/03/31 17:54:55
|
||||||
* File existed as early as: 2010
|
* File existed as early as: 2010
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: hello.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/hello.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/11/13 13:25:43
|
* Under source code control: 1996/11/13 13:25:43
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
30
cal/hms.cal
30
cal/hms.cal
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* hms - calculate in hours, minutes, and seconds
|
* hms - calculate in hours, minutes, and seconds
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Landon Curt Noll
|
* Copyright (C) 2010,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: hms.cal,v 30.2 2010/09/02 06:14:16 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/hms.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2010/09/01 17:14:55
|
* Under source code control: 2010/09/01 17:14:55
|
||||||
* File existed as early as: 2010
|
* File existed as early as: 2010
|
||||||
*
|
*
|
||||||
@@ -57,7 +53,7 @@ define hms_add(a, b)
|
|||||||
{
|
{
|
||||||
local obj hms ans; /* return value */
|
local obj hms ans; /* return value */
|
||||||
|
|
||||||
/* initalize value to 1st arg */
|
/* initialize value to 1st arg */
|
||||||
if (istype(a, ans)) {
|
if (istype(a, ans)) {
|
||||||
/* 1st arg is hms object, load it */
|
/* 1st arg is hms object, load it */
|
||||||
ans.hour = a.hour;
|
ans.hour = a.hour;
|
||||||
@@ -114,7 +110,7 @@ define hms_sub(a, b)
|
|||||||
{
|
{
|
||||||
local obj hms ans; /* return value */
|
local obj hms ans; /* return value */
|
||||||
|
|
||||||
/* initalize value to 1st arg */
|
/* initialize value to 1st arg */
|
||||||
if (istype(a, ans)) {
|
if (istype(a, ans)) {
|
||||||
/* 1st arg is hms object, load it */
|
/* 1st arg is hms object, load it */
|
||||||
ans.hour = a.hour;
|
ans.hour = a.hour;
|
||||||
@@ -356,24 +352,8 @@ define fixhms(a)
|
|||||||
quit "attempt to fix a non hms object";
|
quit "attempt to fix a non hms object";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* force minutes to be intergral */
|
/* use builtin h2hms function */
|
||||||
a.min += frac(a.hour) * 60;
|
h2hms(a.hour + a.min/60 + a.sec/3600, a.hour, a.min, a.sec),;
|
||||||
a.hour = int(a.hour);
|
|
||||||
|
|
||||||
/* force hours to be intergral */
|
|
||||||
a.sec += frac(a.min) * 60;
|
|
||||||
a.min = int(a.min);
|
|
||||||
|
|
||||||
/* carry excess seconds into minutes */
|
|
||||||
a.min += a.sec // 60;
|
|
||||||
a.sec %= 60;
|
|
||||||
|
|
||||||
/* carry excess minutes into hours */
|
|
||||||
a.hour += a.min // 60;
|
|
||||||
a.min %= 60;
|
|
||||||
|
|
||||||
/* round hours by day */
|
|
||||||
a.hour %= 24;
|
|
||||||
|
|
||||||
/* return normalized result */
|
/* return normalized result */
|
||||||
return a;
|
return a;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* intfile - integer to file and file to integer conversion
|
* intfile - integer to file and file to integer conversion
|
||||||
*
|
*
|
||||||
* Copyright (C) 2001 Landon Curt Noll
|
* Copyright (C) 2001,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: intfile.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/intfile.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2001/03/31 08:13:11
|
* Under source code control: 2001/03/31 08:13:11
|
||||||
* File existed as early as: 2001
|
* File existed as early as: 2001
|
||||||
*
|
*
|
||||||
@@ -31,20 +27,20 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: Because leading HALF values are trimmed from integer, a file
|
* NOTE: Because leading HALF values are trimmed from integer, a file
|
||||||
* that begins with lots of 0 bits (in the case of big endian)
|
* that begins with lots of 0 bits (in the case of big Endian)
|
||||||
* or that ends with lots of 0 bits (in the case of little endian)
|
* or that ends with lots of 0 bits (in the case of little Endian)
|
||||||
* will be changed when the subsequent integer is written back.
|
* will be changed when the subsequent integer is written back.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* file2be - convert a file into an big endian integer
|
* file2be - convert a file into an big Endian integer
|
||||||
*
|
*
|
||||||
* given:
|
* given:
|
||||||
* filename filename to read
|
* filename filename to read
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* integer read from its contents on big endian order
|
* integer read from its contents on big Endian order
|
||||||
*/
|
*/
|
||||||
define file2be(filename)
|
define file2be(filename)
|
||||||
{
|
{
|
||||||
@@ -79,13 +75,13 @@ define file2be(filename)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* file2le - convert a file into an little endian integer
|
* file2le - convert a file into an little Endian integer
|
||||||
*
|
*
|
||||||
* given:
|
* given:
|
||||||
* filename filename to read
|
* filename filename to read
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* integer read from its contents on little endian order
|
* integer read from its contents on little Endian order
|
||||||
*/
|
*/
|
||||||
define file2le(filename)
|
define file2le(filename)
|
||||||
{
|
{
|
||||||
@@ -122,7 +118,7 @@ define file2le(filename)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* be2file - convert a big endian integer into a file
|
* be2file - convert a big Endian integer into a file
|
||||||
*
|
*
|
||||||
* given:
|
* given:
|
||||||
* v integer to write to the file
|
* v integer to write to the file
|
||||||
@@ -172,7 +168,7 @@ define be2file(v, filename)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* le2file - convert a little endian integer into a file
|
* le2file - convert a little Endian integer into a file
|
||||||
*
|
*
|
||||||
* given:
|
* given:
|
||||||
* v integer to write to the file
|
* v integer to write to the file
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* intnum - implementation of tanhsinh- and Gauss-Legendre quadrature
|
* intnum - implementation of tanhsinh- and Gauss-Legendre quadrature
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -295,7 +295,7 @@ define quadts(a, b, points)
|
|||||||
* as the number of equally spaced intervals on a straight line
|
* as the number of equally spaced intervals on a straight line
|
||||||
* connecting a and b. Computing the segments here is a bit
|
* connecting a and b. Computing the segments here is a bit
|
||||||
* more complicated but not much, it should have been taught in
|
* more complicated but not much, it should have been taught in
|
||||||
* highschool.
|
* high school.
|
||||||
* Other contours by way of a list of points */
|
* Other contours by way of a list of points */
|
||||||
slope = (im(b) - im(a)) / (re(b) - re(a));
|
slope = (im(b) - im(a)) / (re(b) - re(a));
|
||||||
C = (im(a) + slope) * re(a);
|
C = (im(a) + slope) * re(a);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* lambertw - Lambert's W-function
|
* lambertw - Lambert's W-function
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: lambertw.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/lambertw.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +83,7 @@ define __CZ__lambertw_m1(z,eps){
|
|||||||
or by using the function lambertw_series_print() after running
|
or by using the function lambertw_series_print() after running
|
||||||
lambertw_series(z,eps,branch,terms) at least once with the wanted number of
|
lambertw_series(z,eps,branch,terms) at least once with the wanted number of
|
||||||
terms and z = 1 (which might throw an error because the series will not
|
terms and z = 1 (which might throw an error because the series will not
|
||||||
converge in anybodies lifetime for something that far from the branchpoint).
|
converge in anybodies lifetime for something that far from the branch point).
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +105,7 @@ define lambertw_series_print(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The series is fast but only if _very_ close to the branchpoint
|
The series is fast but only if _very_ close to the branch point
|
||||||
The exact branch must be given explicitly, e.g.:
|
The exact branch must be given explicitly, e.g.:
|
||||||
|
|
||||||
; lambertw(-exp(-1)+.001)-lambertw_series(-exp(-1)+.001,epsilon()*1e-10,0)
|
; lambertw(-exp(-1)+.001)-lambertw_series(-exp(-1)+.001,epsilon()*1e-10,0)
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* linear - perform a simple two point 2D linear interpolation
|
* linear - perform a simple two point 2D linear interpolation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005-2007 Landon Curt Noll
|
* Copyright (C) 2005-2007,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: linear.cal,v 30.2 2007/03/17 05:57:42 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/linear.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2005/12/12 06:41:50
|
* Under source code control: 2005/12/12 06:41:50
|
||||||
* File existed as early as: 2005
|
* File existed as early as: 2005
|
||||||
*
|
*
|
||||||
@@ -33,7 +29,7 @@
|
|||||||
*
|
*
|
||||||
* given:
|
* given:
|
||||||
* x0, y0 first known point on the line
|
* x0, y0 first known point on the line
|
||||||
* x1, y1 second knonw point on the line
|
* x1, y1 second known point on the line
|
||||||
* x a given point to interpolate on
|
* x a given point to interpolate on
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: lnseries.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/lnseries.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
|
1016
cal/lucas.cal
1016
cal/lucas.cal
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* lucas_chk - test all primes of the form h*2^n-1, 1<=h<200 and n <= high_n
|
* lucas_chk - test all primes of the form h*2^n-1, 1<=h<200 and n <= high_n
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: lucas_chk.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/lucas_chk.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/01/11 05:41:43
|
* Under source code control: 1991/01/11 05:41:43
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
@@ -307,7 +303,7 @@ read -once "lucas.cal";
|
|||||||
* [quiet] if given and != 0, then do not print individual test results
|
* [quiet] if given and != 0, then do not print individual test results
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* 1 all is ok
|
* 1 all is OK
|
||||||
* 0 something went wrong
|
* 0 something went wrong
|
||||||
*/
|
*/
|
||||||
define
|
define
|
||||||
|
@@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* lucas_tbl - lucasian criteria for primality tables
|
|
||||||
*
|
|
||||||
* Copyright (C) 1999 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
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
|
||||||
* Public License for more details.
|
|
||||||
*
|
|
||||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
|
||||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
|
||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: lucas_tbl.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/lucas_tbl.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/01/26 02:43:43
|
|
||||||
* File existed as early as: 1991
|
|
||||||
*
|
|
||||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
|
||||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lucasian criteria for primality
|
|
||||||
*
|
|
||||||
* The following table is taken from:
|
|
||||||
*
|
|
||||||
* "Lucasian Criteria for the Primality of N=h*2^n-1", by Hans Riesel,
|
|
||||||
* Mathematics of Computation, Vol 23 #108, p 872.
|
|
||||||
*
|
|
||||||
* The index of the *_val[] arrays correspond to the v(1) values found
|
|
||||||
* in the table. That is, for v(1) == x:
|
|
||||||
*
|
|
||||||
* D == d_val[x]
|
|
||||||
* a == a_val[x]
|
|
||||||
* b == b_val[x]
|
|
||||||
* r == r_val[x] (r == abs(a^2 - b^2*D))
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note that when *_val[i] is not a number, the related v(1) value
|
|
||||||
* is not found in Table 1.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
trymax = 100;
|
|
||||||
mat d_val[trymax+1];
|
|
||||||
mat a_val[trymax+1];
|
|
||||||
mat b_val[trymax+1];
|
|
||||||
mat r_val[trymax+1];
|
|
||||||
/* v1= 0 INVALID */
|
|
||||||
/* v1= 1 INVALID */
|
|
||||||
/* v1= 2 INVALID */
|
|
||||||
d_val[ 3]= 5; a_val[ 3]= 1; b_val[ 3]=1; r_val[ 3]=4;
|
|
||||||
d_val[ 4]= 3; a_val[ 4]= 1; b_val[ 4]=1; r_val[ 4]=2;
|
|
||||||
d_val[ 5]= 21; a_val[ 5]= 3; b_val[ 5]=1; r_val[ 5]=12;
|
|
||||||
d_val[ 6]= 2; a_val[ 6]= 1; b_val[ 6]=1; r_val[ 6]=1;
|
|
||||||
/* v1= 7 INVALID */
|
|
||||||
d_val[ 8]= 15; a_val[ 8]= 3; b_val[ 8]=1; r_val[ 8]=6;
|
|
||||||
d_val[ 9]= 77; a_val[ 9]= 7; b_val[ 9]=1; r_val[ 9]=28;
|
|
||||||
d_val[10]= 6; a_val[10]= 2; b_val[10]=1; r_val[10]=2;
|
|
||||||
d_val[11]= 13; a_val[11]= 3; b_val[11]=1; r_val[11]=4;
|
|
||||||
d_val[12]= 35; a_val[12]= 5; b_val[12]=1; r_val[12]=10;
|
|
||||||
d_val[13]= 165; a_val[13]=11; b_val[13]=1; r_val[13]=44;
|
|
||||||
/* v1=14 INVALID */
|
|
||||||
d_val[15]= 221; a_val[15]=13; b_val[15]=1; r_val[15]=52;
|
|
||||||
d_val[16]= 7; a_val[16]= 3; b_val[16]=1; r_val[16]=2;
|
|
||||||
d_val[17]= 285; a_val[17]=15; b_val[17]=1; r_val[17]=60;
|
|
||||||
/* v1=18 INVALID */
|
|
||||||
d_val[19]= 357; a_val[19]=17; b_val[19]=1; r_val[19]=68;
|
|
||||||
d_val[20]= 11; a_val[20]= 3; b_val[20]=1; r_val[20]=2;
|
|
||||||
d_val[21]= 437; a_val[21]=19; b_val[21]=1; r_val[21]=76;
|
|
||||||
d_val[22]= 30; a_val[22]= 5; b_val[22]=1; r_val[22]=5;
|
|
||||||
/* v1=23 INVALID */
|
|
||||||
d_val[24]= 143; a_val[24]=11; b_val[24]=1; r_val[24]=22;
|
|
||||||
d_val[25]= 69; a_val[25]= 9; b_val[25]=1; r_val[25]=12;
|
|
||||||
d_val[26]= 42; a_val[26]= 6; b_val[26]=1; r_val[26]=6;
|
|
||||||
d_val[27]= 29; a_val[27]= 5; b_val[27]=1; r_val[27]=4;
|
|
||||||
d_val[28]= 195; a_val[28]=13; b_val[28]=1; r_val[28]=26;
|
|
||||||
d_val[29]= 93; a_val[29]= 9; b_val[29]=1; r_val[29]=12;
|
|
||||||
d_val[30]= 14; a_val[30]= 4; b_val[30]=1; r_val[30]=2;
|
|
||||||
d_val[31]= 957; a_val[31]=29; b_val[31]=1; r_val[31]=116;
|
|
||||||
d_val[32]= 255; a_val[32]=15; b_val[32]=1; r_val[32]=30;
|
|
||||||
d_val[33]=1085; a_val[33]=31; b_val[33]=1; r_val[33]=124;
|
|
||||||
/* v1=34 INVALID */
|
|
||||||
d_val[35]=1221; a_val[35]=33; b_val[35]=1; r_val[35]=132;
|
|
||||||
d_val[36]= 323; a_val[36]=17; b_val[36]=1; r_val[36]=34;
|
|
||||||
d_val[37]=1365; a_val[37]=35; b_val[37]=1; r_val[37]=140;
|
|
||||||
d_val[38]= 10; a_val[38]= 3; b_val[38]=1; r_val[38]=1;
|
|
||||||
d_val[39]=1517; a_val[39]=37; b_val[39]=1; r_val[39]=148;
|
|
||||||
d_val[40]= 399; a_val[40]=19; b_val[40]=1; r_val[40]=38;
|
|
||||||
d_val[41]=1677; a_val[41]=39; b_val[41]=1; r_val[41]=156;
|
|
||||||
d_val[42]= 110; a_val[42]=10; b_val[42]=1; r_val[42]=10;
|
|
||||||
d_val[43]= 205; a_val[43]=15; b_val[43]=1; r_val[43]=20;
|
|
||||||
d_val[44]= 483; a_val[44]=21; b_val[44]=1; r_val[44]=42;
|
|
||||||
d_val[45]=2021; a_val[45]=43; b_val[45]=1; r_val[45]=172;
|
|
||||||
d_val[46]= 33; a_val[46]= 6; b_val[46]=1; r_val[46]=3;
|
|
||||||
/* v1=47 INVALID */
|
|
||||||
d_val[48]= 23; a_val[48]= 5; b_val[48]=1; r_val[48]=2;
|
|
||||||
d_val[49]=2397; a_val[49]=47; b_val[49]=1; r_val[49]=188;
|
|
||||||
d_val[50]= 39; a_val[50]= 6; b_val[50]=1; r_val[50]=3;
|
|
||||||
d_val[51]= 53; a_val[51]= 7; b_val[51]=1; r_val[51]=4;
|
|
||||||
/* v1=52 INVALID */
|
|
||||||
d_val[53]=2805; a_val[53]=51; b_val[53]=1; r_val[53]=204;
|
|
||||||
d_val[54]= 182; a_val[54]=13; b_val[54]=1; r_val[54]=13;
|
|
||||||
d_val[55]=3021; a_val[55]=53; b_val[55]=1; r_val[55]=212;
|
|
||||||
d_val[56]= 87; a_val[56]= 9; b_val[56]=1; r_val[56]=6;
|
|
||||||
d_val[57]=3245; a_val[57]=55; b_val[57]=1; r_val[57]=220;
|
|
||||||
d_val[58]= 210; a_val[58]=14; b_val[58]=1; r_val[58]=14;
|
|
||||||
d_val[59]=3477; a_val[59]=57; b_val[59]=1; r_val[59]=228;
|
|
||||||
d_val[60]= 899; a_val[60]=29; b_val[60]=1; r_val[60]=58;
|
|
||||||
d_val[61]= 413; a_val[61]=21; b_val[61]=1; r_val[61]=28;
|
|
||||||
/* v1=62 INVALID */
|
|
||||||
d_val[63]=3965; a_val[63]=61; b_val[63]=1; r_val[63]=244;
|
|
||||||
d_val[64]=1023; a_val[64]=31; b_val[64]=1; r_val[64]=62;
|
|
||||||
d_val[65]= 469; a_val[65]=21; b_val[65]=1; r_val[65]=28;
|
|
||||||
d_val[66]= 17; a_val[66]= 4; b_val[66]=1; r_val[66]=1;
|
|
||||||
d_val[67]=4485; a_val[67]=65; b_val[67]=1; r_val[67]=260;
|
|
||||||
d_val[68]=1155; a_val[68]=33; b_val[68]=1; r_val[68]=66;
|
|
||||||
d_val[69]=4757; a_val[69]=67; b_val[69]=1; r_val[69]=268;
|
|
||||||
d_val[70]= 34; a_val[70]= 6; b_val[70]=1; r_val[70]=2;
|
|
||||||
d_val[71]=5037; a_val[71]=69; b_val[71]=1; r_val[71]=276;
|
|
||||||
d_val[72]=1295; a_val[72]=35; b_val[72]=1; r_val[72]=70;
|
|
||||||
d_val[73]= 213; a_val[73]=15; b_val[73]=1; r_val[73]=12;
|
|
||||||
d_val[74]= 38; a_val[74]= 6; b_val[74]=1; r_val[74]=2;
|
|
||||||
d_val[75]=5621; a_val[75]=73; b_val[75]=1; r_val[75]=292;
|
|
||||||
d_val[76]=1443; a_val[76]=37; b_val[76]=1; r_val[76]=74;
|
|
||||||
d_val[77]= 237; a_val[77]=15; b_val[77]=1; r_val[77]=12;
|
|
||||||
d_val[78]= 95; a_val[78]=10; b_val[78]=1; r_val[78]=5;
|
|
||||||
/* v1=79 INVALID */
|
|
||||||
d_val[80]=1599; a_val[80]=39; b_val[80]=1; r_val[80]=78;
|
|
||||||
d_val[81]=6557; a_val[81]=79; b_val[81]=1; r_val[81]=316;
|
|
||||||
d_val[82]= 105; a_val[82]=10; b_val[82]=1; r_val[82]=5;
|
|
||||||
d_val[83]= 85; a_val[83]= 9; b_val[83]=1; r_val[83]=4;
|
|
||||||
d_val[84]=1763; a_val[84]=41; b_val[84]=1; r_val[84]=82;
|
|
||||||
d_val[85]=7221; a_val[85]=83; b_val[85]=1; r_val[85]=332;
|
|
||||||
d_val[86]= 462; a_val[86]=21; b_val[86]=1; r_val[86]=21;
|
|
||||||
d_val[87]=7565; a_val[87]=85; b_val[87]=1; r_val[87]=340;
|
|
||||||
d_val[88]= 215; a_val[88]=15; b_val[88]=1; r_val[88]=10;
|
|
||||||
d_val[89]=7917; a_val[89]=87; b_val[89]=1; r_val[89]=348;
|
|
||||||
d_val[90]= 506; a_val[90]=22; b_val[90]=1; r_val[90]=22;
|
|
||||||
d_val[91]=8277; a_val[91]=89; b_val[91]=1; r_val[91]=356;
|
|
||||||
d_val[92]= 235; a_val[92]=15; b_val[92]=1; r_val[92]=10;
|
|
||||||
d_val[93]=8645; a_val[93]=91; b_val[93]=1; r_val[93]=364;
|
|
||||||
d_val[94]= 138; a_val[94]=12; b_val[94]=1; r_val[94]=6;
|
|
||||||
d_val[95]=9021; a_val[95]=93; b_val[95]=1; r_val[95]=372;
|
|
||||||
d_val[96]= 47; a_val[96]= 7; b_val[96]=1; r_val[96]=2;
|
|
||||||
d_val[97]=1045; a_val[97]=33; b_val[97]=1; r_val[97]=44;
|
|
||||||
/* v1=98 INVALID */
|
|
||||||
d_val[99]=9797; a_val[99]=97; b_val[99]=1; r_val[99]=388;
|
|
||||||
d_val[100]= 51; a_val[100]= 7; b_val[100]=1; r_val[100]=2;
|
|
||||||
|
|
||||||
if (config("resource_debug") & 3) {
|
|
||||||
print "d_val[100] defined";
|
|
||||||
print "a_val[100] defined";
|
|
||||||
print "b_val[100] defined";
|
|
||||||
print "r_val[100] defined";
|
|
||||||
}
|
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: mersenne.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/mersenne.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/05/22 21:56:36
|
* Under source code control: 1991/05/22 21:56:36
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* mfactor - return the lowest factor of 2^n-1, for n > 0
|
* mfactor - return the lowest factor of 2^n-1, for n > 0
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: mfactor.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/mfactor.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/07/06 06:09:40
|
* Under source code control: 1996/07/06 06:09:40
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
@@ -83,7 +79,7 @@
|
|||||||
* hindx = 0;
|
* hindx = 0;
|
||||||
* } while (test_factor < some_limit);
|
* } while (test_factor < some_limit);
|
||||||
*
|
*
|
||||||
* The test, mfactor(67, 1, 10000) took on an 200 Mhz r4k (user CPU seconds):
|
* The test, mfactor(67, 1, 10000) took on an 200 MHz r4k (user CPU seconds):
|
||||||
*
|
*
|
||||||
* 210.83 (prior to use of hset[])
|
* 210.83 (prior to use of hset[])
|
||||||
* 78.35 (hset[] for p_elim = 7)
|
* 78.35 (hset[] for p_elim = 7)
|
||||||
@@ -103,7 +99,7 @@
|
|||||||
* 57.78 (hset[] for p_elim = 17)
|
* 57.78 (hset[] for p_elim = 17)
|
||||||
* p_elim == 19 rejected because of memory size
|
* p_elim == 19 rejected because of memory size
|
||||||
*
|
*
|
||||||
* The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and
|
* The p_elim == 17 overhead takes ~3 minutes on an 200 MHz r4k CPU and
|
||||||
* requires about ~13 Megs of memory. The p_elim == 13 overhead
|
* requires about ~13 Megs of memory. The p_elim == 13 overhead
|
||||||
* takes about 3 seconds and requires ~1.5 Megs of memory.
|
* takes about 3 seconds and requires ~1.5 Megs of memory.
|
||||||
*
|
*
|
||||||
@@ -260,7 +256,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
|||||||
return q;
|
return q;
|
||||||
} else {
|
} else {
|
||||||
/* report this loop */
|
/* report this loop */
|
||||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
printf("at 2*%d*%d+1, CPU: %f\n",
|
||||||
(q-1)/(2*n), n, usertime());
|
(q-1)/(2*n), n, usertime());
|
||||||
fflush(files(1));
|
fflush(files(1));
|
||||||
loop = 0;
|
loop = 0;
|
||||||
@@ -273,14 +269,14 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
|||||||
*/
|
*/
|
||||||
if (rept_loop <= ++loop) {
|
if (rept_loop <= ++loop) {
|
||||||
/* report this loop */
|
/* report this loop */
|
||||||
printf("at 2*%d*%d+1, cpu: %f\n",
|
printf("at 2*%d*%d+1, CPU: %f\n",
|
||||||
(q-1)/(2*n), n, usertime());
|
(q-1)/(2*n), n, usertime());
|
||||||
fflush(files(1));
|
fflush(files(1));
|
||||||
loop = 0;
|
loop = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skip if divisable by a prime <= 449
|
* skip if divisible by a prime <= 449
|
||||||
*
|
*
|
||||||
* The value 281 was determined by timing loops
|
* The value 281 was determined by timing loops
|
||||||
* which found that 281 was at or near the
|
* which found that 281 was at or near the
|
||||||
@@ -289,7 +285,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
|||||||
* The addition of the do { ... } while (factor(q, 449)>1);
|
* The addition of the do { ... } while (factor(q, 449)>1);
|
||||||
* loop reduced the factoring loop time (36504 k values with
|
* loop reduced the factoring loop time (36504 k values with
|
||||||
* the hset[] initialization time removed) from 25.69 sec to
|
* the hset[] initialization time removed) from 25.69 sec to
|
||||||
* 15.62 sec of CPU time on a 200Mhz r4k.
|
* 15.62 sec of CPU time on a 200MHz r4k.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
/*
|
/*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: mod.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/mod.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:34
|
* Under source code control: 1990/02/15 01:50:34
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* natnumset - functions for sets of natural numbers not exceeding a fixed bound
|
* natnumset - functions for sets of natural numbers not exceeding a fixed bound
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen
|
* Copyright (C) 1999,2021 Ernest Bowen
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: natnumset.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/natnumset.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/09/07 23:53:51
|
* Under source code control: 1997/09/07 23:53:51
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
@@ -80,7 +76,7 @@
|
|||||||
* A \ B = set difference, integers in A but not in B
|
* A \ B = set difference, integers in A but not in B
|
||||||
*
|
*
|
||||||
* ~A = complement of A, integers not in A
|
* ~A = complement of A, integers not in A
|
||||||
* #A = number ofintegers in A
|
* #A = number of integers in A
|
||||||
* !A = 1 or 0 according as A is empty or not empty
|
* !A = 1 or 0 according as A is empty or not empty
|
||||||
* +A = sum of the members of A
|
* +A = sum of the members of A
|
||||||
*
|
*
|
||||||
@@ -104,7 +100,7 @@
|
|||||||
* A >= B = (B <= A)
|
* A >= B = (B <= A)
|
||||||
* A > B = (B < A)
|
* A > B = (B < A)
|
||||||
*
|
*
|
||||||
* Expresssions may be formed from the above "arithmetic" operations in
|
* Expressions may be formed from the above "arithmetic" operations in
|
||||||
* the usual way, with parentheses for variations from the usual precedence
|
* the usual way, with parentheses for variations from the usual precedence
|
||||||
* rules. For example
|
* rules. For example
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* pell - solve Pell's equation
|
* pell - solve Pell's equation
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999,2021 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: pell.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/pell.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:34
|
* Under source code control: 1990/02/15 01:50:34
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
@@ -29,7 +25,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
|
* Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1.
|
||||||
* Type the solution to pells equation for a particular D.
|
* Type the solution to Pell's equation for a particular D.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: pi.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/pi.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/05/22 21:56:37
|
* Under source code control: 1991/05/22 21:56:37
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: pix.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/pix.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/07/09 03:14:14
|
* Under source code control: 1996/07/09 03:14:14
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: pollard.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/pollard.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1991/05/22 21:56:37
|
* Under source code control: 1991/05/22 21:56:37
|
||||||
* File existed as early as: 1991
|
* File existed as early as: 1991
|
||||||
*
|
*
|
||||||
|
10
cal/poly.cal
10
cal/poly.cal
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* poly - calculate with polynomials of one variable
|
* poly - calculate with polynomials of one variable
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen
|
* Copyright (C) 1999,2021 Ernest Bowen
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: poly.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/poly.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
@@ -39,7 +35,7 @@
|
|||||||
* variable has only one name. For some purposes, a name like
|
* variable has only one name. For some purposes, a name like
|
||||||
* "sin(t)" or "(a + b)" or "\lambda" might be useful;
|
* "sin(t)" or "(a + b)" or "\lambda" might be useful;
|
||||||
* names like "*" or "-27" are legal but might give expressions
|
* names like "*" or "-27" are legal but might give expressions
|
||||||
* that are difficult to intepret.
|
* that are difficult to interpret.
|
||||||
*
|
*
|
||||||
* Polynomial expressions may be constructed from numbers and the
|
* Polynomial expressions may be constructed from numbers and the
|
||||||
* independent variable and other polynomials by the algebraic
|
* independent variable and other polynomials by the algebraic
|
||||||
@@ -47,7 +43,7 @@
|
|||||||
* The operations // and % are defined to have the quotient and
|
* The operations // and % are defined to have the quotient and
|
||||||
* remainder meanings as usually defined for polynomials.
|
* remainder meanings as usually defined for polynomials.
|
||||||
*
|
*
|
||||||
* When polynomials are assigned to idenfifiers, it is convenient to
|
* When polynomials are assigned to identifiers, it is convenient to
|
||||||
* think of the polynomials as values. For example, p = (x - 1)^2
|
* think of the polynomials as values. For example, p = (x - 1)^2
|
||||||
* assigns to p a polynomial value in the same way as q = (7 - 1)^2
|
* assigns to p a polynomial value in the same way as q = (7 - 1)^2
|
||||||
* would assign to q a number value. As with number expressions
|
* would assign to q a number value. As with number expressions
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* prompt - eemonstration of some uses of prompt() and eval()
|
* prompt - demonstration of some uses of prompt() and eval()
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen
|
* Copyright (C) 1999,2021 Ernest Bowen
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: prompt.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/prompt.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/12/18 04:43:25
|
* Under source code control: 1995/12/18 04:43:25
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -65,9 +61,9 @@
|
|||||||
* nothing to sum. The last line returns the value 3, i.e. the last
|
* nothing to sum. The last line returns the value 3, i.e. the last
|
||||||
* non-null value found for the expressions separated by semicolons,
|
* non-null value found for the expressions separated by semicolons,
|
||||||
* so sum will be increased by 3 after the "print sum^2;" command
|
* so sum will be increased by 3 after the "print sum^2;" command
|
||||||
* is executed. xxx The terminating semicolon is essential in the
|
* is executed. XXX The terminating semicolon is essential in the
|
||||||
* last two lines. A command like eval("print 7;") is acceptable to
|
* last two lines. A command like eval("print 7;") is acceptable to
|
||||||
* calc but eval("print 7") causes an exit from calc. xxx)
|
* calc but eval("print 7") causes an exit from calc. XXX)
|
||||||
*
|
*
|
||||||
* If the value returned is not a number (e.g. the name of a list or matrix,
|
* If the value returned is not a number (e.g. the name of a list or matrix,
|
||||||
* or if the string has syntax errors as in "2 + ", in which case the
|
* or if the string has syntax errors as in "2 + ", in which case the
|
||||||
@@ -79,7 +75,7 @@
|
|||||||
* "sin(x)", "x^2 + 3*x", "exp(x, 1e-5)".
|
* "sin(x)", "x^2 + 3*x", "exp(x, 1e-5)".
|
||||||
*
|
*
|
||||||
* Values of the function so defined are returned for values of x
|
* Values of the function so defined are returned for values of x
|
||||||
* entered in reponse to the ? prompt. Operation is terminated by
|
* entered in response to the ? prompt. Operation is terminated by
|
||||||
* entering "end", "exit" or "quit".
|
* entering "end", "exit" or "quit".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: psqrt.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/psqrt.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -20,10 +20,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: qtime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/qtime.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1999/10/13 04:10:33
|
* Under source code control: 1999/10/13 04:10:33
|
||||||
* File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* quat - alculate using quaternions of the form: a + bi + cj + dk
|
* quat - calculate using quaternions of the form: a + bi + cj + dk
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 David I. Bell
|
* Copyright (C) 1999,2021 David I. Bell
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: quat.cal,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/quat.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:35
|
* Under source code control: 1990/02/15 01:50:35
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: randbitrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/randbitrun.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/02/13 03:43:11
|
* Under source code control: 1995/02/13 03:43:11
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* randmprime - generate a random prime of the form h*2^n-1
|
* randmprime - generate a random prime of the form h*2^n-1
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999,2021 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: randmprime.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/randmprime.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1994/03/14 23:11:21
|
* Under source code control: 1994/03/14 23:11:21
|
||||||
* File existed as early as: 1994
|
* File existed as early as: 1994
|
||||||
*
|
*
|
||||||
@@ -49,9 +45,9 @@ randmprime(bits, seed, dbg)
|
|||||||
local n; /* n as in h*2^n-1 */
|
local n; /* n as in h*2^n-1 */
|
||||||
local h; /* h as in h*2^n-1 */
|
local h; /* h as in h*2^n-1 */
|
||||||
local plush; /* value added to h since the beginning */
|
local plush; /* value added to h since the beginning */
|
||||||
local init; /* initial cpu time */
|
local init; /* initial CPU time */
|
||||||
local start; /* cpu time before last test */
|
local start; /* CPU time before last test */
|
||||||
local stop; /* cpu time afte last test */
|
local stop; /* CPU time after last test */
|
||||||
local tmp; /* just a tmp place holder value */
|
local tmp; /* just a tmp place holder value */
|
||||||
local ret; /* h*2^n-1 that is prime */
|
local ret; /* h*2^n-1 that is prime */
|
||||||
|
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: randombitrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/randombitrun.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/02/13 03:43:11
|
* Under source code control: 1995/02/13 03:43:11
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: randomrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/randomrun.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/02/19 03:35:59
|
* Under source code control: 1997/02/19 03:35:59
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: randrun.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/randrun.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/02/12 20:00:06
|
* Under source code control: 1995/02/12 20:00:06
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
858
cal/regress.cal
858
cal/regress.cal
File diff suppressed because it is too large
Load Diff
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: repeat.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/repeat.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2003/01/05 00:00:01
|
* Under source code control: 2003/01/05 00:00:01
|
||||||
* File existed as early as: 2003
|
* File existed as early as: 2003
|
||||||
*
|
*
|
||||||
|
@@ -15,10 +15,6 @@
|
|||||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: screen.cal,v 30.2 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/screen.cal,v $
|
|
||||||
*
|
|
||||||
* This file is not covered under version 2.1 of the GNU LGPL.
|
* This file is not covered under version 2.1 of the GNU LGPL.
|
||||||
*
|
*
|
||||||
* Under source code control: 2006/03/08 05:54:09
|
* Under source code control: 2006/03/08 05:54:09
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: seedrandom.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/seedrandom.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/01/01 08:21:00
|
* Under source code control: 1996/01/01 08:21:00
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: set8700.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/set8700.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2006/05/20 14:10:11
|
* Under source code control: 2006/05/20 14:10:11
|
||||||
* File existed as early as: 2006
|
* File existed as early as: 2006
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 30.1 $
|
|
||||||
## @(#) $Id: set8700.line,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/bin/calc/cal/RCS/set8700.line,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 2006/05/20 14:10:11
|
## Under source code control: 2006/05/20 14:10:11
|
||||||
## File existed as early as: 2006
|
## File existed as early as: 2006
|
||||||
##
|
##
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.3 $
|
|
||||||
* @(#) $Id: solve.cal,v 30.3 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/solve.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:37
|
* Under source code control: 1990/02/15 01:50:37
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* specialfunctions - special functions (e.g.: gamma, zeta, psi)
|
* specialfunctions - special functions (e.g.: gamma, zeta, psi)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the version 2.1 of the GNU Lesser General Public
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.6 $
|
|
||||||
* @(#) $Id: specialfunctions.cal,v 30.6 2013/09/01 17:48:27 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/specialfunctions.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
@@ -446,8 +442,8 @@ define lngamma(z)
|
|||||||
if (tmp2 < tmp) {
|
if (tmp2 < tmp) {
|
||||||
return
|
return
|
||||||
newerror(strcat
|
newerror(strcat
|
||||||
("lngamma(1): something happend that ",
|
("lngamma(1): something happened ",
|
||||||
"should not have happend"));
|
"that shouldn't have happened"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,8 +519,8 @@ define lngamma(z)
|
|||||||
if (tmp2 < tmp) {
|
if (tmp2 < tmp) {
|
||||||
return
|
return
|
||||||
newerror(strcat
|
newerror(strcat
|
||||||
("lngamma(1): something happend ",
|
("lngamma(1): something happened ",
|
||||||
"that should not have happend"));
|
"that should not have happened"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -580,8 +576,8 @@ define lngamma(z)
|
|||||||
if (tmp2 < tmp) {
|
if (tmp2 < tmp) {
|
||||||
return
|
return
|
||||||
newerror(strcat
|
newerror(strcat
|
||||||
("lngamma(1): something happend ",
|
("lngamma(1): something happened ",
|
||||||
"that should not have happend"));
|
"that should not have happened"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1051,7 +1047,7 @@ define __CZ__ibeta_cf_var_dm(a, b, z, max)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m > max) {
|
if (m > max) {
|
||||||
return newerror("ibeta: continous fraction does not converge");
|
return newerror("ibeta: continuous fraction does not converge");
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@@ -1294,7 +1290,7 @@ define __CZ__erfinvapprox(x)
|
|||||||
- (2 / (pi() * a) + (ln(1 - x ^ 2)) / 2));
|
- (2 / (pi() * a) + (ln(1 - x ^ 2)) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complementary inverse errror function, faster at about x < 1-.91
|
/* complementary inverse error function, faster at about x < 1-.91
|
||||||
Henry E. Fettis. "A stable algorithm for computing the inverse error function
|
Henry E. Fettis. "A stable algorithm for computing the inverse error function
|
||||||
in the 'tail-end' region" Math. Comp., 28:585-587, 1974.
|
in the 'tail-end' region" Math. Comp., 28:585-587, 1974.
|
||||||
*/
|
*/
|
||||||
@@ -1328,7 +1324,7 @@ define __CZ__fettiscf(y, n)
|
|||||||
return t / (1 + r);
|
return t / (1 + r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* inverse errror function, faster at about x<=.91*/
|
/* inverse error function, faster at about x<=.91*/
|
||||||
define __CZ__inverfbin(x)
|
define __CZ__inverfbin(x)
|
||||||
{
|
{
|
||||||
local places approx flow fhigh eps high low mid fmid epsilon;
|
local places approx flow fhigh eps high low mid fmid epsilon;
|
||||||
@@ -1374,7 +1370,7 @@ define erfinv(x)
|
|||||||
x = -x;
|
x = -x;
|
||||||
flag = 1;
|
flag = 1;
|
||||||
}
|
}
|
||||||
/* No need for full pecision */
|
/* No need for full precision */
|
||||||
eps = epsilon(1e-20);
|
eps = epsilon(1e-20);
|
||||||
if (eps >= 1e-40) {
|
if (eps >= 1e-40) {
|
||||||
/* Winitzki, Sergei (6 February 2008). "A handy approximation for the
|
/* Winitzki, Sergei (6 February 2008). "A handy approximation for the
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* statistics - Some assorted statistics functions.
|
* statistics - Some assorted statistics functions.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Christoph Zurnieden
|
* Copyright (C) 2013,2021 Christoph Zurnieden
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* 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
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.4 $
|
|
||||||
* @(#) $Id: statistics.cal,v 30.4 2013/08/18 20:01:53 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/statistics.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2013/08/11 01:31:28
|
* Under source code control: 2013/08/11 01:31:28
|
||||||
* File existed as early as: 2013
|
* File existed as early as: 2013
|
||||||
*/
|
*/
|
||||||
@@ -110,7 +106,7 @@ define invbetainc_slow(x,a,b){
|
|||||||
GW Cran, KJ Martin, GE Thomas,
|
GW Cran, KJ Martin, GE Thomas,
|
||||||
Remark AS R19 and Algorithm AS 109:
|
Remark AS R19 and Algorithm AS 109:
|
||||||
A Remark on Algorithms AS 63: The Incomplete Beta Integral
|
A Remark on Algorithms AS 63: The Incomplete Beta Integral
|
||||||
and AS 64: Inverse of the Incomplete Beta Integeral,
|
and AS 64: Inverse of the Incomplete Beta integral,
|
||||||
Applied Statistics,
|
Applied Statistics,
|
||||||
Volume 26, Number 1, 1977, pages 111-114.
|
Volume 26, Number 1, 1977, pages 111-114.
|
||||||
|
|
||||||
@@ -375,7 +371,7 @@ define normalcdf(x,mu,sigma){
|
|||||||
|
|
||||||
define probit(p){
|
define probit(p){
|
||||||
if(p<0 || p > 1) return newerror("probit: p out of domain 0<=p<=1");
|
if(p<0 || p > 1) return newerror("probit: p out of domain 0<=p<=1");
|
||||||
return sqrt(2)*ervinv(2*p-1);
|
return sqrt(2)*erfinv(2*p-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
define normalcdfinv(p,mu,sigma){
|
define normalcdfinv(p,mu,sigma){
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: sumsq.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/sumsq.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:37
|
* Under source code control: 1990/02/15 01:50:37
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: sumtimes.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/sumtimes.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 2006/06/22 17:29
|
* Under source code control: 2006/06/22 17:29
|
||||||
* File existed as early as: 2006
|
* File existed as early as: 2006
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: surd.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/surd.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1990/02/15 01:50:38
|
* Under source code control: 1990/02/15 01:50:38
|
||||||
* File existed as early as: before 1990
|
* File existed as early as: before 1990
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test1700.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test1700.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1994/03/14 23:12:51
|
* Under source code control: 1994/03/14 23:12:51
|
||||||
* File existed as early as: 1994
|
* File existed as early as: 1994
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test2300.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test2300.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/07/09 06:12:13
|
* Under source code control: 1995/07/09 06:12:13
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* test2600 - 2600 series of the regress.cal test suite
|
* test2600 - 2600 series of the regress.cal test suite
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: Ernest Bowen
|
* Primary author: Ernest Bowen
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.3 $
|
|
||||||
* @(#) $Id: test2600.cal,v 30.3 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test2600.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/10/13 00:13:14
|
* Under source code control: 1995/10/13 00:13:14
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -54,7 +50,7 @@
|
|||||||
* of b in power(a, b, eps) is large, the computation required for
|
* of b in power(a, b, eps) is large, the computation required for
|
||||||
* a test may be very heavy.
|
* a test may be very heavy.
|
||||||
*
|
*
|
||||||
* Test funcations are called as:
|
* Test functions are called as:
|
||||||
*
|
*
|
||||||
* testabc(str, ..., verbose)
|
* testabc(str, ..., verbose)
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* test2700 - 2700 series of the regress.cal test suite
|
* test2700 - 2700 series of the regress.cal test suite
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: Ernest Bowen
|
* Primary author: Ernest Bowen
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: test2700.cal,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test2700.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/11/01 22:52:25
|
* Under source code control: 1995/11/01 22:52:25
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
@@ -88,7 +84,7 @@ define mkfrac() = rand(2) ? mkposfrac() : -mkposfrac();
|
|||||||
define mksquarereal() = mknonnegreal()^2;
|
define mksquarereal() = mknonnegreal()^2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We might be able to do better than the following. For nonsquare
|
* We might be able to do better than the following. For non-square
|
||||||
* positive integer less than 1e6, could use:
|
* positive integer less than 1e6, could use:
|
||||||
* x = rand(1, 1000);
|
* x = rand(1, 1000);
|
||||||
* return rand(x^2 + 1, (x + 1)^2);
|
* return rand(x^2 + 1, (x + 1)^2);
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test3100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test3100.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/11/28 11:56:57
|
* Under source code control: 1995/11/28 11:56:57
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test3300.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test3300.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/12/02 04:27:41
|
* Under source code control: 1995/12/02 04:27:41
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test3400.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test3400.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/12/02 05:20:11
|
* Under source code control: 1995/12/02 05:20:11
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test3500.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test3500.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1995/12/18 22:50:46
|
* Under source code control: 1995/12/18 22:50:46
|
||||||
* File existed as early as: 1995
|
* File existed as early as: 1995
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.2 $
|
|
||||||
* @(#) $Id: test4000.cal,v 30.2 2013/08/11 08:41:38 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test4000.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/03/13 02:38:45
|
* Under source code control: 1996/03/13 02:38:45
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test4100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test4100.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/03/13 03:53:22
|
* Under source code control: 1996/03/13 03:53:22
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test4600.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test4600.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/07/02 20:04:40
|
* Under source code control: 1996/07/02 20:04:40
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* test5100 - 5100 series of the regress.cal test suite
|
* test5100 - 5100 series of the regress.cal test suite
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
|
* Copyright (C) 1999,2021 Ernest Bowen and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: Ernest Bowen
|
* Primary author: Ernest Bowen
|
||||||
*
|
*
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test5100.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test5100.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1996/12/02 23:57:10
|
* Under source code control: 1996/12/02 23:57:10
|
||||||
* File existed as early as: 1996
|
* File existed as early as: 1996
|
||||||
*
|
*
|
||||||
@@ -39,7 +35,7 @@ defaultverbose = 1; /* default verbose value */
|
|||||||
* with zero value, when the definition is read.
|
* with zero value, when the definition is read.
|
||||||
*
|
*
|
||||||
* The variable a5100 is initialized with the value x if and when this
|
* The variable a5100 is initialized with the value x if and when this
|
||||||
* function is first called with a positive even x. The varable b5100
|
* function is first called with a positive even x. The variable b5100
|
||||||
* is similarly initialized if and when this function is first called positive
|
* is similarly initialized if and when this function is first called positive
|
||||||
* odd x.
|
* odd x.
|
||||||
*
|
*
|
||||||
|
@@ -19,10 +19,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test5200.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test5200.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1997/02/07 02:48:10
|
* Under source code control: 1997/02/07 02:48:10
|
||||||
* File existed as early as: 1997
|
* File existed as early as: 1997
|
||||||
*
|
*
|
||||||
|
@@ -17,10 +17,6 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 30.1 $
|
|
||||||
* @(#) $Id: test8400.cal,v 30.1 2007/03/16 11:09:54 chongo Exp $
|
|
||||||
* @(#) $Source: /usr/local/src/bin/calc/cal/RCS/test8400.cal,v $
|
|
||||||
*
|
|
||||||
* Under source code control: 1999/10/31 01:00:03
|
* Under source code control: 1999/10/31 01:00:03
|
||||||
* File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
*
|
*
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user