mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.0.3
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.18 $
|
||||
# @(#) $Id: Makefile,v 29.18 2006/05/20 19:32:40 chongo Exp $
|
||||
# @(#) $Revision: 29.19 $
|
||||
# @(#) $Id: Makefile,v 29.19 2006/06/10 13:01:34 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
@@ -177,7 +177,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
||||
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
|
||||
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
|
||||
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal screen.cal \
|
||||
dotest.cal set8700.cal set8700.line
|
||||
dotest.cal set8700.cal set8700.line alg_config.cal
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
|
72
cal/README
72
cal/README
@@ -75,7 +75,7 @@ have meanings are as follows:
|
||||
is displayed.
|
||||
|
||||
2 Show func will display more information about a functions
|
||||
arguments as well as more argument sdummary information.
|
||||
arguments as well as more argument summary information.
|
||||
|
||||
3 During execution, allow calc standard resource files
|
||||
to output additional debugging information.
|
||||
@@ -103,7 +103,7 @@ either of the bottom 2 bits set:
|
||||
print "funcB(size, mass, ...) defined";
|
||||
}
|
||||
|
||||
If your the resource file needs to output special debugging informatin,
|
||||
If your the resource file needs to output special debugging information,
|
||||
we recommend that you check for bit 3 of the config("resource_debug")
|
||||
before printing the debug statement:
|
||||
|
||||
@@ -117,12 +117,68 @@ The following is a brief description of some of the calc resource files
|
||||
that are shipped with calc. See above for example of how to read in
|
||||
and execute these files.
|
||||
|
||||
alg_config.cal
|
||||
|
||||
global test_time
|
||||
mul_loop(repeat,x) defined
|
||||
mul_ratio(len) defined
|
||||
best_mul2() defined
|
||||
sq_loop(repeat,x) defined
|
||||
sq_ratio(len) defined
|
||||
best_sq2() defined
|
||||
pow_loop(repeat,x,ex) defined
|
||||
pow_ratio(len) defined
|
||||
best_pow2() defined
|
||||
|
||||
These functions search for an optimal value of config("mul2"),
|
||||
config("sq2"), and config("pow2"). The calc default values of these
|
||||
configuration values were set by running this resource file on a
|
||||
1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS.
|
||||
|
||||
The best_mul2() function returns the optimal value of config("mul2").
|
||||
The best_sq2() function returns the optimal value of config("sq2").
|
||||
The best_pow2() function returns the optimal value of config("pow2").
|
||||
The other functions are just support functions.
|
||||
|
||||
By design, best_mul2(), best_sq2(), and best_pow2() take a few
|
||||
minutes to run. These functions increase the number of times a
|
||||
given computational loop is executed until a minimum amount of CPU
|
||||
time is consumed. To watch these functions progress, one can set
|
||||
the config("user_debug") value.
|
||||
|
||||
Here is a suggested way to use this resource file:
|
||||
|
||||
; read alg_config
|
||||
; config("user_debug",2),;
|
||||
; best_mul2(); best_sq2(); best_pow2();
|
||||
; best_mul2(); best_sq2(); best_pow2();
|
||||
; best_mul2(); best_sq2(); best_pow2();
|
||||
|
||||
NOTE: It is perfectly normal for the optimal value returned to differ
|
||||
slightly from run to run. Slight variations due to inaccuracy in
|
||||
CPU timings will cause the best value returned to differ slightly
|
||||
from run to run.
|
||||
|
||||
One can use a calc startup file to change the initial values of
|
||||
config("mul2"), config("sq2"), and config("pow2"). For example one
|
||||
can place into ~/.calcrc these lines:
|
||||
|
||||
config("mul2", 1780),;
|
||||
config("sq2", 3388),;
|
||||
config("pow2", 176),;
|
||||
|
||||
to automatically and silently change these config values.
|
||||
See help/config and CALCRC in help/environment for more information.
|
||||
|
||||
|
||||
beer.cal
|
||||
|
||||
Calc's contribution to the 99 Bottles of Beer web page:
|
||||
|
||||
http://www.ionet.net/~timtroyr/funhouse/beer.html#calc
|
||||
|
||||
NOTE: This resource produces a lot of output. :-)
|
||||
|
||||
|
||||
bernoulli.cal
|
||||
|
||||
@@ -132,7 +188,7 @@ bernoulli.cal
|
||||
|
||||
NOTE: There is now a bernoulli() builtin function. This file is
|
||||
left here for backward compatibility and now simply returns
|
||||
the buildin function.
|
||||
the builtin function.
|
||||
|
||||
|
||||
bigprime.cal
|
||||
@@ -153,9 +209,9 @@ chi.cal
|
||||
|
||||
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
|
||||
a sifficently small error term as the degress gets large (>100).
|
||||
a sufficiently small error term as the degrees gets large (>100).
|
||||
|
||||
The Z(x) and P(x) are internal statistical funcions.
|
||||
The Z(x) and P(x) are internal statistical functions.
|
||||
|
||||
eps is an optional epsilon() like error term.
|
||||
|
||||
@@ -226,6 +282,8 @@ hello.cal
|
||||
http://www.latech.edu/~acm/HelloWorld.shtml
|
||||
http://www.latech.edu/~acm/helloworld/calc.html
|
||||
|
||||
NOTE: This resource produces a lot of output. :-)
|
||||
|
||||
|
||||
intfile.cal
|
||||
|
||||
@@ -935,8 +993,8 @@ xx_print.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.12 $
|
||||
## @(#) $Id: README,v 29.12 2006/05/21 04:41:09 chongo Exp $
|
||||
## @(#) $Revision: 29.14 $
|
||||
## @(#) $Id: README,v 29.14 2006/06/11 07:22:05 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
|
1253
cal/alg_config.cal
Normal file
1253
cal/alg_config.cal
Normal file
File diff suppressed because it is too large
Load Diff
112
cal/regress.cal
112
cal/regress.cal
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.26 $
|
||||
* @(#) $Id: regress.cal,v 29.26 2006/06/02 09:49:13 chongo Exp $
|
||||
* @(#) $Revision: 29.29 $
|
||||
* @(#) $Id: regress.cal,v 29.29 2006/06/11 07:07:23 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:36
|
||||
@@ -404,14 +404,14 @@ define test_config()
|
||||
'512: config("trace") == 0');
|
||||
vrfy(config("maxprint") == 16,
|
||||
'513: config("maxprint") == 16');
|
||||
vrfy(config("mul2") == 20,
|
||||
'514: config("mul2") == 20');
|
||||
vrfy(config("sq2") == 20,
|
||||
'515: config("sq2") == 20');
|
||||
vrfy(config("pow2") == 40,
|
||||
'516: config("pow2") == 40');
|
||||
vrfy(config("redc2") == 50,
|
||||
'517: config("redc2") == 50');
|
||||
vrfy(config("mul2") == 1780,
|
||||
'514: config("mul2") == 1780');
|
||||
vrfy(config("sq2") == 3388,
|
||||
'515: config("sq2") == 3388');
|
||||
vrfy(config("pow2") == 176,
|
||||
'516: config("pow2") == 176');
|
||||
vrfy(config("redc2") == 220,
|
||||
'517: config("redc2") == 220');
|
||||
vrfy(config("tilde"),
|
||||
'518: config("tilde")');
|
||||
vrfy(config("tab"),
|
||||
@@ -5226,6 +5226,11 @@ define test_is()
|
||||
local square; /* square of an odd prime */
|
||||
local string; /* string */
|
||||
local com; /* complex value */
|
||||
local rndint; /* a random integer */
|
||||
local rndexp; /* a random exponent */
|
||||
local rndval; /* rndint ^ rndexp */
|
||||
local i; /* integer value */
|
||||
local ok; /* 1 ==> issq() tests were OK, 0 ==> failure */
|
||||
|
||||
print '5900: Beginning test_is';
|
||||
|
||||
@@ -6163,15 +6168,75 @@ define test_is()
|
||||
vrfy(istype(matrix,odd) == 0, '6661: istype(matrix,odd) == 0');
|
||||
vrfy(istype(a,odd) == 0, '6662: istype(a,odd) == 0');
|
||||
|
||||
/*
|
||||
* perform more extensive issq() testing
|
||||
*/
|
||||
ok = 1;
|
||||
for (i=0; i < 256; ++i) {
|
||||
/* rndval will be a square - even powers>0 of x>1 */
|
||||
rndexp = random(1, 16) * 2;
|
||||
rndint = random(2, 4294967296);
|
||||
if (issq(rndint)) {
|
||||
++rndint;
|
||||
}
|
||||
rndval = rndint ^ rndexp;
|
||||
if (issq(rndval) == 0) {
|
||||
prob(strprintf("issq(%d^%d) returned 0",
|
||||
rndint, rndexp));
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
print '6663: issq() on 256 squares';
|
||||
} else {
|
||||
print '****: failure(s): 6663: faiissq() on 256 squares';
|
||||
}
|
||||
for (i=0; i < 256; ++i) {
|
||||
/* rndval will not be a square - 1 + even powers>0 of x>1 */
|
||||
rndexp = random(1, 16) * 2;
|
||||
rndint = random(2, 4294967296);
|
||||
rndval = rndint ^ rndexp;
|
||||
if (issq(rndval+1) != 0) {
|
||||
prob(strprintf("issq(%d^%d)+1 returned non-zero",
|
||||
rndint, rndexp));
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
print '6664: issq() on 256 squares+1';
|
||||
} else {
|
||||
print '****: failure(s): 6664: issq() on 256 squares+1';
|
||||
}
|
||||
print '6664: issq() on 256 squares+1';
|
||||
for (i=0; i < 256; ++i) {
|
||||
/* rndval will not be a square - odd powers>0 of x>1 */
|
||||
rndexp = (random(1, 16) * 2) + 1;
|
||||
rndint = random(2, 4294967296);
|
||||
if (issq(rndint)) {
|
||||
++rndint;
|
||||
}
|
||||
rndval = rndint ^ rndexp;
|
||||
if (issq(rndval) != 0) {
|
||||
prob(strprintf("issq(%d^%d) returned non-zero",
|
||||
rndint, rndexp));
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
print '6665: issq() on 256 non-squares';
|
||||
} else {
|
||||
print '****: failure(s): 6665: issq() on 256 non-squares';
|
||||
}
|
||||
|
||||
/*
|
||||
* cleanup
|
||||
*/
|
||||
blkfree("blk5900");
|
||||
print '6663: blkfree("blk5900")';
|
||||
print '6666: blkfree("blk5900")';
|
||||
fclose(ofd);
|
||||
print '6664: fclose(ofd)';
|
||||
print '6667: fclose(ofd)';
|
||||
|
||||
print '6665: Ending test_is';
|
||||
print '6668: Ending test_is';
|
||||
}
|
||||
print '168: test_is()';
|
||||
|
||||
@@ -7847,7 +7912,26 @@ read -once varargs;
|
||||
print '9827: read -once varargs';
|
||||
read -once qtime;
|
||||
print '9828: read -once qtime';
|
||||
print '9829: Ending read of selected calc resource files';
|
||||
read -once chi;
|
||||
print '9829: read -once chi';
|
||||
read -once intfile;
|
||||
print '9830: read -once intfile';
|
||||
read -once lucas;
|
||||
print '9831: read -once lucas';
|
||||
read -once lucas_tbl;
|
||||
print '9832: read -once lucas_tbl';
|
||||
read -once natnumset;
|
||||
print '9833: read -once natnumset';
|
||||
read -once repeat;
|
||||
print '9834: read -once repeat';
|
||||
read -once screen;
|
||||
print '9835: read -once screen';
|
||||
read -once linear;
|
||||
print '9836: read -once linear';
|
||||
print '9837: skipping read -once beer.cal because it is an infinite loop';
|
||||
print '9838: skipping read -once hello.cal because it is an infinite loop';
|
||||
print '9839: skipping read -once xx_print.cal because it is a printing demo';
|
||||
print '9840: Ending read of selected calc resource files';
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: test4100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: test4100.cal,v 29.3 2006/06/10 20:19:20 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
|
||||
*
|
||||
* Under source code control: 1996/03/13 03:53:22
|
||||
@@ -316,8 +316,8 @@ define powtimes(str, N1, N2, n, verbose)
|
||||
mat B[n];
|
||||
v = olen(N1);
|
||||
|
||||
cp = config("pow2", 1);
|
||||
crc = config("redc2", 1);
|
||||
cp = config("pow2", 2);
|
||||
crc = config("redc2", 2);
|
||||
|
||||
/* initialize redc and lastmod info */
|
||||
|
||||
@@ -346,7 +346,7 @@ define powtimes(str, N1, N2, n, verbose)
|
||||
for (i = 0; i < n; i++)
|
||||
z4 += rcpow(Ar[i], B[i], v);
|
||||
trcsmall = round(runtime() - t, 4);
|
||||
config("redc2", 1);
|
||||
config("redc2", 2);
|
||||
t = runtime();
|
||||
for (i = 0; i < n; i++)
|
||||
z5 += rcpow(Ar[i], B[i], v);
|
||||
|
Reference in New Issue
Block a user