Release calc version 2.12.0.4

This commit is contained in:
Landon Curt Noll
2006-06-20 03:31:22 -07:00
parent bd3086138b
commit afe37ec851
25 changed files with 437 additions and 202 deletions

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: ellip.cal,v 29.3 2006/03/07 22:16:25 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: ellip.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
*
* Under source code control: 1990/02/15 01:50:33
@@ -28,16 +28,17 @@
*/
/*
* Attempt to factor numbers using elliptic functions.
* y^2 = x^3 + a*x + b (mod N).
* Attempt to factor numbers using elliptic functions:
*
* Many points (x,y) (mod N) are found that solve the above equation,
* y^2 = x^3 + a*x + b (mod ellip_N).
*
* Many points (x,y) (mod ellip_N) are found that solve the above equation,
* starting from a trivial solution and 'multiplying' that point together
* to generate high powers of the point, looking for such a point whose
* order contains a common factor with N. The order of the group of points
* varies almost randomly within a certain interval for each choice of a
* and b, and thus each choice provides an independent opportunity to
* factor N. To generate a trivial solution, a is chosen and then b is
* order contains a common factor with ellip_N. The order of the group of
* points varies almost randomly within a certain interval for each choice of
* a and b, and thus each choice provides an independent opportunity to
* factor ellip_N. To generate a trivial solution, a is chosen and then b is
* selected so that (1,1) is a solution. The multiplication is done using
* the basic fact that the equation is a cubic, and so if a line hits the
* curve in two rational points, then the third intersection point must
@@ -45,9 +46,9 @@
* the number of rational solutions can be made very large. When modular
* arithmetic is used, solving for the third point requires the taking of a
* modular inverse (instead of division), and if this fails, then the GCD
* of the failing value and N provides a factor of N. This description is
* only an approximation, read "A Course in Number Theory and Cryptography"
* by Neal Koblitz for a good explanation.
* of the failing value and ellip_N provides a factor of ellip_N.
* This description is only an approximation, read "A Course in Number
* Theory and Cryptography" by Neal Koblitz for a good explanation.
*
* efactor(iN, ia, B, force)
* iN is the number to be factored.
@@ -81,15 +82,15 @@
*
* 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 N.
* variable ellip_N.
*/
obj point {x, y};
global N; /* number to factor */
global a; /* first coefficient */
global b; /* second coefficient */
global f; /* found factor */
global ellip_N; /* number to factor */
global ellip_a; /* first coefficient */
global ellip_b; /* second coefficient */
global ellip_f; /* found factor */
define efactor(iN, ia, B, force)
@@ -103,28 +104,28 @@ define efactor(iN, ia, B, force)
if (isnull(ia))
ia = 1;
obj point x;
a = ia;
b = -ia;
N = iN;
C = isqrt(N);
ellip_a = ia;
ellip_b = -ia;
ellip_N = iN;
C = isqrt(ellip_N);
C = 2 * C + 2 * isqrt(C) + 1;
f = 0;
while (f == 0) {
print "A =", a;
ellip_f = 0;
while (ellip_f == 0) {
print "A =", ellip_a;
x.x = 1;
x.y = 1;
print 2, x;
x = x ^ (2 ^ (highbit(C) + 1));
for (p = 3; ((p < B) && (f == 0)); p += 2) {
for (p = 3; ((p < B) && (ellip_f == 0)); p += 2) {
if (!ptest(p, 1))
continue;
print p, x;
x = x ^ (p ^ ((highbit(C) // highbit(p)) + 1));
}
a++;
b--;
ellip_a++;
ellip_b--;
}
return f;
return ellip_f;
}
@@ -143,16 +144,16 @@ define point_mul(p1, p2)
if (p1 == p2)
return point_square(`p1);
obj point r;
m = (minv(p2.x - p1.x, N) * (p2.y - p1.y)) % N;
m = (minv(p2.x - p1.x, ellip_N) * (p2.y - p1.y)) % ellip_N;
if (m == 0) {
if (f == 0)
f = gcd(p2.x - p1.x, N);
if (ellip_f == 0)
ellip_f = gcd(p2.x - p1.x, ellip_N);
r.x = 1;
r.y = 1;
return r;
}
r.x = (m^2 - p1.x - p2.x) % N;
r.y = ((m * (p1.x - r.x)) - p1.y) % N;
r.x = (m^2 - p1.x - p2.x) % ellip_N;
r.y = ((m * (p1.x - r.x)) - p1.y) % ellip_N;
return r;
}
@@ -162,16 +163,16 @@ define point_square(p)
local r, m;
obj point r;
m = ((3 * p.x^2 + a) * minv(p.y << 1, N)) % N;
m = ((3 * p.x^2 + ellip_a) * minv(p.y << 1, ellip_N)) % ellip_N;
if (m == 0) {
if (f == 0)
f = gcd(p.y << 1, N);
if (ellip_f == 0)
ellip_f = gcd(p.y << 1, ellip_N);
r.x = 1;
r.y = 1;
return r;
}
r.x = (m^2 - p.x - p.x) % N;
r.y = ((m * (p.x - r.x)) - p.y) % N;
r.x = (m^2 - p.x - p.x) % ellip_N;
r.y = ((m * (p.x - r.x)) - p.y) % ellip_N;
return r;
}
@@ -184,7 +185,7 @@ define point_pow(p, pow)
if (isodd(pow))
r = p;
t = p;
for (bit = 2; ((bit <= pow) && (f == 0)); bit <<= 1) {
for (bit = 2; ((bit <= pow) && (ellip_f == 0)); bit <<= 1) {
t = point_square(`t);
if (bit & pow)
r = point_mul(`t, `r);

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: prompt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: prompt.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/prompt.cal,v $
*
* Under source code control: 1995/12/18 04:43:25
@@ -101,7 +101,7 @@ define adder() {
}
}
global x;
global prompt_x;
define showvalues(str) {
local s;
@@ -109,8 +109,8 @@ define showvalues(str) {
s = prompt("? ");
if (s == "end")
break;
x = eval(s);
if (!isnum(x)) {
prompt_x = eval(s);
if (!isnum(prompt_x)) {
print "Please enter a number";
continue;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.29 $
* @(#) $Id: regress.cal,v 29.29 2006/06/11 07:07:23 chongo Exp $
* @(#) $Revision: 29.31 $
* @(#) $Id: regress.cal,v 29.31 2006/06/20 10:25:00 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -201,7 +201,6 @@ define test_variables()
local x1, x2, x3;
global g1, g2;
local t;
global globalvar;
local x;
print '350: Beginning test_variables';
@@ -3972,7 +3971,7 @@ print '088: parsed test_fileop()';
/*
* global and static assignment tests
*/
global a = 10, b, c d = 20, e, f;
global a = 10, b, c d = 20, e;
print '089: global a = 10, b, c d = 20, e, f';
vrfy(a == 10, '090: a == 10');
vrfy(b == 0, '091: b == 0');
@@ -4672,13 +4671,11 @@ print '137: parsed test_random()';
/*
* test_newsyn - test new command completion syntax and scope rules
*/
for (s5500 = 0, i = 0; i < 5; i++)
s5500 += i;
for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;
print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
vrfy(s5500 == 10, '139: s5500 == 10');
vrfy(i == 5, '140: i == 5');
for (s5500 = 0, i = 0; i < 9; i++)
{
for (s5500 = 0, i = 0; i < 9; i++) {
s5500 += i;
}
print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }";
@@ -4726,7 +4723,6 @@ define test_newsyn()
vrfy(i == 3, '5509: i == 3');
/**/
{
local i;
for (s5500 = 0, i = 0; i < 11; i++)
s5500 += i;
vrfy(s5500 == 55, '5510: s5500 == 45');
@@ -5138,8 +5134,6 @@ print '156: parsed test_size()';
/*
* test_assign - test assignment of constants and variables
*/
global A, B; /* A, B for "constants" */
print '157: global A, B';
global X5800, Y5800; /* X5800, Y5800 for "variables" */
print '158: global X5800, Y5800';
obj xy5800 {x, y};
@@ -7818,7 +7812,27 @@ read -once "test8500";
print;
print '8600: Starting test of up to 1024 args'
read -once "test8600";
/* 86xx: Ending test of up to 1024 args is printed by test8600.cal */
/* 860x: Ending test of up to 1024 args is printed by test8600.cal */
/*
* dupvar_warn and redecl_warn testing
*/
print;
print '8650: Starting test of dupvar_warn and redecl_warn config parameters';
vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)');
vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)');
vrfy(u_glob == 6, '8653: u_glob == 6');
global u_glob = 555;
print '8654: reclare u_glob';
vrfy(u_glob == 555, '8655: u_glob == 555');
define func_8650(u_glob) { local u_glob; return u_glob; }
print '8656: u_glob as both local and parameter';
define func_8650a(u_glob) { static u_glob; return u_glob; }
print '8657: u_glob as both static and parameter';
vrfy(config("redecl_warn",1)==0, '8658: config("redecl_warn",1)==0');
vrfy(config("dupvar_warn",1)==0, '8659: config("dupvar_warn",1)==0');
/* 865x: Ending test of up to 1024 args is printed by test8600.cal */
/*
@@ -7826,6 +7840,7 @@ read -once "test8600";
*
* We use the dotest driver to evaluate test-97xx data files.
*/
print;
print '8700: Starting dotest runs'
print '8701: read -once "dotest"';
read -once "dotest";
@@ -7835,6 +7850,7 @@ vrfy(dotest("set8700.line", 8703) == 0,
'8703: dotest("set8700.line", 8703) == 0');
/* 87xx: Ending dotest runs is printed by set8700.test */
/*
* read various calc resource files
*

View File

@@ -17,8 +17,8 @@
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: set8700.line,v 29.1 2006/05/20 19:35:33 chongo Exp $
## @(#) $Revision: 29.2 $
## @(#) $Id: set8700.line,v 29.2 2006/06/20 09:29:16 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
##
## Under source code control: 2006/05/20 14:10:11
@@ -143,7 +143,7 @@ a #= 4, a == 1
## Binary # operator not defined for strings
global set8700_A; protect(set8700_A) == 0
protect(set8700_A) == 0
## Testing with one lvalue
isnull(protect(set8700_A,65))
protect(set8700_A) == 65
@@ -302,7 +302,7 @@ protect(set8700_B,0), set8700_B = set8700_getA1(), protect(set8700_B) == 1024
protect(set8700_B,0), set8700_B = set8700_getA2(), protect(set8700_B) == 1024
set8700_B = set8700_getvar(), protect(set8700_B) == 1024 + 256
global set8700_x, set8700_y; set8700_x = 7, protect(set8700_x) == 0
set8700_x = 7, protect(set8700_x) == 0
protect(7,2) == error(10234)
protect(set8700_x,2.5) == error(10235)
protect(set8700_x,"abc") == error(10235)
@@ -322,7 +322,6 @@ set8700_x++ == error(10385)
set8700_x == 7
set8700_x-- == error(10388)
global set8700_A, set8700_B; 1
protect(set8700_A,0), protect(set8700_A,16), 1
set8700_A = "abcdef", protect(set8700_A) == 16 ## No copy to set8700_A
protect(set8700_B,0), set8700_B = "xyz", protect(set8700_B) == 0

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test2700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test2700.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
*
* Under source code control: 1995/11/01 22:52:25
@@ -41,8 +41,7 @@
*/
global defaultverbose = 1;
global err;
defaultverbose = 1;
define mknonnegreal() {
switch(rand(8)) {

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3300.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
*
* Under source code control: 1995/12/02 04:27:41
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
define testi(str, n, N, verbose)
{

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3400.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3400.cal,v $
*
* Under source code control: 1995/12/02 05:20:11
@@ -54,8 +54,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
global pi1k = pi(1e-1000);

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3500.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3500.cal,v $
*
* Under source code control: 1995/12/18 22:50:46
@@ -53,8 +53,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
define testfrem(x,y,verbose)
{

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test4000.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test4000.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
*
* Under source code control: 1996/03/13 02:38:45
@@ -75,8 +75,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test defaults

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: test4100.cal,v 29.3 2006/06/10 20:19:20 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: test4100.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
*
* Under source code control: 1996/03/13 03:53:22
@@ -70,18 +70,16 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test defaults
*/
global K1 = 2^17;
global K2 = 2^12;
global BASEB = 16;
global BASE = 2^BASEB;
global test4100_K1 = 2^17;
global test4100_K2 = 2^12;
global test4100_BASE = 2^config("baseb");
define rlen_4100(N) = rand(BASE^(N-1), BASE^N);
define rlen_4100(N) = rand(test4100_BASE^(N-1), test4100_BASE^N);
define olen(N)
{
@@ -234,7 +232,7 @@ define times(str,N,n,verbose)
m = olen(N);
m2 = m^2;
if (isnull(n)) {
n = ceil(K1/power(N,1.585));
n = ceil(test4100_K1/power(N,1.585));
if (verbose > 1)
printf("n = %d\n", n);
}
@@ -308,7 +306,7 @@ define powtimes(str, N1, N2, n, verbose)
N2 = 1;
if (isnull(n)) {
n = ceil(K2/power(N1, 1.585)/N2);
n = ceil(test4100_K2/power(N1, 1.585)/N2);
printf ("n = %d\n", n);
}
mat A[n];
@@ -408,7 +406,7 @@ define inittimes(str,N,n,verbose)
}
m = 0;
if (isnull(n)) {
n = ceil(K1/N^2);
n = ceil(test4100_K1/N^2);
if (verbose > 1) {
printf ("n = %d\n", n);
}

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: test4600.cal,v 29.4 2001/04/10 22:09:02 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: test4600.cal,v 29.5 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
*
* Under source code control: 1996/07/02 20:04:40
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1 /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test globals

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test5100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test5100.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5100.cal,v $
*
* Under source code control: 1996/12/02 23:57:10
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* We test the new code generator declaration scope and order.

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test5200.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test5200.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5200.cal,v $
*
* Under source code control: 1997/02/07 02:48:10
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test the fix of a global/static bug