Release calc version 2.10.3t5.45

This commit is contained in:
Landon Curt Noll
1997-10-04 20:06:29 -07:00
parent 4618313a82
commit 6e10e97592
300 changed files with 38279 additions and 8584 deletions

View File

@@ -43,47 +43,96 @@ FMT= fmt
CMP= cmp
CAT= cat
# Standard help files
# Standard and Builtin help files
#
# The obj.file is special and is not listed here.
#
STD_HELP_FILES1= intro overview help command config \
define environment expression file history interrupt mat
STD_HELP_FILES2= operator statement types usage variable
STD_HELP_FILES3= todo credit
STD_HELP_FILES= ${STD_HELP_FILES1} ${STD_HELP_FILES2} ${STD_HELP_FILES3}
SYMBOL_HELP= assign
STD_HELP_FILES_1= intro overview help
STD_HELP_FILES_2= assoc
# These two lists are prodiced by the detaillist and missinglist rules
# when no WARNINGS are detected.
BLT_HELP_FILES_3= builtin
STD_HELP_FILES_4= command config custom define environment expression
BLT_HELP_FILES_5= errorcodes
STD_HELP_FILES_6= file history interrupt list mat
# beacuse obj is built special (due to confusion with it as
# a symlink for some built environments, we treat obj specially
# and call it obj.file
#
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch append appr archive \
arg asec asech asin asinh assoc atan atan2 atanh avg base bround \
btrunc ceil cfappr cfsim char cmdbuf cmp comb conj cos cosh cot coth \
count cp csc csch ctime delete den det digit digits dp epsilon errno \
SPECIAL_HELP_7= obj.file
STD_HELP_FILES_8= operator statement
BLT_HELP_FILES_9= stdlib
STD_HELP_FILES_10= types usage unexpected variable
BLT_HELP_FILES_11= altbind bindings custom_cal libcalc new_custom stdlib
STD_HELP_FILES_12= archive
BLT_HELP_FILES_13= bugs changes
STD_HELP_FILES_14= contrib credit todo
# These files are used in the following order to construct full
#
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
${BLT_HELP_FILES_13} ${STD_HELP_FILES_14}
# These full files are those who are not built or constrcuted
#
STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
${STD_HELP_FILES_12} ${STD_HELP_FILES_14}
# These full files are those who are built by this Makefile
#
# Note that ${SPECIAL_HELP_7} is not included in this list
# because of problems with its name.
#
BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
${BLT_HELP_FILES_9} \
${BLT_HELP_FILES_11} ${BLT_HELP_FILES_13}
# This list is prodiced by the detaillist rule when no WARNINGS are detected.
#
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
appr arg arrow asec asech asin asinh assign atan atan2 atanh avg base \
bit blk blkcpy blkfree blocks bround btrunc ceil cfappr cfsim char \
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime delete \
den dereference det digit digits dp epsilon errcount errmax errno \
error eval exp fact factor fclose fcnt feof ferror fflush fgetc \
fgetfield fgetline fgets fgetstr fib files floor fopen forall fprintf \
fputc fputs fputstr frac frem freopen fscan fscanf fseek fsize ftell \
gcd gcdrem getenv hash head highbit hmean hypot ilog ilog10 ilog2 im \
insert int inverse iroot isassoc isatty isconfig iserror iseven \
isfile ishash isident isint islist ismat ismult isnull isnum isobj \
isodd isprime isqrt isrand israndom isreal isrel isset issimple issq \
isstr istype jacobi join lcm lcmfact lfactor list ln lowbit ltol \
makelist matdim matfill matmax matmin matsum mattrans max meq min \
minv mmin mne mod modify near newerror nextcand nextprime norm null \
num ord param perm pfact pi pix places pmod polar poly pop power \
prevcand prevprime printf prompt ptest push putenv quo quomod rand \
randbit randperm rcin rcmul rcout rcpow rcsq re rm remove reverse \
rewind root round rsearch runtime scale scan scanf search sec sech \
segment select sgn sin sinh size sizeof sort sqrt srand ssq str \
strcat strerror strlen strpos strprintf strscan strscanf substr swap \
system tail tan tanh time trunc xor
fputc fputs fputstr frac free freeglobals freeredc freestatics frem \
freopen fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head \
highbit hmean hnrmod hypot ilog ilog10 ilog2 im insert int inverse \
iroot isassoc isatty isblk isconfig isdefined iserror iseven isfile \
ishash isident isint islist ismat ismult isnull isnum isobj isobjtype \
isodd isprime isptr isqrt isrand israndom isreal isrel issimple issq \
isstr istype jacobi join lcm lcmfact lfactor ln lowbit ltol makelist \
matdim matfill matmax matmin matsum mattrace mattrans max md5 memsize \
meq min minv mmin mne mod modify name near newerror nextcand \
nextprime norm null num oldvalue ord param perm pfact pi pix places \
pmod polar poly pop popcnt power prevcand prevprime printf prompt \
protect ptest push putenv quo quomod rand randbit random randombit \
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
round rsearch runtime saveval scale scan scanf search sec sech \
segment select sgn sha sha1 sin sinh size sizeof sort sqrt srand \
srandom ssq str strcat strerror strlen strpos strprintf strscan \
strscanf substr sum swap system tail tan tanh test time trunc xor
# Help files that are constructed from other sources
# This list is of files that are clones of DETAIL_HELP files. They are
# built from DETAIL_HELP files.
#
# The obj.file is special and is not listed here.
#
BUILT_HELP_FILES= bindings altbind changes libcalc stdlib bugs errorcodes
DETAIL_CLONE= copy
# Singular files
#
@@ -94,12 +143,12 @@ SINGULAR_FILES= binding bug change errorcode type
# These files are found (but not built) in the distribution
#
DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${SYMBOL_HELP} ${MAKE_FILE} \
DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
obj.file builtin.top builtin.end funclist.sed \
errorcodes.hdr errorcodes.sed
all: ${STD_HELP_FILES} obj.file ${BUILT_HELP_FILES} full \
${DETAIL_HELP} ${SINGULAR_FILES} builtin .all
all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
${SINGULAR_FILES} calc .all
# used by the upper level Makefile to determine of we have done all
#
@@ -111,9 +160,9 @@ all: ${STD_HELP_FILES} obj.file ${BUILT_HELP_FILES} full \
touch .all
bindings: ../lib/bindings
rm -f bindings
cp ../lib/bindings bindings
chmod 0444 bindings
rm -f $@
cp ../lib/bindings $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -123,9 +172,9 @@ bindings: ../lib/bindings
fi
altbind: ../lib/altbind
rm -f altbind
cp ../lib/altbind altbind
chmod 0444 altbind
rm -f $@
cp ../lib/altbind $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -135,9 +184,9 @@ altbind: ../lib/altbind
fi
stdlib: ../lib/README
rm -f stdlib
cp ../lib/README stdlib
chmod 0444 stdlib
rm -f $@
cp ../lib/README $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -147,9 +196,9 @@ stdlib: ../lib/README
fi
changes: ../CHANGES
rm -f changes
cp ../CHANGES changes
chmod 0444 changes
rm -f $@
cp ../CHANGES $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -159,9 +208,9 @@ changes: ../CHANGES
fi
libcalc: ../LIBRARY
rm -f libcalc
${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' < ../LIBRARY > libcalc
chmod 0444 libcalc
rm -f $@
${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' < ../LIBRARY > $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -171,9 +220,9 @@ libcalc: ../LIBRARY
fi
bugs: ../BUGS
rm -f bugs
cp ../BUGS bugs
chmod 0444 bugs
rm -f $@
cp ../BUGS $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -183,10 +232,10 @@ bugs: ../BUGS
fi
errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
rm -f errorcodes
${CAT} errorcodes.hdr > errorcodes
${SED} -n -f errorcodes.sed < ../calcerr.h >> errorcodes
chmod 0444 errorcodes
rm -f $@
${CAT} errorcodes.hdr > $@
${SED} -n -f errorcodes.sed < ../calcerr.h >> $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
@@ -195,11 +244,58 @@ errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
true; \
fi
full: ${STD_HELP_FILES} ${BUILT_HELP_FILES} ${MAKE_FILE}
calc: usage
rm -f $@
cp usage $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
echo ''; \
else \
true; \
fi
custom_cal: ../custom/CUSTOM_CAL
rm -f $@
cp usage $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
echo ''; \
else \
true; \
fi
new_custom: ../custom/HOW_TO_ADD
rm -f $@
cp usage $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
echo ''; \
else \
true; \
fi
copy: blkcpy
rm -f $@
cp usage $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= skipping the cat of help/$@ =-=-='; \
echo ''; \
else \
true; \
fi
full: ${FULL_HELP_FILES} ${MAKE_FILE}
${Q}echo "forming full"
-${Q}rm -f full
-${Q}for i in ${STD_HELP_FILES1} obj.file ${STD_HELP_FILES2} \
${BUILT_HELP_FILES} ${STD_HELP_FILES3}; do \
-${Q}rm -f $@
-${Q}for i in ${FULL_HELP_FILES}; do \
if [ Xintro != X"$$i" ]; then \
echo " "; \
else \
@@ -215,7 +311,7 @@ full: ${STD_HELP_FILES} ${BUILT_HELP_FILES} ${MAKE_FILE}
echo "*************"; \
echo ""; \
cat $$i; \
done > full
done > $@
${Q}echo "full formed"
-@if [ -z "${Q}" ]; then \
echo ''; \
@@ -302,8 +398,8 @@ distlist: ${DISTLIST}
# The bsdi distribution has generated files as well as distributed files.
#
bsdilist: ${DISTLIST} ${BUILT_HELP_FILES}
${Q}for i in ${DISTLIST} ${BUILT_HELP_FILES}; do \
bsdilist: ${DISTLIST} ${BLT_HELP_FILES}
${Q}for i in ${DISTLIST} ${BLT_HELP_FILES}; do \
echo calc/help/$$i; \
done | ${SORT}
@@ -333,8 +429,9 @@ clean:
rm -f obj mkbuiltin funclist.c funclist.o funclist
clobber:
rm -f ${BUILT_HELP_FILES} full builtin .all
rm -f obj mkbuiltin funclist.c funclist.o funclist ${SINGULAR_FILES}
rm -f ${BLT_HELP_FILES} full .all calc
rm -f obj mkbuiltin funclist.c funclist.o funclist
rm -f ${SINGULAR_FILES} ${DETAIL_CLONE}
install: all
-${Q}if [ ! -d ${TOPDIR} ]; then \
@@ -355,8 +452,8 @@ install: all
else \
true; \
fi
${Q}for i in ${STD_HELP_FILES} ${BUILT_HELP_FILES} builtin \
full ${DETAIL_HELP} ${SINGULAR_FILES} ${SYMBOL_HELP}; do \
${Q}for i in ${STD_HELP_FILES} ${BLT_HELP_FILES} builtin \
full ${DETAIL_HELP} ${SINGULAR_FILES}; do \
echo rm -f ${HELPDIR}/$$i; \
rm -f ${HELPDIR}/$$i; \
echo cp $$i ${HELPDIR}; \
@@ -367,3 +464,5 @@ install: all
rm -f ${HELPDIR}/obj
cp obj.file ${HELPDIR}/obj
chmod 0444 ${HELPDIR}/obj
# remove dead files
-@rm -f rmblk block

View File

@@ -15,14 +15,18 @@ TYPES
eps ignored if x is real, nonzero real for complex x,
defaults to epsilon().
return real
return non-negative real
DESCRIPTION
If x is real, returns x if x is positive or zero, -x if x is negative.
If x is real, returns the absolute value of x, i.e. x if x >= 0,
-x if x < 0.
For complex x, returns the multiple of eps nearest or next to nearest
to the absolute value of x. The result usually has error less in
absolute value than abs(eps), but should not exceed 0.75 * abs(eps).
For complex x with zero real part, returns the absolute value of im(x).
For other complex x, returns the multiple of eps nearest to the absolute
value of x, or in the case of two equally near nearest values, the
the nearest even multiple of eps. In particular, with eps = 10^-n,
the result will be the absolute value correct to n decimal places.
EXAMPLE
> print abs(3.4), abs(-3.4)
@@ -35,7 +39,7 @@ LIMITS
none
LIBRARY
none
NUMBER *qqabs(NUMBER *x)
SEE ALSO
cmp, epsilon, hypot, norm, near, obj

View File

@@ -20,27 +20,30 @@ DESCRIPTION
'w' or bit 1 for writing, 'x' or bit 0 for execution.
EXAMPLE
The system error-numbers and messages may differ for different
implementations
> !rm -f junk
> access("junk")
Error 10002 XXX This number will probably be changed
System error 2
> strerror(.)
"No such file or directory"
> f = fopen("junk", "w")
> access("junk")
> fputs(f, "Now is the time");
> freopen(f, "r");
> fputs(f, "Alpha")
> fclose(f)
> !chmod u-w junk
> fgets(f)
"Now is the time"
> access("junk", "w")
Error 10013 XXX
> freopen(f, "w")
Error 10013 XXX
System error 13
> strerror(.)
"Permission denied"
LIMITS
none - XXX - is this correct?
There may be implementation-dependent limits inherited from the
system call "access" used by this function.
LIBRARY
none - XXX - is this correct?
none
SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
fopen, fclose, isfile, files

View File

@@ -21,9 +21,7 @@ EXAMPLE
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
LIMITS
unlike sin and cos, x must be real
abs(x) <= 1
eps > 0
none
LIBRARY
NUMBER *qacos(NUMBER *x, NUMBER *eps)

View File

@@ -11,19 +11,20 @@ TYPES
return nonnegative real
DESCRIPTION
Returns the cosh of x to a multiple of eps with error less in
Returns the acosh of x to a multiple of eps with error less in
absolute value than .75 * eps.
acosh(x) = ln(x + sqrt(x^2 - 1)) is the nonnegative real number v
for which cosh(v) = x.
acosh(x) is the nonnegative real number v for which cosh(v) = x.
It is given by
acosh(x) = ln(x + sqrt(x^2 - 1))
EXAMPLE
> print acosh(2, 1e-5), acosh(2, 1e-10), acosh(2, 1e-15), acosh(2, 1e-20)
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qacosh(NUMBER *x, NUMBER *eps)

View File

@@ -21,8 +21,7 @@ EXAMPLE
.46365 .463647609 .463647609000806 .46364760900080611621
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qacot(NUMBER *x, NUMBER *eps)

View File

@@ -14,17 +14,16 @@ DESCRIPTION
Returns the acoth of x to a multiple of eps with error less in
absolute value than .75 * eps.
acoth(x) = ln((x + 1)/(x - 1))/2 is the real number v for which
coth(v) = x.
acoth(x) is the real number v for which coth(v) = x.
It is given by
acoth(x) = ln((x + 1)/(x - 1))/2
EXAMPLE
> print acoth(2, 1e-5), acoth(2, 1e-10), acoth(2, 1e-15), acoth(2, 1e-20)
.54931 .5493061443 .549306144334055 .5493061443340548457
LIMITS
unlike sin and cos, x must be real
abs(x) > 1
eps > 0
none
LIBRARY
NUMBER *qacoth(NUMBER *x, NUMBER *eps)

View File

@@ -21,9 +21,7 @@ EXAMPLE
.5236 .5235987756 .523598775598299 .52359877559829887308
LIMITS
unlike sin and cos, x must be real
abs(x) >= 1
eps > 0
none
LIBRARY
NUMBER *qacsc(NUMBER *x, NUMBER *eps)

View File

@@ -14,17 +14,17 @@ DESCRIPTION
Returns the acsch of x to a multiple of eps with error less in
absolute value than .75 * eps.
acsch(x) = ln((1 + sqrt(1 + x^2))/x) is the real number v for
which csch(v) = x.
acsch(x) is the real number v for which csch(v) = x. It is given by
acsch(x) = ln((1 + sqrt(1 + x^2))/x)
EXAMPLE
> print acsch(2, 1e-5), acsch(2, 1e-10), acsch(2, 1e-15), acsch(2, 1e-20)
.48121 .4812118251 .481211825059603 .4812118250596034475
LIMITS
unlike sin and cos, x must be real
x != 0
eps > 0
none
LIBRARY
NUMBER *qacsch(NUMBER *x, NUMBER *eps)

161
help/address Normal file
View File

@@ -0,0 +1,161 @@
NAME
& - address operator
SYNOPSIS
&X
TYPES
X expression specifying an octet, lvalue, string or number
return pointer
DESCRIPTION
&X returns the address at which information for determining the current
value of X is stored. After an assignment as in p = &X, the
value of X is accessible by *p so long as the connection between p
and the value is not broken by relocation of the information or by the
value ceasing to exist. Use of an address after the connection
is broken is unwise since the calculator may use that address for other
purposes; the consequences of attempting to write data to, or
otherwise accessing, such a vacated address may be catastrophic.
An octet is normally expressed by B[i] where B is a block and
0 <= i < sizeof(B). &B[i] then returns the address at which this
octet is located until the block is freed or relocated. Freeing
of an unnamed block B occurs when a new value is assigned to B or
when B ceases to exist; a named block B is freed by blkfree(B().
A block is relocated when an operation like copying to B requires
a change of sizeof(B).
An lvalue may be expressed by an identifier for a variable, or by
such an identifier followed by one or more qualifiers compatible with
the type of values associated with the variable and earlier qualifiers.
If an identifier A specifies a global or static variable, the address
&A is permanently associated with that variable. For a local variable
or function parameter A, the association of the variable with &A
is limited to each occasion when the function is called. If X specifies a
component or element of a matrix or object, connection of
&X with that component or element depends only on the continued existence
of the matrix or object. For example, after
> mat A[3]
the addresses &A[0], &A[1], &A[2] locate the three elements
of the matrix specified by A until another value is assigned to A, etc.
Note one difference from C in that &A[0] is not the same as A.
An element of a list has a fixed address while the list exists and
the element is not removed by pop(), remove(), or delete(); the index
of the element changes if an element is pushed onto the list, or if
earlier elements are popped or deleted.
Elements of an association have fixed addresses so long as the association
exists. If A[a,b,...] has not been defined for the association A,
&A[a,b,...] returns the constant address of a particular null value.
Some other special values have fixed addresses; e.g. the old value (.).
Some arithmetic operations are defined for addresses but these should
be used only for octets or components of a matrix or object where the
results refer to octets in the same block or existing components of the
same matrix or object. For example, immediately after
> mat A[10]
> p = &A[5]
it is permitted to use expressions like p + 4, p - 5, p++ .
Strings defined literally have fixed addresses, e.g., after
> p = &"abc"
> A = "abc"
The address &*A of the value of A will be equal to p.
Except in cases like strcat(A, "") when *A identified with a literal
string as above, definitions of string values using strcat() or substr()
will copy the relevant strings to newly allocated addresses which will
be useable only while the variables retain these defined values.
For example,
> B = C = strcat("a", "bc");
&*B and &*C will be different. If p is defined by p = &*B, p should
not be used after a mew value is assigned to B, or B ceases to exist,
etc.
When compilation of a function encounters for the first time a particular
literal number or the result of simple arithmetic operations (like +, -, *,
or /) on literal numbers, that number is assigned to a particular
address which is then used for later similar occurrences of that number
so long as the number remains associated with at least one function or
lvalue. For example, after
> x = 27;
> y = 3 * 9;
> define f(a) = 27 + a;
the three occurrences of 27 have the same address which may be displayed
by any of &27, &*x, &*y and &f(0). If x and y are assigned
other values and f is redefined or undefined and the 27 has not been
stored elsewhere (e.g. as the "old value" or in another function
definition or as an element in an association), the address assigned at
the first occurrence of 27 will be freed and calc may later use it for
another number.
When a function returns a number value, that number value is usually
placed at a newly allocated address, even if an equal number is stored
elsewhere. For example calls to f(a), as defined above, with the same
non-zero value for a will be assigned to different addresses as can be
seen from printing &*A, &*B, &*C after
> A = f(2); B = f(2); C = f(2);
(the case of f(0) is exceptional since 27 + 0 simply copies the 27
rather than creating a new number value). Here it is clearly more
efficient to use
> A = B = C = f(2);
which, not only performs the addition n f() only once, but stores the
number values for A, B and C at the same address.
Whether a value V is a pointer and if so, its type, is indicated by the
value returned by isptr(V): 1, 2, 3, 4 for octet-, value-, string-
and number-pointer respectively, and 0 otherwise.
The output when addresses are printed consists of a description (o_ptr,
v_ptr, s_ptr, n_ptr) followed by : and the address printed in
%p format.
Iteration of & is not permitted; &&X causes a "non-variable operand"
scan error.
EXAMPLE
Addresses for particular systems may differ from those displayed here.
> mat A[3]
> B = blk()
> print &A, &A[0], &A[1]
v-ptr: 1400470d0 v-ptr: 140044b70 v-ptr: 140044b80
> print &B, &B[0], &B[1]
v-ptr: 140047130 o-ptr: 140044d00 o-ptr: 140044d01
> a = A[0] = 27
> print &*a, &*A[0]. &27
n_ptr: 14003a850 n_ptr: 14003a850 n_ptr: 14003a850
> a = A[0] = "abc"
> print &*a, &*A[0], &"abc"
s_ptr: 14004cae0 s_ptr: 14004cae0 s_ptr: 14004cae0
LIMITS
none
LIBRARY
none
SEE ALSO
dereference, isptr

57
help/agd Normal file
View File

@@ -0,0 +1,57 @@
NAME
agd - inverse gudermannian function
SYNOPSIS
agd(z [,eps])
TYPES
z number (real or complex)
eps nonzero real, defaults to epsilon()
return number or infinite error value
DESCRIPTION
Calculate the inverse gudermannian of z to a nultiple of eps with
errors in real and imaginary parts less in absolute value than .75 * eps,
or an error value if z is very close to one of the one of the branch
points of agd(z)..
agd(z) is usually defined initially for real z with abs(z) < pi/2 by
one of the formulae
agd(z) = ln(sec(z) + tan(z))
= 2 * atanh(tan(z/2))
= asinh(tan(z)),
or as the integral from 0 to z of (1/cos(t))dt. For complex z, the
principal branch, approximated by gd(z, eps), has cuts along the real
axis outside -pi/2 < z < pi/2.
If z = x + i * y and abs(x) < pi/2, agd(z) is given by
agd(z) = atanh(sin(x)/cosh(y)) + i * atan(sinh(y)/cos(x)>
EXAMPLE
> print agd(1, 1e-5), agd(1, 1e-10), agd(1, 1e-15)
1.22619 1.2261911709 1.226191170883517
> print agd(2, 1e-5), agd(2, 1e-10)
1.52345-3.14159i 1.5234524436-3.1415926536i
> print agd(5, 1e-5), agd(5, 1e-10), agd(5, 1e-15)
-1.93237 -1.9323667197 -1.932366719745925
> print agd(1+2i, 1e-5), agd(1+2i, 1e-10)
.22751+1.42291i .2275106584+1.4229114625i
LIMITS
none
LIBRARY
COMPLEX *cagd(COMPLEX *x, NUMBER *eps)
SEE ALSO
gd, exp, ln, sin, sinh, etc.

View File

@@ -22,7 +22,7 @@ DESCRIPTION
there is no "approximation" - the result represents x exactly.
In the following it is assumed y is nonzero and x is not a multiple of y.
For Real x:
For real x:
appr(x,y,z) is either the nearest multiple of y greater
than x or the nearest multiple of y less than x. Thus, if
@@ -45,9 +45,9 @@ DESCRIPTION
z = 3 round away from zero, sgn(r) = -sgn(x)
z = 4 round down
z = 4 round down, r > 0
z = 5 round up
z = 5 round up, r < 0
z = 6 round towards or from zero according as y is positive or
negative, sgn(r) = sgn(x/y)
@@ -82,7 +82,9 @@ DESCRIPTION
appr(x,y,z) returns the matrix or list indexed in the same way as x,
in which each element t has been replaced by appr(t,y,z).
XXX - complex x needs to be documented
Complex x:
Returns appr(re(x), y, z) + appr(im(x), y, z) * 1i
PROPERTIES
If appr(x,y,z) != x, then abs(x - appr(x,y,z)) < abs(y).
@@ -134,6 +136,10 @@ EXAMPLES
> print appr(-.44,-.1,15),appr(.44,-.1,15),appr(5.7,-1,15),appr(-5.7,-1,15)
-.4 .5 5 -6
> x = sqrt(7-3i, 1e-20)
> print appr(x,1e-5,0), appr(x,1e-5,1), appr(x,1e-5,2), appr(x,1e-6,3)
2.70331-.55488i 2.70332-.55487i 2.70331-.55487i 2.70332-.55488i
LIMITS
none

View File

@@ -22,4 +22,10 @@ Where to get the the latest versions of calc
where "address" is your EMail address and "your_full_name"
is your full name.
Landon Curt Noll <chongo@toad.com> /\oo/\
See:
http://prime.corp.sgi.com/csp/ioccc/noll/noll.html#calc
for details.
Landon Curt Noll <chongo@toad.com> /\oo/\

View File

@@ -13,7 +13,7 @@ TYPES
DESCRIPTION
Returns the argument of x to the nearest or next to nearest multiple of
eps; the error will be less in absolute value than 0.75 * abs(eps),
but usually less than 0.5 * abs(eps). By default, acc is epsilon().
but usually less than 0.5 * abs(eps).
EXAMPLE
> print arg(2), arg(2+3i, 1e-5), arg(2+3i, 1e-10), arg(2+3i, 1e-20)

51
help/arrow Normal file
View File

@@ -0,0 +1,51 @@
SYMBOL and NAME
-> - arrow operator
SYNOPSIS
p -> X
TYPES
p pointer to an lvalue
X identifier
return lvalue
DESCRIPTION
p->X returns the same as (*p).X. Thus the current value of *p is
to be an object of a type for which X identifies one element.
p->X then returns the lvalue corresponding to that element of of the
value of *p.
The expression *p.X will cause a runtime error since this is
interpreted as *(p.X) in which p is expected to be an object of
an appropriate type.
Spaces or tabs on either side of -> are optional.
EXAMPLES
> obj pair {one, two}
> obj pair A, B
> p = &A
> p->one = 1; p->two = 2
> A
obj pair {1, 2}
> A->two = &B
> p->two->one = 3; p->two->two = 4
> *p->ptwo
obj pair {3, 4}
> B = {5,6}
> *p->two
obj pair {5, 6}
LIMITS
none
LIBRARY
none
SEE ALSO
address, dereference, isptr, dot

View File

@@ -21,9 +21,7 @@ EXAMPLE
1.0472 1.0471975512 1.047197551196598 1.04719755119659774615
LIMITS
unlike sin and cos, x must be real
abs(x) >= 1
eps > 0
none
LIBRARY
NUMBER *qasec(NUMBER *x, NUMBER *eps)

View File

@@ -14,17 +14,16 @@ DESCRIPTION
Returns the asech of x to a multiple of eps with error less in
absolute value than .75 * eps.
asech(x) = ln((1 + sqrt(1 - x^2))/x) is the real number v for which
sech(v) = x.
asech(x) is the real number v for which sech(v) = x. It is given by
asech(x) = ln((1 + sqrt(1 - x^2))/x)
EXAMPLE
> print asech(.5,1e-5), asech(.5,1e-10), asech(.5,1e-15), asech(.5,1e-20)
1.31696 1.3169578969 1.316957896924817 1.31695789692481670862
LIMITS
unlike sin and cos, x must be real
0 < x <= 1
eps > 0
none
LIBRARY
NUMBER *qasech(NUMBER *x, NUMBER *eps)

View File

@@ -21,9 +21,7 @@ EXAMPLE
.5236 .5235987756 .523598775598299 .52359877559829887308
LIMITS
unlike sin and cos, x must be real
abs(x) <= 1
eps > 0
none
LIBRARY
NUMBER *qasin(NUMBER *q, NUMBER *epsilon)

View File

@@ -14,16 +14,16 @@ DESCRIPTION
Returns the asinh of x to a multiple of eps with error less in
absolute value than .75 * eps.
asinh(x) = ln(x + sqrt(1 + x^2)) is the real number v for which
sinh(v) = x.
asinh(x) is the real number v for which sinh(v) = x. It is given by
asinh(x) = ln(x + sqrt(1 + x^2))
EXAMPLE
> print asinh(2, 1e-5), asinh(2, 1e-10), asinh(2, 1e-15), asinh(2, 1e-20)
1.44363 1.4436354752 1.44363547517881 1.44363547517881034249
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qasinh(NUMBER *x, NUMBER *eps)

View File

@@ -3,22 +3,111 @@ NAME
SYNOPSIS
a = b
a = {e_1, e_2, ...[ { ... } ] }
TYPES
a lvalue
b expression
a lvalue, current value a structure in { } case
return lvalue
b expression
e_0, e_1, ... expressions, blanks, or initializer lists
return lvalue (a)
DESCRIPTION
Here an lvalue is either a simple variable specified by an identifier,
or an element of an existing structure specified by one or more
qualifiers following an identifier.
An initializer list is a comma-separated list enclosed in braces as in
{e_0, e_1, ... }
where each e_i is an expression, blank or initializer list.
a = b evaluates b, assigns its value to a, and returns a.
a = {e_0, e_1, ... } where the e_i are expressions or blanks,
requires the current value of a to be a matrix, list
or object with at least as many elements as listed e_i. Each non-blank
e_i is evaluated and its value is assigned to a[[i]]; elements a[[i]]
corresponding to blank e_i are unchanged.
If, in a = {e_0, e_1, ...}, e_i is an initializer list, as in
{e_i_0, e_1_1, ...}, the corresponding a[[i]] is to be a matrix, list
or object with at least as many elements as listed e_i_j. Depending on
whether e_i_j is an expression, blank, or initializer list, one, no, or
possibly more than one assignment, is made to a[[i]][[j]] or, if
relevant and possible, its elements.
In simple assignments, = associates from right to left so that, for
example,
a = b = c
has the effect of a = (b = c) and results in assigning the value of c
to both a and b. The expression (a = b) = c is acceptable, but has the
effect of a = b; a = c; in which the first assignment is superseded by
the second.
In initializations, = { ...} associates from left to right so that,
for example,
a = {e_0, ... } = {v_0, ...}
first assigns e_0, ... to the elements of a, and then assigns v_0, ...
to the result.
If there are side effects in the evaluations involved in executing a = b,
it should be noted that the order of evaluations is: first the address
for a, then the value of b, and finally the assignment. For example if
A is a matrix and i = 0, then the assignment in A[i++] = A[i] is
that of A[0] = A[1].
If, in execution of a = b, a is changed by the evaluation of b, the
value of b may be stored in an unintended or inaccessible location. For
example,
mat A[2]= {1,2};
A[0] = (A = 3);
results in the value 3 being stored not only as the new value for A
but also at the now unnamed location earlier used for A[0].
EXAMPLE
> b = 3+1
> a = b
> print a, b
4 4
> obj point {x,y}
> mat A[3] = {1, list(2,3), obj point = {4,5}}
> A[1][[0]] = 6; A[2].x = 7
> print A[1]
list (2 elements, 2 nonzero):
[[0]] = 6
[[1]] = 3
> print A[2]
obj point {7, 5}
> A = {A[2], , {9,10}}
> print A[0]
obj point {7, 5}
> print A[2]
obj point {9, 10}
> A = {, {2}}
print A[1]
list (2 elements, 2 nonzero):
[[0]] = 2
[[1]] = 3
LIMITS
none
@@ -26,4 +115,4 @@ LIBRARY
none
SEE ALSO
XXX - fill in
swap, quomod

View File

@@ -8,38 +8,34 @@ TYPES
return association
DESCRIPTION
This functions returns an empty association array.
This function returns an empty association array.
Associations are special values that act like matrices, except
that they are more general (and slower) than normal matrices.
Unlike matrices, associations can be indexed by arbitrary values.
For example, if 'val' was an association, you could do the following:
After A = assoc(), elements can be added to the association by
assignments of the forms
val['hello'] = 11;
val[4.5] = val['hello'];
print val[9/2];
A[a_1] = v_1
A[a_1, a_2] = v_2
A[a_1, a_2, a_3] = v_3
A[a_1, a_2, a_3, a_4] = v_4
and 11 would be printed.
There are no restrictions on the values of the "indices" a_i or
the "values" v_i.
Associations are created by the 'assoc' function. It takes no
arguments, and simply returns an empty association. You can then
insert elements into the association by indexing the returned value
as shown above.
After the above assignments, so long as no new values have been
assigned to A[a_i], etc., the expressions A[a_1], A[a_1, a_2], etc.
will return the values v_1, v_2, ...
Associations are multi-dimensional. You can index them using one to
four dimensions as desired, and the elements with different numbers
of dimensions will remain separated. For example, 'val[3]' and
'val[3,0]' can both be used in the same association and will be
distinct elements.
Until A[a_1], A[a_1, a_2], ... are defined as described above, these
expressions return the null value.
When references are made to undefined elements of an association,
a null value is simply returned. Therefore no bounds errors can
occur when indexing an association. Assignments of a null value
Thus associations act like matrices except that different elements
may have different numbers (between 1 and 4 inclusive) of indices,
and these indices need not be integers in specified ranges.
Assignments of a null value
to an element of an association does not delete the element, but
a later reference to that element will return the null value as if
the element was undefined. Elements with null values are implicitly
created on certain other operations which require an address to be
taken, such as the += operator and using & in a function call.
the element is undefined.
The elements of an association are stored in a hash table for
quick access. The index values are hashed to select the correct
@@ -65,9 +61,18 @@ DESCRIPTION
and are illegal.
EXAMPLE
> print assoc()
> A = assoc(); print A
assoc (0 elements):
assoc (0 elements):
> A["zero"] = 0; A["one"] = 1; A["two"] = 2; A["three"] = 3;
> A["smallest", "prime"] = 2;
> print A
assoc (5 elements);
["two"] = 2
["three"] = 3
["one"] = 1
["zero"] = 0
["smallest","prime"] = 2
LIMITS
none

View File

@@ -21,8 +21,7 @@ EXAMPLE
1.10715 1.1071487178 1.107148717794091 1.10714871779409050302
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qatan(NUMBER *x, NUMBER *eps)

View File

@@ -2,32 +2,33 @@ NAME
atan2 - angle to point
SYNOPSIS
atan2(y, x, [,acc])
atan2(y, x, [,eps])
TYPES
y real
x real
acc real
eps nonzero real, defaults to epsilon()
return real
DESCRIPTION
Return the angle which is determined by the point (x,y). This
function computes the arctangent of y/x in the range [-pi, pi].
The value acc specifies the accuracy of the result. By default, acc
is epsilon().
If x and y are not both zero, atan2(y, x, eps) returns, as a multiple of
eps with error less than abs(eps), the angle t such that
-pi < t <= pi and x = r * cos(t), y = r * sin(t), where
r > 0. Usually the error does not exceed abs(eps)/2.
Note that by convention, y is the first argument.
Note that by convention, y is the first argument; if x > 0,
atan2(y, x) = atan(y/x).
To conform to the 4.3BSD ANSI/IEEE 754-1985 math lib, atan2(0,0) is
defined to return 0.
To conform to the 4.3BSD ANSI/IEEE 754-1985 math lib, atan2(0,0)
returns 0.
EXAMPLE
> print atan2(0,0), atan2(1,sqrt(3)), atan2(17,53,1e-100)
0 ~.52359877559829887307 ~.31038740713235146535
LIMITS
acc > 0
none
LIBRARY
NUMBER *qatan2(NUMBER *y, *x, *acc)

View File

@@ -14,16 +14,16 @@ DESCRIPTION
Returns the atanh of x to a multiple of eps with error less in
absolute value than .75 * eps.
atanh(x) = ln((1 + x)/(1 - x))/2 is the real number v for whichi
tanh(v) = x.
atanh(x) is the real number v for which tanh(v) = x. It is given by
atanh(x) = ln((1 + x)/(1 - x))/2
EXAMPLE
> print atanh(.5,1e-5), atanh(.5,1e-10), atanh(.5,1e-15), atanh(.5,1e-20)
.54931 .5493061443 .549306144334055 .5493061443340548457
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qatanh(NUMBER *x, NUMBER *eps)

View File

@@ -11,7 +11,7 @@ TYPES
DESCRIPTION
The base function allows one to specify how numbers should be
printer. The base function provides a numeric shorthand to the
printed. The base function provides a numeric shorthand to the
config("mode") interface. With no args, base() will return the
current mode. With 1 arg, base(val) will set the mode according to
the arg and return the previous mode.

43
help/bit Normal file
View File

@@ -0,0 +1,43 @@
NAME
bit - whether a given binary bit is set in a value
SYNOPSIS
bit(x, y)
TYPES
x real
y int
return int
DESCRIPTION
Determine if the binary bit y is set in x. If:
x
int(---) mod 2 == 1
2^y
return 1, otherwise return 0.
EXAMPLE
> print bit(9,0), bit(9,1), bit(9,2), bit(9,3)
1 0 0 1
> print bit(9,4), bit(0,0), bit(9,-1)
0 0 0
> print bit(1.25, -2), bit(1.25, -1), bit(1.25, 0)
1 0 1
> p = pi()
> print bit(p, 1), bit(p, -2), bit(p, -3)
1 0 1
LIMITS
-2^31 < y < 2^31
LIBRARY
BOOL qbit(NUMBER *x, long y)
SEE ALSO
highbit, lowbit, digit

219
help/blk Normal file
View File

@@ -0,0 +1,219 @@
NAME
blk - generate or modify block values
SYNOPSIS
blk([len, chunk]);
blk(val [, len, chunk]);
TYPES
len null or integer
chunk null or integer
val non-null string, block, or named block
return block or named block
DESCRIPTION
With only integer arguments, blk(len, chunk) attempts to
allocate a block of memory consisting of N octets (unsigned 8-bit
bytes). Allocation is always done in multiples of chunk
octets, so the actual allocation size of len rounded up
to the next multiple of chunk.
The default value for len is 0. The default value for chunk is 256.
If the allocation is successful, blk(len, chunk) returns a value B, say,
for which the octets in the block may be referenced by B[0], B[1],
... , B[len-1], these all initially having zero value.
The octets B[i] for i >= len always have zero value. If B[i] with
some i >= len is referenced, len is increased by 1. For example:
B[i] = x
has an effect like that of two operations on a file stream fs:
fseek(fs, pos);
fputc(fs, x).
Similarly:
x = B[i]
is like:
fseek(fs, pos);
x = fgetc(fs).
The value of chunk is stored as the "chunksize" for B.
The size(B) builtin returns the current len for the block; sizeof(B)
returns its maxsize; memsize(B) returns maxsize + overhead for any block
value. Also size(B) is analogous to the length of a file stream in that
if size(B) < sizeof(B):
B[size(B)] = x
will append one octet to B and increment size(B).
The builtin test(B) returns 1 or 0 according as at least one octet
is zero or all octets are zero. If B1 and B2 are blocks, they are
considered equal (B1 == B2) if they have the same length and the
same data, i.e. B1[i] == B2[i] for 0 <= i < len. Chunksizes
and maxsizes are ignored.
The output for print B occupies two lines, the first line giving
the chunksize, number of octets allocated (len rounded up to the
next chunk) and len, and the second line up to 30 octets of data.
If the datalen is zero, the second line is blank. If the datalen
exceeds 30, this indicated by a trailing "...".
If a block value B created by B = blk(len, chunk) is assigned to
another variable by C = B, a new block of the same structure as B
is created to become the value of C, and the octets in B are copied
to this new block. A block with possibly different length or
chunksize is created by C = blk(B, newlen, newchunk), only the first
min(len, newlen) octets being copied from B; later octets are
assigned zero value. If omitted, newlen and newchunk default to
the current datalen and chunk-size for B. The curent datalen,
chunksize and number of allocated octets for B may be changed by:
B = blk(B, newlen, newchunk).
No data is lost if newlen is greater than or equal to the old
size(B).
The memory block allocated by blk(len, chunk) is freed at or before
termination of the statement in which this occurred, the memory
allocated in B = blk(len, chunk) is freed when B is assigned another
value.
With a string str as its first argument, blk(str [, len, chunk])
when called for the first time creates a block with str as its
name. Here there no restriction on the characters used in str;
thus the string may include white space or characters normally used
for punctuation or operators. Any subsequent call to blk(str, ...)
with the same str will refer to the same named block.
A named block is assigned length and chunksize and consequent
maximum size in the same way as unnamed blocks. A major difference
is that in assignments, a named block is not copied. Thus, if a
block A has been created by:
A = blk("foo")
any subsequent:
B = A
or:
B = blk("foo")
will give a second variable B referring to the same block as A.
Either A[i] = x or B[i] = x may then be used to assign a value
to an octet in the book. Its length or chunksize may be changed by
instructions like:
blk(A, len, chunk);
A = blk(A, len, chunk);
null(blk(A, len, chunk)).
These have the same effect on A; when working interactively, the
last two avoid printing of the new value for A.
Named blocks are assigned index numbers 0, 1, 2, ..., in the order
of their creation. The block with index id is returned by blocks(id).
With no argument, blocks() returns the number of current unfreed
named blocks. A named block may be used
The memory allocated to a named block is freed by the blkfree()
function with argument the named block, its name, or its id number.
The block remains in existence but with a null data pointer,
its length and size being reduced to zero. A new block of memory
may be allocated to it, with possibly new length and chunksize by:
blk(val [, len, chunk])
where val is either the named block or its name.
The printing output for a named block is in three lines, the first
line displaying its id number and name, the other two as for an
unnamed block, except that "NULL" is printed if the memory has been
freed.
The identifying numbers and names of the current named blocks are
displayed by:
show blocks
If A and B are named blocks, A == B will be true only if they refer
to the same block of memory. Thus, blocks with the same data and
datalen will be considered unequal if they have different names.
If A is a named block, str(A) returns the name of the block.
Values may be assigned to the early octets of a named or unnamed
block by use of = { } initialization as for matrices.
EXAMPLE
> B = blk(15,10)
> B[7] = 0xff
> B
chunksize = 10, maxsize = 20, datalen = 15
00000000000000ff00000000000000
> B[18] = 127
> B
chunksize = 10, maxsize = 20, datalen = 18
00000000000000ff0000000000000000007f
> B[20] = 2
Index out of bounds for block
> print size(B), sizeof(B)
18 20
> B = blk(B, 100, 20)
> B
chunksize = 20, maxsize = 120, datalen = 100
00000000000000ff0000000000000000007f000000000000000000000000...
> C = blk(B, 10} = {1,2,3}
> C
chunksize = 20, maxsize = 20, datalen = 10
01020300000000ff0000
> A1 = blk("alpha")
> A1
block 0: alpha
chunksize = 256, maxsize = 256, datalen = 0
> A1[7] = 0xff
> A2 = A1
> A2[17] = 127
> A1
block 0: alpha
chunksize = 256, maxsize = 256, datalen = 18
00000000000000ff0000000000000000007f
> A1 = blk(A1, 1000)
> A1
block 0: alpha
chunksize = 256, maxsize = 1024, datalen = 1000
00000000000000ff0000000000000000007f000000000000000000000000...
> A1 = blk(A1, , 16)
> A1
block 0: alpha
chunksize = 16, maxsize = 1008, datalen = 1000
00000000000000ff0000000000000000007f000000000000000000000000...
LIMITS
0 <= len < 2^31
1 <= chunk < 2^31
LIBRARY
XXX
SEE ALSO
blocks, blkfree

192
help/blkcpy Normal file
View File

@@ -0,0 +1,192 @@
NAME
blkcpy, copy - copy items from a structure to a structure
SYNOPSIS
blkcpy(dst, src [, num [, dsi [, ssi]]]
copy(src, dest [, [ssi [, num [, dsi]]])
TYPES
src block, file, string, matrix, or list
dest block, file, matrix or list - compatible with src
ssi nonnegative integer, defaults to zero
num nonnegative integer, defaults to maximum possible
dsi nonnegative integer, defaults to datalen for a block, filepos
for a file, zero for other structures
return null if successful, error value otherwise
DESCRIPTION
A call to:
blkcpy(dst, src, num, dsi, ssi)
attempts to copy 'num' consecutive items (octets or values) starting
from the source item 'src' with index 'ssi'. By default, 'num'
is the maximum possible and 'ssi' is 0.
A call to:
copy(src, dst, ssi, num, dsi)
does the same thing, but with a different arg order.
A copy fails if ssi or num is too large for the number of items in
the source, if sdi is too large for the number of positions
available in the destination, or, in cases involving a file stream,
if the file is not open in the required mode. The source and
destination need not be of the same type, e.g. when a block is
copied to a matrix the octets are converted to numbers.
The following pairs of source-type, destination-type are permitted:
block to
int
block
matrix
file
matrix to
block
matrix
list
string to
block
file
list to
list
matrix
file to
block
int to
block
In the above table, int refers to integer values. However if a
rational value is supplied, only the numerator is copied.
Each copied octet or value replaces the octet or value in the
corresponding place in the destination structure. When copying values
to values, the new values are stored in a buffer, the old values are
removed, and the new values copied from the buffer to the destination.
This permits movement of data within one matrix or list, and copying
of an element of structure to the structure.
Except for copying to files or blocks, the destination is already to have
sufficient memory allocated for the copying. For example, to copy
a matrix M of size 100 to a newly created list, one may use:
L = makelist(100);
copy(M, L);
or:
L = makelist(100);
blkcpy(L, M);
For copying from a block B (named or unnamed), the total number of octets
available for copying is taken to the the datalen for that block,
so that num can be at most size(B) - ssi.
For copying to a block B (named or unnamed), reallocation will be
required if dsi + num > sizeof(B). (This will not be permitted if
protect(B) has bit 4 set.)
For copying from a file stream fs, num can be at most size(fs) - ssi.
For copying from a string str, the string is taken to include the
terminating '\0', so the total number of octets available is
strlen(str) + 1 and num can be at most strlen(str) + 1 - ssi.
If num <= strlen(str) - ssi, the '\0' is not copied.
For copying from or to a matrix M, the total number of values in
M is size(M), so in the source case, num <= size(M) - ssi, and
in the destination case, num <= size(M) - dsi. The indices ssi
and dsi refer to the double-bracket method of indexing, i.e. the
matrix is as if its elements were indexed 0, 1, ..., size(M) - 1.
EXAMPLE
> A = blk() = {1,2,3,4}
> B = blk()
> blkcpy(B,A)
> B
chunksize = 256, maxsize = 256, datalen = 4
01020304
>
> blkcpy(B,A)
> B
chunksize = 256, maxsize = 256, datalen = 8
0102030401020304
> blkcpy(B, A, 2, 10)
> B
chunksize = 256, maxsize = 256, datalen = 12
010203040102030400000102
> blkcpy(B,32767)
> B
chunksize = 256, maxsize = 256, datalen = 16
010203040102030400000102ff7f0000
> mat M[2,2]
> blkcpy(M, A)
> M
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 1
[0,1] = 2
[1,0] = 3
[1,1] = 4
> blkcpy(M, A, 2, 2)
> M
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 1
[0,1] = 2
[1,0] = 1
[1,1] = 2
> A = blk() = {1,2,3,4}
> B = blk()
> copy(A,B)
> B
chunksize = 256, maxsize = 256, datalen = 4
01020304
> copy(A,B)
> B
chunksize = 256, maxsize = 256, datalen = 8
0102030401020304
> copy(A,B,1,2)
> B
chunksize = 256, maxsize = 256, datalen = 10
01020304010203040203
> mat M[2,2]
> copy(A,M)
> M
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 1
[0,1] = 2
[1,0] = 3
[1,1] = 4
> copy(A,M,2)
> M
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 3
[0,1] = 4
[1,0] = 3
[1,1] = 4
> copy(A,M,0,2,2)
> M
mat [2,2] (4 elements, 4 nonzero):
[0,0] = 3
[0,1] = 4
[1,0] = 1
[1,1] = 2
LIMITS
none
LIBRARY
none
SEE ALSO
blk, mat, file, list, str

58
help/blkfree Normal file
View File

@@ -0,0 +1,58 @@
NAME
blkfree - free memory allocated to named block
SYNOPSIS
blkfree(val)
TYPES
val named block, string, or integer
return null value
DESCRIPTION
If val is a named block, or the name of a named block, or the
identifying index for a named block, blkfree(val) frees the
memory block allocated to this named block. The block remains
in existence with the same name, identifying index, and chunksize,
but its size and maxsize becomes zero and the pointer for the start
of its data block null.
A new block of memory may be allocated to a freed block B by
blk(B [, len, chunk]), len defaulting to zero and chunk to the
chunksize when the block was freed.
EXAMPLE
> B1 = blk("foo")
> B2 = blk("Second block")
show blocks
id name
---- -----
0 foo
1 Second block
> blkfree(B1)
> show blocks
id name
---- -----
1 Second block
> B1
block 0: foo
chunksize = 256, maxsize = 0, datalen = 0
NULL
> blk(B1); B[7] = 5
> B1
block 0: foo
chunksize = 256, maxsize = 256, datalen = 8
0000000000000005
LIMITS
none
LIBRARY
none
SEE ALSO
blk, blocks

43
help/blocks Normal file
View File

@@ -0,0 +1,43 @@
NAME
blocks - return a named file or number of unfreed named blocks
SYNOPSIS
blocks([id])
TYPES
id non-negative integer
return named block or null value
DESCRIPTION
With no argument blocks() returns the number of blocks that have
been created but not freed by the blkfree function.
With argument id less than the number of named blocks that have been
created, blocks(id) returns the named block with identifying index id.
These indices 0, 1, 2, ... are assigned to named blocks in the order
of their creation.
EXAMPLE
> A = blk("alpha")
> B = blk("beta") = {1,2,3}
> blocks()
2
> blocks(1)
block 1: beta
chunksize = 256, maxsize = 256, datalen = 3
010203
> blocks(2)
Error 10211
> strerror()
"Non-allocated index number for blocks"
LIMITS
none
LIBRARY
none
SEE ALSO
blk, blkfree

View File

@@ -2,19 +2,24 @@ NAME
btrunc - truncate a value to a number of binary places
SYNOPSIS
btrunc(x [,j])
btrunc(x [,plcs])
TYPES
x real
j int
plcs integer, defaults to zero
return real
DESCRIPTION
Truncate x to j binary places. If j is omitted, 0 places is assumed.
Specifying zero places makes the result identical to int().
Truncate x to plcs binary places, rounding if necessary towards zero,
i.e. btrunc(x, plcs) is a multiple of 2^-plcs and the remainder
x - btrunc(x, plcs) is either zero or has the same sign as x and
absolute value less than 2^-plcs. Here plcs may be positive, zero or
negative.
Truncation of a non-integer prodcues values nearer to zero.
Except that it is defined only for real x, btrunc(x, plcs) is equivalent
to bround(x, plcs, 2). btrunc(x,0) and btrunc(x) are equivalent to
int(x).
EXAMPLE
> print btrunc(pi()), btrunc(pi(), 10)
@@ -26,8 +31,11 @@ EXAMPLE
> print btrunc(-3.3), btrunc(-3.7), btrunc(-3.3, 2), btrunc(-3.7, 2)
-3 -3 -3.25 -3.5
> print btrunc(55.123, -4), btrunc(-55.123, -4)
48 -48
LIMITS
0 <= j < 2^31
abs(j) < 2^31
LIBRARY
NUMBER *qbtrunc(NUMBER *x, *j)

View File

@@ -35,10 +35,10 @@
the user. For example, x=eval(prompt("Number: ")) sets x to the
value input by the user.
The digit and isset functions return individual digits of a number,
The digit and bit functions return individual digits of a number,
either in base 10 or in base 2, where the lowest digit of a number
is at digit position 0. For example, digit(5678, 3) is 5, and
isset(0b1000100, 2) is 1. Negative digit positions indicate places
bit(0b1000100, 2) is 1. Negative digit positions indicate places
to the right of the decimal or binary point, so that for example,
digit(3.456, -1) is 4.

View File

@@ -13,8 +13,11 @@ DESCRIPTION
this function will return an empty string.
EXAMPLE
> cmdbuf("")
""
% calc "print cmdbuf(); a = 3; print a^2;"
print cmdbuf(); a = 3; print a^2;
9
%
LIMITS
none

105
help/cmp
View File

@@ -1,71 +1,95 @@
NAME
cmp - compare two values
cmp - compare two values of certain simple or object types
SYNOPSIS
cmp(x, y)
TYPES
If x is an object of type xx or x is not an object and y is an object
of type xx, the funcion xx_cmp has to have been defined; any
If x is an object of type xx, or x is not an object and y is an object
of type xx, the function xx_rel has to have been defined; any
further conditions on x and y, and the type of the returned
value depends on the definition of xx_cmp.
value depends on the definition of xx_rel.
For non-object x and y:
x number or string
y same as x
x any
y any
return -1, 0, 1 (real & string)
-1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i (complex)
return if x and y are both real: -1, 0, or 1
if x and y are both numbers but not both real:
-1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i, or 1-1i
if x and y are both strings: -1, 0, or 1
all other cases: the null value
DESCRIPTION
Compare two values and return a value based on their relationship.
Comparison by type is indicated below. Where more than one test is
indicated, tests are performed in the order listed. If the test is
inconclusive, the next test is performed. If all tests are
inconclusive, the values are considered equivalent.
real (returns -1, 0, or 1)
the greater number is greater
x and y both real: cmp(x, y) = sgn(x - y), i.e. -1, 0, or 1
according as x < y, x == y, or x > y
complex (returns -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i)
sgn(re(x) - re(y)) + sgn(im(x) - im(y)) * 1i
x and y both numbers, at least one being complex:
cmp(x,y) = sgn(re(x) - re(y)) + sgn(im(x) - im(y)) * 1i
string (returns -1, 0, or 1)
the string with the greater first different character is greater
the longer string is greater
x and y both strings: successive characters are compared until either
different characters are encountered or at least one string is
completed. If the comparison ends because of different characters,
cmp(x,y) = 1 or -1 according as the greater character is in x or y.
If all characters compared in both strings are equal, then
cmp(x,y) = -1, 0 or 1 according as the length of x is less than,
equal to, or greater than the length of y. (This comparison
is performed via the strcmp() libc function.)
object (depends on xx_cmp)
the greater object as defined by xx_cmp is greater
objects: comparisons of objects are usually intended for some total or
partial ordering and appropriate definitions of cmp(a,b) may
make use of comparison of numerical or string components.
definitions using comparison of numbers or strings are usually
appropriate. For example, after
String comparison is performed via the strcmp() libc function.
obj point {x,y};
Note that this function is not a substitution for equality. The ==
operator always takes epsilon() into account when comparing numeric
values. For example:
if points with real components are to be partially ordered by their
euclidean distance from the origin, an appropriate point_rel
function may be that given by
> cmp(1, 1+epsilon()/2)
-1
> 1 == 1+epsilon()/2
0
define point_rel(a,b) = sgn(a.x^2 + a.y^2 - b.x^2 - b.y^2);
It should be noted epsilon() is used when comparing complex values.
A total "lexicographic" ordering is that given by:
Properties of cmp(a,b) for real or complex a and b are:
define point_rel(a,b) {
if (a.y != b.y)
return sgn(a.y - b.y);
return (a.x - b.x);
}
cmp(a + c, b + c) = cmp(a,b)
A comparison function that compares points analogously to
cmp(a,b) for real and complex numbers is that given by
define point_rel(P1, P2) {
return obj point = {sgn(P1.x-P2.x), sgn(P1.y-P2.y)};
}
The range of this function is the set of nine points with zero
or unit components.
Some properties of cmp(a,b) for real or complex a and b are:
cmp(a + c, b + c) = cmp(a, b)
cmp(a, b) == 0 if and only if a == b
cmp(b, a) = -cmp(a,b)
cmp(b, a) = -cmp(a, b)
if c is real or pure imaginary, cmp(c * a, c * b) = c * cmp(a,b)
cmp(a,b) == cmp(b,c) if and only if b is "between" a and c
Then a function that defines "b is between a and c" in an often useful
sense is
The numbers between 2 + 3i and 4 + 5i are those with real part between
2 and 4, imaginary part between 3 and 5; the numbers between 2 + 3i
and 4 + 3i are those with real part between 2 and 4, imaginary part = 3.
define between(a,b,c) = (cmp(a,b) == cmp(b,c)).
For example, in this sense, 3 + 4i is between 1 + 5i and 4 + 2i.
Note that using cmp to compare non-object values of different types,
for example, cmp(2, "2"), returns the null value.
EXAMPLE
> print cmp(3,4), cmp(4,3), cmp(4,4), cmp("a","b"), cmp("abcd","abc")
@@ -84,7 +108,8 @@ LIMITS
none
LIBRARY
none
FLAG qrel(NUMBER *q1, NUMBER *q2)
FLAG zrel(ZVALUE z1, ZVALUE z2)
SEE ALSO
abs, epsilon, sgn
sgn, test, operator

View File

@@ -5,10 +5,10 @@ SYNOPSIS
comb(x, y)
TYPES
x int
y int
x integer
y integer
return int
return integer
DESCRIPTION
Return the combinatorial number C(x,y) which is defined as:
@@ -33,7 +33,7 @@ LIMITS
x-y < 2^24
LIBRARY
void zcomb(NUMBER x, y, *ret)
void zcomb(ZVALUE x, ZVALUE y, ZVALUE *res)
SEE ALSO
fact, perm

View File

@@ -33,9 +33,16 @@ Configuration parameters
"outround" sets rounding mode for printing of numbers
"leadzero" enables/disables printing of 0 as in 0.5
"fullzero" enables/disables padding zeros as in .5000
"maxerr" maximum number of scan errors before abort
"maxscan" maximum number of scan errors before abort
"prompt" default interactive prompt
"more" default interactive multi-line input prompt
"blkmaxprint" number of block octets to print, 0 means all
"blkverbose" TRUE=>print all lines, FALSE=>skip duplicates
"blkbase" block output base
"blkfmt" block output format
"lib_debug" calc library script debug level
"calc_debug" internal calc debug level
"user_debug" user defined debug level
The "all" config value allows one to save/restore the configuration
@@ -90,6 +97,8 @@ Configuration parameters
8: the opcodes for a new functions are displayed when the function
is successfully defined.
See also lib_debug, calc_debug and user_debug below for more debug levels.
The "display" parameter specifies the maximum number of digits after
the decimal point to be printed in real or exponential mode in
normal unformatted printing (print, strprint, fprint) or in
@@ -128,7 +137,6 @@ Configuration parameters
"oct" octal fractions
"bin" binary fractions
The "maxprint" parameter specifies the maximum number of elements to
be displayed when a matrix or list is printed. The initial value is 16.
@@ -172,7 +180,7 @@ Configuration parameters
Config ("tab") controls the printing of a tab before results
automatically displayed when working interactively. It does not
affect the printing by the functions print, printf, etc. The inital
affect the printing by the functions print, printf, etc. The initial
"tab" value is 1.
The "quomod", "quo", "mod", "sqrt", "appr", "cfappr", "cfsim", and
@@ -232,11 +240,11 @@ Configuration parameters
parameter is 0, so that, for example, if config("display") >= 2,
5/4 will print in "real" mode as 1.25.
The maxerr value controls how many scan errors are allowed
The maxscan value controls how many scan errors are allowed
before the compiling phase of a computation is aborted. The initial
value of "maxerr" is 20. Setting maxerr to 0 disables this feature.
value of "maxscan" is 20. Setting maxscan to 0 disables this feature.
The default prompt when in teractive mode is "> ". One may change
The default prompt when in interactive mode is "> ". One may change
this prompt to a more cut-and-paste friendly prompt by:
config("prompt", "; ")
@@ -250,6 +258,121 @@ Configuration parameters
config("more", ";; ")
The "blkmaxprint" config value limits the number of octets to print
for a block. A "blkmaxprint" of 0 means to print all octets of a
block, regardless of size.
The default is to print only the first 256 octets.
The "blkverbose" determines if all lines, including duplicates
should be printed. If TRUE, then all lines are printed. If false,
duplicate lines are skipped and only a "*" is printed in a style
similar to od. This config value has not meaning if "blkfmt" is "str".
The default value for "blkverbose" is FALSE: duplicate lines are
not printed.
The "blkbase" determines the base in which octets of a block
are printed. Possible values are:
"hexadecimal" Octets printed in 2 digit hex
"hex"
"octal" Octets printed in 3 digit octal
"oct"
"character" Octets printed as chars with non-printing
"char" chars as \123 or \n, \t, \r
"binary" Octets printed as 0 or 1 chars
"bin"
"raw" Octets printed as is, i.e. raw binary
"none"
The default "blkbase" is "hex".
The "blkfmt" determines for format of how block are printed:
"line" print in lines of up to 79 chars + newline
"lines"
"str" print as one long string
"string"
"strings"
"od" print in od-like format, with leading offset,
"odstyle" followed by octets in the given base
"od_style"
"hd" print in hex dump format, with leading offset,
"hdstyle" followed by octets in the given base, followed
"hd_style" by chars or '.' if no-printable or blank
The default "blkfmt" is "hd".
With regards to "lib_debug", "calc_debug" and "user_debug":
higher absolute values result in more detailed debugging and
more verbose debug messages. The default value is 0 in which
a very amount of debugging will be performed with nil messages.
The -1 value is reserved for no debugging or messages. Any
value <-1 will perform debugging silently (presumably collecting
data to be displayed at a later time). Values >0 result in a
greater degree of debugging and more verbose messages.
The "lib_debug" is reserved by convention for calc library scripts.
This config parameter takes the place of the lib_debug global variable.
By convention, "lib_debug" has the following meanings:
<-1 no debug messages are printed though some internal
debug actions and information may be collected
-1 no debug messages are printed, no debug actions will be taken
0 only usage message regarding each important object are
printed at the time of the read (default)
>0 messages regarding each important object are
printed at the time of the read in addition
to other debug messages
The "calc_debug" is reserved by convention for internal calc routines.
The output of "calc_debug" will change from release to release.
Generally this value is used by calc wizards and by the regress.cal
routine (make check). By convention, "calc_debug" has the following
meanings:
<-1 reserved for future use
-1 no debug messages are printed, no debug actions will be taken
0 very little, if any debugging is performed (and then mostly
in alpha test code). The only output is as a result of
internal fatal errors (typically either math_error() or
exit() will be called). (default)
>0 a greater degree of debugging is performed and more
verbose messages are printed (regress.cal uses 1).
The "user_debug" is provided for use by users. Calc ignores this value
other than to set it to 0 by default (for both "oldstd" and "newstd").
No calc code or shipped library will change this value other than
during startup or during a config("all", xyz) call.
The following is suggested as a convention for use of "user_debug".
These are only suggestions: feel free to use it as you like:
<-1 no debug messages are printed though some internal
debug actions and information may be collected
-1 no debug messages are printed, no debug actions will be taken
0 very little, if any debugging is performed. The only output
are from fatal errors. (default)
>0 a greater degree of debugging is performed and more
verbose messages are printed
The following are synonyms for true:
"on" "yes" "y" "true" "t" "1" any non-zero number

View File

@@ -14,6 +14,7 @@ TYPES
return real, complex, or matrix
DESCRIPTION
For real x, conj(x) returns x.
For complex x, conj(x) returns re(x) - im(x) * 1i.
@@ -21,6 +22,11 @@ DESCRIPTION
For matrix x, conj(x) returns a matrix of the same structure as x
in which each element t of x has been replaced by conj(t).
For xx objects, xx_conj(a) may return any type of value, but
for the properties usually expected of conjugates, xx_conj(a)
would return an xx object in which each number component is the
conjugate of the corresponding component of a.
EXAMPLE
> print conj(3), conj(3 + 4i)
3 3-4i

48
help/contrib Normal file
View File

@@ -0,0 +1,48 @@
We welcome and encourage you to send us:
* calc scripts
* any builtin functions that you have modified or written
* custom functions that you have modified or written
* any other source code modifications
Prior to doing so, you should consider trying your changes on the most
recent alpha test code. To obtain the most recent code, look under
http://reality.sgi.com/chongo/calc/
You should also consider joining the calc testing group by sending a
request to:
calc-tester-request@postofc.corp.sgi.com
Your message body (not the subject) should consist of:
subscribe calc-tester address
end
name your_full_name
where "address" is your EMail address and "your_full_name"
is your full name.
In order to consider integrating your code, we need:
* help files (documentation)
* CHANGES text (brief description of what it does)
* regress.cal test (to test non-custom code)
* your source code and/or source code changes (:-))
The best way to send us new code, if your changes are small, is
via a patch (diff -c from the latest alpha code to your code).
If your change is large, you should send entire files (either
as a diff -c /dev/null your-file patch, or as a uuencoded and
gziped (or compressed) tar file).
You should send submissions to:
calc-tester@postofc.corp.sgi.com
Thanks for considering submitting code to calc. Calc is a collective
work by a number of people. It would not be what it is today without
your efforts and submissions!
Landon Curt Noll <chongo@toad.com> /\oo/\

View File

@@ -26,7 +26,7 @@ EXAMPLE
.5 0 -1
LIMITS
eps > 0
none
LIBRARY
NUMBER *qcos(NUMBER *x, NUMBER *eps)

View File

@@ -21,8 +21,7 @@ EXAMPLE
1.54308 1.5430806348 1.543080634815244 1.54308063481524377848
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qcosh(NUMBER *x, NUMBER *eps)

View File

@@ -19,12 +19,10 @@ EXAMPLE
.64209 .6420926159 .642092615934331 .64209261593433070301
LIMITS
unlike sin and cos, x must be real
x != 0
eps > 0
none
LIBRARY
NUMBER *qcot(NUMBER *x, *eps)
NUMBER *qcot(NUMBER *x, NUMBER *eps)
SEE ALSO
sin, cos, tan, sec, csc, epsilon

View File

@@ -21,9 +21,7 @@ EXAMPLE
1.31304 1.3130352855 1.313035285499331 1.31303528549933130364
LIMITS
unlike sin and cos, x must be real
x != 0
eps > 0
none
LIBRARY
NUMBER *qcoth(NUMBER *x, NUMBER *eps)

View File

@@ -8,7 +8,7 @@ TYPES
x list or matrix
y string
return int
return integer
DESCRIPTION
For count(x, y), y is to be the name of a user-defined function;
@@ -28,4 +28,4 @@ LIBRARY
none
SEE ALSO
XXX - fill in
select, modify

View File

@@ -27,8 +27,8 @@ EXAMPLE
[2] = -1
LIMITS
x 1-dimensional matrix with 3 elements
y 1-dimensional matrix with 3 elements
The components of the matrices are to be of types for which the
required algebraic operations have been defined.
LIBRARY
MATRIX *matcross(MATRIX *x, MATRIX *y)

View File

@@ -19,8 +19,7 @@ EXAMPLE
1.1884 1.1883951058 1.188395105778121 1.18839510577812121626
LIMITS
unlike sin and cos, x must be real
eps > 0
none
LIBRARY
NUMBER *qcsc(NUMBER *x, NUMBER *eps)

View File

@@ -21,9 +21,7 @@ EXAMPLE
.85092 .8509181282 .850918128239322 .85091812823932154513
LIMITS
unlike sin and cos, x must be real
x != 0
eps > 0
none
LIBRARY
NUMBER *qcsch(NUMBER *x, NUMBER *eps)

View File

@@ -9,14 +9,14 @@ TYPES
DESCRIPTION
The ctime() builtin returns the string formed by the first 24
characters returned by the C library function, ctime():
characters returned by the C library function, ctime(): E.g.
"Mon Oct 28 00:47:00 1996"
The 25th ctime() character, '\n' is removed.
EXAMPLE
> printf("The time is now %s.\n", time())
> printf("The time is now %s.\n", ctime())
The time is now Mon Apr 15 12:41:44 1996.
LIMITS

95
help/custom Normal file
View File

@@ -0,0 +1,95 @@
NAME
custom - custom builtin interface
SYNOPSIS
custom([custname [, arg ...]])
TYPES
custname string
arg any
return any
DESCRIPTION
This function will invoke the custom function interface. Custom
functions are accessed by the custname argument. The remainder
of the args, if any, are passed to the custom function. The
custom function may return any value, including null. Calling
custom with no args is equivalent to the command 'show custom'.
In order to use the custom interface, two things must happen:
1) Calc must be built to allow custom functions. By default,
the master Makefile is shipped with ALLOW_CUSTOM= -DCUSTOM
which causes custom functions to be compiled in.
2) Calc must be invoked with an argument of -C as in:
calc -C
In other words, explicit action must be taken in order to
enable the use of custom functions. By default (no -C arg)
custom functions are compiled in but disabled so that only
portable calc scripts may be used.
The main focus for calc is to provide a portable platform for
multi-precision calculations in a C-like environment. You should
consider implementing algorithms in the calc language as a first
choice. Sometimes an algorithm requires use of special hardware, a
non-portable OS or pre-compiled C library. In these cases a custom
interface may be needed.
The custom function interface is intended to make is easy for
programmers to add functionality that would be otherwise
un-suitable for general distribution. Functions that are
non-portable (machine, hardware or OS dependent) or highly
specialized are possible candidates for custom functions.
To add a new custom function requires access to calc source.
For information on how to add a new custom function, try:
help new_custom
To serve as examples, calc is shipped with a few custom functions.
If calc if invoked with -C, then either of the following will
display information about the custom functions that are available:
show custom
or:
custom()
A few library script that uses these function are also provided
to serve as usage examples.
We welcome submissions for new custom functions. For information
on how to submit new custom functions for general distribution, see:
help contrib
EXAMPLE
If calc compiled with ALLOW_CUSTOM= (custom disabled):
> print custom("sysinfo", "baseb")
Calc was built with custom functions disabled
Error 10195
If calc compiled with ALLOW_CUSTOM= -DCUSTOM and is invoked without -C:
> print custom("sysinfo", "baseb")
Calc must be run with a -C argument to use custom function
Error 10194
If calc compiled with ALLOW_CUSTOM= -DCUSTOM and is invoked with -C:
> print custom("sysinfo", "baseb")
32
LIMITS
By default, custom is limited to 100 args.
LIBRARY
none
SEE ALSO
custom_cal, new_custom, contrib

View File

@@ -1,21 +1,34 @@
Function definitions
Function definitions are introduced by the 'define' keyword.
Other than this, the basic structure of a function is like in C.
That is, parameters are specified for the function within parenthesis,
the function body is introduced by a left brace, variables are
declared for the function, statements implementing the function
follow, and the function is ended with a right brace.
Other than this, the basic structure of an ordinary definition
is like in that in C: parameters are specified for the function
within parenthesis, the function body is introduced by a left brace,
variables may declared for the function, statements implementing the
function may follow, any value to be returned by the function is specified
by a return statement, and the function definition is ended with a
right brace.
There are some subtle differences, however. The types of parameters
and variables are not defined at compile time, but instead are typed
at runtime. Thus there is no definitions needed to distinguish
between integers, fractions, complex numbers, matrices, and so on.
Thus when declaring parameters for a function, only the name of
the parameter is needed. Thus there are never any declarations
between the function parameter list and the body of the function.
and variables are not defined at compile time, and may vary during
execution and be different in different calls to the function. For
example, a two-argument function add may be defined by
For example, the following function computes a factorial:
define add(a,b) {
return a + b;
}
and be called with integer, fractional, or complex number values for a
and b, or, under some compatibility conditions, matrices or objects.
Any variable, not already defined as global, used in a definition has
to be declared as local, global or static, and retains this character
until its scope is terminated by the end of the definition, the end of
the file being read or some other condition (see help variable for
details).
For example, the following function computes the factorial of n, where
we may suppose it is to be called only with positive integral values
for n:
define factorial(n)
{
@@ -27,22 +40,38 @@ Function definitions
return ans;
}
If a function is very simple and just returns a value, then the
function can be defined in shortened manner by using an equals sign
in place of the left brace. In this case, the function declaration
is terminated by a newline character, and its value is the specified
expression. Statements such as 'if' are not allowed. An optional
semicolon ending the expression is allowed. As an example, the
(In calc, this definition is unncessary since there is a built-in
function fact(n), also expressible as n!, which returns the factorial
of n.)
Any functions used in the body of the definition need not have already
been defined; it is sufficient that they have been defined when they are
encountered during evaluation when the function is called.
If a function definition is sufficiently simple and does not require
local or static variables, it may be defined in shortened manner by
using an equals sign following by an expression involving some or all
of the parameters and already existing global variables.
In this case, the definition is terminated by a newline character
(which may be preceded by a semicolon), and the value the function
returns when called will be determined by the specified expression.
Loops and "if" statements are not allowed (but ? : expressions and the
logical operators ||, && and ! are permitted). As an example, the
average of two numbers could be defined as:
define average(a, b) = (a + b) / 2;
Functions can be defined which can be very complex. These can be
(Again, this function is not necessary, as the same result is
returned by the builtin function avg() when called with the
two arguments a, b.)
Function definitions can be very complicated. Functions may be
defined on the command line if desired, but editing of partial
functions is not possible past a single line. If an error is made
on a previous line, then the function must be finished (with probable
errors) and reentered from the beginning. Thus for complicated
functions, it is best to use an editor to create the function in a
functions, it is best to use an editor to create the definition in a
file, and then enter the calculator and read in the file containing
the definition.
@@ -52,7 +81,7 @@ Function definitions
the parameters are numbered starting from 1. The total number
of parameters to the function is returned by using 'param(0)'.
Using this function allows you to implement varargs-like routines
which can handle any number of calling parameters. For example:
which can handle up to 100 calling parameters. For example:
define sc()
{
@@ -64,5 +93,24 @@ Function definitions
return s;
}
defines a function which returns the sum of the cubes of all it's
defines a function which returns the sum of the cubes of all its
parameters.
Any identifier other than a reserved word (if, for, etc.) and the
name of a builtin function (abs, fact, sin, etc.) can be used when
defining a new function or redefining an existing function.
An indication of how a user-defined function is stored may be obtained
by using the "show opcodes" command. For example:
> global alpha
> define f(x) = 5 + alpha * x
"f" defined
> show opcodes f
0: NUMBER 5
2: GLOBALADDR alpha
4: PARAMADDR 0
6: MUL
7: ADD
8: RETURN

View File

@@ -1,20 +1,18 @@
NAME
delete - delete an element from a list at a given position
delete - delete an element from a list at a specified position
SYNOPSIS
delete(lst, idx)
delete(lst, index)
TYPES
lst list, &list
idx int, &int
lst list
index nonnegative integer less than the size of the list
return any
return type of the deleted element
DESCRIPTION
Delete element at index idx from list lst.
The index must refer to an element in the list. That is, idx must
be in the range [0, size(lst)-1].
Deletes element at the specified index from list lst, and returns
the value of this element.
EXAMPLE
> lst = list(2,3,4,5)
@@ -41,4 +39,4 @@ LIBRARY
none
SEE ALSO
append, insert, islist, list, pop, push, remove, rsearch, search, size
append, insert, pop, push, remove, size

View File

@@ -10,7 +10,8 @@ TYPES
return integer
DESCRIPTION
For real x, den(x) returns the denominator of x. In calc,
For real x, den(x) returns the denominator of x when x is expressed
in lowest terms with positive denominator. In calc,
real values are actually rational values. Each calc real
value can be uniquely expressed as:
@@ -22,7 +23,7 @@ DESCRIPTION
gcd(n,d) == 1
d > 0
If x = n/x, then den(x) == d.
The denominator for this n/d is d.
EXAMPLE
> print den(7), den(-1.25), den(121/33)

82
help/dereference Normal file
View File

@@ -0,0 +1,82 @@
NAME
* - dereference or indirection operator
SYNOPSIS
* X
TYPES
X address or lvalue
return any
DESCRIPTION
When used as a binary operator, '*' performs multiplication. When
used as a operator, '*' returns the value at a given address.
If X is an address, *X returns the value at that address. This value
will be an octet, lvalue, string, or number, depending on the
type of address. Thus, for any addressable A, *&A is the same as A.
If X is an lvalue, *X returns the current value at the address
considered to be specified by X. This value may be an lvalue or
octet, in which cases, for most operations except when X is the
destination of an assignment, *X will contribute the same as X to
the result of the operation. For example, if A and B are lvalues
whose current values are numbers, A + B, *A + B, A + *B and *A + *B
will all return the same result. However if C is an lvalue and A is
the result of the assignment A = &C, then A = B will assign the value
of B to A, *A = B will assign the value of B to C without affecting
the value of A.
If X is an lvalue whose current value is a structure (matrix, object,
list, or association), the value returned by *X is a copy of the
structure rather than the structure identified by X. For example,
suppose B has been created by
mat B[3] = {1,2,3}
then
A = *B = {4,5,6}
will assign the values 4,5,6 to the elements of a copy of B, which
will then become the value of A, so that the values of A and B will
be different. On the other hand,
A = B = {4,5,6}
will result in A and B having the same value.
If X is an octet, *X returns the value of that octet as a number.
The * operator may be iterated with suitable sequences of pointer-valued
lvalues. For example, after
> global a, b, c;
> b = &a;
> c = &b;
**c returns the lvalue a; ***c returns the value of a.
EXAMPLE
> mat A[3] = {1,2,3}
> p = &A[0]
> print *p, *(p + 1), *(p + 2)
1 2 3
> *(p + 1) = 4
> print A[1]
4
> A[0] = &a
> a = 7
> print **p
7
LIMITS
none
LIBRARY
none
SEE ALSO
address, isptr

View File

@@ -29,7 +29,7 @@ EXAMPLE
0 1 4 2 8
LIMITS
none
If x is not an integer, y > -2^31
LIBRARY
long qdigit(NUMBER *x, long y)

View File

@@ -11,7 +11,7 @@ TYPES
DESCRIPTION
For real x, digits(x) returns the number of digits in the decimal
representation of int(abs(x)).
representation of int(abs(x)). If x >= 1, digits(x) = 1 + ilog10(x).
EXAMPLE
> print digits(0), digits(0.0123), digits(3.7), digits(-27), digits(-99.7)

View File

@@ -5,7 +5,7 @@ SYNOPSIS
dp(x, y)
TYPES
x, y 1-dimensional matrices with the same number of elements
x, y 1-dimensional matrices of the same size
return depends on the nature of the elements of x and y
@@ -23,13 +23,12 @@ DESCRIPTION
EXAMPLE
> mat x[3] = {2,3,4}
> mat y[3] = {3,4,5}
> mat y[1:3] = {3,4,5}
> print dp(x,y)
38
LIMITS
x and y are 1-dimensional matrices
x and y have the same number of elements
none
LIBRARY
VALUE matdot(MATRIX *x, MATRIX *y)

View File

@@ -24,11 +24,11 @@ EXAMPLE
> .000001 1.414214 .000001 1.4142 .0001
LIMITS
0 < eps < 1
none
LIBRARY
void setepsilon(NUMBER *eps)
NUMBER *_epsilon_
SEE ALSO
XXX - fill in
config

46
help/errcount Normal file
View File

@@ -0,0 +1,46 @@
NAME
errcount - return or set the internal error count
SYNOPSIS
errcount([num])
TYPES
num integer
return integer
DESCRIPTION
An internal variable keeps count of the number of functions
evaluating to an error value either internally or by a call to
error() or newerror().
The errcount() with no args returns the current error count. Calling
errcount(num) returns the current error count and resets it to num.
If the count exceeds the current value of errmax, execution is aborted
with a message displaying the errno for the error.
If an error value is assigned to a variable as in:
infty = 1/0;
then a function returning that variable does not contribute to
errcount.
EXAMPLE
> errmax(10)
0
> errcount()
0
> a = 1/0; b = 2 + ""; c = error(27); d = newerror("a");
> print errcount(), a, errcount(), errmax();
4 Error 10001 4 10
LIMITS
0 <= num < 2^32
LIBRARY
none
SEE ALSO
errmax, error, strerror, iserror, errno, newerror, errorcodes

40
help/errmax Normal file
View File

@@ -0,0 +1,40 @@
NAME
errmax - return or set maximum error-count before execution stops
SYNOPSIS
errmax([num])
TYPES
num integer
return integer
DESCRIPTION
Without an argument, errmax() returns the current value of an
internal variable errmax. Calling errmax(num) returns this value
but then resets its value to num. Execution is aborted if
evaluation of an error value if this makes errcount > errmax.
An error message displays the errno for the error.
EXAMPLE
> errmax(2)
0
> errcount()
0
> a = 1/0; b = 2 + ""; c = error(27); d = newerror("alpha");
Error 27 caused errcount to exceed errmax
> print c, d
0 0
Here global variables c and d were created when compiling the line
but execution was aborted before the intended assignments to c and d.
LIMITS
0 <= num < 2^32
LIBRARY
none
SEE ALSO
errcount, error, strerror, iserror, errno, newerror, errorcodes

View File

@@ -1,31 +1,48 @@
NAME
errno - return a system error message
errno - return or set a stored error-number
SYNOPSIS
errno(errnum)
errno([errnum])
TYPES
errnum int
errnum integer, 0 <= errnum <= 32767
return string
return integer
DESCRIPTION
If a file builtin function such as fopen() encounters an error,
it will return an errno number. This function will convert this
number into a somewhat more meaningful string.
Note that errno() may return different strings on different systems.
Whenever an operation or evaluation of function returns an error-value,
the numerical code for that value is stored as calc_errno.
errno() returns the current value of calc_errno.
errno(errnum) sets calc_errno to the value errnum and returns its
previous value.
To detect whether an error occurs during some sequence of operations,
one may immediately before that sequence set the stored error-number
to zero by errno(0), and then after the operations, whether or not
an error has occurred will be indicated by errno() being nonzero or
zero. If a non-zero value is returned, that value will be the code
for the most recent error encountered.
The default argument for the functions error() and strerror() is the
currently stored error-number; in particular, if no error-value has
been returned after the last errno(0), strerror() will return
"No error".
EXAMPLE
Assuming there is no file with name "not_a_file"
> errno(0)
> errmax(errcount()+4)
0
> badfile = fopen("not_a_file", "r")
> if (!isfile(badfile)) print "error #" : badfile : ":", errno(badfile);
error #2: No such file or directory
> print errno(), error(), strerror()
2 System error 2 No such file or directory
> print errno(13)
Permission denied
> errno(31)
"Too many links"
> a = 1/0
> print errno(), error(), strerror()
10001 Error 10001 Division by zero
LIMITS
none
@@ -34,5 +51,4 @@ LIBRARY
none
SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, files, fopen,
fprintf, isfile, printf, prompt
errmax, errcount, error, strerror, iserror, newerror, errorcodes

View File

@@ -1,28 +1,41 @@
NAME
error - generate a value of an error type
error - generate a value of specified error type
SYNOPSIS
error(n)
error([n])
TYPES
n integer less than 32768
n integer, 0 <= n <= 32767; defaults to errno()
return null value or error value
DESCRIPTION
If n is zero or negative, error(n) returns the null value.
If n is zero, error(n) returns the null value.
For positive n, error(n) returns a value of error type n.
error(n) sets calc_errno to n so that until another error-value
is returned by some function, errno() will return the value n.
EXAMPLE
Note that by default, errmax() is 0 so unless errmax() is
increased you will get:
> ba = error(10009)
Error 10009 caused errcount to exceed errmax
> errmax(errcount()+1)
0
> a = error(10009)
a
Error 10009
> a
Error 10009
LIMITS
0 <= n < 32768
none
LIBRARY
none
SEE ALSO
errorcodes, iserror
errcount, errmax, errorcodes, iserror, errno, strerror, newerror

View File

@@ -58,4 +58,4 @@ LIBRARY
none
SEE ALSO
XXX = fill in
command, expression, define, prompt

36
help/free Normal file
View File

@@ -0,0 +1,36 @@
NAME
free - free the memory used to store values of lvalues
SYNOPSIS
free(a, b, ...)
TYPES
a, b, ... any
return null value
DESCRIPTION
Those of the arguments a, b, ... that specify lvalues are assigned
the null value, effectively freeing whatever memory is used to
store their current values. Other arguments are ignored.
free(.) frees the current "old value".
EXAMPLE
> a = 7
> mat M[3] = {1, list(2,3,4), list(5,6)}
> print memsize(a), memsize(M)
80 736
> free(a, M[1])
> print memsize(a), memsize(M)
16 424
LIMITS
none
LIBRARY
none
SEE ALSO
freeglobals, freestatics, freeredc

47
help/freeglobals Normal file
View File

@@ -0,0 +1,47 @@
NAME
freeglobals - free memory used for values of global variabls
SYNOPSIS
freeglobals()
TYPES
return null value
DESCRIPTION
This function frees the memory used for the values of all global
and not unscoped static variables by assigning null values.
The oldvalue (.) is not freed by this function.
EXAMPLE
> global a = 1, b = list(2,3,4), c = mat[3]
> static a = 2
> show globals
Name Level Type
---- ----- -----
a 1 real = 2
a 0 real = 1
b 0 list
c 0 matrix
Number: 4
> freeglobals()
> show globals
Name Level Type
---- ----- -----
a 1 null
a 0 null
b 0 null
c 0 null
Number: 4
LIMITS
none
LIBRARY
none
SEE ALSO
free, freestatics, freeredc

31
help/freeredc Normal file
View File

@@ -0,0 +1,31 @@
NAME
freeredc - free the memory used to store redc data
SYNOPSIS
freeredc()
TYPES
return null value
DESCRIPTION
This function frees the memory used for any redc data currently stored by
calls to rcin, rcout, etc.
EXAMPLE
> a = rcin(10,27)
> b = rcin(10,15)
> show redc
0 1 27
1 2 15
> freeredc()
> show redc
>
LIMITS
none
LIBRARY
none
SEE ALSO
free, freeglobals, freestatics

45
help/freestatics Normal file
View File

@@ -0,0 +1,45 @@
NAME
freestatics - free memory used for static variables
SYNOPSIS
freestatics()
TYPES
return null value
DESCRIPTION
This function frees the memory used for the values of all unscoped
static variables by in effect assigning null values to them. As this
will usually have significant effects of any functions in whose
definitions these variables have been used, it is primarily intended
for use when these functions are being undefined or redefined..
EXAMPLE
> static a = 5
> define f(x) = a++ * x;
f() defined
> global a
> f(1)
5
> show statics
Name Scopes Type
---- ------ -----
a 1 0 real = 6
Number: 1
> freestatics()
> f(1)
Error 10005
> strerror(.)
"Bad arguments for *"
LIMITS
none
LIBRARY
none
SEE ALSO
free, freeglobals, freeredc

51
help/gd Normal file
View File

@@ -0,0 +1,51 @@
NAME
gd - gudermannian function
SYNOPSIS
gd(z [,eps])
TYPES
z number (real or complex)
eps nonzero real, defaults to epsilon()
return number or "Log of zero or infinity" error value
DESCRIPTION
Calculate the gudermannian of z to a nultiple of eps with errors in
real and imaginary parts less in absolute value than .75 * eps,
or return an error value if z is close to one of the branch points
at odd multiples of (pi/2) * i.
gd(z) is usually defined initially for real z by one of the formulae
gd(z) = 2 * atan(exp(z)) - pi/2
= 2 * atan(tanh(z/2))
= atan(sinh(z)),
or as the integral from 0 to z of (1/cosh(t))dt. For complex z, the
principal branch, approximated by gd(z, eps), has the cut:
re(z) = 0, abs(im(z)) >= pi/2; on the cut calc takes gd(z) to be
the limit as z is approached from the right or left according as
im(z) > or < 0.
If z = x + y*i and abs(y) < pi/2, gd(z) is given by
gd(z) = atan(sinh(x)/cos(y)) + i * atanh(sin(y)/cosh(x)).
EXAMPLE
> print gd(1, 1e-5), gd(1, 1e-10), gd(1, 1e-15)
.86577 .8657694832 .865769483239659
> print gd(2+1i, 1e-5), gd(2+1i, 1e-10)
1.42291+.22751i 1.4229114625+.2275106584i
LIMITS
none
LIBRARY
COMPLEX *cgd(COMPLEX *x, NUMBER *eps)
SEE ALSO
agd, exp, ln, sin, sinh, etc.

View File

@@ -11,6 +11,7 @@ following topics:
builtin builtin functions
command top level commands
config configuration parameters
custom information about the custom builtin interface
define how to define functions
environment how environment variables effect calc
errorcodes calc generated error codes
@@ -25,21 +26,25 @@ following topics:
statement flow control and declaration statements
stdlib description of some lib files shipped with calc
types builtin data types
unexpected unexpected syntax/usage surprises for C programmers
usage how to invoke the calc command
variable variables and variable declarations
bindings input & history character bindings
altbind alternative input & history character bindings
changes recent changes to calc
bindings input & history character bindings
custom_cal information about custom calc library files
libcalc using the arbitrary precision routines in a C program
new_custom information about how to add new custom functions
stdlib standard calc library files and standards
bugs known bugs and mis-features
todo needed enhancements and wish list
credit who wrote calc and who helped
archive where to get the latest versions of calc
bugs known bugs and mis-features
changes recent changes to calc
contrib how to contribute scripts, code or custom functions
credit who wrote calc and who helped
todo needed enhancements and wish list
full all of the above
full all of the above (in the above order)
You can also ask for help on a particular function name. For example,
@@ -67,3 +72,28 @@ then the help facility will be disabled. See:
help usage
for details of the -m mode.
The help command is able to display installed help files for custom builtin
functions. However, if the custom name is the same as a standard help
file, the standard help file will be displayed instead. The custom help
builtin should be used to directly access the custom help file.
For example, the custom help builtin has the same name as the standard
help file. That is:
help help
will print this file only. However the custom help builtin will print
only the custom builtin help file:
custom("help", "help");
will by-pass a standard help file and look for the custom version directly.
As a hack, the following:
help custhelp/anything
as the same effect as:
custom("help", "anything");

43
help/hnrmod Normal file
View File

@@ -0,0 +1,43 @@
NAME
hnrmod - compute mod h * 2^n +r
SYNOPSIS
hnrmod(v, h, n, r)
TYPES
v integer
h integer
n integer
r integer
return integer
DESCRIPTION
Compute the value:
v % (h * 2^n +r)
where:
h > 0
n > 0
r == -1, 0 or 1
This builtin in faster than the standard mod in that is makes use
of shifts and additions when h == 1. When h > 1, a division by h
is also needed.
EXAMPLE
> print hnrmod(2^177-1, 1, 177, -1), hnrmod(10^40, 17, 51, 1)
0 33827019788296445
LIMITS
h > 0
2^31 > n > 0
r == -1, 0 or 1
LIBRARY
void zhnrmod(ZVALUE v, ZVALUE h, ZVALUE zn, ZVALUE zr, ZVALUE *res)
SEE ALSO
mod

View File

@@ -53,3 +53,7 @@ Quick introduction
(2+3i) * (4-3i)
prints "17+6i".
For more information about the calc lauguage and features, try:
help overview

View File

@@ -25,5 +25,8 @@ LIBRARY
none
SEE ALSO
isfile, isident, isint, islist, ismat, isnull, isnum, isobj,
isreal, isstr, issimple, istype
assoc,
isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -5,7 +5,7 @@ SYNOPSIS
isatty(fd)
TYPES
fd file
fd any
return int
@@ -21,10 +21,15 @@ EXAMPLE
0
LIMITS
fd must be associaed with an open file
none
LIBRARY
none
SEE ALSO
XXX - fill in
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt,
isassoc, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

44
help/isblk Normal file
View File

@@ -0,0 +1,44 @@
NAME
isblk - whether or not a value is a block
SYNOPSIS
isblk(val)
TYPES
val any
return 0, 1, or 2
DESCRIPTION
isblk(val) returns 1 if val is an unnamed block, 2 if val is a
named block, 0 otherwise.
Note that a named block B retains its name after its data block is
freed by rmblk(B). That a named block B has null data block may be
tested using sizeof(B); this returns 0 if and only if the memory
has been freed.
EXAMPLE
> A = blk()
> isblk(A)
1
> B = blk("beta")
> isblk(B)
2
> isblk(3)
0
LIMITS
none
LIBRARY
none - XXX ???
SEE ALSO
blk, blocks, blkfree,
isassoc, isatty, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -2,7 +2,7 @@ NAME
isconfig - whether a value is a configuration state
SYNOPSIS
isrand(x)
isconfig(x)
TYPES
x any, &any
@@ -25,4 +25,8 @@ LIBRARY
none
SEE ALSO
config
config,
isassoc, isatty, isblk, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

44
help/isdefined Normal file
View File

@@ -0,0 +1,44 @@
NAME
isdefined - whether a string names a defined function
SYNOPSIS
isdefined(str)
TYPES
str string
return 0, 1, or 2
DESCRIPTION
isdefined(str) returns 1 if str is the name of a builtin function,
2 if str is the name of a user-defined function, 0 otherwise.
EXAMPLE
> isdefined("abs")
1
> isdefined("fun")
0
> define fun() { }
fun() defined
> isdefined("fun")
2
> undefine fun
> isdefined("fun")
0
LIMITS
none
LIBRARY
none - XXX ?
SEE ALSO
define, undefine,
isassoc, isatty, isblk, isconfig, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -1,5 +1,5 @@
NAME
error - test whether a value is an error value
iserror - test whether a value is an error value
SYNOPSIS
iserror(x)
@@ -25,4 +25,8 @@ LIBRARY
none
SEE ALSO
error, errorcodes
error, errorcodes,
isassoc, isatty, isblk, isconfig, isdefined, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,4 +27,7 @@ LIBRARY
none
SEE ALSO
iseven, isint, isnum, isodd, isreal
isassoc, isatty, isblk, isconfig, isdefined, iserror, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -5,7 +5,7 @@ SYNOPSIS
isfile(x)
TYPES
x any, &any
x any
return int
@@ -25,5 +25,7 @@ LIBRARY
none
SEE ALSO
isassoc, isident, isint, islist, ismat, isnull, isnum, isobj,
isreal, isstr, issimple, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -5,18 +5,22 @@ SYNOPSIS
ishash(x)
TYPES
x any, &any
x any
return int
return integer
DESCRIPTION
Determine if x is a hash state. This function will return 1 if x is
a file, 0 otherwise.
The value returned by ishash(x) is:
0 if x is not a hash state,
1 if x is a sha hash state,
2 if x is a sha1 hash state,
3 if x is a md5 hash state.
EXAMPLE
> a = shs(0)
> print ishash(a), ishash(0);
1 0
> a = shs(0), b = shs1(0), c = md5(0)
> print ishash(0), ishash(a), ishash(b), ishash(c);
0 1 2 3
LIMITS
none
@@ -25,4 +29,8 @@ LIBRARY
none
SEE ALSO
XXX - fill in
sha, sha1, md5,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -5,22 +5,28 @@ SYNOPSIS
isident(m)
TYPES
m mat
m any
return int
DESCRIPTION
This function returns 1 if m is an identity matrix, 0 otherwise.
This function returns 1 if m is an 2 dimensional identity matrix,
0 otherwise.
EXAMPLE
XXX - fill in
> mat x[3,3] = {1,0,0,0,1,0,0,0,1};
> isident(x)
1
LIMITS
m must be a 2 dimensional matrix
none
LIBRARY
none
SEE ALSO
isassoc, isfile, isint, islist, ismat, isnull, isnum, isobj,
isreal, isstr, issimple, istype
mat, matdim, matfill, matmax, matmin, matsum, mattrans,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,5 +27,8 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, islist, ismat, isnull, isnum, isobj,
isreal, isstr, issimple, istype
int,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -25,5 +25,9 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, ismat, isnull, isnum, isobj,
isreal, isstr, issimple, istype
append, delete, insert, islist, pop, push, remove, rsearch,
search, size, list,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -25,5 +25,8 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, isnull, isnum, isobj,
isreal, isstr, issimple, istype
mat, matdim, matfill, matmax, matmin, matsum, mattrans,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -33,4 +33,7 @@ LIBRARY
BOOL zdivides(ZVALUE x, y)
SEE ALSO
ismult, isprime, isrel, issq
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -25,5 +25,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnum, isobj,
isreal, isstr, issimple, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,5 +27,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isobj,
isreal, isstr, issimple, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -25,5 +25,8 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isnum,
isreal, isstr, issimple, istype
obj,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

35
help/isobjtype Normal file
View File

@@ -0,0 +1,35 @@
NAME
isobjtype - whether a string names an object type
SYNOPSIS
isobjtype(str)
TYPES
str string
return 0 or 1
DESCRIPTION
isobjtype(str) returns 1 or 0 according as an object type with name
str has been defined or not defined.
EXAMPLE
> isobjtype("xy")
0
> obj xy {x, y}
> isobjtype("xy")
1
LIMITS
none
LIBRARY
none - XXX ???
SEE ALSO
obj,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,4 +27,7 @@ LIBRARY
none
SEE ALSO
iseven, isint, isnum, isodd, isreal
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -45,4 +45,8 @@ LIBRARY
FLAG zisprime(ZVALUE x) (return 1 if prime, 0 not prime, -1 if >= 2^32)
SEE ALSO
factor, lfactor, nextprime, prevprime, pfact, pix
factor, lfactor, nextprime, prevprime, pfact, pix,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isrand, israndom, isreal, isrel,
issimple, issq, isstr, istype

41
help/isptr Normal file
View File

@@ -0,0 +1,41 @@
NAME
isptr - whether a value is a pointer
SYNOPSIS
isptr(x)
TYPES
x any
return 0, 1, 2, 3, or 4
DESCRIPTION
isptr(x) returns:
0 if x is a not pointer
1 if x is an octet-pointer
2 if x is a value-pointer
3 if x is a string-pointer
4 if x is a number-pointer
Pointers are initially defined by using the addreess (&) operator
with an "addressable" value; currently, these are octets, lvalues,
strings and real numbers.
EXAMPLE
> a = "abc", b = 3, B = blk()
> p1 = &B[1]
> p2 = &a
> p3 = &*a
> p4 = &*b
> print isptr(a), isptr(p1), isptr(p2), isptr(p3), isptr(p4)
0 1 2 3 4
LIMITS
none
LIBRARY
none
SEE ALSO
isnum, isstr, isblk, isoctet

View File

@@ -25,4 +25,8 @@ LIBRARY
none
SEE ALSO
rand, srand
rand, srand, randbit,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, israndom, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,4 +27,8 @@ LIBRARY
none
SEE ALSO
XXX - fill in
random, srandom, randombit,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, isreal, isrel,
issimple, issq, isstr, istype

View File

@@ -27,5 +27,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isnum, isobj,
isstr, issimple, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isrel,
issimple, issq, isstr, istype

View File

@@ -28,4 +28,8 @@ LIBRARY
BOOL zrelprime(ZVALUE x, y)
SEE ALSO
gcd, ismult, isprime, isrel, issq
gcd,
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal,
issimple, issq, isstr, istype

View File

@@ -1,43 +0,0 @@
NAME
isset - whether a given binary bit is set in a value
SYNOPSIS
isset(x, y)
TYPES
x real
y int
return int
DESCRIPTION
Determine if the binary bit y is set in x. If:
x
int(---) mod 2 == 1
2^y
return 1, otherwise return 0.
EXAMPLE
> print isset(9,0), isset(9,1), isset(9,2), isset(9,3)
1 0 0 1
> print isset(9,4), isset(0,0), isset(9,-1)
0 0 0
> print isset(1.25, -2), isset(1.25, -1), isset(1.25, 0)
1 0 1
> p = pi()
> print isset(p, 1), isset(p, -2), isset(p, -3)
1 0 1
LIMITS
-2^31 < y < 2^31
LIBRARY
BOOL qisset(NUMBER *x, long y)
SEE ALSO
highbit, lowbit

View File

@@ -35,5 +35,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isnum, isobj,
isreal, isstr, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issq, isstr, istype

View File

@@ -31,4 +31,7 @@ LIBRARY
BOOL zissquare(ZVALUE x)
SEE ALSO
ismult, isprime, isrel, issq
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, isstr, istype

View File

@@ -24,5 +24,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isnum, isobj,
isreal, issimple, istype
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, istype

View File

@@ -35,5 +35,7 @@ LIBRARY
none
SEE ALSO
isassoc, isfile, isident, isint, islist, ismat, isnull, isnum, isobj,
isreal, isstr, issimple
isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile,
ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj,
isobjtype, isodd, isprime, isrand, israndom, isreal, isrel,
issimple, issq, isstr

31
help/mattrace Normal file
View File

@@ -0,0 +1,31 @@
NAME
mattrace - trace of a square matrix
SYNOPSIS
mattrace(m)
TYPES
m square matrix with summable diagonal elements
return determined by addition of elements
DESCRIPTION
For a two-dimensional square matrix, mattrace(m) returns the sum of
the elements on the principal diagonal. In particular, if m
has been created by mat m[N,N] where N > 0, mattrace(m) returns
m[0,0] + m{1,1] + ... + m[N-1,N-1]
EXAMPLE
> mat m[2,2] = {1,2,3,4}
> print mattrace(m), mattrace(m^2)
5 29
LIMITS
none
LIBRARY
none
SEE ALSO
mat, mattrans

Some files were not shown because too many files have changed in this diff Show More