/usr/share/calc/test3300.cal is in apcalc-common 2.12.4.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /*
* test3300 - 3300 series of the regress.cal test suite
*
* Copyright (C) 1999 Ernest Bowen and Landon Curt Noll
*
* Primary author: 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.
* 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/cmd/calc/cal/RCS/test3300.cal,v $
*
* Under source code control: 1995/12/02 04:27:41
* File existed as early as: 1995
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
defaultverbose = 1; /* default verbose value */
define testi(str, n, N, verbose)
{
local A, t, i, j, d1, d2;
local m;
if (isnull(verbose)) verbose = defaultverbose;
if (verbose > 0) {
print str:":",:;
}
if (isnull(N))
N = 1e6;
mat A[n,n];
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
A[i,j] = rand(-N, N);
t = runtime();
d1 = det(A);
t = runtime() - t;
d2 = det(A^2);
if (d2 != d1^2) {
if (verbose > 0) {
printf("*** Failure for n=%d, N=%d, d1=%d\n", n, N, d1);
}
return 1; /* error */
} else {
if (verbose > 0) {
printf("no errors\n");
}
if (verbose > 1) {
printf("ok: n=%d, N=%d, d1=%d, t=%d\n", n, N, d1, t);
}
}
return 0; /* ok */
}
define testr(str, n, N, verbose)
{
local A, t, i, j, d1, d2;
if (isnull(verbose)) verbose = defaultverbose;
if (verbose > 0) {
print str:":",:;
}
if (isnull(N))
N = 1e6;
mat A[n,n];
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
A[i,j] = rand(-(N^2), N^2)/rand(1, N);
t = usertime();
d1 = det(A);
t = usertime() - t;
d2 = det(A^2);
if (d2 != d1^2) {
if (verbose > 0) {
printf("*** Failure for n=%d, N=%d, d1=%d\n", n, N, d1);
}
return 1; /* error */
} else {
if (verbose > 0) {
printf("no errors\n");
}
if (verbose > 1) {
printf("ok: n=%d, N=%d, d1=%d, t=%d\n", n, N, d1, t);
}
}
return 0; /* ok */
}
/*
* test3300 - perform all of the above tests a bunch of times
*/
define test3300(verbose, tnum)
{
local N; /* test parameter */
local i;
/*
* set test parameters
*/
if (isnull(verbose)) {
verbose = defaultverbose;
}
N = 1e6;
srand(3300e3300);
/*
* test a lot of stuff
*/
for (i=0; i < 19; ++i) {
err += testi(strcat(str(tnum++), ": testi(", str(i), ")"), \
i, N, verbose);
}
for (i=0; i < 9; ++i) {
err += testr(strcat(str(tnum++), ": testr(", str(i), ")"), \
i, N, verbose);
}
/*
* test results
*/
if (verbose > 1) {
if (err) {
print "***", err, "error(s) found in testall";
} else {
print "no errors in testall";
}
}
return tnum;
}
|