Release calc version 2.12.0.5

This commit is contained in:
Landon Curt Noll
2006-06-25 16:40:26 -07:00
parent afe37ec851
commit 87570b56fe
109 changed files with 1203 additions and 627 deletions

View File

@@ -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.19 $
# @(#) $Id: Makefile,v 29.19 2006/06/10 13:01:34 chongo Exp $
# @(#) $Revision: 29.20 $
# @(#) $Id: Makefile,v 29.20 2006/06/23 00:34:55 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 alg_config.cal
dotest.cal set8700.cal set8700.line alg_config.cal sumtimes.cal
# These files are found (but not built) in the distribution
#

View File

@@ -701,6 +701,27 @@ sumsq.cal
4N+1, and always impossible for primes of the form 4N-1.
sumtimes.cal
timematsum(N)
timelistsum(N)
timematsort(N)
timelistsort(N)
timematreverse(N)
timelistreverse(N)
timematssq(N)
timelistssq(N)
timehmean(N,M)
doalltimes(N)
Give the runtimes for various ways of evaluating sums, sums of
squares, etc, for large lists and matrices. N is the size of
the list or matrix to use. The doalltimes() function will run
all fo the sumtimes tests. For example:
doalltimes(1e6);
surd.cal
surd(a, b)
@@ -993,8 +1014,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.14 $
## @(#) $Id: README,v 29.14 2006/06/11 07:22:05 chongo Exp $
## @(#) $Revision: 29.15 $
## @(#) $Id: README,v 29.15 2006/06/23 00:34:55 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32

View File

