mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.0t10
This commit is contained in:
@@ -60,14 +60,14 @@ all: ${CALC_FILES} ${MAKE_FILE} .all
|
||||
|
||||
##
|
||||
#
|
||||
# File list generation. You can ignore this section.
|
||||
# File list generation. You can ignore this section.
|
||||
#
|
||||
#
|
||||
# We will form the names of source files as if they were in a
|
||||
# sub-directory called calc/lib.
|
||||
#
|
||||
# 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-emoty else clause for every if condition. *sigh*
|
||||
#
|
||||
##
|
||||
|
||||
|
14
lib/README
14
lib/README
@@ -38,8 +38,8 @@ If you write something that you think is useful, please send it to:
|
||||
[[ Replace 'at' with @, 'dot' is with . and remove the spaces ]]
|
||||
|
||||
By convention, a lib file only defines and/or initializes functions,
|
||||
objects and variables. (The regress.cal and testxxx.cal regression test
|
||||
suite is an exception.) Also by convention, an additional usage message
|
||||
objects and variables. (The regress.cal and testxxx.cal regression test
|
||||
suite is an exception.) Also by convention, an additional usage message
|
||||
regarding important object and functions is printed.
|
||||
|
||||
If a lib file needs to load another lib file, it should use the -once
|
||||
@@ -192,7 +192,7 @@ mfactor.cal
|
||||
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
|
||||
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.
|
||||
|
||||
The value p_elim == 17 is best for long factorizations. It is the
|
||||
@@ -306,7 +306,7 @@ pollard.cal
|
||||
|
||||
poly.cal
|
||||
|
||||
Calculate with polynomials of one variable. There are many functions.
|
||||
Calculate with polynomials of one variable. There are many functions.
|
||||
Read the documentation in the library file.
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ quat.cal
|
||||
quat_scale(a, b)
|
||||
quat_shift(a, b)
|
||||
|
||||
Calculate using quaternions of the form: a + bi + cj + dk. In these
|
||||
Calculate using quaternions of the form: a + bi + cj + dk. In these
|
||||
functions, quaternians are manipulated in the form: s + v, where
|
||||
s is a scalar and v is a vector of size 3.
|
||||
|
||||
@@ -416,7 +416,7 @@ randrun.cal
|
||||
regress.cal
|
||||
|
||||
Test the correct execution of the calculator by reading this library file.
|
||||
Errors are reported with '****' mssages, or worse. :-)
|
||||
Errors are reported with '****' mssages, or worse. :-)
|
||||
|
||||
|
||||
seedrandom.cal
|
||||
@@ -426,7 +426,7 @@ seedrandom.cal
|
||||
Given:
|
||||
seed1 - a large random value (at least 10^20 and perhaps < 10^93)
|
||||
seed2 - a large random value (at least 10^20 and perhaps < 10^93)
|
||||
size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024)
|
||||
size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024)
|
||||
trials - number of ptest() trials (default 25) (optional arg)
|
||||
|
||||
Returns:
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# are used in place of those found below.
|
||||
|
||||
map base-map
|
||||
default insert-char
|
||||
default insert-char
|
||||
^@ set-mark
|
||||
^A start-of-line
|
||||
^B backward-char
|
||||
@@ -30,7 +30,7 @@ default insert-char
|
||||
^[ ignore-char esc-map
|
||||
|
||||
map esc-map
|
||||
default ignore-char base-map
|
||||
default ignore-char base-map
|
||||
G start-of-line
|
||||
H backward-history
|
||||
P forward-history
|
||||
|
@@ -22,6 +22,6 @@ define bigprime(a, m, p)
|
||||
continue;
|
||||
if (pmod(a, n1 / p, n) == 1)
|
||||
continue;
|
||||
print " " : n;
|
||||
print " " : n;
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# are used in place of those found below.
|
||||
|
||||
map base-map
|
||||
default insert-char
|
||||
default insert-char
|
||||
^@ set-mark
|
||||
^A start-of-line
|
||||
^B backward-char
|
||||
@@ -30,7 +30,7 @@ default insert-char
|
||||
^[ ignore-char esc-map
|
||||
|
||||
map esc-map
|
||||
default ignore-char base-map
|
||||
default ignore-char base-map
|
||||
G start-of-line
|
||||
H backward-history
|
||||
P forward-history
|
||||
|
@@ -11,16 +11,16 @@
|
||||
* where the residues r1, r2, ... and the moduli m1, m2, ... are
|
||||
* given integers. The Chinese remainder theorem states that if
|
||||
* m1, m2, ... are relatively prime in pairs, the above congruences
|
||||
* 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
|
||||
* exists. If solutions exist, the general solution is expressible as:
|
||||
*
|
||||
* x = r (mod m)
|
||||
* x = r (mod m)
|
||||
*
|
||||
* where m = lcm(m1,m2,...), and if m > 0, 0 <= r < m. This
|
||||
* where m = lcm(m1,m2,...), and if m > 0, 0 <= r < m. This
|
||||
* solution may be interpreted as:
|
||||
*
|
||||
* x = r + k * m [[NOTE 1]]
|
||||
* x = r + k * m [[NOTE 1]]
|
||||
*
|
||||
* where k is an arbitrary integer.
|
||||
*
|
||||
@@ -30,15 +30,15 @@
|
||||
*
|
||||
* chrem(r1,m1 [,r2,m2, ...])
|
||||
*
|
||||
* r1, r2, ... remainder integers or null values
|
||||
* m1, m2, ... moduli integers
|
||||
* r1, r2, ... remainder integers or null values
|
||||
* m1, m2, ... moduli integers
|
||||
*
|
||||
* chrem(r_list, [m_list])
|
||||
*
|
||||
* r_list list (r1,r2, ...)
|
||||
* m_list list (m1,m2, ...)
|
||||
*
|
||||
* If m_list is omitted, then 'defaultmlist' is used.
|
||||
* If m_list is omitted, then 'defaultmlist' is used.
|
||||
* This default list is a global value that may be changed
|
||||
* by the user. Initially it is the first 8 primes.
|
||||
*
|
||||
@@ -50,13 +50,13 @@
|
||||
*
|
||||
* The moduli may be any integers, not necessarily relatively prime in
|
||||
* pairs (as required for the Chinese remainder theorem). Any moduli
|
||||
* may be zero; x = r (mod 0) has the meaning of x = r.
|
||||
* may be zero; x = r (mod 0) has the meaning of x = r.
|
||||
*
|
||||
* returns:
|
||||
*
|
||||
* If args were integer pairs:
|
||||
*
|
||||
* r ('r' is defined above, see [[NOTE 1]])
|
||||
* r ('r' is defined above, see [[NOTE 1]])
|
||||
*
|
||||
* If 1 or 2 list args were given:
|
||||
*
|
||||
@@ -96,7 +96,7 @@ define chrem()
|
||||
local argc; /* number of args given */
|
||||
local rlist; /* reminder list - ri */
|
||||
local mlist; /* modulus list - mi */
|
||||
local list_args; /* true => args given are lists, not r1,m1, ... */
|
||||
local list_args; /* true => args given are lists, not r1,m1, ... */
|
||||
local m,z,r,y,d,t,x,u,i;
|
||||
|
||||
/*
|
||||
@@ -121,7 +121,7 @@ define chrem()
|
||||
mlist = list();
|
||||
for (i=1; i <= argc; i+=2) {
|
||||
push(rlist, param(i));
|
||||
push(mlist, param(i+1));
|
||||
push(mlist, param(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Attempt to factor numbers using elliptic functions.
|
||||
* y^2 = x^3 + a*x + b (mod N).
|
||||
* y^2 = x^3 + a*x + b (mod N).
|
||||
*
|
||||
* Many points (x,y) (mod N) are found that solve the above equation,
|
||||
* starting from a trivial solution and 'multiplying' that point together
|
||||
@@ -55,7 +55,7 @@
|
||||
* of the powers so far.
|
||||
*
|
||||
* If a factor is found, it is returned and is also saved in the global
|
||||
* variable f. The number being factored is also saved in the global
|
||||
* variable f. The number being factored is also saved in the global
|
||||
* variable N.
|
||||
*/
|
||||
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
/*
|
||||
* lucas - perform a Lucas primality test on h*2^n-1
|
||||
@@ -34,26 +34,26 @@
|
||||
* Sergio Zarantonello proved the following 65087 digit number to be prime:
|
||||
*
|
||||
* 216193
|
||||
* 391581 * 2 -1
|
||||
* 391581 * 2 -1
|
||||
*
|
||||
* At the time of discovery, this number was the largest known prime.
|
||||
* The primality was demonstrated by a program implementing the test
|
||||
* found in these routines. An Amdahl 1200 takes 1987 seconds to test
|
||||
* the primality of this number. A Cray 2 took several hours to
|
||||
* confirm this prime. As of 31 Dec 1995, this prime was the 3rd
|
||||
* confirm this prime. As of 31 Dec 1995, this prime was the 3rd
|
||||
* largest known prime and the largest known non-Mersenne prime.
|
||||
*
|
||||
* The same team also discovered the following twin prime pair:
|
||||
*
|
||||
* 11235 11235
|
||||
* 1706595 * 2 -1 1706595 * 2 +1
|
||||
* 1706595 * 2 -1 1706595 * 2 +1
|
||||
*
|
||||
* At the time of discovery, this was the largest known twin prime pair.
|
||||
*
|
||||
* NOTE: Both largest known and largest known twin prime records have been
|
||||
* broken. Rather than update this file each time, I'll just
|
||||
* broken. Rather than update this file each time, I'll just
|
||||
* congratulate the finders and encourage others to try for
|
||||
* larger finds. Records were made to be broken afterall!
|
||||
* larger finds. Records were made to be broken afterall!
|
||||
*
|
||||
* ON GAINING A WORLD RECORD:
|
||||
*
|
||||
@@ -89,7 +89,7 @@
|
||||
* 'h', the time to test each number remains relatively constant.
|
||||
*
|
||||
* It is clearly a win to eliminate potential test candidates by
|
||||
* rejecting numbers that that are divisible by 'small' primes. We
|
||||
* rejecting numbers that that are divisible by 'small' primes. We
|
||||
* (the "Amdahl 6") rejected all numbers that were divisible by primes
|
||||
* less than '2^40'. We stopped looking for small factors at '2^40'
|
||||
* when the rate of candidates being eliminated was slowed down to
|
||||
@@ -132,7 +132,7 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */
|
||||
* ABOUT THE TEST:
|
||||
*
|
||||
* This routine will perform a primality test on h*2^n-1 based on
|
||||
* the mathematics of Lucas, Lehmer and Riesel. One should read
|
||||
* the mathematics of Lucas, Lehmer and Riesel. One should read
|
||||
* the following article:
|
||||
*
|
||||
* Ref1:
|
||||
@@ -153,7 +153,7 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */
|
||||
*
|
||||
* This test is performed as follows: (see Ref1, Theorem 5)
|
||||
*
|
||||
* a) generate u(0) (see the function gen_u0() below)
|
||||
* a) generate u(0) (see the function gen_u0() below)
|
||||
*
|
||||
* b) generate u(n-2) according to the rule:
|
||||
*
|
||||
@@ -163,9 +163,9 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */
|
||||
*
|
||||
* Now the following conditions must be true for the test to work:
|
||||
*
|
||||
* n >= 2
|
||||
* n >= 2
|
||||
* h >= 1
|
||||
* h < 2^n
|
||||
* h < 2^n
|
||||
* h mod 2 == 1
|
||||
*
|
||||
* A few misc notes:
|
||||
@@ -179,9 +179,9 @@ global pprod256; /* product of "primes up to 256" / "primes up to 46" */
|
||||
* as 2^39).
|
||||
*
|
||||
* The condition 'h mod 2 == 1' is not a problem. Say one is testing
|
||||
* 'j*2^m-1', where j is even. If we note that:
|
||||
* 'j*2^m-1', where j is even. If we note that:
|
||||
*
|
||||
* j mod 2^x == 0 for x>0 implies j*2^m-1 == ((j/2^x)*2^(m+x))-1,
|
||||
* j mod 2^x == 0 for x>0 implies j*2^m-1 == ((j/2^x)*2^(m+x))-1,
|
||||
*
|
||||
* then we can let h=j/2^x and n=m+x and test 'h*2^n-1' which is the value.
|
||||
* We need only consider odd values of h because we can rewrite our numbers
|
||||
@@ -227,7 +227,7 @@ lucas(h, n)
|
||||
*/
|
||||
oldh = h;
|
||||
oldn = n;
|
||||
shiftdown = fcnt(h,2); /* h % 2^shiftdown == 0, max shiftdown */
|
||||
shiftdown = fcnt(h,2); /* h % 2^shiftdown == 0, max shiftdown */
|
||||
if (shiftdown > 0) {
|
||||
h >>= shiftdown;
|
||||
n += shiftdown;
|
||||
@@ -238,13 +238,13 @@ lucas(h, n)
|
||||
*/
|
||||
if (h <= 0 || n <= 0) {
|
||||
print "ERROR: reduced args violate the rule: 0 < h < 2^n";
|
||||
print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n;
|
||||
print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n;
|
||||
ldebug("lucas", "unknown: h <= 0 || n <= 0");
|
||||
return -1;
|
||||
}
|
||||
if (highbit(h) >= n) {
|
||||
print "ERROR: reduced args violate the rule: h < 2^n";
|
||||
print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n;
|
||||
print " ERROR: h=":oldh, "n=":oldn, "reduced h=":h, "n=":n;
|
||||
ldebug("lucas", "unknown: highbit(h) >= n");
|
||||
return -1;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ lucas(h, n)
|
||||
* the v(1) into u(0).
|
||||
*
|
||||
* If gen_v1() returns a negative value, then we failed to
|
||||
* generate a test for h*2^n-1. This is because h mod 3 == 0
|
||||
* generate a test for h*2^n-1. This is because h mod 3 == 0
|
||||
* is hard to do, and in rare cases, exceed the tables found
|
||||
* in this program. We will generate an message and assume
|
||||
* the number is not prime, even though if we had a larger
|
||||
@@ -561,14 +561,14 @@ gen_u0(h, n, v1)
|
||||
quickmax = 8;
|
||||
mat d_qval[quickmax];
|
||||
mat v1_qval[quickmax];
|
||||
d_qval[0] = 5; v1_qval[0] = 3; /* a=1 b=1 r=4 */
|
||||
d_qval[1] = 7; v1_qval[1] = 5; /* a=3 b=1 r=12 D=21 */
|
||||
d_qval[2] = 13; v1_qval[2] = 11; /* a=3 b=1 r=4 */
|
||||
d_qval[3] = 11; v1_qval[3] = 20; /* a=3 b=1 r=2 */
|
||||
d_qval[4] = 29; v1_qval[4] = 27; /* a=5 b=1 r=4 */
|
||||
d_qval[5] = 53; v1_qval[5] = 51; /* a=53 b=1 r=4 */
|
||||
d_qval[6] = 17; v1_qval[6] = 66; /* a=17 b=1 r=1 */
|
||||
d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
d_qval[0] = 5; v1_qval[0] = 3; /* a=1 b=1 r=4 */
|
||||
d_qval[1] = 7; v1_qval[1] = 5; /* a=3 b=1 r=12 D=21 */
|
||||
d_qval[2] = 13; v1_qval[2] = 11; /* a=3 b=1 r=4 */
|
||||
d_qval[3] = 11; v1_qval[3] = 20; /* a=3 b=1 r=2 */
|
||||
d_qval[4] = 29; v1_qval[4] = 27; /* a=5 b=1 r=4 */
|
||||
d_qval[5] = 53; v1_qval[5] = 51; /* a=53 b=1 r=4 */
|
||||
d_qval[6] = 17; v1_qval[6] = 66; /* a=17 b=1 r=1 */
|
||||
d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
|
||||
/*
|
||||
* gen_v1 - compute the v(1) for a given h*2^n-1 if we can
|
||||
@@ -671,7 +671,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
* are true, and return the related v(1).
|
||||
*
|
||||
* Before we address the two conditions, we need some background information
|
||||
* on two symbols, Legendre and Jacobi. In Ref 2, pp 278, 284-285, we find
|
||||
* on two symbols, Legendre and Jacobi. In Ref 2, pp 278, 284-285, we find
|
||||
* the following definitions of J(a,p) and L(a,n):
|
||||
*
|
||||
* The Legendre symbol L(a,p) takes the value:
|
||||
@@ -724,7 +724,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
*
|
||||
* From Ref2, table 32:
|
||||
*
|
||||
* p mod 8 == +/-1 implies L(2,p) == 1 {note 3}
|
||||
* p mod 8 == +/-1 implies L(2,p) == 1 {note 3}
|
||||
* p mod 12 == +/-1 implies L(3,p) == 1 {note 4}
|
||||
*
|
||||
* Since h*2^n-1 mod 8 == -1, for n>2, note 3 implies:
|
||||
@@ -737,14 +737,14 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
*
|
||||
* By use of {A3.5}, {note 2}, {note 5} and {note 6}, one can show:
|
||||
*
|
||||
* L((2^g)*(3^l)*(z^2), h*2^n-1) == 1 (g>=0,l>=0,z>0,n>2) {note 7}
|
||||
* L((2^g)*(3^l)*(z^2), h*2^n-1) == 1 (g>=0,l>=0,z>0,n>2) {note 7}
|
||||
*
|
||||
* Returning to the testing of conditions, take condition 1:
|
||||
*
|
||||
* L(D, h*2^n-1) == -1 [condition 1]
|
||||
*
|
||||
* In order for J(D, h*2^n-1) to be defined, we must ensure that D
|
||||
* is not a factor of h*2^n-1. This is done by pre-screening h*2^n-1 to
|
||||
* is not a factor of h*2^n-1. This is done by pre-screening h*2^n-1 to
|
||||
* not have small factors and selecting D less than that factor check limit.
|
||||
*
|
||||
* By use of {note 7}, we can show that when we choose D to be:
|
||||
@@ -765,7 +765,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
* == J(h*2^n-1 mod P, P)*(-1)^((h*2^n-2)*(P-1)/4) {note 0}
|
||||
*
|
||||
* When does J(h*2^n-1 mod P, P)*(-1)^((h*2^n-2)*(P-1)/4) take the value of -1,
|
||||
* thus satisfy [condition 1]? The answer depends on P. Now P is a prime>2,
|
||||
* thus satisfy [condition 1]? The answer depends on P. Now P is a prime>2,
|
||||
* thus P mod 4 == 1 or -1.
|
||||
*
|
||||
* Take P mod 4 == 1:
|
||||
@@ -780,7 +780,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
*
|
||||
* Take P mod 4 == -1:
|
||||
*
|
||||
* P mod 4 == -1 implies (-1)^((h*2^n-2)*(P-1)/4) == -1
|
||||
* P mod 4 == -1 implies (-1)^((h*2^n-2)*(P-1)/4) == -1
|
||||
*
|
||||
* Thus:
|
||||
*
|
||||
@@ -832,7 +832,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
* == J(h*2^n-1 mod Q, Q)*(-1)^((h*2^n-2)*(Q-1)/4) {note 0}
|
||||
*
|
||||
* When does J(h*2^n-1 mod Q, Q)*(-1)^((h*2^n-2)*(Q-1)/4) take the value of 1,
|
||||
* thus satisfy [condition 2]? The answer depends on Q. Now Q is a prime>2,
|
||||
* thus satisfy [condition 2]? The answer depends on Q. Now Q is a prime>2,
|
||||
* thus Q mod 4 == 1 or -1.
|
||||
*
|
||||
* Take Q mod 4 == 1:
|
||||
@@ -847,7 +847,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
*
|
||||
* Take Q mod 4 == -1:
|
||||
*
|
||||
* Q mod 4 == -1 implies (-1)^((h*2^n-2)*(Q-1)/4) == -1
|
||||
* Q mod 4 == -1 implies (-1)^((h*2^n-2)*(Q-1)/4) == -1
|
||||
*
|
||||
* Thus:
|
||||
*
|
||||
@@ -855,7 +855,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
* == L(h*2^n-1 mod Q, Q) * -1
|
||||
* == -J(h*2^n-1 mod Q, Q)
|
||||
*
|
||||
* Therefore [condition 2] is met by selecting D = Q*(2^j)*(3^k)*(z^2),
|
||||
* Therefore [condition 2] is met by selecting D = Q*(2^j)*(3^k)*(z^2),
|
||||
* where Q is prime>2, j>=0, k>=0, z>0; if and only if one of the following
|
||||
* to cases are true:
|
||||
*
|
||||
@@ -894,7 +894,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
*
|
||||
* r == Q*(2^j)*(3^k)*(z^2) (Q==1 or Q is prime>2, j>=0, k>=0, z>0)
|
||||
*
|
||||
* one of the following is true:
|
||||
* one of the following is true:
|
||||
* P mod 4 == 1 and J(h*2^n-1 mod P, P) == -1
|
||||
* P mod 4 == -1 and J(h*2^n-1 mod P, P) == 1
|
||||
*
|
||||
@@ -903,7 +903,7 @@ d_qval[7] = 19; v1_qval[7] = 74; /* a=38 b=1 r=2 */
|
||||
* Q mod 4 == -1 and J(h*2^n-1 mod Q, Q) == -1
|
||||
*
|
||||
* If we cannot find a v(1) quickly enough, then we will give up
|
||||
* testing h*2^n-1. This does not happen too often, so this hack
|
||||
* testing h*2^n-1. This does not happen too often, so this hack
|
||||
* is not too bad.
|
||||
*
|
||||
***
|
||||
@@ -971,28 +971,28 @@ gen_v1(h, n)
|
||||
*
|
||||
* We will check with:
|
||||
*
|
||||
* v(1)=81 D=6557 a=79 b=1 r=316
|
||||
* v(1)=81 D=6557 a=79 b=1 r=316
|
||||
*
|
||||
* Now, D==79*83 and r=79*2^2. If we show that:
|
||||
* Now, D==79*83 and r=79*2^2. If we show that:
|
||||
*
|
||||
* J(h*2^n-1 mod 79, 79) == -1
|
||||
* J(h*2^n-1 mod 83, 83) == 1
|
||||
*
|
||||
* then we will satisfy [condition 1]. Observe:
|
||||
* then we will satisfy [condition 1]. Observe:
|
||||
*
|
||||
* 79 mod 4 == -1 implies (-1)^((h*2^n-2)*(79-1)/4) == -1
|
||||
* 83 mod 4 == -1 implies (-1)^((h*2^n-2)*(83-1)/4) == -1
|
||||
* 79 mod 4 == -1 implies (-1)^((h*2^n-2)*(79-1)/4) == -1
|
||||
* 83 mod 4 == -1 implies (-1)^((h*2^n-2)*(83-1)/4) == -1
|
||||
*
|
||||
* J(D, h*2^n-1) == J(83, h*2^n-1) * J(79, h*2^n-1)
|
||||
* == J(h*2^n-1, 83) * (-1)^((h*2^n-2)*(83-1)/4) *
|
||||
* J(h*2^n-1, 79) * (-1)^((h*2^n-2)*(79-1)/4)
|
||||
* J(h*2^n-1, 79) * (-1)^((h*2^n-2)*(79-1)/4)
|
||||
* == J(h*2^n-1 mod 83, 83) * -1 *
|
||||
* J(h*2^n-1 mod 79, 79) * -1
|
||||
* J(h*2^n-1 mod 79, 79) * -1
|
||||
* == 1 * -1 *
|
||||
* -1 * -1
|
||||
* == -1
|
||||
*
|
||||
* We will also satisfy [condition 2]. Observe:
|
||||
* We will also satisfy [condition 2]. Observe:
|
||||
*
|
||||
* (a^2 - b^2*D)/r == (79^2 - 1^1*6557)/316
|
||||
* == -1
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
/*
|
||||
* primes of the form h*2^n-1 for 1<=h<200 and 1<=n<1000
|
||||
@@ -259,7 +259,7 @@ static mat n_p[prime_cnt] = {
|
||||
59, 75, 103, 163, 235, 375, 615, 767, 2, 18,
|
||||
38, 62, 1, 5, 7, 9, 15, 19, 21, 35,
|
||||
37, 39, 41, 49, 69, 111, 115, 141, 159, 181,
|
||||
201, 217, 487, 567, 677, 765, 811, 841, 917, 2, /* 900 */
|
||||
201, 217, 487, 567, 677, 765, 811, 841, 917, 2, /* 900 */
|
||||
4, 6, 8, 12, 18, 26, 32, 34, 36, 42,
|
||||
60, 78, 82, 84, 88, 154, 174, 208, 256, 366,
|
||||
448, 478, 746, 5, 13, 15, 31, 77, 151, 181,
|
||||
@@ -299,7 +299,7 @@ read -once "lucas.cal";
|
||||
*
|
||||
* input:
|
||||
* high_n skip tests on n_p[i] > high_n
|
||||
* [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:
|
||||
* 1 all is ok
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
/*
|
||||
* Lucasian criteria for primality
|
||||
@@ -53,103 +53,103 @@ 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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[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("lib_debug") & 3) {
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
|
||||
|
||||
@@ -64,10 +64,10 @@
|
||||
* k = (Q*g + hx/n)/2
|
||||
*
|
||||
* This allows us to quickly eliminate factor values that are divisible
|
||||
* by 2, 3, 5, 7, 11, 13 or 17. (well <= p value found below)
|
||||
* by 2, 3, 5, 7, 11, 13 or 17. (well <= p value found below)
|
||||
*
|
||||
* The following loop shows how test_factor is advanced to higher test
|
||||
* values using hset[]. Here, hcount is the number of elements in hset[].
|
||||
* values using hset[]. Here, hcount is the number of elements in hset[].
|
||||
* It can be shown that hset[0] == 0. We add hset[hcount] to the hset[]
|
||||
* array for looping control convenience.
|
||||
*
|
||||
@@ -83,22 +83,22 @@
|
||||
*
|
||||
* The test, mfactor(67, 1, 10000) took on an 200 Mhz r4k (user CPU seconds):
|
||||
*
|
||||
* 210.83 (prior to use of hset[])
|
||||
* 78.35 (hset[] for p_elim = 7)
|
||||
* 73.87 (hset[] for p_elim = 11)
|
||||
* 73.92 (hset[] for p_elim = 13)
|
||||
* 234.16 (hset[] for p_elim = 17)
|
||||
* 210.83 (prior to use of hset[])
|
||||
* 78.35 (hset[] for p_elim = 7)
|
||||
* 73.87 (hset[] for p_elim = 11)
|
||||
* 73.92 (hset[] for p_elim = 13)
|
||||
* 234.16 (hset[] for p_elim = 17)
|
||||
* p_elim == 19 requires over 190 Megs of memory
|
||||
*
|
||||
* Over a long period of time, the call to load_hset() becomes insignificant.
|
||||
* If we look at the user CPU seconds from the first 10000 cycle to the
|
||||
* end of the test we find:
|
||||
*
|
||||
* 205.00 (prior to use of hset[])
|
||||
* 75.89 (hset[] for p_elim = 7)
|
||||
* 73.74 (hset[] for p_elim = 11)
|
||||
* 70.61 (hset[] for p_elim = 13)
|
||||
* 57.78 (hset[] for p_elim = 17)
|
||||
* 205.00 (prior to use of hset[])
|
||||
* 75.89 (hset[] for p_elim = 7)
|
||||
* 73.74 (hset[] for p_elim = 11)
|
||||
* 70.61 (hset[] for p_elim = 13)
|
||||
* 57.78 (hset[] for p_elim = 17)
|
||||
* p_elim == 19 rejected because of memory size
|
||||
*
|
||||
* The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and
|
||||
@@ -124,7 +124,7 @@
|
||||
*
|
||||
* We know that factors of a Mersenne number are of the form:
|
||||
*
|
||||
* 2*k*n+1 and +/- 1 mod 8
|
||||
* 2*k*n+1 and +/- 1 mod 8
|
||||
*
|
||||
* We make use of the hset[] difference array to eliminate factor
|
||||
* candidates that would otherwise be divisible by 2, 3, 5, 7 ... p_elim.
|
||||
@@ -140,7 +140,7 @@
|
||||
*
|
||||
* NOTE: The p_elim argument is optional and defaults to 17. A p_elim value
|
||||
* of 17 is faster than 13 for even medium length runs. However 13
|
||||
* uses less memory and has a shorter startup time.
|
||||
* uses less memory and has a shorter startup time.
|
||||
*/
|
||||
define mfactor(n, start_k, rept_loop, p_elim)
|
||||
{
|
||||
|
@@ -62,9 +62,9 @@
|
||||
* !A = 1 or 0 according as A is empty or not empty
|
||||
* +A = sum of the members of A
|
||||
*
|
||||
* min(A) = least member of A, -1 for empty set
|
||||
* max(A) = greatest member of A, -1 for empty set
|
||||
* sum(A) = sum of the members of A
|
||||
* min(A) = least member of A, -1 for empty set
|
||||
* max(A) = greatest member of A, -1 for empty set
|
||||
* sum(A) = sum of the members of A
|
||||
*
|
||||
* In the following a and b denote arbitrary members of A and B:
|
||||
*
|
||||
|
18
lib/pix.cal
18
lib/pix.cal
@@ -1,21 +1,21 @@
|
||||
/*
|
||||
* Here is an iterative method of finding the number of primes less than
|
||||
* or equal to a given number. This method is from "Computer Recreations"
|
||||
* or equal to a given number. This method is from "Computer Recreations"
|
||||
* June 1996 issue of Scientific American.
|
||||
*
|
||||
* NOTE: For reasonable values of x, the builtin function pix(x) is
|
||||
* much faster. This code is provided because the method
|
||||
* is interesting.
|
||||
* much faster. This code is provided because the method
|
||||
* is interesting.
|
||||
*/
|
||||
|
||||
define pi_of_x(x)
|
||||
{
|
||||
local An; /* A(n) */
|
||||
local An1; /* A(n-1) */
|
||||
local An2; /* A(n-2) */
|
||||
local An3; /* A(n-3) */
|
||||
local primes; /* number of primes found */
|
||||
local n; /* loop counter */
|
||||
local An; /* A(n) */
|
||||
local An1; /* A(n-1) */
|
||||
local An2; /* A(n-2) */
|
||||
local An3; /* A(n-3) */
|
||||
local primes; /* number of primes found */
|
||||
local n; /* loop counter */
|
||||
|
||||
/*
|
||||
* setup
|
||||
|
26
lib/poly.cal
26
lib/poly.cal
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A collection of functions designed for calculations involving
|
||||
* polynomials in one variable (by Ernest W. Bowen).
|
||||
* polynomials in one variable (by Ernest W. Bowen).
|
||||
*
|
||||
* On starting the program the independent variable has identifier x
|
||||
* and name "x", i.e. the user can refer to it as x, the
|
||||
@@ -24,25 +24,25 @@
|
||||
* would assign to q a number value. As with number expressions
|
||||
* involving operations, the expression used to define the
|
||||
* polynomial is usually lost; in the above example, the normal
|
||||
* computer display for p will be x^2 - 2x + 1. Different
|
||||
* computer display for p will be x^2 - 2x + 1. Different
|
||||
* identifiers may of course have the same polynomial value.
|
||||
*
|
||||
* The polynomial we think of as a_0 + a_1 * x + ... + a_n * x^n,
|
||||
* for number coefficients a_0, a_1, ... a_n may also be
|
||||
* constructed as pol(a_0, a_1, ..., a_n). Note that here the
|
||||
* constructed as pol(a_0, a_1, ..., a_n). Note that here the
|
||||
* coefficients are to be in ascending power order. The independent
|
||||
* variable is pol(0,1), so to use t, say, as an identifier for
|
||||
* this, one may assign t = pol(0,1). To simultaneously specify
|
||||
* an identifier and a name for the independent variable, there is
|
||||
* the instruction var, used as in identifier = var(name). For
|
||||
* the instruction var, used as in identifier = var(name). For
|
||||
* example, to use "t" in the way "x" is initially, one may give
|
||||
* the instruction t = var("t").
|
||||
* the instruction t = var("t").
|
||||
*
|
||||
* There are four parameters pmode, order, iod and ims for controlling
|
||||
* the format in which polynomials are displayed.
|
||||
* The parameter pmode may have values "alg" or "list": the
|
||||
* former gives a display as an algebraic formula, while
|
||||
* the latter only lists the coefficients. Whether the terms or
|
||||
* the latter only lists the coefficients. Whether the terms or
|
||||
* coefficients are in ascending or descending power order is
|
||||
* controlled by order being "up" or "down". If the
|
||||
* parameter iod (for integer-only display), the polynomial
|
||||
@@ -69,7 +69,7 @@
|
||||
* polynomial, list or matrix were a function. For example,
|
||||
* if a = 1 + x^2, a(2) will return the value 5, just as if
|
||||
* define a(t) = 1 + t^2;
|
||||
* had been used. However, when the polynomial definition is
|
||||
* had been used. However, when the polynomial definition is
|
||||
* used, changing the polynomial a will change a(t) to the value
|
||||
* of the new polynomial at t. For example,
|
||||
* after
|
||||
@@ -87,7 +87,7 @@
|
||||
* Matrices with polynomial elements may be added, subtracted and
|
||||
* multiplied as long as the usual rules for compatibility are
|
||||
* observed. Also, matrices may be multiplied by polynomials,
|
||||
* i.e. if p is a polynomial and A a matrix whose elements
|
||||
* i.e. if p is a polynomial and A a matrix whose elements
|
||||
* may be numbers or polynomials, p * A returns the matrix of
|
||||
* the same shape as A with each element multiplied by p.
|
||||
* Square matrices may also be 'substituted for the variable' in
|
||||
@@ -106,7 +106,7 @@
|
||||
* Functions defined include:
|
||||
*
|
||||
* monic(a) returns the monic multiple of a, i.e., if a != 0,
|
||||
* the multiple of a with leading coefficient 1
|
||||
* the multiple of a with leading coefficient 1
|
||||
* conj(a) returns the complex conjugate of a
|
||||
* ispmult(a,b) returns 1 or 0 according as a is or is not
|
||||
* a polynomial multiple of b
|
||||
@@ -119,7 +119,7 @@
|
||||
* by Newtonian divided difference interpolation, where
|
||||
* X is a list of x-values, Y a list of corresponding
|
||||
* y-values. If t is omitted, the interpolating
|
||||
* polynomial is returned. A y-value may be replaced by
|
||||
* polynomial is returned. A y-value may be replaced by
|
||||
* list (y, y_1, y_2, ...), where y_1, y_2, ... are
|
||||
* the reduced derivatives at the corresponding x;
|
||||
* i.e. y_r is the r-th derivative divided by fact(r).
|
||||
@@ -328,7 +328,7 @@ define poly_cmp(a,b) {
|
||||
local sa, sb;
|
||||
sa = findlist(a);
|
||||
sb=findlist(b);
|
||||
return (sa != sb);
|
||||
return (sa != sb);
|
||||
}
|
||||
|
||||
define poly_mul(a,b) {
|
||||
@@ -547,7 +547,7 @@ define D(a, n) {
|
||||
local i,j,v;
|
||||
if (isnull(n)) n = 1;
|
||||
if (!isint(n) || n < 1) quit "Bad order for derivative";
|
||||
if (ismat(a)) {
|
||||
if (ismat(a)) {
|
||||
v = a;
|
||||
for (i = matmin(a,1); i <= matmax(a,1); i++)
|
||||
for (j = matmin(a,2); j <= matmax(a,2); j++)
|
||||
@@ -561,7 +561,7 @@ define D(a, n) {
|
||||
define Dp(a,n) {
|
||||
local i, v;
|
||||
if (n > 1) return Dp(Dp(a, n-1), 1);
|
||||
obj poly v;
|
||||
obj poly v;
|
||||
v.p=list();
|
||||
for (i=1; i<size(a.p); i++) append (v.p, i*a.p[[i]]);
|
||||
return v;
|
||||
|
@@ -36,14 +36,14 @@
|
||||
* 3; print sum^2;
|
||||
*
|
||||
* (Here the second line creates x as a global variable; the local
|
||||
* variable x in the fourth line has no effect on the global x. In
|
||||
* variable x in the fourth line has no effect on the global x. In
|
||||
* the last three lines, sum is the sum of numbers already entered, so
|
||||
* the third last line doubles the value of sum. The value returned
|
||||
* by "print sum^2;" is the null value, so the second last line adds
|
||||
* nothing to sum. The last line returns the value 3, i.e. the last
|
||||
* non-null value found for the expressions separated by semicolons,
|
||||
* 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
|
||||
* calc but eval("print 7") causes an exit from calc. xxx)
|
||||
*
|
||||
@@ -57,7 +57,7 @@
|
||||
* "sin(x)", "x^2 + 3*x", "exp(x, 1e-5)".
|
||||
*
|
||||
* Values of the function so defined are returned for values of x
|
||||
* entered in reponse to the ? prompt. Operation is terminated by
|
||||
* entered in reponse to the ? prompt. Operation is terminated by
|
||||
* entering "end", "exit" or "quit".
|
||||
*/
|
||||
|
||||
|
@@ -34,11 +34,11 @@ define qtime(utc_hr_offset)
|
||||
"to ", "", "past "
|
||||
};
|
||||
local adj_mins = (((time() + utc_hr_offset*3600) % 86400) + 30) // 60 + 27;
|
||||
local hours = (adj_mins // 60) % 12;
|
||||
local hours = (adj_mins // 60) % 12;
|
||||
local minutes = adj_mins % 60;
|
||||
local almost = minutes % 5;
|
||||
local divisions = (minutes // 5) - 5;
|
||||
local to_past_idx = divisions > 0 ? 1 : 0;
|
||||
local to_past_idx = divisions > 0 ? 1 : 0;
|
||||
|
||||
if (divisions < 0) {
|
||||
divisions = -divisions;
|
||||
|
@@ -5,17 +5,17 @@
|
||||
* The odds that we will have n bits the same in a row is 1/2^n.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1995 by Landon Curt Noll. All Rights Reserved.
|
||||
* Copyright 1995 by Landon Curt Noll. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright, this permission notice, and the
|
||||
* disclaimer below appear in all of the following:
|
||||
*
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
@@ -36,7 +36,7 @@ define randbitrun(run_cnt)
|
||||
local last; /* last random number */
|
||||
local current; /* current random number */
|
||||
local MAX_RUN = 18; /* max run we will keep track of */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */
|
||||
|
||||
/*
|
||||
@@ -77,7 +77,7 @@ define randbitrun(run_cnt)
|
||||
/* look for a run break */
|
||||
if (current != last) {
|
||||
|
||||
/* record the stats */
|
||||
/* record the stats */
|
||||
if (run > max_run) {
|
||||
max_run = run;
|
||||
}
|
||||
|
@@ -21,10 +21,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
|
||||
/* obtain our required libs */
|
||||
@@ -64,7 +64,7 @@ randmprime(bits, seed, dbg)
|
||||
bits = 1;
|
||||
}
|
||||
if (param(0) == 2 || dbg < 0) {
|
||||
dbg = 0;
|
||||
dbg = 0;
|
||||
}
|
||||
|
||||
/* seed generator */
|
||||
@@ -96,7 +96,7 @@ randmprime(bits, seed, dbg)
|
||||
/* bump h, and n if needed */
|
||||
if (dbg >= 2) {
|
||||
stop = runtime();
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
print "DEBUG2: last test:", stop-start, " total time:", stop-init;
|
||||
}
|
||||
if (dbg >= 1) {
|
||||
print "DEBUG1: composite: (h+" : plush : ")*2^" : n : "-1";
|
||||
|
@@ -5,17 +5,17 @@
|
||||
* The odds that we will have n bits the same in a row is 1/2^n.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1997 by Landon Curt Noll. All Rights Reserved.
|
||||
* Copyright 1997 by Landon Curt Noll. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright, this permission notice, and the
|
||||
* disclaimer below appear in all of the following:
|
||||
*
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
@@ -36,7 +36,7 @@ define randombitrun(run_cnt)
|
||||
local last; /* last random number */
|
||||
local current; /* current random number */
|
||||
local MAX_RUN = 18; /* max run we will keep track of */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */
|
||||
|
||||
/*
|
||||
@@ -77,7 +77,7 @@ define randombitrun(run_cnt)
|
||||
/* look for a run break */
|
||||
if (current != last) {
|
||||
|
||||
/* record the stats */
|
||||
/* record the stats */
|
||||
if (run > max_run) {
|
||||
max_run = run;
|
||||
}
|
||||
|
@@ -14,17 +14,17 @@
|
||||
* chi-square test and to make estimating the run length probs easy.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1997 by Landon Curt Noll. All Rights Reserved.
|
||||
* Copyright 1997 by Landon Curt Noll. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright, this permission notice, and the
|
||||
* disclaimer below appear in all of the following:
|
||||
*
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
@@ -45,7 +45,7 @@ define randomrun(run_cnt)
|
||||
local last; /* last random number */
|
||||
local current; /* current random number */
|
||||
local MAX_RUN = 9; /* max run we will keep track of */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */
|
||||
|
||||
/*
|
||||
@@ -86,7 +86,7 @@ define randomrun(run_cnt)
|
||||
/* look for a run break */
|
||||
if (current < last) {
|
||||
|
||||
/* record the stats */
|
||||
/* record the stats */
|
||||
if (run > max_run) {
|
||||
max_run = run;
|
||||
}
|
||||
|
@@ -14,17 +14,17 @@
|
||||
* chi-square test and to make estimating the run length probs easy.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1995 by Landon Curt Noll. All Rights Reserved.
|
||||
* Copyright 1995 by Landon Curt Noll. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and
|
||||
* its documentation for any purpose and without fee is hereby granted,
|
||||
* provided that the above copyright, this permission notice, and the
|
||||
* disclaimer below appear in all of the following:
|
||||
*
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
* * supporting documentation
|
||||
* * source copies
|
||||
* * source works derived from this source
|
||||
* * binaries derived from this source or from derived source
|
||||
*
|
||||
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
@@ -45,7 +45,7 @@ define randrun(run_cnt)
|
||||
local last; /* last random number */
|
||||
local current; /* current random number */
|
||||
local MAX_RUN = 9; /* max run we will keep track of */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat tally[1:MAX_RUN]; /* tally of length of a rise run of 'x' */
|
||||
local mat prob[1:MAX_RUN]; /* prob[x] = probability of 'x' length run */
|
||||
|
||||
/*
|
||||
@@ -86,7 +86,7 @@ define randrun(run_cnt)
|
||||
/* look for a run break */
|
||||
if (current < last) {
|
||||
|
||||
/* record the stats */
|
||||
/* record the stats */
|
||||
if (run > max_run) {
|
||||
max_run = run;
|
||||
}
|
||||
|
344
lib/regress.cal
344
lib/regress.cal
@@ -4,11 +4,11 @@
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Test the correct execution of the calculator by reading this library file.
|
||||
* Errors are reported with '****' messages, or worse. :-)
|
||||
* Errors are reported with '****' messages, or worse. :-)
|
||||
*
|
||||
* NOTE: Unlike most calc lib files, this one performs its work when
|
||||
* it is read. Normally one would just define functions and
|
||||
* values for later use. In the case of the regression test,
|
||||
* it is read. Normally one would just define functions and
|
||||
* values for later use. In the case of the regression test,
|
||||
* we do not want to do this.
|
||||
*/
|
||||
|
||||
@@ -148,7 +148,7 @@ define test_booleans()
|
||||
else
|
||||
prob = prob + 1;
|
||||
|
||||
vrfy(1, '311: vrfy 1');
|
||||
vrfy(1, '311: vrfy 1');
|
||||
vrfy(2 == 2, '312: vrfy 2 == 2');
|
||||
vrfy(2 != 3, '313: vrfy 2 != 3');
|
||||
vrfy(2 < 3, '314: vrfy 2 < 3');
|
||||
@@ -159,7 +159,7 @@ define test_booleans()
|
||||
vrfy(3 >= 2, '319: vrfy 3 >= 2');
|
||||
vrfy(!0, '320: vrfy !0');
|
||||
vrfy(!1 == 0,'321: vrfy !1 == 0');
|
||||
vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3');
|
||||
vrfy((1 ? 2 ? 3 : 4 : 5) == 3, '322: (1 ? 2 ? 3 : 4 : 5) == 3');
|
||||
|
||||
print '323: Ending test_booleans';
|
||||
}
|
||||
@@ -269,7 +269,7 @@ define test_variables()
|
||||
x = 2 && 0; vrfy(x == 0, '381: (2 && 0) == 0');
|
||||
x = 0 && 3; vrfy(x == 0, '382: (0 && 3) == 0');
|
||||
x = 2 || prob('2 || prob()');
|
||||
print "383: x = 2 || prob('2 || prob()'";
|
||||
print "383: x = 2 || prob('2 || prob()'";
|
||||
x = 0 && prob('0 && prob()');
|
||||
print "384: x = 0 && prob('0 && prob()'";
|
||||
|
||||
@@ -305,34 +305,34 @@ define test_arithmetic()
|
||||
vrfy(6+12/3==10, '418: 6+12/3 == 10');
|
||||
vrfy(2+3==1+4, '419: 2+3 == 1+4');
|
||||
vrfy(-(2+3)==-5, '420: -(2+3) == -5');
|
||||
vrfy(7&18==2, '421: 7&18 == 2');
|
||||
vrfy(3|17==19, '422: 3|17 == 19');
|
||||
vrfy(2&3|1==3, '423: 2&3|1 == 3');
|
||||
vrfy(7&18==2, '421: 7&18 == 2');
|
||||
vrfy(3|17==19, '422: 3|17 == 19');
|
||||
vrfy(2&3|1==3, '423: 2&3|1 == 3');
|
||||
vrfy(2&(3|1)==2, '424: 2&(3|1) == 2');
|
||||
vrfy(3<<4==48, '425: 3<<4 == 48');
|
||||
vrfy(5>>1==2, '426: 5>>1 == 2');
|
||||
vrfy(3<<-1==1, '427: 3<<-1 == 1');
|
||||
vrfy(5>>-2==20, '428: 5>>-2 == 20');
|
||||
vrfy(3<<4==48, '425: 3<<4 == 48');
|
||||
vrfy(5>>1==2, '426: 5>>1 == 2');
|
||||
vrfy(3<<-1==1, '427: 3<<-1 == 1');
|
||||
vrfy(5>>-2==20, '428: 5>>-2 == 20');
|
||||
vrfy(1<<2<<3==65536, '429: 1<<2<<3 == 65536');
|
||||
vrfy((1<<2)<<3==32, '430: (1<<2)<<3 == 32');
|
||||
vrfy(2^3^2==512, '431: 2^3^2 == 512');
|
||||
vrfy((2^3)^2==64, '432: (2^3)^2 == 64');
|
||||
vrfy(4//3==1, '433: 4//3==1');
|
||||
vrfy(4//-3==-1, '434: 4//-3==-1');
|
||||
vrfy(4//3==1, '433: 4//3==1');
|
||||
vrfy(4//-3==-1, '434: 4//-3==-1');
|
||||
vrfy(0.75//-0.51==-1, '435: 0.75//-0.51==-1');
|
||||
vrfy(0.75//-0.50==-1, '436: 0.75//-0.50==-1');
|
||||
vrfy(0.75//-0.49==-1, '437: 0.75//-0.49==-1');
|
||||
vrfy((3/4)//(-1/4)==-3, '438: (3/4)//(-1/4)==-3');
|
||||
vrfy(7%3==1, '439: 7%3==1');
|
||||
vrfy(7%3==1, '439: 7%3==1');
|
||||
vrfy(0-.5==-.5, '440: 0-.5==-.5');
|
||||
vrfy(0^0 == 1, '441: 0^0 == 1');
|
||||
vrfy(0^1 == 0, '442: 0^1 == 0');
|
||||
vrfy(1^0 == 1, '443: 1^0 == 1');
|
||||
vrfy(1^1 == 1, '444: 1^1 == 1');
|
||||
vrfy(0^0 == 1, '441: 0^0 == 1');
|
||||
vrfy(0^1 == 0, '442: 0^1 == 0');
|
||||
vrfy(1^0 == 1, '443: 1^0 == 1');
|
||||
vrfy(1^1 == 1, '444: 1^1 == 1');
|
||||
vrfy(1/(.8+.8i)==.625-.625i, '445: 1/(.8+.8i)==.625-.625i');
|
||||
vrfy((.6+.8i)*(3.6-4.8i)==6, '446: (.6+.8i)*(3.6-4.8i)==6');
|
||||
vrfy(-16^-2 == -1/256, '447: -16^-2 == -1/256');
|
||||
vrfy(-7^2 == -49, '448: -7^2 == -49');
|
||||
vrfy(-7^2 == -49, '448: -7^2 == -49');
|
||||
vrfy(-3! == -6, '449: -3! == -6');
|
||||
|
||||
print '450: Ending test_arithmetic';
|
||||
@@ -353,14 +353,14 @@ define test_config()
|
||||
|
||||
/* check the set and return of all config */
|
||||
callcfg = config("all");
|
||||
print '501: callcfg = config("all")';
|
||||
print '501: callcfg = config("all")';
|
||||
callcfg = config("all", "oldstd");
|
||||
print '502: callcfg = config("all","oldstd")';
|
||||
print '502: callcfg = config("all","oldstd")';
|
||||
oldcfg = config("all", "newstd");
|
||||
print '503: oldcfg = config("all","newstd")';
|
||||
print '503: oldcfg = config("all","newstd")';
|
||||
vrfy(callcfg == startcfg, '504: callcfg == startcfg');
|
||||
newcfg = config("all");
|
||||
print '505: newcfg = config("all")';
|
||||
print '505: newcfg = config("all")';
|
||||
vrfy(config("all") == newcfg, '506: config("all") == newcfg');
|
||||
vrfy(config("all", oldcfg) == newcfg,
|
||||
'507: config("all", oldcfg) == newcfg');
|
||||
@@ -455,8 +455,8 @@ define test_config()
|
||||
/* restore calling config */
|
||||
vrfy(config("all",callcfg) == oldcfg,
|
||||
'550: config("all",callcfg) == oldcfg');
|
||||
vrfy(config("all") == callcfg, '551: config("all") == callcfg');
|
||||
vrfy(config("all") == startcfg, '552: config("all") == startcfg');
|
||||
vrfy(config("all") == callcfg, '551: config("all") == callcfg');
|
||||
vrfy(config("all") == startcfg, '552: config("all") == startcfg');
|
||||
|
||||
print '553: Ending test_config';
|
||||
}
|
||||
@@ -707,19 +707,19 @@ define test_functions()
|
||||
|
||||
print '700: Beginning test_functions';
|
||||
|
||||
vrfy(abs(3) == 3, '701: abs(3) == 3');
|
||||
vrfy(abs(-4) == 4, '702: abs(-4) == 4');
|
||||
vrfy(avg(7) == 7, '703: avg(7) == 7');
|
||||
vrfy(abs(3) == 3, '701: abs(3) == 3');
|
||||
vrfy(abs(-4) == 4, '702: abs(-4) == 4');
|
||||
vrfy(avg(7) == 7, '703: avg(7) == 7');
|
||||
vrfy(avg(3,5) == 4, '704: avg(3,5) == 4');
|
||||
vrfy(cmp(2,3) == -1, '705: cmp(2,3) == -1');
|
||||
vrfy(cmp(6,6) == 0, '706: cmp(6,6) == 0');
|
||||
vrfy(cmp(7,4) == 1, '707: cmp(7,4) == 1');
|
||||
vrfy(comb(9,9) == 1, '708: comb(9,9) == 1');
|
||||
vrfy(comb(5,2) == 10, '709: comb(5,2) == 10');
|
||||
vrfy(conj(4) == 4, '710: conj(4) == 4');
|
||||
vrfy(conj(4) == 4, '710: conj(4) == 4');
|
||||
vrfy(conj(2-3i) == 2+3i, '711: conj(2-3i) == 2+3i');
|
||||
vrfy(den(17) == 1, '712: den(17) == 1');
|
||||
vrfy(den(3/7) == 7, '713: den(3/7) == 7');
|
||||
vrfy(den(17) == 1, '712: den(17) == 1');
|
||||
vrfy(den(3/7) == 7, '713: den(3/7) == 7');
|
||||
vrfy(den(-2/3) == 3, '714: den(-2/3) == 3');
|
||||
vrfy(digits(0) == 1, '715: digits(0) == 1');
|
||||
vrfy(digits(9) == 1, '716: digits(9) == 1');
|
||||
@@ -728,15 +728,15 @@ define test_functions()
|
||||
vrfy(eval('2+3') == 5, "719: eval('2+3') == 5");
|
||||
vrfy(fcnt(11,3) == 0, '720: fcnt(11,3) == 0');
|
||||
vrfy(fcnt(18,3) == 2, '721: fcnt(18,3) == 2');
|
||||
vrfy(fib(0) == 0, '722: fib(0) == 0');
|
||||
vrfy(fib(1) == 1, '723: fib(1) == 1');
|
||||
vrfy(fib(9) == 34, '724: fib(9) == 34');
|
||||
vrfy(fib(0) == 0, '722: fib(0) == 0');
|
||||
vrfy(fib(1) == 1, '723: fib(1) == 1');
|
||||
vrfy(fib(9) == 34, '724: fib(9) == 34');
|
||||
vrfy(frem(12,5) == 12, '725: frem(12,5) == 12');
|
||||
vrfy(frem(45,3) == 5, '726: frem(45,3) == 5');
|
||||
vrfy(fact(0) == 1, '727: fact(0) == 1');
|
||||
vrfy(fact(1) == 1, '728: fact(1) == 1');
|
||||
vrfy(fact(1) == 1, '728: fact(1) == 1');
|
||||
vrfy(fact(5) == 120, '729: fact(5) == 120');
|
||||
vrfy(frac(3) == 0, '730: frac(3) == 0');
|
||||
vrfy(frac(3) == 0, '730: frac(3) == 0');
|
||||
vrfy(frac(2/3) == 2/3, '731: frac(2/3) == 2/3');
|
||||
vrfy(frac(17/3) == 2/3, '732: frac(17/3) == 2/3');
|
||||
vrfy(gcd(0,3) == 3, '733: gcd(0,3) == 3');
|
||||
@@ -749,9 +749,9 @@ define test_functions()
|
||||
vrfy(highbit(15) == 3, '740: highbit(15) == 3');
|
||||
vrfy(hypot(3,4) == 5, '741: hypot(3,4) == 5');
|
||||
vrfy(ilog(90,3) == 4, '742: ilog(90,3) == 4');
|
||||
vrfy(ilog10(123) == 2, '743: ilog10(123) == 2');
|
||||
vrfy(ilog10(123) == 2, '743: ilog10(123) == 2');
|
||||
vrfy(ilog2(17) == 4, '744: ilog2(17) == 4');
|
||||
vrfy(im(3) == 0, '745: im(3) == 0');
|
||||
vrfy(im(3) == 0, '745: im(3) == 0');
|
||||
vrfy(im(2+3i) == 3, '746: im(2+3i) == 3');
|
||||
vrfy(fact(20) == 2432902008176640000,
|
||||
'747: fact(20) == 2432902008176640000');
|
||||
@@ -765,31 +765,31 @@ define test_functions()
|
||||
print '754: test unused';
|
||||
print '755: test unused';
|
||||
print '756: test unused';
|
||||
vrfy(int(5) == 5, '757: int(5) == 5');
|
||||
vrfy(int(19/3) == 6, '758: int(19/3) == 6');
|
||||
vrfy(int(5) == 5, '757: int(5) == 5');
|
||||
vrfy(int(19/3) == 6, '758: int(19/3) == 6');
|
||||
vrfy(inverse(3/2) == 2/3, '759: inverse(3/2) == 2/3');
|
||||
vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4');
|
||||
vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4');
|
||||
vrfy(iseven(10) == 1, '762: iseven(10) == 1');
|
||||
vrfy(iseven(13) == 0, '763: iseven(13) == 0');
|
||||
vrfy(iseven('a') == 0, "764: iseven('a') == 0");
|
||||
vrfy(isint(7) == 1, '765: isint(7) == 1');
|
||||
vrfy(iroot(18,2) == 4, '760: iroot(18,2) == 4');
|
||||
vrfy(iroot(100,3) == 4, '761: iroot(100,3) == 4');
|
||||
vrfy(iseven(10) == 1, '762: iseven(10) == 1');
|
||||
vrfy(iseven(13) == 0, '763: iseven(13) == 0');
|
||||
vrfy(iseven('a') == 0, "764: iseven('a') == 0");
|
||||
vrfy(isint(7) == 1, '765: isint(7) == 1');
|
||||
vrfy(isint(19/2) == 0, '766: isint(19/2) == 0');
|
||||
vrfy(isint('a') == 0, "767: isint('a') == 0");
|
||||
vrfy(islist(3) == 0, '768: islist(3) == 0');
|
||||
vrfy(islist(list(2,3)) == 1, '769: islist(list(2,3)) == 1');
|
||||
vrfy(ismat(3) == 0, '770: ismat(3) == 0');
|
||||
vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0');
|
||||
vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1');
|
||||
vrfy(isnull(3) == 0, '773: isnull(3) == 0');
|
||||
vrfy(isnull(null()) == 1, '774: isnull(null()) == 1');
|
||||
vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1');
|
||||
vrfy(isnum('xx') == 0, "776: isnum('xx') == 0");
|
||||
vrfy(isobj(3) == 0, '777: isobj(3) == 0');
|
||||
vrfy(isodd(7) == 1, '778: isodd(7) == 1');
|
||||
vrfy(isodd(8) == 0, '779: isodd(8) == 0');
|
||||
vrfy(isodd('x') == 0, "780: isodd('a') == 0");
|
||||
vrfy(isqrt(27) == 5, '781: isqrt(27) == 5');
|
||||
vrfy(ismult(7,3) == 0, '771: ismult(7,3) == 0');
|
||||
vrfy(ismult(15,5) == 1, '772: ismult(15,5) == 1');
|
||||
vrfy(isnull(3) == 0, '773: isnull(3) == 0');
|
||||
vrfy(isnull(null()) == 1, '774: isnull(null()) == 1');
|
||||
vrfy(isnum(2/3) == 1, '775: isnum(2/3) == 1');
|
||||
vrfy(isnum('xx') == 0, "776: isnum('xx') == 0");
|
||||
vrfy(isobj(3) == 0, '777: isobj(3) == 0');
|
||||
vrfy(isodd(7) == 1, '778: isodd(7) == 1');
|
||||
vrfy(isodd(8) == 0, '779: isodd(8) == 0');
|
||||
vrfy(isodd('x') == 0, "780: isodd('a') == 0");
|
||||
vrfy(isqrt(27) == 5, '781: isqrt(27) == 5');
|
||||
vrfy(isreal(3) == 1, '782: isreal(3) == 1');
|
||||
vrfy(isreal('x') == 0, "783: isreal('x') == 0");
|
||||
vrfy(isreal(2+3i) == 0, '784: isreal(2+3i) == 0');
|
||||
@@ -805,7 +805,7 @@ define test_functions()
|
||||
print '794: test unused';
|
||||
vrfy(istype(9,4) == 1, '795: istype(9,4) == 1');
|
||||
vrfy(istype(3,'xx') == 0, "796: istype(3,'xx') == 0");
|
||||
vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1');
|
||||
vrfy(jacobi(5,11) == 1, '797: jacobi(2,7) == 1');
|
||||
vrfy(jacobi(6,13) == -1, '798: jacobi(6,13) == -1');
|
||||
vrfy(lcm(3,4,5,6) == 60, '799: lcm(3,4,5,6) == 60');
|
||||
vrfy(lcmfact(8) == 840, '800: lcmfact(8) == 840');
|
||||
@@ -821,14 +821,14 @@ define test_functions()
|
||||
vrfy(minv(13,97) == 15, '810: minv(13,97) == 15');
|
||||
vrfy(mne(16,37,10) == 1, '811: mne(16,37,10) == 1');
|
||||
vrfy(mne(46,79,11) == 0, '812: mne(46,79,11) == 0');
|
||||
vrfy(norm(4) == 16, '813: norm(4) == 16');
|
||||
vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13');
|
||||
vrfy(num(7) == 7, '815: num(7) == 7');
|
||||
vrfy(norm(4) == 16, '813: norm(4) == 16');
|
||||
vrfy(norm(2-3i) == 13, '814: norm(2-3i) == 13');
|
||||
vrfy(num(7) == 7, '815: num(7) == 7');
|
||||
vrfy(num(11/4) == 11, '816: num(11/4) == 11');
|
||||
vrfy(num(-9/5) == -9, '817: num(-9/5) == -9');
|
||||
vrfy(num(-9/5) == -9, '817: num(-9/5) == -9');
|
||||
vrfy(char(ord('a')+2) == 'c', "818: char(ord('a')+2) == 'c'");
|
||||
vrfy(perm(7,3) == 210, '819: perm(7,3) == 210');
|
||||
vrfy(pfact(10) == 210, '820: pfact(10) == 210');
|
||||
vrfy(perm(7,3) == 210, '819: perm(7,3) == 210');
|
||||
vrfy(pfact(10) == 210, '820: pfact(10) == 210');
|
||||
vrfy(places(3/7) == -1, '821: places(3/7) == -1');
|
||||
vrfy(places(.347) == 3, '822: places(.347) == 3');
|
||||
vrfy(places(17) == 0, '823: places(17) == 0');
|
||||
@@ -836,21 +836,21 @@ define test_functions()
|
||||
vrfy(poly(2,3,5,2) == 19, '825: poly(2,3,5,2) == 19');
|
||||
vrfy(ptest(101,10) == 1, '826: ptest(101,10) == 1');
|
||||
vrfy(ptest(221,30) == 0, '827: ptest(221,30) == 0');
|
||||
vrfy(re(9) == 9, '828: re(9) == 9');
|
||||
vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7');
|
||||
vrfy(scale(3,4) == 48, '830: scale(3,4) == 48');
|
||||
vrfy(sgn(-4) == -1, '831: sgn(-4) == -1');
|
||||
vrfy(sgn(0) == 0, '832: sgn(0) == 0');
|
||||
vrfy(sgn(3) == 1, '833: sgn(3) == 1');
|
||||
vrfy(size(7) == 1, '834: size(7) == 1');
|
||||
vrfy(sqrt(121) == 11, '835: sqrt(121) == 11');
|
||||
vrfy(re(9) == 9, '828: re(9) == 9');
|
||||
vrfy(re(-7+3i) == -7, '829: re(-7+3i) == -7');
|
||||
vrfy(scale(3,4) == 48, '830: scale(3,4) == 48');
|
||||
vrfy(sgn(-4) == -1, '831: sgn(-4) == -1');
|
||||
vrfy(sgn(0) == 0, '832: sgn(0) == 0');
|
||||
vrfy(sgn(3) == 1, '833: sgn(3) == 1');
|
||||
vrfy(size(7) == 1, '834: size(7) == 1');
|
||||
vrfy(sqrt(121) == 11, '835: sqrt(121) == 11');
|
||||
vrfy(ssq(2,3,4) == 29, '836: ssq(2,3,4) == 29');
|
||||
vrfy(str(45) == '45', "837: str(45) == '45'");
|
||||
vrfy(str(45) == '45', "837: str(45) == '45'");
|
||||
vrfy(strcat('a','bc','def')=='abcdef',
|
||||
"838: strcat('a','bc','def')=='abcdef'");
|
||||
vrfy(strlen('') == 0, "839: strlen('') == 0");
|
||||
vrfy(strlen('') == 0, "839: strlen('') == 0");
|
||||
vrfy(strlen('abcd') == 4, "840: strlen('abcd') == 4");
|
||||
vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'");
|
||||
vrfy(substr('abcd',2,1) == 'b', "841: substr('abcd',2,1) == 'b'");
|
||||
vrfy(substr('abcd',3,4) == 'cd', "842: substr('abcd',3,4) == 'cd'");
|
||||
vrfy(substr('abcd',1,3) == 'abc', "843: substr('abcd',1,3) == 'abc'");
|
||||
vrfy(xor(17,17) == 0, '844: xor(17,17) == 0');
|
||||
@@ -924,7 +924,7 @@ define test_functions()
|
||||
vrfy(istype(2, 3i) == 0, '912: istype(2, 3i) == 0');
|
||||
vrfy(istype(2i+2, 3i) == 1, '913: istype(2i+2, 3i) == 1');
|
||||
a = epsilon();
|
||||
print '914: a = epsilon()';
|
||||
print '914: a = epsilon()';
|
||||
vrfy(epsilon(a) == epsilon(), '915: epsilon(a) == epsilon()');
|
||||
vrfy(epsilon(a) == epsilon(), '916: epsilon(a) == epsilon()');
|
||||
vrfy(epsilon(a) == epsilon(), '917: epsilon(a) == epsilon()');
|
||||
@@ -1060,7 +1060,7 @@ define test_functions()
|
||||
vrfy(fib(-1) == 1, '1033: fib(-1) == 1');
|
||||
vrfy(fib(-10) == -55, '1034: fib(-10) == -55');
|
||||
vrfy(ilog(1/8, 3) == -2, '1035: ilog(1/8, 3) == -2');
|
||||
vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1');
|
||||
vrfy(ilog(8.9, 3) == 1, '1036: ilog(8.9, 3) == 1');
|
||||
vrfy(iroot(1,9) == 1, '1037: iroot(1,9) == 1');
|
||||
vrfy(iroot(pi()^8,5) == 6, '1038: iroot(pi()^8,5)');
|
||||
vrfy(isqrt(8.5) == 2, '1039: isqrt(8.5) == 2');
|
||||
@@ -1162,7 +1162,7 @@ define test_functions()
|
||||
vrfy(popcnt(-237/39929) == 17,
|
||||
'1099: popcnt(-237/39929) == 17');
|
||||
vrfy(popcnt(pi(1e-20)) == 65, '1100: popcnt(pi(1e-20)) == 65');
|
||||
vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69');
|
||||
vrfy(popcnt(pi(1e-20),0) == 69, '1101: popcnt(pi(1e-20),0) == 69');
|
||||
vrfy(popcnt(17^777) == 1593, '1102: popcnt(17^777) == 1593');
|
||||
|
||||
/*
|
||||
@@ -1302,7 +1302,7 @@ define test_list()
|
||||
vrfy(isnull(search(a,3,2)), '1407: isnull(search(a,3,2))');
|
||||
vrfy(rsearch(a,3,2) == 1, '1408: rsearch(a,3,2) == 1');
|
||||
push(a,7);
|
||||
print '1409: push(a,7)';
|
||||
print '1409: push(a,7)';
|
||||
vrfy(search(a,7) == 0, '1410: search(a,7) == 0');
|
||||
vrfy(pop(a) == 7, '1411: pop(a) == 7');
|
||||
vrfy(size(a) == 3, '1412: size(a) == 3');
|
||||
@@ -1482,7 +1482,7 @@ define test_rand()
|
||||
vrfy(srand() == init, '1520: srand() == init');
|
||||
tmp = srand(0x87e6ec938ff55aa5<<64);
|
||||
print '1521: tmp = srand(0x87e6ec938ff55aa5<<64)';
|
||||
vrfy(srand() == init, '1522: srand() == init');
|
||||
vrfy(srand() == init, '1522: srand() == init');
|
||||
tmp = srand(state0);
|
||||
print '1523: tmp = srand(state0)';
|
||||
vrfy(srand() == init, '1524: srand() == init');
|
||||
@@ -1506,10 +1506,10 @@ define test_rand()
|
||||
print '1533: tmp = srand(0)';
|
||||
vrfy(randbit(32) == 0xc79ef743, '1534: randbit(32) == 0xc79ef743');
|
||||
vrfy(randbit(32) == 0xe2e6849c, '1535: randbit(32) == 0xe2e6849c');
|
||||
vrfy(randbit(1) == 0x1, '1536: randbit(1) == 0x1');
|
||||
vrfy(randbit(5) == 0x3, '1537: randbit(5) == 0x3');
|
||||
vrfy(randbit(33) == 0x96e595f6, '1538: randbit(33) == 0x96e595f6');
|
||||
vrfy(randbit(25) == 0x1321284, '1539: randbit(25) == 0x1321284');
|
||||
vrfy(randbit(1) == 0x1, '1536: randbit(1) == 0x1');
|
||||
vrfy(randbit(5) == 0x3, '1537: randbit(5) == 0x3');
|
||||
vrfy(randbit(33) == 0x96e595f6, '1538: randbit(33) == 0x96e595f6');
|
||||
vrfy(randbit(25) == 0x1321284, '1539: randbit(25) == 0x1321284');
|
||||
vrfy(randbit(2) == 0x1, '1540: randbit(2) == 0x1');
|
||||
vrfy(randbit(13) == 0x7a5, '1541: randbit(13) == 0x7a5');
|
||||
vrfy(randbit(18) == 0x1a63e, '1542: randbit(18) == 0x1a63e');
|
||||
@@ -1608,43 +1608,43 @@ define test_mode()
|
||||
tmp = config("mode", "bin");
|
||||
print '1619: tmp = config("mode", "bin")';
|
||||
vrfy(tmp == "octal", '1620: tmp == "octal"');
|
||||
vrfy(base() == 2, '1621: base() == 2');
|
||||
vrfy(base() == 2, '1621: base() == 2');
|
||||
|
||||
tmp = config("mode", "real");
|
||||
print '1622: tmp = config("mode", "real")';
|
||||
vrfy(tmp == "binary", '1623: tmp == "binary"');
|
||||
print '1622: tmp = config("mode", "real")';
|
||||
vrfy(tmp == "binary", '1623: tmp == "binary"');
|
||||
|
||||
tmp = base(1/3);
|
||||
print '1624: tmp = base(1/3)';
|
||||
vrfy(config("mode") == "frac", '1625: config("mode") == "frac"');
|
||||
print '1624: tmp = base(1/3)';
|
||||
vrfy(config("mode") == "frac", '1625: config("mode") == "frac"');
|
||||
|
||||
tmp = base(-10);
|
||||
print '1626: tmp = base(-10)';
|
||||
vrfy(config("mode") == "int", '1627: config("mode") == "int"');
|
||||
print '1626: tmp = base(-10)';
|
||||
vrfy(config("mode") == "int", '1627: config("mode") == "int"');
|
||||
|
||||
tmp = base(10);
|
||||
print '1628: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", '1629: config("mode") == "real"');
|
||||
print '1628: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", '1629: config("mode") == "real"');
|
||||
|
||||
tmp = base(1e20);
|
||||
print '1630: tmp = base(1e20)';
|
||||
vrfy(config("mode") == "exp", '1631: config("mode") == "exp"');
|
||||
print '1630: tmp = base(1e20)';
|
||||
vrfy(config("mode") == "exp", '1631: config("mode") == "exp"');
|
||||
|
||||
tmp = base(16);
|
||||
print '1632: tmp = base(16)';
|
||||
print '1632: tmp = base(16)';
|
||||
vrfy(config("mode") == "hexadecimal", \
|
||||
'1633: config("mode") == "hexadecimal"');
|
||||
|
||||
tmp = base(8);
|
||||
print '1634: tmp = base(8)';
|
||||
print '1634: tmp = base(8)';
|
||||
vrfy(config("mode") == "octal", '1635: config("mode") == "octal"');
|
||||
|
||||
tmp = base(2);
|
||||
print '1636: tmp = base(2)';
|
||||
print '1636: tmp = base(2)';
|
||||
vrfy(config("mode") == "binary",'1637: config("mode") == "binary"');
|
||||
|
||||
tmp = base(8);
|
||||
print '1638: tmp = base(8)';
|
||||
print '1638: tmp = base(8)';
|
||||
vrfy(str(0x80000000) == "020000000000", \
|
||||
'1639: str(0x8000000) == \"020000000000\"');
|
||||
vrfy(str(0xffffffff) == "037777777777", \
|
||||
@@ -1653,7 +1653,7 @@ define test_mode()
|
||||
'1641: str(3e9) == \"026264057000\"');
|
||||
|
||||
tmp = base(16);
|
||||
print '1642: tmp = base(16)';
|
||||
print '1642: tmp = base(16)';
|
||||
vrfy(str(0x80000000) == "0x80000000", \
|
||||
'1643: str(0x8000000) == \"0x80000000\"');
|
||||
vrfy(str(0xffffffff) == "0xffffffff", \
|
||||
@@ -1662,7 +1662,7 @@ define test_mode()
|
||||
'1645: str(3e9) == \"0xb2d05e00\"');
|
||||
|
||||
tmp = base(10);
|
||||
print '1646: tmp = base(10)';
|
||||
print '1646: tmp = base(10)';
|
||||
vrfy(config("mode") == "real", \
|
||||
'1647: config("mode") == "real"');
|
||||
|
||||
@@ -1799,7 +1799,7 @@ define test_prime()
|
||||
vrfy(nextprime(65536) == 65537,
|
||||
'1944: nextprime(65536) == 65537');
|
||||
vrfy(nextprime(1234576,2)==1234577,
|
||||
'1945: nextprime(1234576,2)==1234577');
|
||||
'1945: nextprime(1234576,2)==1234577');
|
||||
vrfy(nextprime(2^31-9) == 2^31-1,
|
||||
'1946: nextprime(2^31-9) == 2^31-1');
|
||||
vrfy(nextprime(2^31-1) == 2^31+11,
|
||||
@@ -1807,10 +1807,10 @@ define test_prime()
|
||||
vrfy(nextprime(3e9) == 3e9+19,'1948: nextprime(3e9) == 3e9+19');
|
||||
vrfy(nextprime(2^32-7) == 2^32-5,
|
||||
'1949: nextprime(2^32-7) == 2^32-5');
|
||||
vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1');
|
||||
vrfy(nextprime(2^32,-1) == -1, '1950: nextprime(2^32,-1) == -1');
|
||||
vrfy(nextprime(2^32+5,-1) == -1,'1951: nextprime(2^32+5,-1) == -1');
|
||||
vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1');
|
||||
vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2');
|
||||
vrfy(nextprime(3^99,-1) == -1, '1952: nextprime(3^99,-1) == -1');
|
||||
vrfy(nextprime(3^99,2) == 2, '1953: nextprime(3^99,2) == 2');
|
||||
vrfy(prevprime(-3,-1) == 2, '1954: prevprime(-3,-1) == 2');
|
||||
vrfy(prevprime(0,-1) == 0, '1955: prevprime(0,-1) == 0');
|
||||
vrfy(prevprime(1,-1) == 0, '1956: prevprime(1,-1) == 0');
|
||||
@@ -1841,7 +1841,7 @@ define test_prime()
|
||||
vrfy(prevprime(65539) == 65537,
|
||||
'1972: prevprime(65539) == 65537');
|
||||
vrfy(prevprime(1234578,2)==1234577,
|
||||
'1973: prevprime(1234578,2)==1234577');
|
||||
'1973: prevprime(1234578,2)==1234577');
|
||||
vrfy(prevprime(2^31-1) == 2^31-19,
|
||||
'1974: prevprime(2^31-1) == 2^31-19');
|
||||
vrfy(prevprime(2^31+11) == 2^31-1,
|
||||
@@ -1851,9 +1851,9 @@ define test_prime()
|
||||
'1977: prevprime(2^32-3) == 2^32-5');
|
||||
vrfy(prevprime(2^32-1) == 2^32-5,
|
||||
'1978: prevprime(2^32-1) == 2^32-5');
|
||||
vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1');
|
||||
vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1');
|
||||
vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2');
|
||||
vrfy(prevprime(2^32,-1) == -1, '1979: prevprime(2^32,-1) == -1');
|
||||
vrfy(prevprime(3^99,-1) == -1, '1980: prevprime(3^99,-1) == -1');
|
||||
vrfy(prevprime(3^99,2) == 2, '1981: prevprime(3^99,2) == 2');
|
||||
vrfy(pix(-1) == 0, '1982: pix(-1) == 0');
|
||||
vrfy(pix(1) == 0, '1983: pix(1) == 0');
|
||||
vrfy(pix(2) == 1, '1984: pix(2) == 1');
|
||||
@@ -1865,9 +1865,9 @@ define test_prime()
|
||||
vrfy(pix(2^19+59) == 43393, '1990: pix(2^19+59) == 43393');
|
||||
vrfy(pix(1000000) == 78498, '1991: pix(1000000) == 78498');
|
||||
vrfy(pix(10000000) == 664579, '1992: pix(10000000) == 664579');
|
||||
vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220');
|
||||
vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221');
|
||||
vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221');
|
||||
vrfy(pix(2^32-6) == 203280220, '1993: pix(2^32-6) == 203280220');
|
||||
vrfy(pix(2^32-5) == 203280221, '1994: pix(2^32-5) == 203280221');
|
||||
vrfy(pix(2^32-1) == 203280221, '1995: pix(2^32-1) == 203280221');
|
||||
vrfy(pfact(40) == 7420738134810,'1996: pfact(40) == 7420738134810');
|
||||
vrfy(pfact(200)/pfact(198)==199,'1997: pfact(200)/pfact(198)==199');
|
||||
vrfy(nextprime(3e9)==nextcand(3e9),
|
||||
@@ -1919,7 +1919,7 @@ define test_prime()
|
||||
vrfy(lfactor(1001,100) == 7, '2023: lfactor(1001,100) == 7');
|
||||
vrfy(lfactor(1001,4) == 7, '2024: lfactor(1001,4) == 7');
|
||||
vrfy(lfactor(1001,3) == 1, '2025: lfactor(1001,3) == 1');
|
||||
vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1');
|
||||
vrfy(lfactor(127,10000) == 1, '2026: lfactor(127,10000) == 1');
|
||||
vrfy(lfactor(2^19-1,10000) == 1,'2027: lfactor(2^19-1,10000) == 1');
|
||||
vrfy(lfactor(2^31-1,10000) == 1,'2028: lfactor(2^31-1,10000) == 1');
|
||||
vrfy(lfactor(2^32-5,10000) == 1,'2029: lfactor(2^32-5,10000) == 1');
|
||||
@@ -1974,19 +1974,19 @@ define test_newop()
|
||||
print '2200: Beginning new operator functionality test';
|
||||
|
||||
(v = 3) = 4;
|
||||
print '2201: (v = 3) = 4';
|
||||
print '2201: (v = 3) = 4';
|
||||
vrfy(v == 4, '2202: v == 4');
|
||||
(v += 3) *= 4;
|
||||
print '2203: (v += 3) *= 4';
|
||||
print '2203: (v += 3) *= 4';
|
||||
vrfy(v == 28, '2204: v == 28');
|
||||
vrfy(A == A2, '2205: A == A2');
|
||||
matfill(B = A, 4);
|
||||
print '2206: matfill(B = A, 4)';
|
||||
vrfy(A == A2, '2207: A == A2');
|
||||
vrfy(size(B) == 3, '2208: size(B) == 3');
|
||||
vrfy(B[0] == 4, '2209: B[0] == 4');
|
||||
vrfy(B[1] == 4, '2210: B[1] == 4');
|
||||
vrfy(B[2] == 4, '2211: B[2] == 4');
|
||||
vrfy(B[0] == 4, '2209: B[0] == 4');
|
||||
vrfy(B[1] == 4, '2210: B[1] == 4');
|
||||
vrfy(B[2] == 4, '2211: B[2] == 4');
|
||||
a = 3;
|
||||
print '2212: a = 3';
|
||||
++(b = a);
|
||||
@@ -2562,7 +2562,7 @@ define test_matrix()
|
||||
matfill(e,1,0);
|
||||
print '2862: matfill(e,1,0)';
|
||||
vrfy(matsum(d) == 945, '2863: matsum(d) == 945');
|
||||
vrfy(matsum(e) == 20, '2864: matsum(e) == 20');
|
||||
vrfy(matsum(e) == 20, '2864: matsum(e) == 20');
|
||||
vrfy(search(binv,1) == 1, '2865: search(binv,1) == 1');
|
||||
vrfy(search(binv,2) == 4, '2866: search(binv,2) == 4');
|
||||
vrfy(search(binv,2,4) == 4, '2867: search(binv,2,4) == 4');
|
||||
@@ -2603,7 +2603,7 @@ define test_matrix()
|
||||
vrfy(cp(xp,yp) == zp, '2898: cp(xp,yp) == zp');
|
||||
vrfy(cp(yp,xp) == -zp, '2899: cp(yp,xp) == -zp');
|
||||
matfill(zero3,0);
|
||||
print '2900: matfill(zero3,0)';
|
||||
print '2900: matfill(zero3,0)';
|
||||
vrfy(cp(xp,xp) == zero3, '2901: cp(xp,xp) == zero3');
|
||||
vrfy(dp(xp,yp) == 38, '2902: dp(xp,yp) == 38');
|
||||
vrfy(dp(yp,xp) == 38, '2903: dp(yp,xp) == 38');
|
||||
@@ -2657,12 +2657,12 @@ define test_strings()
|
||||
print '3000: Beginning test_strings';
|
||||
|
||||
x = 'string';
|
||||
print "3001: x = 'string'";
|
||||
print "3001: x = 'string'";
|
||||
y = "string";
|
||||
print '3002: y = "string"';
|
||||
print '3002: y = "string"';
|
||||
z = x;
|
||||
print '3003: z = x';
|
||||
vrfy(z == "string", '3004: z == "string"');
|
||||
print '3003: z = x';
|
||||
vrfy(z == "string", '3004: z == "string"');
|
||||
vrfy(z != "foo", '3005: z != "foo"');
|
||||
vrfy(z != 3, '3006: z != 3');
|
||||
vrfy('' == "", '3007: \'\' == ""');
|
||||
@@ -2701,7 +2701,7 @@ define test_matobj()
|
||||
vrfy(det(A^3) == -474552, '3103: det(A^3) == -474552');
|
||||
vrfy(det(A^-1) == -1/78, '3104: det(A^-1) == -1/78');
|
||||
md = 0;
|
||||
print '3105: md = 0';
|
||||
print '3105: md = 0';
|
||||
B[0,0] = res(2);
|
||||
print '3106: B[0,0] = res(2)';
|
||||
B[0,1] = res(3);
|
||||
@@ -2888,8 +2888,8 @@ define test_error()
|
||||
vrfy(0/0 == error(10002), '3605: 0/0 == error(10002)');
|
||||
vrfy(2 + "x" == error(10003), '3606: 2 + "x" == error(10003)');
|
||||
vrfy("x" - 2 == error(10004), '3607: "x" - 2 == error(10004)');
|
||||
vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)');
|
||||
vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)');
|
||||
vrfy("x" * "y" == error(10005), '3608: "x" * "y" == error(10005)');
|
||||
vrfy("x" / "y" == error(10006), '3609: "x" / "y" == error(10006)');
|
||||
vrfy(-list(1) == error(10007), '3610: -list(1) == error(10007)');
|
||||
vrfy("x"^2 == error(10008), '3611: "x"^2 == error(10008)');
|
||||
vrfy(inverse("x")==error(10009),'3612: inverse("x") == error(10009)');
|
||||
@@ -2903,8 +2903,8 @@ define test_error()
|
||||
print '3618: strx = "x"';
|
||||
vrfy(--strx == error(10011), '3619: strx == error(10011)');
|
||||
vrfy(int("x") == error(10012), '3620: int("x") == error(10012)');
|
||||
vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)');
|
||||
vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)');
|
||||
vrfy(frac("x") == error(10013), '3621: frac("x") == error(10013)');
|
||||
vrfy(conj("x") == error(10014), '3622: conj("x") == error(10014)');
|
||||
vrfy(appr("x",.1) == error(10015),
|
||||
'3623: appr("x",.1) == error(10015)');
|
||||
vrfy(appr(1.27,.1i) == error(10016),
|
||||
@@ -2954,7 +2954,7 @@ define test_error()
|
||||
vrfy(1.5 << 2 == error(10031), '3647: 1.5 << 2 == error(10031)');
|
||||
vrfy(3 << "x" == error(10032), '3648: 3 << "x" == error(10032)');
|
||||
vrfy(3 << 1.5 == error(10032), '3649: 3 << 1.5 == error(10032)');
|
||||
vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)');
|
||||
vrfy(3 << 2^31 == error(10032), '3650: 3 << 2^31 == error(10032)');
|
||||
vrfy(scale("x",2) == error(10033),
|
||||
'3651: scale("x",2) == error(10033)');
|
||||
vrfy(scale(3,"x") == error(10034),
|
||||
@@ -3035,8 +3035,8 @@ define test_error()
|
||||
b = newerror("beta");
|
||||
print '3705: c = newerror("alpha")';
|
||||
c = newerror("alpha");
|
||||
vrfy(a == c, '3706: a == c');
|
||||
vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"');
|
||||
vrfy(a == c, '3706: a == c');
|
||||
vrfy(strerror(a) == "alpha", '3707: strerror(a) == "alpha"');
|
||||
print '3708: n = iserror(a)';
|
||||
n = iserror(a);
|
||||
vrfy(a == error(n), '3709: a == error(n)');
|
||||
@@ -3338,7 +3338,7 @@ define test_matdcl()
|
||||
vrfy(ismat(mat_X2), '4307: ismat(mat_X2)');
|
||||
vrfy(ismat(mat_X3), '4308: ismat(mat_X3)');
|
||||
mat_Y0 = mat[4];
|
||||
print '4309: mat_Y0 = mat[4]';
|
||||
print '4309: mat_Y0 = mat[4]';
|
||||
vrfy(size(mat_Y0) == 4, '4310: size(mat_Y0) == 4');
|
||||
vrfy(size(mat_Y1) == 2, '4311: size(mat_Y1) == 2');
|
||||
vrfy(size(mat_Y2) == 2, '4312: size(mat_Y2) == 2');
|
||||
@@ -3390,9 +3390,9 @@ define test_matdcl()
|
||||
for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i]);
|
||||
print '4349: for (i=0; i < 4; ++i) mat_X0[i] = size(mat_Y0[i])';
|
||||
mat_X0==(mat[4]={2,1,2,3});
|
||||
print '4350: mat_X0==(mat[4]={2,1,2,3})';
|
||||
print '4350: mat_X0==(mat[4]={2,1,2,3})';
|
||||
vrfy(mat_Y0[0] == mat_Z0, '4351: mat_Y0[0] == mat_Z0');
|
||||
vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0');
|
||||
vrfy(mat_Y0[1] == 0, '4352: mat_Y0[1] == 0');
|
||||
vrfy(mat_Y0[2] == mat_Z1, '4353: mat_Y0[2] == mat_Z1');
|
||||
vrfy(mat_Y0[3] == mat_X3, '4354: mat_Y0[3] == mat_X3');
|
||||
vrfy(mat_Y0[0][0] == 2, '4355: mat_Y0[0][0] == 2');
|
||||
@@ -3449,7 +3449,7 @@ define test_objmat()
|
||||
vrfy(Q == (mat[2]={5+3i,17+4i}), '4408: Q == (mat[2]={5+3i,17+4i})');
|
||||
R = {M2,M3};
|
||||
print '4409: R = {M2,M3}';
|
||||
vrfy(norm(R) == M4, '4410: norm(R) == M4');
|
||||
vrfy(norm(R) == M4, '4410: norm(R) == M4');
|
||||
vrfy(det(surd_value(R^2)) == -23-6i, \
|
||||
'4411: det(surd_value(R^2)) == -23-6i');
|
||||
vrfy(det(norm(R^5))==268107761663283843865, \
|
||||
@@ -3484,13 +3484,13 @@ define test_objmat()
|
||||
'4424: (mat [] = {1,2,3}) == (mat[3] = {1,2,3})');
|
||||
|
||||
mat A[3] = {2,3,5};
|
||||
print '4425: mat A[3] = {2,3,5}';
|
||||
print '4425: mat A[3] = {2,3,5}';
|
||||
mat A[3] = {A[0], A[2], A[1]};
|
||||
print '4426: mat A[3] = {A[0], A[2], A[1]}';
|
||||
vrfy(A == (mat[3] = {2, 5, 3}), '4427: A == (mat[3] = {2, 5, 3})');
|
||||
|
||||
B = mat[3] = {2,5,3};
|
||||
print '4428: B = mat[3] = {2,5,3}';
|
||||
print '4428: B = mat[3] = {2,5,3}';
|
||||
vrfy(A == B, '4429: A == B');
|
||||
|
||||
mat A[2] = {A[1], A[2]};
|
||||
@@ -3727,7 +3727,7 @@ define test_strprintf()
|
||||
vrfy(strprintf("%5s", "abc") == " abc",
|
||||
'4833: strprintf("%5s", "abc") == " abc"');
|
||||
vrfy(strprintf("%-5s", "abc") == "abc ",
|
||||
'4834: strprintf("%-5s", "abc") == "abc "');
|
||||
'4834: strprintf("%-5s", "abc") == "abc "');
|
||||
|
||||
/* restore config */
|
||||
c = config("all", callcfg);
|
||||
@@ -3817,8 +3817,8 @@ define test_listsearch()
|
||||
vrfy(search(L,0,-5) == 8, '4913: search(L,0,-5) == 8');
|
||||
vrfy(rsearch(L,0,-9,-2) == 4, '4914: rsearch(L,0,-9,-2) == 4');
|
||||
vrfy(isnull(search(L,3,20)), '4915: isnull(search(L,3,20)');
|
||||
vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)');
|
||||
vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)');
|
||||
vrfy(isnull(search(L,3,0,-20)), '4916: isnull(search(L,3,0,-20)');
|
||||
vrfy(isnull(rsearch(L,3,20,2)), '4917: isnull(rsearch(L,3,20,2)');
|
||||
vrfy(rsearch(L,3,-20,20) == 7, '4918: rsearch(L,3,-20,20) == 7');
|
||||
|
||||
print '4919: Ending test_strprintf';
|
||||
@@ -3905,7 +3905,7 @@ define test_filesearch()
|
||||
vrfy(ftell(f) == 17, '5029: ftell(f) == 17');
|
||||
vrfy(rsearch(f, "", 5) == 5, '5030: rsearch(f, "", 5) == 5');
|
||||
vrfy(ftell(f) == 5, '5031: ftell(f) == 5');
|
||||
vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6');
|
||||
vrfy(search(f, "beta", 0) == 6, '5032: search(f, "beta", 0) == 6');
|
||||
vrfy(ftell(f) == 10, '5033: ftell(f) == 10');
|
||||
vrfy(rsearch(f, "beta", 100) == 6,
|
||||
'5034: rsearch(f, "beta", 100) == 6');
|
||||
@@ -3916,16 +3916,16 @@ define test_filesearch()
|
||||
vrfy(search(f, "m") == 13, '5039: search(f, "m") == 13');
|
||||
vrfy(search(f, "m") == 14, '5040: search(f, "m") == 14');
|
||||
vrfy(isnull(search(f, "m")), '5041: isnull(search(f, "m"))');
|
||||
vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14');
|
||||
vrfy(rsearch(f, "m", 15) == 14, '5042: rsearch(f, "m", 14) == 14');
|
||||
vrfy(isnull(search(f, "beta", 7)),
|
||||
'5043: isnull(search(f, "beta", 7))');
|
||||
vrfy(ftell(f) == 14, '5044: ftell(f) == 14');
|
||||
vrfy(search(f,"a",2,15) == 4, '5045: search(f,"a",2,15) == 4');
|
||||
vrfy(ftell(f) == 5, '5046: ftell(f) == 5');
|
||||
vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))');
|
||||
vrfy(isnull(search(f,"a",2,4)), '5047: isnull(search(f,"a",2,4))');
|
||||
vrfy(ftell(f) == 4, '5048: ftell(f) == 4');
|
||||
vrfy(search(f,"a",,5) == 4, '5049: search(f,"a",,5) == 4');
|
||||
vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12');
|
||||
vrfy(rsearch(f,"a",2,15) == 12, '5050: rsearch(f,"a",2,15) == 12');
|
||||
vrfy(ftell(f) == 12, '5051: ftell(f) == 12');
|
||||
vrfy(rsearch(f,"a",2,12) == 9, '5052: rsearch(f,"a",2,12) == 9');
|
||||
|
||||
@@ -4157,7 +4157,7 @@ define test_random()
|
||||
vrfy(srandom() == init, '5320: srandom() == init');
|
||||
tmp = srandom(0x87e6ec938ff55aa5<<64);
|
||||
print '5321: tmp = srandom(0x87e6ec938ff55aa5<<64)';
|
||||
vrfy(srandom() == init, '5322: srandom() == init');
|
||||
vrfy(srandom() == init, '5322: srandom() == init');
|
||||
tmp = srandom(state0);
|
||||
print '5323: tmp = srandom(state0)';
|
||||
vrfy(srandom() == init, '5324: srandom() == init');
|
||||
@@ -4184,7 +4184,7 @@ define test_random()
|
||||
vrfy(randombit(1) == 0x1, '5336: randombit(1) == 0x1');
|
||||
vrfy(randombit(5) == 0xe, '5337: randombit(5) == 0xe');
|
||||
vrfy(randombit(33) == 0xececfda2, '5338: randombit(33) == 0xececfda2');
|
||||
vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb');
|
||||
vrfy(randombit(25) == 0x40f7bb, '5339: randombit(25) == 0x40f7bb');
|
||||
vrfy(randombit(2) == 0x3, '5340: randombit(2) == 0x3');
|
||||
vrfy(randombit(13) == 0xd3, '5341: randombit(13) == 0xd3');
|
||||
vrfy(randombit(18) == 0x37a76, '5342: randombit(18) == 0x37a76');
|
||||
@@ -4671,8 +4671,8 @@ define test_commaeq()
|
||||
*/
|
||||
obj xy5600 A = {1, 2} = {3, 4};
|
||||
print '5612: obj xy5600 A = {1, 2} = {3, 4}';
|
||||
vrfy(A.x == 3, '5613: A.x == 3');
|
||||
vrfy(A.y == 4, '5614: A.y == 4');
|
||||
vrfy(A.x == 3, '5613: A.x == 3');
|
||||
vrfy(A.y == 4, '5614: A.y == 4');
|
||||
obj xy5600 B = {A,A};
|
||||
print '5613: obj xy5600 B = {A,A}';
|
||||
vrfy(B.x.x == 3, '5615: B.x.x == 3');
|
||||
@@ -6011,7 +6011,7 @@ define test_blk()
|
||||
|
||||
/* Assignment of copy with initialization */
|
||||
|
||||
B = A;
|
||||
B = A;
|
||||
print '6733: B = A;';
|
||||
C=blk(A)={,,,,,,,,,,0xbb};
|
||||
print '6734: C=blk(A)={,,,,,,,,,,0xbb};';
|
||||
@@ -6135,7 +6135,7 @@ define test_blkcpy()
|
||||
{
|
||||
local A, B, C, A1, A2, B1, fs, S, M1, M2, L1, L2, x;
|
||||
|
||||
print '6800: Beginning test_blkcpy';
|
||||
print '6800: Beginning test_blkcpy';
|
||||
|
||||
A = blk() = {1,2,3,4,5};
|
||||
print '6801: A = blk() = {1,2,3,4,5};';
|
||||
@@ -6230,7 +6230,7 @@ define test_blkcpy()
|
||||
vrfy(M2 == (mat[4]={1,2,3,4}), '6844: M2 == (mat[4]={1,2,3,4}');
|
||||
blkcpy(M2, M2, 2, 2, 0);
|
||||
print '6845: blkcpy(M2, M2, 2, 2, 0);';
|
||||
vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}');
|
||||
vrfy(M2 == (mat[4]={1,2,1,2}), '6846: M2 == (mat[4]={1,2,1,2}');
|
||||
|
||||
/* blkcpy between blocks and matrices */
|
||||
|
||||
@@ -6394,7 +6394,7 @@ define test_sha()
|
||||
vrfy(y == sha(1), '7106: y == sha(1)');
|
||||
vrfy(sha(y,2) == sha(1,2), '7107: sha(y,2) == sha(1,2)');
|
||||
|
||||
vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef,
|
||||
vrfy(sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef,
|
||||
'7108: sha(sha()) == 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef');
|
||||
|
||||
vrfy(sha(sha("a"))==0x37f297772fae4cb1ba39b6cf9cf0381180bd62f2,
|
||||
@@ -6426,10 +6426,10 @@ define test_sha()
|
||||
vrfy(sha(sha(isqrt(2e1000))) ==
|
||||
0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0,
|
||||
'7120: sha(sha(isqrt(2e1000)==0x6db8d9cf0b018b8f9cbbf5aa1edb8066d19e1bb0');
|
||||
vrfy(sha("x", "y", "z") == sha("xyz"),
|
||||
vrfy(sha("x", "y", "z") == sha("xyz"),
|
||||
'7121: sha("x", "y", "z") == sha("xyz")');
|
||||
|
||||
vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
||||
vrfy(sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
||||
0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a,
|
||||
'7122: sha(sha("this is", 7^19-8, ..., "hash")) == 0x21e4...');
|
||||
|
||||
@@ -6494,17 +6494,17 @@ define test_sha1()
|
||||
print '7204: z = sha1(1);';
|
||||
vrfy(sha1(y,1) == z, '7205: sha1(y,1) == z');
|
||||
vrfy(sha1(z,2) == sha1(1,2), '7206: sha1(z,2) == sha1(1,2)');
|
||||
vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709,
|
||||
vrfy(sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709,
|
||||
'7207: sha1(sha1()) == 0xda39a3ee5e6b4b0d3255bfef95601890afd80709');
|
||||
vrfy(sha1("x", "y", "z") == sha1("xyz"),
|
||||
vrfy(sha1("x", "y", "z") == sha1("xyz"),
|
||||
'7208: sha1("x", "y", "z") == sha1("xyz")');
|
||||
|
||||
vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) ==
|
||||
vrfy(sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) ==
|
||||
0xc3e1b562bf45b3bcfc055ac65b5b39cdeb6a6c55,
|
||||
'7209: sha1(sha1("this is",7^19-8,"a composit",3i+4.5,"hash")) == ...');
|
||||
|
||||
|
||||
z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
print '7210: z = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi());';
|
||||
vrfy(sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f,
|
||||
'7211: sha1(z) == 0xc19e7317675dbf71e293b4c41e117169e9da5b6f');
|
||||
@@ -6582,17 +6582,17 @@ define test_md5()
|
||||
vrfy(y == z, '7306: y == z');
|
||||
vrfy(md5(z,2) == md5(1,2), '7307: md5(z,2) == md5(1,2)');
|
||||
|
||||
vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e,
|
||||
vrfy(md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e,
|
||||
'7308: md5(md5()) == 0xd41d8cd98f00b204e9800998ecf8427e');
|
||||
vrfy(md5("x", "y", "z") == md5("xyz"),
|
||||
vrfy(md5("x", "y", "z") == md5("xyz"),
|
||||
'7309: md5("x", "y", "z") == md5("xyz")');
|
||||
|
||||
vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
||||
vrfy(md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) ==
|
||||
0x39a5a8e24a2eb65a51af462c8bdd5e3,
|
||||
'7310: md5(md5("this is", 7^19-8, "a composit", 3i+4.5, "hash")) == ...');
|
||||
|
||||
|
||||
z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());
|
||||
print '7311: z = md5(list(1,2,3), "curds and whey", 2^21701-1, pi());';
|
||||
vrfy(md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5,
|
||||
'7312: md5(z) == 0x63d2b2fccae2de265227c30b05abb6b5');
|
||||
@@ -6675,7 +6675,7 @@ define test_ptr()
|
||||
/* testing octet pointers */
|
||||
|
||||
B = blk() = {1,2,3,4,5,6};
|
||||
print '7503: B = blk() = {1,2,3,4,5,6};';
|
||||
print '7503: B = blk() = {1,2,3,4,5,6};';
|
||||
vrfy(isoctet(B[0]) == 1, '7504: isoctet(B[0]) == 1');
|
||||
vrfy(isnum(B[0]) == 0, '7505: isnum(B[0]) == 0');
|
||||
vrfy(isptr(B[0]) == 0, '7506: isptr(B[0]) == 0');
|
||||
@@ -6721,7 +6721,7 @@ define test_ptr()
|
||||
vrfy(B[3] == 8, '7537: B[3] == 8');
|
||||
p0 = p++;
|
||||
print '7538: p0 = p++;';
|
||||
vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]');
|
||||
vrfy(p0 == &B[0] && p == &B[1], '7539: p0 == &B[0] && p == &B[1]');
|
||||
q0 = --q;
|
||||
print '7540: q0 = --q';
|
||||
vrfy(q0 == &B[4] && q == q0, '7541: q0 == &B[4] && q == q0');
|
||||
@@ -6753,7 +6753,7 @@ define test_ptr()
|
||||
vrfy(g7500c(&A[0],2) == 3, '7558: g7500c(&A[0], 2) == 3');
|
||||
vrfy(g7500d(`A[0]) == &A[0], '7559: g7500d(`A[0]) == &A[0]');
|
||||
p = &A[0];
|
||||
print '7560: p = &A[0];';
|
||||
print '7560: p = &A[0];';
|
||||
vrfy(g7500a(*p, 6) == 6, '7561: g7500a(*p, 6) == 6');
|
||||
vrfy(*p == 6, '7562: *p == 6');
|
||||
vrfy(g7500a(`*p,6) == 6, '7563: g7500a(`*p,6) == 6');
|
||||
@@ -6806,8 +6806,8 @@ define test_ptr()
|
||||
vrfy(M[1] == 2 && M[2] == 3, '7597: M[1] == 2 && M[2] == 3');
|
||||
A = *M = {7,8};
|
||||
print '7598: A = *M = {7,8};';
|
||||
vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})');
|
||||
vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})');
|
||||
vrfy(M == (mat[4] = {5,2,3,4}), '7599: M == (mat[4] = {5,2,3,4})');
|
||||
vrfy(A == (mat[4] = {7,8,3,4}), '7600: A == (mat[4] = {7,8,3,4})');
|
||||
|
||||
/* Values which point to themselves */
|
||||
|
||||
@@ -7078,7 +7078,7 @@ define test_natnumset()
|
||||
vrfy(#~A == 97, '8109: #~A == 97');
|
||||
vrfy(A + 5 == set(5,7,22,29), '8110: A + 5 == set(5,7,22,29)');
|
||||
vrfy(A - 5 == set(12,19), '8111: A - 5 == set(12,19)');
|
||||
vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)');
|
||||
vrfy(30 - A == set(6,13,28,30), '8112: 30 - A == set(6,13,28,30)');
|
||||
vrfy(2 * A == set(0,4,34,48), '8113: 2 * A == set(0,4,34,48)');
|
||||
vrfy(10 * A == set(0,20), '8114: 10 * A == set(0,20)');
|
||||
vrfy(A + A == set(0,2,4,17,19,24,26,34,41,48),
|
||||
@@ -7416,7 +7416,7 @@ saveval(1);
|
||||
print '7402: a7400 = 2;';
|
||||
a7400 = 2;
|
||||
vrfy(. == 2, '7403: . == 2;');
|
||||
vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)');
|
||||
vrfy((. += 3, . == 5), '7404: (. += 3, . == 5)');
|
||||
vrfy(. == 5, '7405: . == 5;');
|
||||
print '7406: a7400 = 5; b7400 = 6;';
|
||||
a7400 = 5; b7400 = 6;
|
||||
|
@@ -19,10 +19,10 @@
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -57,10 +57,10 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
{
|
||||
local p; /* first Blum prime */
|
||||
local fp; /* prime co-factor of p-1 */
|
||||
local sp; /* min bit size of p */
|
||||
local sp; /* min bit size of p */
|
||||
local q; /* second Blum prime */
|
||||
local fq; /* prime co-factor of q-1 */
|
||||
local sq; /* min bit size of q */
|
||||
local sq; /* min bit size of q */
|
||||
local n; /* Blum modulus */
|
||||
local binsize; /* smallest power of 2 > n=p*q */
|
||||
local r; /* initial quadratic residue */
|
||||
@@ -135,7 +135,7 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
* seed the Blum generator
|
||||
*/
|
||||
n = p*q; /* the Blum modulus */
|
||||
binsize = highbit(n)+1; /* smallest power of 2 > p*q */
|
||||
binsize = highbit(n)+1; /* smallest power of 2 > p*q */
|
||||
r = pmod(rand(1<<ceil(binsize*4/5), 1<<(binsize-2)), 2, n);
|
||||
if (config("lib_debug") & 3) {
|
||||
print "/* seed quadratic residue */ r=", r;
|
||||
|
@@ -3,10 +3,10 @@
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This library is used by the 1700 series of the regress.cal test suite.
|
||||
*/
|
||||
|
@@ -3,10 +3,10 @@
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This library is used by the 2300 series of the regress.cal test suite.
|
||||
*/
|
||||
|
@@ -480,7 +480,7 @@ define test2600(verbose, tnum)
|
||||
for (i=0; i < 32; ++i) {
|
||||
config("sqrt", i);
|
||||
err += testsqrt(strcat(str(tnum++),": sqrt",str(i)), n*10,
|
||||
ep, verbose);
|
||||
ep, verbose);
|
||||
}
|
||||
if (verbose > 1) {
|
||||
if (err) {
|
||||
|
@@ -124,7 +124,7 @@ define testcsqrt(str, n, verbose)
|
||||
}
|
||||
|
||||
|
||||
define checksqrt(x,y,z,v) /* Returns >0 if an error is detected */
|
||||
define checksqrt(x,y,z,v) /* Returns >0 if an error is detected */
|
||||
{
|
||||
local A, B, X, Y, t1, t2, eps, u, n, f, s;
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
* Stringent tests of the functions frem, fcnt, gcdrem.
|
||||
*
|
||||
* testf(n) gives n tests of frem(x,y) and fcnt(x,y) with randomly
|
||||
* integers x and y generated so that x = f * y^k where f, y and
|
||||
* integers x and y generated so that x = f * y^k where f, y and
|
||||
* k are randomly generated.
|
||||
*
|
||||
* testg(n) gives n tests of gcdrem(x,y) with x and y generated as for
|
||||
@@ -22,7 +22,7 @@
|
||||
* powers of small primes some of which are common to both x and y.
|
||||
* This test uses f = abs(x) and iteratively f = frem(f,p) where
|
||||
* p varies over the prime divisors of y; the final value for f
|
||||
* should equal g. For both x and y the primes are raised to the
|
||||
* should equal g. For both x and y the primes are raised to the
|
||||
* power rand(N); N defaults to 10.
|
||||
*
|
||||
* If verbose is > 1, the numbers x, y and values for some of the
|
||||
|
@@ -53,7 +53,7 @@
|
||||
* modulus to 1.
|
||||
*/
|
||||
|
||||
global defaultverbose = 1; /* default verbose value */
|
||||
global defaultverbose = 1; /* default verbose value */
|
||||
global err;
|
||||
|
||||
/*
|
||||
@@ -302,7 +302,7 @@ define testnextcand(str, N, n, count, skip, residue, modulus, verbose)
|
||||
if (isnull(count))
|
||||
count = COUNT;
|
||||
if (isnull(n)) {
|
||||
n = ceil(K3/(H3 + N^3));
|
||||
n = ceil(K3/(H3 + N^3));
|
||||
print "n =",n;
|
||||
}
|
||||
if (isnull(skip))
|
||||
@@ -356,7 +356,7 @@ define testprevcand(str, N, n, count, skip, residue, modulus, verbose)
|
||||
if (isnull(count))
|
||||
count = COUNT;
|
||||
if (isnull(n)) {
|
||||
n = ceil(K3/(H3 + N^3));
|
||||
n = ceil(K3/(H3 + N^3));
|
||||
print "n =",n;
|
||||
}
|
||||
if (isnull(skip))
|
||||
|
@@ -48,7 +48,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
global defaultverbose = 1; /* default verbose value */
|
||||
global defaultverbose = 1; /* default verbose value */
|
||||
global err;
|
||||
|
||||
/*
|
||||
|
@@ -3,10 +3,10 @@
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
* By: Landon Curt Noll
|
||||
* http://reality.sgi.com/chongo/
|
||||
*
|
||||
* chongo <was here> /\../\
|
||||
* chongo <was here> /\../\
|
||||
*
|
||||
* This library is used by the 8400 series of the regress.cal test suite.
|
||||
*/
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* Represent a fraction as sum of distinct unit fractions.
|
||||
* The output is the unit fractions themselves, and in square brackets,
|
||||
* the number of digits in the numerator and denominator of the value left
|
||||
* to be found. Numbers larger than 3.5 become very difficult to calculate.
|
||||
* to be found. Numbers larger than 3.5 become very difficult to calculate.
|
||||
*/
|
||||
|
||||
define unitfrac(x)
|
||||
@@ -21,9 +21,9 @@ define unitfrac(x)
|
||||
if (n > d)
|
||||
d = n;
|
||||
di = 1/d;
|
||||
print ' [': digits(num(x)): '/': digits(den(x)): ']',, di;
|
||||
print ' [': digits(num(x)): '/': digits(den(x)): ']',, di;
|
||||
x -= di;
|
||||
d++;
|
||||
} while ((num(x) > 1) || (x == di) || (x == 1));
|
||||
print ' [1/1]',, x;
|
||||
print ' [1/1]',, x;
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ define mat_print (a) {
|
||||
|
||||
for (i = matmin(a,1); i <= matmax(a,1); i++) {
|
||||
if (i >= matmin(a,1) + matcolmax) {
|
||||
print " ...";
|
||||
print " ...";
|
||||
break;
|
||||
}
|
||||
for (j = matmin(a,2); j <= matmax(a,2); j++) {
|
||||
|
Reference in New Issue
Block a user