mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.0t8.5
This commit is contained in:
42
lib/README
42
lib/README
@@ -50,37 +50,41 @@ version of read:
|
||||
This will cause the needed library files to be read once. If these
|
||||
files have already been read, the read -once will act as a noop.
|
||||
|
||||
By convention, the config parameter "lib_debug" is used to control
|
||||
the verbosity of debug information printed by lib files. By default,
|
||||
the "lib_debug" has a value of 0.
|
||||
The "lib_debug" parameter is intended for controlling the possible
|
||||
display of special information relating to functions, objects, and
|
||||
other structures created by instructions in calc scripts.
|
||||
Zero value of config("lib_debug") means that no such information
|
||||
is displayed. For other values, the non-zero bits which currently
|
||||
have meanings are as follows:
|
||||
|
||||
The "lib_debug" config parameter takes the place of the lib_debug
|
||||
global variable. By convention, "lib_debug" has the following meanings:
|
||||
n Meaning of bit n of config("lib_debug")
|
||||
|
||||
<-1 no debug messages are printed though some internal
|
||||
debug actions and information may be collected
|
||||
0 When a function is defined, redefined or undefined at
|
||||
interactive level, a message saying what has been done
|
||||
is displayed.
|
||||
|
||||
-1 no debug messages are printed, no debug actions will be taken
|
||||
1 When a function is defined, redefined or undefined during
|
||||
the reading of a file, a message saying what has been done
|
||||
is displayed.
|
||||
|
||||
0 only usage message regarding each important object are
|
||||
printed at the time of the read (default)
|
||||
The value for config("lib_debug") in both oldstd and newstd is 3,
|
||||
but if calc is invoked with the -d flag, its initial value is zero.
|
||||
Thus, if calc is started without the -d flag, until config("lib_debug")
|
||||
is changed, a message will be output when a function is defined
|
||||
either interactively or during the reading of a file.
|
||||
|
||||
>0 messages regarding each important object are
|
||||
printed at the time of the read in addition
|
||||
to other debug messages
|
||||
|
||||
When config("lib_debug") >= 0, function names and their arg are
|
||||
printed as they are defined. Sometimes this printing is not enough
|
||||
information. For example:
|
||||
Sometimes the information printed is not enough. In addition to the
|
||||
standard information, one might want to print:
|
||||
|
||||
* useful obj definitions
|
||||
* functions with optional args
|
||||
* functions with optional args where the param() interface is used
|
||||
|
||||
For these cases we suggest that you place at the bottom of your code
|
||||
something like:
|
||||
something that prints extra information if config("lib_debug") has
|
||||
either of the bottom 2 bits set:
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj xyz defined";
|
||||
print "funcA([val1 [, val2]]) defined";
|
||||
print "funcB(size, mass, ...) defined";
|
||||
|
@@ -174,7 +174,7 @@ define chrem()
|
||||
}
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "chrem(r1,m1 [,r2,m2 ...]) defined";
|
||||
print "chrem(rlist [,mlist]) defined";
|
||||
}
|
||||
|
@@ -111,6 +111,6 @@ define fixdms(a)
|
||||
a.deg %= 360;
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj dms {deg, min, sec} defined";
|
||||
}
|
||||
|
@@ -1027,7 +1027,7 @@ gen_v1(h, n)
|
||||
define
|
||||
ldebug(funct, str)
|
||||
{
|
||||
if (config("lib_debug") > 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "DEBUG:", funct:":", str;
|
||||
}
|
||||
return;
|
||||
|
@@ -331,7 +331,7 @@ lucas_chk(high_n, quiet)
|
||||
|
||||
/* skip primes where h>=2^n */
|
||||
if (highbit(h_p[i]) >= n_p[i]) {
|
||||
if (config("lib_debug") > 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "h>=2^n skip:", h_p[i]:"*2^":n_p[i]:"-1";
|
||||
}
|
||||
continue;
|
||||
|
@@ -152,7 +152,7 @@ d_val[97]=1045; a_val[97]=33; b_val[97]=1; r_val[97]=44;
|
||||
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") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "d_val[100] defined";
|
||||
print "a_val[100] defined";
|
||||
print "b_val[100] defined";
|
||||
|
@@ -312,6 +312,6 @@ define mfactor(n, start_k, rept_loop, p_elim)
|
||||
return q;
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "mfactor(n [, start_k=1 [, rept_loop=10000 [, p_elim=17]]])"
|
||||
}
|
||||
|
@@ -189,7 +189,7 @@ define mod_pow(a, b)
|
||||
}
|
||||
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj mod {a} defined";
|
||||
print "mod_value defined";
|
||||
print "set mod_value as needed";
|
||||
|
@@ -687,6 +687,6 @@ a=pol(1,4,4,2,3,1);
|
||||
b=pol(5,16,8,1);
|
||||
c=pol(1+2i,3+4i,5+6i);
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj poly {p} defined";
|
||||
}
|
||||
|
@@ -195,6 +195,6 @@ define quat_shift(a, b)
|
||||
return x.s;
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj quat {s, v} defined";
|
||||
}
|
||||
|
@@ -122,6 +122,6 @@ define randrun(run_cnt)
|
||||
printf("max length=%d\n", max_run);
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "randrun([run_length]) defined";
|
||||
}
|
||||
|
@@ -28,8 +28,8 @@ global ecnt; /* expected value of errcount() */
|
||||
ecnt = 0; /* clear expected errcount() value */
|
||||
|
||||
initcfg = config("all", "oldstd"); /* set config to startup default */
|
||||
initcfg = config("lib_debug", -4); /* disable lib startup messages */
|
||||
initcfg = config("calc_debug", 1); /* enable more internal debugging */
|
||||
initcfg = config("lib_debug", 0); /* disable lib startup messages */
|
||||
initcfg = config("calc_debug", 0); /* disable internal debugging */
|
||||
initcfg = config("all"); /* save state for later use */
|
||||
|
||||
print '003: parsed global definitions';
|
||||
@@ -7150,9 +7150,11 @@ define test_somenew()
|
||||
|
||||
a = isqrt(2e1000); s = "xyz";
|
||||
print '8217: a = isqrt(2e1000); s = "xyz";';
|
||||
vrfy(hash(a,s) == 1916476840, '8218: hash(a,s) == 1916476840');
|
||||
vrfy(hash(a,s) == 2378490456, '8218: hash(a,s) == 2378490456');
|
||||
vrfy(hash("curds n whey") == 2376141927,
|
||||
'8219: hash("curds n whey") == 2376141927');
|
||||
|
||||
print '8219: Ending test_somenew';
|
||||
print '8220: Ending test_somenew';
|
||||
}
|
||||
print '189: parsed test_somenew()';
|
||||
|
||||
|
@@ -113,7 +113,7 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
p = 2*fp+1;
|
||||
} while (ptest(p,1,0) == 0);
|
||||
} while(ptest(p, trials) == 0 || ptest(fp, trials) == 0);
|
||||
if (config("lib_debug") > 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "/* 1st Blum prime */ p=", p;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
q = 2*fq+1;
|
||||
} while (ptest(q,1,0) == 0);
|
||||
} while(ptest(q, trials) == 0 || ptest(fq, trials) == 0);
|
||||
if (config("lib_debug") > 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "/* 2nd Blum prime */ q=", q;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
n = p*q; /* the Blum modulus */
|
||||
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") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "/* seed quadratic residue */ r=", r;
|
||||
print "/* newn", binsize, "bit quadratic residue*/ newn=", n;
|
||||
}
|
||||
@@ -154,6 +154,6 @@ define seedrandom(seed1, seed2, size, trials)
|
||||
return old_state;
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "seedrandom(seed1, seed2, size [, trials]) defined";
|
||||
}
|
||||
|
@@ -261,7 +261,7 @@ define surd_rel(a, b)
|
||||
return sgn(x^2 - y^2 * surd_type) * sgn(x);
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "obj surd {a, b} defined";
|
||||
print "surd_type defined";
|
||||
print "set surd_type as needed";
|
||||
|
@@ -23,6 +23,6 @@ define sc()
|
||||
return s;
|
||||
}
|
||||
|
||||
if (config("lib_debug") >= 0) {
|
||||
if (config("lib_debug") & 3) {
|
||||
print "sc(a, b, ...) defined";
|
||||
}
|
||||
|
Reference in New Issue
Block a user