@@ -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.31 $
* @(#) $Id: regress.cal,v 29.31 2006/06/20 10:25:00 chongo Exp $
* @(#) $Revision: 29.34 $
* @(#) $Id: regress.cal,v 29.34 2006/06/25 20:33:26 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -1316,7 +1316,65 @@ define test_functions()
*/
vrfy(isstr(calcpath()), '1155: isstr(calcpath())');
print '1156: Ending test_functions';
/*
* ssq use of lists
*/
vrfy(ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204,
'1156: ssq(1,2, list(3,4,list(5,6)), list(), 7, 8) == 204');
/*
* quomod 5th argument rounding tests
*/
vrfy(quomod(10,-3,a,b,0) == 1, '1157: vrfy(quomod(10,-3,a,b,0) == 1');
vrfy(a == -4, '1158: a == -4');
vrfy(b == -2, '1159: b == -2');
vrfy(quomod(-10,-3,a,b,1) == 1, '1160: vrfy(quomod(-10,-3,a,b,1) == 1');
vrfy(a == 4, '1161: a == 4');
vrfy(b == 2, '1162: b == 2');
vrfy(quomod(10,3,a,b,2) == 1, '1163: vrfy(quomod(10,3,a,b,2) == 1');
vrfy(a == 3, '1164: a == 3');
vrfy(b == 1, '1165: b == 1');
vrfy(quomod(-10,3,a,b,3) == 1, '1166: vrfy(quomod(-10,3,a,b,3) == 1');
vrfy(a == -4, '1167: a == -4');
vrfy(b == 2, '1168: b == 2');
vrfy(quomod(10,-3,a,b,4) == 1, '1169: vrfy(quomod(10,-3,a,b,4) == 1');
vrfy(a == -3, '1170: a == -3');
vrfy(b == 1, '1171: b == 1');
vrfy(quomod(-10,-3,a,b,5) == 1, '1172: vrfy(quomod(-10,-3,a,b,5) == 1');
vrfy(a == 3, '1173: a == 3');
vrfy(b == -1, '1174: b == -1');
vrfy(quomod(10,3,a,b,6) == 1, '1175: vrfy(quomod(10,3,a,b,6) == 1');
vrfy(a == 3, '1176: a == 3');
vrfy(b == 1, '1177: b == 1');
vrfy(quomod(-10,3,a,b,7) == 1, '1178: vrfy(quomod(-10,3,a,b,7) == 1');
vrfy(a == -4, '1179: a == -4');
vrfy(b == 2, '1180: b == 2');
vrfy(quomod(10,-3,a,b,8) == 1, '1181: vrfy(quomod(10,-3,a,b,8) == 1');
vrfy(a == -4, '1182: a == -4');
vrfy(b == -2, '1183: b == -2');
vrfy(quomod(-10,-3,a,b,9) == 1, '1184: vrfy(quomod(-10,-3,a,b,9) == 1');
vrfy(a == 3, '1185: a == 3');
vrfy(b == -1, '1186: b == -1');
vrfy(quomod(10,3,a,b,10) == 1, '1187: vrfy(quomod(10,3,a,b,10) == 1');
vrfy(a == 4, '1188: a == 4');
vrfy(b == -2, '1189: b == -2');
vrfy(quomod(-10,3,a,b,11) == 1, '1190: vrfy(quomod(-10,3,a,b,11) == 1');
vrfy(a == -4, '1191: a == -4');
vrfy(b == 2, '1192: b == 2');
vrfy(quomod(10,-3,a,b,12) == 1, '1193: vrfy(quomod(10,-3,a,b,12) == 1');
vrfy(a == -3, '1194: a == -3');
vrfy(b == 1, '1195: b == 1');
vrfy(quomod(-10,-3,a,b,13) == 1,'1196: vrfy(quomod(-10,-3,a,b,13) == 1');
vrfy(a == 4, '1197: a == 4');
vrfy(b == 2, '1198: b == 2');
vrfy(quomod(10,3,a,b,14) == 1, '1199: vrfy(quomod(10,3,a,b,14) == 1');
vrfy(a == 4, '1200: a == 4');
vrfy(b == -2, '1201: b == -2');
vrfy(quomod(-10,3,a,b,15) == 1, '1202: vrfy(quomod(-10,3,a,b,15) == 1');
vrfy(a == -4, '1203: a == -4');
vrfy(b == 2, '1204: b == 2');
print '1205: Ending test_functions';
}
print '017: parsed test_functions()';
@@ -1333,14 +1391,14 @@ define _test_underscore()
local _a = 27;
local __a = 23209;
print "1200: Beginning _test_underscore";
print "1290: Beginning _test_underscore";
vrfy(_a == 27, '1201: _a == 27');
vrfy(_ == 49, '1202: _ == 49');
vrfy(__ == 63, '1203: __ == 63');
vrfy(__a == 23209, '1204: __a == 23209');
vrfy(_a == 27, '1291: _a == 27');
vrfy(_ == 49, '1292: _ == 49');
vrfy(__ == 63, '1293: __ == 63');
vrfy(__a == 23209, '1294: __a == 23209');
print "1205: Ending _test_underscore";
print "1295: Ending _test_underscore";
}
print '020: parsed _test_underscore';
@@ -7947,7 +8005,9 @@ 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';
read -once sumtimes;
print '9840: read -once sumtimes';
print '9841: Ending read of selected calc resource files';
/*

186
cal/sumtimes.cal Normal file
View File

@@ -0,0 +1,186 @@
/*
* sumtimes - runtimes evaluating sums & squares of large lists and mats
*
* Copyright (C) 2006 Ernest Bowen
*
* 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.1 $
* @(#) $Id: sumtimes.cal,v 29.1 2006/06/23 00:35:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumtimes.cal,v $
*
* Under source code control: 2006/06/22 17:29
* File existed as early as: 2006
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
global sumtimes_t0, sumtimes_t1, sumtimes_t2, sumtimes_t3;
global sumtimes_A, sumtimes_B;
config("tilde", 0),;
define timematsum(N) {
local n, s, p, ptop;
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
ptop = &sumtimes_A[n-1];
sumtimes_t0 = runtime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
sumtimes_t1 = runtime();
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += *p;
sumtimes_t2 = runtime();
s = matsum(sumtimes_A);
sumtimes_t3 = runtime();
print "Matrix sum runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
printf('\t"For" loop using pointers:\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
printf('\tUsing builtin "matsum":\t\t%.4f\n', sumtimes_t3 - sumtimes_t2);
}
define timelistsum(N) {
local n, s;
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
sumtimes_t1 = runtime();
s = sum(sumtimes_A);
sumtimes_t2 = runtime();
print "List sum runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
printf('\tUsing builtin "sum":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
}
define timematsort(N) {
local n;
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sort(sumtimes_A);
sumtimes_t1 = runtime();
printf('\tMatrix sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
define timelistsort(N) {
local n;
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sort(sumtimes_A);
sumtimes_t1 = runtime();
printf('\tList sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
define timematreverse(N) {
local n;
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
reverse(sumtimes_A);
sumtimes_t1 = runtime();
printf('\tMatrix reverse runtime %.4f\n', sumtimes_t1 - sumtimes_t0);
}
define timelistreverse(N) {
local n;
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
reverse(sumtimes_A);
sumtimes_t1 = runtime();
printf('\tList reverse runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
define timematssq(N) {
local n, s, p, ptop;
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
ptop = &sumtimes_A[n-1];
sumtimes_t0 = runtime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
sumtimes_t1 = runtime();
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += (*p)^2;
sumtimes_t2 = runtime();
print "Matrix sum of squares runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
printf('\t"For" loop using pointers:\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
}
define timelistssq(N) {
local n, s;
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
sumtimes_t1 = runtime();
s = ssq(sumtimes_A);
sumtimes_t2 = runtime();
print "List sum of squares runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
printf('\tUsing builtin "ssq":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
}
define timehmean(N, M = 10) {
local n, s, v1, v2;
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(1, M);
sumtimes_t0 = runtime();
for (s = n = 0; n < N; n++) s += 1/sumtimes_A[n];
v1 = N/s;
sumtimes_t1 = runtime();
v2 = hmean(sumtimes_A);
sumtimes_t2 = runtime();
print v1, v2;
print "List harmonic meanruntimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
printf('\tUsing builtin "hmean":\t\t%.4f\n', sumtimes_t2 - sumtimes_t1);
}
define doalltimes(N) {
timematsum(N);
print;
timelistsum(N);
print;
timematssq(N);
print;
timelistssq(N);
print;
timematsort(N);
timelistsort(N);
timematreverse(N);
timelistreverse(N);
print;
}

View File

@@ -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.3 $
* @(#) $Id: test2700.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: test2700.cal,v 29.4 2006/06/25 22:06:23 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
*
* Under source code control: 1995/11/01 22:52:25
@@ -88,11 +88,11 @@ define mkfrac() = rand(2) ? mkposfrac() : -mkposfrac();
define mksquarereal() = mknonnegreal()^2;
/*
* XXX - Should be able to do better than the following. For nonsquare
* positive integer less than 1e6, could use
* We might be able to do better than the following. For nonsquare
* positive integer less than 1e6, could use:
* x = rand(1, 1000);
* return rand(x^2 + 1, (x + 1)^2);
* Maybe could do
* Maybe could do:
* do
* x = mkreal_2700();
* while