Release calc version 2.12.1.6

This commit is contained in:
Landon Curt Noll
2007-01-03 13:33:37 -08:00
parent 4e92927183
commit ee30d787ea
32 changed files with 862 additions and 269 deletions

View File

@@ -714,7 +714,7 @@ sumtimes.cal
timehmean(N,M)
doalltimes(N)
Give the runtimes 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
the list or matrix to use. The doalltimes() function will run
all fo the sumtimes tests. For example:
@@ -1014,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.15 $
## @(#) $Id: README,v 29.15 2006/06/23 00:34:55 chongo Exp $
## @(#) $Revision: 29.16 $
## @(#) $Id: README,v 29.16 2006/12/16 11:18:46 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.14 $
* @(#) $Id: alg_config.cal,v 29.14 2006/06/11 07:22:05 chongo Exp $
* @(#) $Revision: 29.15 $
* @(#) $Id: alg_config.cal,v 29.15 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/alg_config.cal,v $
*
* Under source code control: 2006/06/07 14:10:11
@@ -85,7 +85,7 @@ define mul_loop(repeat, x)
}
/* multiply pairwise, all sets of a given length */
start = runtime();
start = usertime();
for (i=0; i < repeat; ++i) {
if (len == 1) {
@@ -130,7 +130,7 @@ define mul_loop(repeat, x)
/*
* return duration
*/
end = runtime();
end = usertime();
return end-start;
}
@@ -477,7 +477,7 @@ define sq_loop(repeat, x)
}
/* square pairwise, all sets of a given length */
start = runtime();
start = usertime();
for (i=0; i < repeat; ++i) {
if (len == 1) {
@@ -524,7 +524,7 @@ define sq_loop(repeat, x)
/*
* return duration
*/
end = runtime();
end = usertime();
return end-start;
}
@@ -874,7 +874,7 @@ define pow_loop(repeat, x, ex)
}
/* pmod pairwise, all sets of a given length */
start = runtime();
start = usertime();
for (i=0; i < repeat; ++i) {
if (len == 1) {
@@ -927,7 +927,7 @@ define pow_loop(repeat, x, ex)
/*
* return duration
*/
end = runtime();
end = usertime();
return end-start;
}

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.2 $
* @(#) $Id: mfactor.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: mfactor.cal,v 29.3 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/mfactor.cal,v $
*
* Under source code control: 1996/07/06 06:09:40
@@ -261,7 +261,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
} else {
/* report this loop */
printf("at 2*%d*%d+1, cpu: %f\n",
(q-1)/(2*n), n, runtime());
(q-1)/(2*n), n, usertime());
fflush(files(1));
loop = 0;
}
@@ -274,7 +274,7 @@ define mfactor(n, start_k, rept_loop, p_elim)
if (rept_loop <= ++loop) {
/* report this loop */
printf("at 2*%d*%d+1, cpu: %f\n",
(q-1)/(2*n), n, runtime());
(q-1)/(2*n), n, usertime());
fflush(files(1));
loop = 0;
}

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.2 $
* @(#) $Id: randmprime.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: randmprime.cal,v 29.3 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/randmprime.cal,v $
*
* Under source code control: 1994/03/14 23:11:21
@@ -88,8 +88,8 @@ randmprime(bits, seed, dbg)
* loop until we find a prime
*/
if (dbg >= 1) {
start = runtime();
init = runtime();
start = usertime();
init = usertime();
plush = 0;
print "DEBUG1: testing (h+" : plush : ")*2^" : n : "-1";
}
@@ -97,7 +97,7 @@ randmprime(bits, seed, dbg)
/* bump h, and n if needed */
if (dbg >= 2) {
stop = runtime();
stop = usertime();
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
}
if (dbg >= 1) {
@@ -116,7 +116,7 @@ randmprime(bits, seed, dbg)
/* found a prime */
if (dbg >= 2) {
stop = runtime();
stop = usertime();
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
print "DEBUG3: " : h : "*2^" : n : "-1 is prime";
}

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.35 $
* @(#) $Id: regress.cal,v 29.35 2006/08/20 16:16:11 chongo Exp $
* @(#) $Revision: 29.36 $
* @(#) $Id: regress.cal,v 29.36 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -497,7 +497,33 @@ define test_config()
vrfy(config("mode2") == "off",
'556: config("mode2") == "off"');
print '557: Ending test_config';
/* hz is numeric */
vrfy(isint(config("hz")), '557: isint(config("hz"))');
/* compile_custom is simple */
vrfy(issimple(config("compile_custom")),
'558: issimple(config("compile_custom"))');
/* allow_custom is simple */
vrfy(issimple(config("allow_custom")),
'559: issimple(config("allow_custom"))');
/* allow_custom is simple */
vrfy(issimple(config("allow_custom")),
'559: issimple(config("allow_custom"))');
/* baseb is numeric */
vrfy(isint(config("baseb")), '560: isint(config("baseb"))');
/* redecl_warn is simple */
vrfy(issimple(config("redecl_warn")),
'561: issimple(config("redecl_warn"))');
/* dupvar_warn is simple */
vrfy(issimple(config("dupvar_warn")),
'562: issimple(config("rdupvar_warn"))');
print '563: Ending test_config';
}
print '010: parsed test_config()';
@@ -1375,7 +1401,12 @@ define test_functions()
vrfy(a == -4, '1203: a == -4');
vrfy(b == 2, '1204: b == 2');
print '1205: Ending test_functions';
/* runtime(), systime(), usertime() return numeric values */
vrfy(isnum(runtime()), '1205: isnum(runtime())');
vrfy(isnum(systime()), '1206: isnum(systime())');
vrfy(isnum(usertime()), '1207: isnum(usertime())');
print '1208: Ending test_functions';
}
print '017: parsed test_functions()';

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.1 $
* @(#) $Id: sumtimes.cal,v 29.1 2006/06/23 00:35:30 chongo Exp $
* @(#) $Revision: 29.2 $
* @(#) $Id: sumtimes.cal,v 29.2 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/sumtimes.cal,v $
*
* Under source code control: 2006/06/22 17:29
@@ -40,13 +40,13 @@ define timematsum(N) {
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
ptop = &sumtimes_A[n-1];
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += *p;
sumtimes_t2 = runtime();
sumtimes_t2 = usertime();
s = matsum(sumtimes_A);
sumtimes_t3 = runtime();
sumtimes_t3 = usertime();
print "Matrix sum runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
@@ -60,11 +60,11 @@ define timelistsum(N) {
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n];
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
s = sum(sumtimes_A);
sumtimes_t2 = runtime();
sumtimes_t2 = usertime();
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);
@@ -76,9 +76,9 @@ define timematsort(N) {
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
sort(sumtimes_A);
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
printf('\tMatrix sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
@@ -88,9 +88,9 @@ define timelistsort(N) {
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
sort(sumtimes_A);
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
printf('\tList sort runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
@@ -99,9 +99,9 @@ define timematreverse(N) {
sumtimes_A = mat[N];
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
reverse(sumtimes_A);
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
printf('\tMatrix reverse runtime %.4f\n', sumtimes_t1 - sumtimes_t0);
}
@@ -110,9 +110,9 @@ define timelistreverse(N) {
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
reverse(sumtimes_A);
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
printf('\tList reverse runtime:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
}
@@ -124,11 +124,11 @@ define timematssq(N) {
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
ptop = &sumtimes_A[n-1];
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
for (s = 0, p = &sumtimes_A[0]; p <= ptop; p++) s += (*p)^2;
sumtimes_t2 = runtime();
sumtimes_t2 = usertime();
print "Matrix sum of squares runtimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);
@@ -141,11 +141,11 @@ define timelistssq(N) {
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(N);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
for (s = n = 0; n < N; n++) s += sumtimes_A[n]^2;
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
s = ssq(sumtimes_A);
sumtimes_t2 = runtime();
sumtimes_t2 = usertime();
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);
@@ -157,12 +157,12 @@ define timehmean(N, M = 10) {
sumtimes_A = makelist(N);
for (n = 0; n < N; n++) sumtimes_A[n] = rand(1, M);
sumtimes_t0 = runtime();
sumtimes_t0 = usertime();
for (s = n = 0; n < N; n++) s += 1/sumtimes_A[n];
v1 = N/s;
sumtimes_t1 = runtime();
sumtimes_t1 = usertime();
v2 = hmean(sumtimes_A);
sumtimes_t2 = runtime();
sumtimes_t2 = usertime();
print v1, v2;
print "List harmonic meanruntimes";
printf('\tStandard "for" loop:\t\t%.4f\n', sumtimes_t1 - sumtimes_t0);

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: test3300.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: test3300.cal,v 29.5 2006/12/16 11:19:45 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
*
* Under source code control: 1995/12/02 04:27:41
@@ -81,9 +81,9 @@ define testr(str, n, N, verbose)
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
A[i,j] = rand(-(N^2), N^2)/rand(1, N);
t = runtime();
t = usertime();
d1 = det(A);
t = runtime() - t;
t = usertime() - t;
d2 = det(A^2);
if (d2 != d1^2) {
if (verbose > 0) {

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: test4000.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: test4000.cal,v 29.4 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
*
* Under source code control: 1996/03/13 02:38:45
@@ -145,7 +145,7 @@ define ptimes(str, N, n, count, skip, verbose)
mat A[n];
for (i = 0; i < n; i++)
A[i] = plen(N);
t = runtime();
t = usertime();
for (i = 0; i < n; i++) {
p = ptest(A[i], count, skip);
if (!p) {
@@ -159,7 +159,7 @@ define ptimes(str, N, n, count, skip, verbose)
if (m) {
printf("*** %d error(s)\n", m);
} else {
t = round(runtime() - t, 4);
t = round(usertime() - t, 4);
if (verbose > 1) {
printf("%d probable primes: time = %d\n", n, t);
} else {
@@ -194,7 +194,7 @@ define ctimes(str, N, n, count, skip, verbose)
mat A[n];
for (i = 0; i < n; i++)
A[i] = clen(N);
t = runtime();
t = usertime();
for (i = 0; i < n; i++) {
p = ptest(A[i], count, skip);
if (p) {
@@ -208,7 +208,7 @@ define ctimes(str, N, n, count, skip, verbose)
if (m) {
printf("*** %d error(s)\n", m);
} else {
t = round(runtime() - t, 4);
t = round(usertime() - t, 4);
if (verbose > 1) {
printf("%d probable primes: time = %d\n", n, t);
} else {
@@ -242,7 +242,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
A[i] = rand(a,b);
P[i] = ptest(A[i], 20, 0);
}
t = runtime();
t = usertime();
for (i = 0; i < n; i++) {
p = ptest(A[i], count, skip);
if (p != P[i]) {
@@ -257,7 +257,7 @@ define crtimes(str, a, b, n, count, skip, verbose)
if (m) {
printf("*** %d error(s)?\n", m);
} else {
t = round(runtime() - t, 4);
t = round(usertime() - t, 4);
if (verbose > 1) {
printf("%d probable primes: time = %d\n", n, t);
} else {
@@ -295,16 +295,16 @@ define ntimes(str, N, n, count, skip, residue, modulus, verbose)
mat A[n];
for (i = 0; i < n; i++)
A[i] = rlen(N);
t = runtime();
t = usertime();
for (i = 0; i < n; i++) {
p = nextcand(A[i], count, skip, residue, modulus);
}
tnext = round(runtime() - t, 4);
t = runtime();
tnext = round(usertime() - t, 4);
t = usertime();
for (i = 0; i < n; i++) {
p = prevcand(A[i], count, skip, residue, modulus);
}
tprev = round(runtime() - t, 4);
tprev = round(usertime() - t, 4);
if (verbose > 0) {
printf("%d evaluations, nextcand: %d, prevcand: %d\n", n, tnext, tprev);
}

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.4 $
* @(#) $Id: test4100.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: test4100.cal,v 29.5 2006/12/16 11:18:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
*
* Under source code control: 1996/03/13 03:53:22
@@ -245,38 +245,38 @@ define times(str,N,n,verbose)
C[i] = rand(m2);
}
z = rcin(0,m); /* to initialize redc and maybe lastmod information */
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
z = rcin(A[i],m);
trcin = round(runtime() - t, 3);
t = runtime();
trcin = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = rcout(A[i],m);
trcout = round(runtime() - t, 3);
t = runtime();
trcout = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = rcmul(A[i],B[i],m);
trcmul = round(runtime() - t, 3);
t = runtime();
trcmul = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = rcsq(A[i],m);
trcsq = round(runtime() - t, 3);
t = runtime();
trcsq = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = A[i] * B[i];
tmul = round(runtime() - t, 3);
t = runtime();
tmul = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = A[i]^2;
tsq = round(runtime() - t, 3);
t = runtime();
tsq = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
z = C[i] % A[i];
tmod = round(runtime() - t, 3);
t = runtime();
tmod = round(usertime() - t, 3);
t = usertime();
for (i = 0; i < n; i++)
quomod(C[i], A[i], x, y);
tquomod = round(runtime() - t,3);
tquomod = round(usertime() - t,3);
if (verbose > 1) {
printf("rcin: %d, rcout: %d, rcmul: %d, rcsq: %d\n",
@@ -326,29 +326,29 @@ define powtimes(str, N1, N2, n, verbose)
Ar[i] = rcin(A[i], v);
B[i] = rlen_4100(N2);
}
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
z1 += pmod(A[i], B[i], v);
tbignum = round(runtime() - t, 4);
tbignum = round(usertime() - t, 4);
config("pow2", 1e6);
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
z2 += pmod(A[i], B[i], v);
tnormal = round(runtime() - t, 4);
tnormal = round(usertime() - t, 4);
config("redc2",1e6);
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
z3 += pmod(A[i], B[i], v);
tsmall = round(runtime() - t, 4);
t = runtime();
tsmall = round(usertime() - t, 4);
t = usertime();
for (i = 0; i < n; i++)
z4 += rcpow(Ar[i], B[i], v);
trcsmall = round(runtime() - t, 4);
trcsmall = round(usertime() - t, 4);
config("redc2", 2);
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
z5 += rcpow(Ar[i], B[i], v);
trcbig = round(runtime() - t, 4);
trcbig = round(usertime() - t, 4);
if (z1 != z2) {
++m;
@@ -419,13 +419,13 @@ define inittimes(str,N,n,verbose)
M[i] = olen(N);
A[i] = rand(M[i]);
}
t = runtime();
t = usertime();
for (i = 0; i < n; i++)
R[i] = rcin(A[i], M[i]);
trcin = round(runtime() - t, 4);
trcin = round(usertime() - t, 4);
for (i = 0; i < n; i++)
B[i] = rcout(R[i], M[i]);
trcout = round(runtime() - t, 4);
trcout = round(usertime() - t, 4);
for (i = 0; i < n; i++) {
if (B[i] != A[i]) {
++m;