Release calc version 2.11.11

This commit is contained in:
Landon Curt Noll
2005-12-11 22:58:55 -08:00
parent 64a732b678
commit 7165fa17c7
34 changed files with 650 additions and 534 deletions

6
BUGS
View File

@@ -90,7 +90,7 @@ Known bugs:
This is not an error in the ellip standard calc resource files.
It is a bug inside calc. Versions going back as far as version
2.11.4t2 in the year 2000 (and perhaps even further) alll have
2.11.4t2 in the year 2000 (and perhaps even further) all have
this bug.
Anyone want to track down and fix this bug?
@@ -323,8 +323,8 @@ Problems with old systems that have known work-a-rounds:
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.21 $
## @(#) $Id: BUGS,v 29.21 2004/10/23 01:13:51 chongo Exp $
## @(#) $Revision: 29.22 $
## @(#) $Id: BUGS,v 29.22 2004/10/23 02:25:02 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
##
## Under source code control: 1994/03/18 14:06:13

31
CHANGES
View File

@@ -24,6 +24,33 @@ The following are the changes from calc version 2.11.10.1 to date:
to the BUGS file. See "help bugs" or the BUGS source file for details.
Anyone want to track down and fix this bug?
Fixed typo in the "help mat" example and improved the mat_print example.
Renamed most COMPLEX C function names to start with c_ to avoid
conflicts with new C standard functions. Note that the calc
builtin function names remain the same. The C function names
inside the C source that calc is written in changed. This means
that code that linked to libcalc.a will need to change in order
to call calc's functions instead of the C standard functions.
See cmath.h, comfunc.c, and commath.c for details. See also
http://www.opengroup.org/onlinepubs/009695399/basedefs/complex.h.html
for names of the new C standard functions.
Changed the calc man page to note that using -- in the command will
separate calc options from arguments as in:
calc -p -- -1 - -7
Noted how Apple OS X can make use of readline in the Makefile.
In particular:
# For Apple OS X: install fink from http://fink.sourceforge.net
# and then do a 'fink install readline' and then use:
#
READLINE_LIB= -L/sw/lib -lreadline -lhistory -lncurses
Added linear.cal as a calc standard resource file.
The following are the changes from calc version 2.11.10 to 2.11.10:
@@ -5785,8 +5812,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.70 $
## @(#) $Id: CHANGES,v 29.70 2004/10/23 01:16:23 chongo Exp $
## @(#) $Revision: 29.71 $
## @(#) $Id: CHANGES,v 29.71 2005/12/12 06:47:21 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

View File

@@ -33,8 +33,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
MAKEFILE_REV= $$Revision: 29.73 $$
# @(#) $Id: Makefile.ship,v 29.73 2004/07/28 12:52:37 chongo Exp $
MAKEFILE_REV= $$Revision: 29.74 $$
# @(#) $Id: Makefile.ship,v 29.74 2005/10/18 11:53:37 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
#
# Under source code control: 1990/02/15 01:48:41
@@ -794,6 +794,11 @@ READLINE_LIB=
#READLINE_LIB= -L/usr/gnu/lib -lreadline -lhistory -lncurses
#READLINE_LIB= -L/usr/local/lib -lreadline -lhistory -lncurses
#
# For Apple OS X: install fink from http://fink.sourceforge.net
# and then do a 'fink install readline' and then use:
#
#READLINE_LIB= -L/sw/lib -lreadline -lhistory -lncurses
#
READLINE_INCLUDE=
#READLINE_INCLUDE= -I/usr/gnu/include
#READLINE_INCLUDE= -I/usr/local/include

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.15 $
# @(#) $Id: Makefile,v 29.15 2003/01/05 08:10:56 chongo Exp $
# @(#) $Revision: 29.16 $
# @(#) $Id: Makefile,v 29.16 2005/12/12 06:42:30 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
#
# Under source code control: 1991/07/21 05:00:54
@@ -170,7 +170,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
lucas_tbl.cal mersenne.cal mod.cal pell.cal pi.cal pix.cal \
pollard.cal poly.cal psqrt.cal quat.cal regress.cal solve.cal \
sumsq.cal surd.cal unitfrac.cal varargs.cal chrem.cal mfactor.cal \
bindings randmprime.cal test1700.cal randrun.cal \
bindings randmprime.cal test1700.cal randrun.cal linear.cal \
randbitrun.cal bernoulli.cal test2300.cal test2600.cal \
test2700.cal test3100.cal test3300.cal test3400.cal prompt.cal \
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \

View File

@@ -222,6 +222,14 @@ intfile.cal
of the integer become the last octets of the file.
linear.cal
linear(x0, y0, x1, y1, x)
Returns the value y such that (x,y) in on the line (x0,y0), (x1,y1).
Requires x0 != y0.
lucas.cal
lucas(h, n)
@@ -825,8 +833,8 @@ xx_print.cal
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.9 $
## @(#) $Id: README,v 29.9 2003/01/05 08:10:56 chongo Exp $
## @(#) $Revision: 29.10 $
## @(#) $Id: README,v 29.10 2005/12/12 06:39:18 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32

26
cal/linear.cal Normal file
View File

@@ -0,0 +1,26 @@
/*
* linear - perform a simple two point 2D linear interpolation
*
* given:
* x0, y0 first known point on the line
* x1, y1 second knonw point on the line
* x a given point to interpolate on
*
* returns:
* y such that (x,y) is on the line defined by (x0,y0) and (x1,y1)
*
* NOTE: The line cannot be vertical. So x0 != y0.
*/
define linear(x0, y0, x1, y1, x)
{
/* firewall */
if (!isnum(x0) || ! isnum(y0) || !isnum(x1) || ! isnum(y1) || !isnum(x)) {
quit "non-numeric argument passed to linear";
}
if (x0 == x1) {
quit "linear given a line with an infinite slope";
}
/* return y = y0 + (delta_Y/delta_X) * (x - x0) */
return y0 + (((y1-y0)/(x1-x0)) * (x - x0));
}

View File

@@ -15,8 +15,8 @@
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
.\"
.\" @(#) $Revision: 29.17 $
.\" @(#) $Id: calc.man,v 29.17 2004/10/23 00:58:33 chongo Exp $
.\" @(#) $Revision: 29.18 $
.\" @(#) $Id: calc.man,v 29.18 2005/10/18 11:10:18 chongo Exp $
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
.\"
.\" Under source code control: 1991/07/23 05:48:26
@@ -51,7 +51,7 @@ calc \- arbitrary precision calculator
.RB [ \-s ]
.RB [ \-u ]
.RB [ \-v ]
.RB [ calc_cmd\ \&.\|.\|. ]
.RB [ [\-\-]\ calc_cmd\ \&.\|.\|. ]
.in -5n
.sp
\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP
@@ -435,6 +435,21 @@ Disable buffering of stdin and stdout.
Print the
.B calc
version number and exit.
.TP
.B \-\-
The double dash indicates to calc that no more option follow.
Thus calc will ignore a later argument on the command line
even if it starts with a dash.
This is useful when entering negative values on the command line as in:
.sp 1
.in +5n
.nf
calc \-p \-\- \-1 - -7
.sp 1
.fi
.in -5n
.PP
\&
@@ -477,32 +492,50 @@ calc 23 + 47
.fi
.in -5n
.sp 1
should respond with display of 70, but
will print 70.
However, command lines will have problems:
.sp 1
.in +5n
.nf
calc 23 * 47
.sp 1
calc -23 + 47
.fi
.in -5n
.sp 1
may fail.
Such cases can usually be made to work as expected by
enclosing the command between single marks as in:
The first example above fails because the shell interprets the '*'
as a file glob.
The second example fails because '\-23' is viewed as a calc option
(which it is not) and do calc objects to that it thinks of as an unknown option.
These cases can usually be made to work as expected by
enclosing the command between quotes:
.sp 1
.in +5n
.nf
calc "23 * 47"
.fi
.in -5n
calc '23 * 47'
.sp 1
and
.sp 1
.in +5n
.nf
calc "print sqrt(2), exp(1)"
.fi
.in -5n
.sp
.sp 1
or in parentheses and quotes to avoid leading \-'s as in:
.sp 1
.in +5n
.nf
calc '(-23 + 47)'
.fi
.in -5n
.sp 1
One may also use a double dash to denote that calc options have ended as in:
.sp 1
.in +5n
.nf
calc -- -23 + 47
.sp 1
calc -q -- -23 + 47
.fi
.in -5n
.sp 1
If '!' is to be used to indicate the factorial function, for
shells like
.BI csh (1)

View File

@@ -2,7 +2,7 @@
#
# calc.spec.in - template specfile for calc
#
# Copyright (C) 2003-2004 Petteri Kettunen and Landon Curt Noll
# Copyright (C) 2003-2005 Petteri Kettunen and Landon Curt Noll
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of the version 2.1 of the GNU Lesser General Public License
@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.13 $
# @(#) $Id: calc.spec.in,v 29.13 2004/02/23 14:04:01 chongo Exp $
# @(#) $Revision: 29.14 $
# @(#) $Id: calc.spec.in,v 29.14 2005/12/12 06:57:27 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.spec.in,v $
#
# Under source code control: 2003/02/16 20:21:39
@@ -30,7 +30,7 @@
# BUGS
# - Uninstalling calc and calc-devel leaves empty dirs /usr/include/calc
# and /usr/share/calc and its subdird. In case e.g. %{_includedir}/calc
# and /usr/share/calc and its subdirs. In case e.g. %{_includedir}/calc
# is defined in `%files devel' section, then rpmbuild complains that
# header files are defined twice - rpmbuild bug or bug in specfile conf???
@@ -48,11 +48,11 @@ BuildRoot: %{_tmppath}/%{name}-root
%description
Calc is arbitrary precision C-like arithmetic system that is a
calculator, an algorithm prototyper and mathematical research
calculator, an algorithm prototype and mathematical research
tool. Calc comes with a rich set of builtin mathematical and
programmatic functions.
For the latest calc release, see the project home page:
For the latest calc release, see the calc project home page:
http://www.isthe.com/chongo/tech/comp/calc/index.html
@@ -100,6 +100,9 @@ rm -rf %{buildroot}
%attr(644, root, root) %{_libdir}/*.a
%changelog
* Sun Dec 11 2006 Landon Curt Noll http://www.isthe.com/chongo
- Release of calc-2.11.11
- Fixed description in spec file
* Wed Feb 26 2003 Landon Curt Noll http://www.isthe.com/chongo
- Release of calc-2.11.7-2
- Fixed attributes on include and lib calc-devel files

92
cmath.h
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: cmath.h,v 29.6 2002/03/12 09:38:26 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: cmath.h,v 29.7 2005/10/18 10:43:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/cmath.h,v $
*
* Under source code control: 1993/07/30 19:42:45
@@ -63,63 +63,63 @@ extern void cprintfr(COMPLEX *c);
* Basic numeric routines.
*/
extern COMPLEX *cadd(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *csub(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *cmul(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *cdiv(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *caddq(COMPLEX *c, NUMBER *q);
extern COMPLEX *csubq(COMPLEX *c, NUMBER *q);
extern COMPLEX *cmulq(COMPLEX *c, NUMBER *q);
extern COMPLEX *cdivq(COMPLEX *c, NUMBER *q);
extern COMPLEX *cscale(COMPLEX *c, long i);
extern COMPLEX *cshift(COMPLEX *c, long i);
extern COMPLEX *csquare(COMPLEX *c);
extern COMPLEX *cconj(COMPLEX *c);
extern COMPLEX *c_add(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_sub(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_mul(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_div(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_addq(COMPLEX *c, NUMBER *q);
extern COMPLEX *c_subq(COMPLEX *c, NUMBER *q);
extern COMPLEX *c_mulq(COMPLEX *c, NUMBER *q);
extern COMPLEX *c_divq(COMPLEX *c, NUMBER *q);
extern COMPLEX *c_scale(COMPLEX *c, long i);
extern COMPLEX *c_shift(COMPLEX *c, long i);
extern COMPLEX *c_square(COMPLEX *c);
extern COMPLEX *c_conj(COMPLEX *c);
extern COMPLEX *c_real(COMPLEX *c);
extern COMPLEX *c_imag(COMPLEX *c);
extern COMPLEX *cneg(COMPLEX *c);
extern COMPLEX *cinv(COMPLEX *c);
extern COMPLEX *cint(COMPLEX *c);
extern COMPLEX *cfrac(COMPLEX *c);
extern BOOL ccmp(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_neg(COMPLEX *c);
extern COMPLEX *c_inv(COMPLEX *c);
extern COMPLEX *c_int(COMPLEX *c);
extern COMPLEX *c_frac(COMPLEX *c);
extern BOOL c_cmp(COMPLEX *c1, COMPLEX *c2);
/*
* More complicated functions.
*/
extern COMPLEX *cpowi(COMPLEX *c, NUMBER *q);
extern NUMBER *cilog(COMPLEX *c, ZVALUE base);
extern COMPLEX *c_powi(COMPLEX *c, NUMBER *q);
extern NUMBER *c_ilog(COMPLEX *c, ZVALUE base);
/*
* Transcendental routines. These all take an epsilon argument to
* specify how accurately these are to be calculated.
*/
extern COMPLEX *cpower(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
extern COMPLEX *csqrt(COMPLEX *c, NUMBER *epsilon, long R);
extern COMPLEX *croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
extern COMPLEX *cexp(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cln(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *ccos(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *csin(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *ccosh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *csinh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cpolar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
extern COMPLEX *crel(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *casin(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacos(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *catan(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacot(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *casec(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacsc(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *casinh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacosh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *catanh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacoth(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *casech(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cacsch(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cgd(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *cagd(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon);
extern COMPLEX *c_sqrt(COMPLEX *c, NUMBER *epsilon, long R);
extern COMPLEX *c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon);
extern COMPLEX *c_exp(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_ln(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_cos(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_sin(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_cosh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_sinh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon);
extern COMPLEX *c_rel(COMPLEX *c1, COMPLEX *c2);
extern COMPLEX *c_asin(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acos(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_atan(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acot(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_asec(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acsc(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_asinh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acosh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_atanh(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acoth(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_asech(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_acsch(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_gd(COMPLEX *c, NUMBER *epsilon);
extern COMPLEX *c_agd(COMPLEX *c, NUMBER *epsilon);

260
comfunc.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: comfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: comfunc.c,v 29.4 2005/10/18 10:43:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/comfunc.c,v $
*
* Under source code control: 1990/02/15 01:48:13
@@ -41,7 +41,7 @@
* q power to raise it to
*/
COMPLEX *
cpowi(COMPLEX *c, NUMBER *q)
c_powi(COMPLEX *c, NUMBER *q)
{
COMPLEX *tmp, *res; /* temporary values */
long power; /* power to raise to */
@@ -74,22 +74,22 @@ cpowi(COMPLEX *c, NUMBER *q)
case 1:
return clink(c);
case -1:
return cinv(c);
return c_inv(c);
case 2:
return csquare(c);
return c_square(c);
case -2:
tmp = csquare(c);
res = cinv(tmp);
tmp = c_square(c);
res = c_inv(tmp);
comfree(tmp);
return res;
case 3:
tmp = csquare(c);
res = cmul(c, tmp);
tmp = c_square(c);
res = c_mul(c, tmp);
comfree(tmp);
return res;
case 4:
tmp = csquare(c);
res = csquare(tmp);
tmp = c_square(c);
res = c_square(tmp);
comfree(tmp);
return res;
}
@@ -102,26 +102,26 @@ cpowi(COMPLEX *c, NUMBER *q)
while ((bit & power) == 0)
bit >>= 1L;
bit >>= 1L;
res = csquare(c);
res = c_square(c);
if (bit & power) {
tmp = cmul(res, c);
tmp = c_mul(res, c);
comfree(res);
res = tmp;
}
bit >>= 1L;
while (bit) {
tmp = csquare(res);
tmp = c_square(res);
comfree(res);
res = tmp;
if (bit & power) {
tmp = cmul(res, c);
tmp = c_mul(res, c);
comfree(res);
res = tmp;
}
bit >>= 1L;
}
if (sign < 0) {
tmp = cinv(res);
tmp = c_inv(res);
comfree(res);
res = tmp;
}
@@ -134,7 +134,7 @@ cpowi(COMPLEX *c, NUMBER *q)
* Type of rounding of each component specified by R as for qsqrt().
*/
COMPLEX *
csqrt(COMPLEX *c, NUMBER *epsilon, long R)
c_sqrt(COMPLEX *c, NUMBER *epsilon, long R)
{
COMPLEX *r;
NUMBER *es, *aes, *bes, *u, *v, qtemp;
@@ -363,7 +363,7 @@ csqrt(COMPLEX *c, NUMBER *epsilon, long R)
* Each component of the result is within the specified error.
*/
COMPLEX *
croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
c_root(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
{
COMPLEX *r;
NUMBER *a2pb2, *root, *tmp1, *tmp2, *epsilon2;
@@ -376,7 +376,7 @@ croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
if (cisone(c) || qisone(q))
return clink(c);
if (qistwo(q))
return csqrt(c, epsilon, 24L);
return c_sqrt(c, epsilon, 24L);
if (cisreal(c) && !qisneg(c->real)) {
tmp1 = qroot(c->real, q, epsilon);
if (tmp1 == NULL)
@@ -388,8 +388,8 @@ croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
}
/*
* Calculate the root using the formula:
* croot(a + bi, n) =
* cpolar(qroot(a^2 + b^2, 2 * n), qatan2(b, a) / n).
* c_root(a + bi, n) =
* c_polar(qroot(a^2 + b^2, 2 * n), qatan2(b, a) / n).
*/
n = qilog2(epsilon);
epsilon2 = qbitvalue(n - 4);
@@ -415,7 +415,7 @@ croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
qfree(epsilon2);
tmp2 = qqdiv(tmp1, q);
qfree(tmp1);
r = cpolar(root, tmp2, epsilon);
r = c_polar(root, tmp2, epsilon);
qfree(root);
qfree(tmp2);
return r;
@@ -428,7 +428,7 @@ croot(COMPLEX *c, NUMBER *q, NUMBER *epsilon)
* exp(a + bi) = exp(a) * (cos(b) + i * sin(b)).
*/
COMPLEX *
cexp(COMPLEX *c, NUMBER *epsilon)
c_exp(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *r;
NUMBER *sin, *cos, *tmp1, *tmp2, *epsilon1;
@@ -485,7 +485,7 @@ cexp(COMPLEX *c, NUMBER *epsilon)
* ln(a + bi) = ln(a^2 + b^2) / 2 + i * atan2(b, a).
*/
COMPLEX *
cln(COMPLEX *c, NUMBER *epsilon)
c_ln(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *r;
NUMBER *a2b2, *tmp1, *tmp2, *epsilon1;
@@ -526,7 +526,7 @@ cln(COMPLEX *c, NUMBER *epsilon)
* cos(x) = (exp(1i * x) + exp(-1i * x))/2;
*/
COMPLEX *
ccos(COMPLEX *c, NUMBER *epsilon)
c_cos(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *r, *ctmp1, *ctmp2, *ctmp3;
NUMBER *epsilon1;
@@ -545,7 +545,7 @@ ccos(COMPLEX *c, NUMBER *epsilon)
ctmp1->real = neg ? qneg(c->imag) : qlink(c->imag);
ctmp1->imag = neg ? qlink(c->real) : qneg(c->real);
epsilon1 = qbitvalue(n - 2);
ctmp2 = cexp(ctmp1, epsilon1);
ctmp2 = c_exp(ctmp1, epsilon1);
comfree(ctmp1);
qfree(epsilon1);
if (ctmp2 == NULL)
@@ -554,11 +554,11 @@ ccos(COMPLEX *c, NUMBER *epsilon)
comfree(ctmp2);
return clink(&_czero_);
}
ctmp1 = cinv(ctmp2);
ctmp3 = cadd(ctmp2, ctmp1);
ctmp1 = c_inv(ctmp2);
ctmp3 = c_add(ctmp2, ctmp1);
comfree(ctmp1);
comfree(ctmp2);
ctmp1 = cscale(ctmp3, -1);
ctmp1 = c_scale(ctmp3, -1);
comfree(ctmp3);
r = comalloc();
qfree(r->real);
@@ -576,7 +576,7 @@ ccos(COMPLEX *c, NUMBER *epsilon)
* sin(x) = (exp(1i * x) - exp(-i1*x))/(2i).
*/
COMPLEX *
csin(COMPLEX *c, NUMBER *epsilon)
c_sin(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *r, *ctmp1, *ctmp2, *ctmp3;
NUMBER *qtmp, *epsilon1;
@@ -597,7 +597,7 @@ csin(COMPLEX *c, NUMBER *epsilon)
ctmp1->real = neg ? qneg(c->imag) : qlink(c->imag);
ctmp1->imag = neg ? qlink(c->real) : qneg(c->real);
epsilon1 = qbitvalue(n - 2);
ctmp2 = cexp(ctmp1, epsilon1);
ctmp2 = c_exp(ctmp1, epsilon1);
comfree(ctmp1);
qfree(epsilon1);
if (ctmp2 == NULL)
@@ -606,11 +606,11 @@ csin(COMPLEX *c, NUMBER *epsilon)
comfree(ctmp2);
return clink(&_czero_);
}
ctmp1 = cinv(ctmp2);
ctmp3 = csub(ctmp2, ctmp1);
ctmp1 = c_inv(ctmp2);
ctmp3 = c_sub(ctmp2, ctmp1);
comfree(ctmp1);
comfree(ctmp2);
ctmp1 = cscale(ctmp3, -1);
ctmp1 = c_scale(ctmp3, -1);
comfree(ctmp3);
r = comalloc();
qtmp = neg ? qlink(ctmp1->imag) : qneg(ctmp1->imag);
@@ -627,105 +627,105 @@ csin(COMPLEX *c, NUMBER *epsilon)
COMPLEX *
ccosh(COMPLEX *c, NUMBER *epsilon)
c_cosh(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
tmp1 = cexp(c, epsilon);
tmp1 = c_exp(c, epsilon);
if (tmp1 == NULL)
return NULL;
tmp2 = cneg(c);
tmp3 = cexp(tmp2, epsilon);
tmp2 = c_neg(c);
tmp3 = c_exp(tmp2, epsilon);
comfree(tmp2);
if (tmp3 == NULL)
return NULL;
tmp2 = cadd(tmp1, tmp3);
tmp2 = c_add(tmp1, tmp3);
comfree(tmp1);
comfree(tmp3);
tmp1 = cscale(tmp2, -1);
tmp1 = c_scale(tmp2, -1);
comfree(tmp2);
return tmp1;
}
COMPLEX *
csinh(COMPLEX *c, NUMBER *epsilon)
c_sinh(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
tmp1 = cexp(c, epsilon);
tmp1 = c_exp(c, epsilon);
if (tmp1 == NULL)
return NULL;
tmp2 = cneg(c);
tmp3 = cexp(tmp2, epsilon);
tmp2 = c_neg(c);
tmp3 = c_exp(tmp2, epsilon);
comfree(tmp2);
if (tmp3 == NULL)
return NULL;
tmp2 = csub(tmp1, tmp3);
tmp2 = c_sub(tmp1, tmp3);
comfree(tmp1);
comfree(tmp3);
tmp1 = cscale(tmp2, -1);
tmp1 = c_scale(tmp2, -1);
comfree(tmp2);
return tmp1;
}
COMPLEX *
casin(COMPLEX *c, NUMBER *epsilon)
c_asin(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cmul(&_conei_, c);
tmp2 = casinh(tmp1, epsilon);
tmp1 = c_mul(&_conei_, c);
tmp2 = c_asinh(tmp1, epsilon);
comfree(tmp1);
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
return tmp1;
}
COMPLEX *
cacos(COMPLEX *c, NUMBER *epsilon)
c_acos(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = csquare(c);
tmp2 = csub(&_cone_, tmp1);
tmp1 = c_square(c);
tmp2 = c_sub(&_cone_, tmp1);
comfree(tmp1);
tmp1 = csqrt(tmp2, epsilon, 24);
tmp1 = c_sqrt(tmp2, epsilon, 24);
comfree(tmp2);
tmp2 = cmul(&_conei_, tmp1);
tmp2 = c_mul(&_conei_, tmp1);
comfree(tmp1);
tmp1 = cadd(c, tmp2);
tmp1 = c_add(c, tmp2);
comfree(tmp2);
tmp2 = cln(tmp1, epsilon);
tmp2 = c_ln(tmp1, epsilon);
comfree(tmp1);
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
return tmp1;
}
COMPLEX *
casinh(COMPLEX *c, NUMBER *epsilon)
c_asinh(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
BOOL neg;
neg = qisneg(c->real);
tmp1 = neg ? cneg(c) : clink(c);
tmp2 = csquare(tmp1);
tmp3 = cadd(&_cone_, tmp2);
tmp1 = neg ? c_neg(c) : clink(c);
tmp2 = c_square(tmp1);
tmp3 = c_add(&_cone_, tmp2);
comfree(tmp2);
tmp2 = csqrt(tmp3, epsilon, 24);
tmp2 = c_sqrt(tmp3, epsilon, 24);
comfree(tmp3);
tmp3 = cadd(tmp2, tmp1);
tmp3 = c_add(tmp2, tmp1);
comfree(tmp1);
comfree(tmp2);
tmp1 = cln(tmp3, epsilon);
tmp1 = c_ln(tmp3, epsilon);
comfree(tmp3);
if (neg) {
tmp2 = cneg(tmp1);
tmp2 = c_neg(tmp1);
comfree(tmp1);
return tmp2;
}
@@ -734,153 +734,153 @@ casinh(COMPLEX *c, NUMBER *epsilon)
COMPLEX *
cacosh(COMPLEX *c, NUMBER *epsilon)
c_acosh(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = csquare(c);
tmp2 = csub(tmp1, &_cone_);
tmp1 = c_square(c);
tmp2 = c_sub(tmp1, &_cone_);
comfree(tmp1);
tmp1 = csqrt(tmp2, epsilon, 24);
tmp1 = c_sqrt(tmp2, epsilon, 24);
comfree(tmp2);
tmp2 = cadd(c, tmp1);
tmp2 = c_add(c, tmp1);
comfree(tmp1);
tmp1 = cln(tmp2, epsilon);
tmp1 = c_ln(tmp2, epsilon);
comfree(tmp2);
return tmp1;
}
COMPLEX *
catan(COMPLEX *c, NUMBER *epsilon)
c_atan(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
if (qiszero(c->real) && qisunit(c->imag))
return NULL;
tmp1 = csub(&_conei_, c);
tmp2 = cadd(&_conei_, c);
tmp3 = cdiv(tmp1, tmp2);
tmp1 = c_sub(&_conei_, c);
tmp2 = c_add(&_conei_, c);
tmp3 = c_div(tmp1, tmp2);
comfree(tmp1);
comfree(tmp2);
tmp1 = cln(tmp3, epsilon);
tmp1 = c_ln(tmp3, epsilon);
comfree(tmp3);
tmp2 = cscale(tmp1, -1);
tmp2 = c_scale(tmp1, -1);
comfree(tmp1);
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
return tmp1;
}
COMPLEX *
cacot(COMPLEX *c, NUMBER *epsilon)
c_acot(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
if (qiszero(c->real) && qisunit(c->imag))
return NULL;
tmp1 = cadd(c, &_conei_);
tmp2 = csub(c, &_conei_);
tmp3 = cdiv(tmp1, tmp2);
tmp1 = c_add(c, &_conei_);
tmp2 = c_sub(c, &_conei_);
tmp3 = c_div(tmp1, tmp2);
comfree(tmp1);
comfree(tmp2);
tmp1 = cln(tmp3, epsilon);
tmp1 = c_ln(tmp3, epsilon);
comfree(tmp3);
tmp2 = cscale(tmp1, -1);
tmp2 = c_scale(tmp1, -1);
comfree(tmp1);
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
return tmp1;
}
COMPLEX *
casec(COMPLEX *c, NUMBER *epsilon)
c_asec(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cinv(c);
tmp2 = cacos(tmp1, epsilon);
tmp1 = c_inv(c);
tmp2 = c_acos(tmp1, epsilon);
comfree(tmp1);
return tmp2;
}
COMPLEX *
cacsc(COMPLEX *c, NUMBER *epsilon)
c_acsc(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cinv(c);
tmp2 = casin(tmp1, epsilon);
tmp1 = c_inv(c);
tmp2 = c_asin(tmp1, epsilon);
comfree(tmp1);
return tmp2;
}
COMPLEX *
catanh(COMPLEX *c, NUMBER *epsilon)
c_atanh(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
if (qiszero(c->imag) && qisunit(c->real))
return NULL;
tmp1 = cadd(&_cone_, c);
tmp2 = csub(&_cone_, c);
tmp3 = cdiv(tmp1, tmp2);
tmp1 = c_add(&_cone_, c);
tmp2 = c_sub(&_cone_, c);
tmp3 = c_div(tmp1, tmp2);
comfree(tmp1);
comfree(tmp2);
tmp1 = cln(tmp3, epsilon);
tmp1 = c_ln(tmp3, epsilon);
comfree(tmp3);
tmp2 = cscale(tmp1, -1);
tmp2 = c_scale(tmp1, -1);
comfree(tmp1);
return tmp2;
}
COMPLEX *
cacoth(COMPLEX *c, NUMBER *epsilon)
c_acoth(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
if (qiszero(c->imag) && qisunit(c->real))
return NULL;
tmp1 = cadd(c, &_cone_);
tmp2 = csub(c, &_cone_);
tmp3 = cdiv(tmp1, tmp2);
tmp1 = c_add(c, &_cone_);
tmp2 = c_sub(c, &_cone_);
tmp3 = c_div(tmp1, tmp2);
comfree(tmp1);
comfree(tmp2);
tmp1 = cln(tmp3, epsilon);
tmp1 = c_ln(tmp3, epsilon);
comfree(tmp3);
tmp2 = cscale(tmp1, -1);
tmp2 = c_scale(tmp1, -1);
comfree(tmp1);
return tmp2;
}
COMPLEX *
casech(COMPLEX *c, NUMBER *epsilon)
c_asech(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cinv(c);
tmp2 = cacosh(tmp1, epsilon);
tmp1 = c_inv(c);
tmp2 = c_acosh(tmp1, epsilon);
comfree(tmp1);
return tmp2;
}
COMPLEX *
cacsch(COMPLEX *c, NUMBER *epsilon)
c_acsch(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cinv(c);
tmp2 = casinh(tmp1, epsilon);
tmp1 = c_inv(c);
tmp2 = c_asinh(tmp1, epsilon);
comfree(tmp1);
return tmp2;
}
COMPLEX *
cgd(COMPLEX *c, NUMBER *epsilon)
c_gd(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2, *tmp3;
NUMBER *q1, *q2;
@@ -947,30 +947,30 @@ cgd(COMPLEX *c, NUMBER *epsilon)
return tmp1;
}
neg = qisneg(c->real);
tmp1 = neg ? cneg(c) : clink(c);
tmp2 = cexp(tmp1, epsilon);
tmp1 = neg ? c_neg(c) : clink(c);
tmp2 = c_exp(tmp1, epsilon);
comfree(tmp1);
if (tmp2 == NULL)
return NULL;
tmp1 = cmul(&_conei_, tmp2);
tmp3 = cadd(&_conei_, tmp2);
tmp1 = c_mul(&_conei_, tmp2);
tmp3 = c_add(&_conei_, tmp2);
comfree(tmp2);
tmp2 = cadd(tmp1, &_cone_);
tmp2 = c_add(tmp1, &_cone_);
comfree(tmp1);
if (ciszero(tmp2) || ciszero(tmp3)) {
comfree(tmp2);
comfree(tmp3);
return NULL;
}
tmp1 = cdiv(tmp2, tmp3);
tmp1 = c_div(tmp2, tmp3);
comfree(tmp2);
comfree(tmp3);
tmp2 = cln(tmp1, epsilon);
tmp2 = c_ln(tmp1, epsilon);
comfree(tmp1);
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
if (neg) {
tmp2 = cneg(tmp1);
tmp2 = c_neg(tmp1);
comfree(tmp1);
return tmp2;
}
@@ -979,16 +979,16 @@ cgd(COMPLEX *c, NUMBER *epsilon)
COMPLEX *
cagd(COMPLEX *c, NUMBER *epsilon)
c_agd(COMPLEX *c, NUMBER *epsilon)
{
COMPLEX *tmp1, *tmp2;
tmp1 = cmul(&_conei_, c);
tmp2 = cgd(tmp1, epsilon);
tmp1 = c_mul(&_conei_, c);
tmp2 = c_gd(tmp1, epsilon);
comfree(tmp1);
if (tmp2 == NULL)
return NULL;
tmp1 = cdiv(tmp2, &_conei_);
tmp1 = c_div(tmp2, &_conei_);
comfree(tmp2);
return tmp1;
}
@@ -1000,7 +1000,7 @@ cagd(COMPLEX *c, NUMBER *epsilon)
* q1 * cos(q2) + q1 * sin(q2) * i.
*/
COMPLEX *
cpolar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
c_polar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
{
COMPLEX *r;
NUMBER *tmp, *cos, *sin;
@@ -1042,7 +1042,7 @@ cpolar(NUMBER *q1, NUMBER *q2, NUMBER *epsilon)
* specified error.
*/
COMPLEX *
cpower(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon)
c_power(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon)
{
COMPLEX *ctmp1, *ctmp2;
long k1, k2, k, m1, m2, m, n;
@@ -1099,11 +1099,11 @@ cpower(COMPLEX *c1, COMPLEX *c2, NUMBER *epsilon)
if (k < n)
return clink(&_czero_);
epsilon1 = qbitvalue(n - k - m - 2);
ctmp1 = cln(c1, epsilon1);
ctmp1 = c_ln(c1, epsilon1);
qfree(epsilon1);
ctmp2 = cmul(ctmp1, c2);
ctmp2 = c_mul(ctmp1, c2);
comfree(ctmp1);
ctmp1 = cexp(ctmp2, epsilon);
ctmp1 = c_exp(ctmp2, epsilon);
comfree(ctmp2);
return ctmp1;
}
@@ -1165,7 +1165,7 @@ cprintfr(COMPLEX *c)
NUMBER *
cilog(COMPLEX *c, ZVALUE base)
c_ilog(COMPLEX *c, ZVALUE base)
{
NUMBER *qr, *qi;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: commath.c,v 29.3 2002/03/12 09:38:26 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: commath.c,v 29.4 2005/10/18 10:43:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/commath.c,v $
*
* Under source code control: 1990/02/15 01:48:10
@@ -42,7 +42,7 @@ static COMPLEX _cnegone_ = { &_qnegone_, &_qzero_, 1 };
* Add two complex numbers.
*/
COMPLEX *
cadd(COMPLEX *c1, COMPLEX *c2)
c_add(COMPLEX *c1, COMPLEX *c2)
{
COMPLEX *r;
@@ -67,7 +67,7 @@ cadd(COMPLEX *c1, COMPLEX *c2)
* Subtract two complex numbers.
*/
COMPLEX *
csub(COMPLEX *c1, COMPLEX *c2)
c_sub(COMPLEX *c1, COMPLEX *c2)
{
COMPLEX *r;
@@ -98,7 +98,7 @@ csub(COMPLEX *c1, COMPLEX *c2)
* Then (a+bi) * (c+di) = (q2 - q3) + (q1 - q2 - q3)i.
*/
COMPLEX *
cmul(COMPLEX *c1, COMPLEX *c2)
c_mul(COMPLEX *c1, COMPLEX *c2)
{
COMPLEX *r;
NUMBER *q1, *q2, *q3, *q4;
@@ -110,9 +110,9 @@ cmul(COMPLEX *c1, COMPLEX *c2)
if (cisone(c2))
return clink(c1);
if (cisreal(c2))
return cmulq(c1, c2->real);
return c_mulq(c1, c2->real);
if (cisreal(c1))
return cmulq(c2, c1->real);
return c_mulq(c2, c1->real);
/*
* Need to do the full calculation.
*/
@@ -141,7 +141,7 @@ cmul(COMPLEX *c1, COMPLEX *c2)
* Square a complex number.
*/
COMPLEX *
csquare(COMPLEX *c)
c_square(COMPLEX *c)
{
COMPLEX *r;
NUMBER *q1, *q2;
@@ -183,7 +183,7 @@ csquare(COMPLEX *c)
* Divide two complex numbers.
*/
COMPLEX *
cdiv(COMPLEX *c1, COMPLEX *c2)
c_div(COMPLEX *c1, COMPLEX *c2)
{
COMPLEX *r;
NUMBER *q1, *q2, *q3, *den;
@@ -254,7 +254,7 @@ cdiv(COMPLEX *c1, COMPLEX *c2)
* Invert a complex number.
*/
COMPLEX *
cinv(COMPLEX *c)
c_inv(COMPLEX *c)
{
COMPLEX *r;
NUMBER *q1, *q2, *den;
@@ -296,7 +296,7 @@ cinv(COMPLEX *c)
* Negate a complex number.
*/
COMPLEX *
cneg(COMPLEX *c)
c_neg(COMPLEX *c)
{
COMPLEX *r;
@@ -320,7 +320,7 @@ cneg(COMPLEX *c)
* This means take the integer part of both components.
*/
COMPLEX *
cint(COMPLEX *c)
c_int(COMPLEX *c)
{
COMPLEX *r;
@@ -340,7 +340,7 @@ cint(COMPLEX *c)
* This means take the fractional part of both components.
*/
COMPLEX *
cfrac(COMPLEX *c)
c_frac(COMPLEX *c)
{
COMPLEX *r;
@@ -360,7 +360,7 @@ cfrac(COMPLEX *c)
* This negates the complex part.
*/
COMPLEX *
cconj(COMPLEX *c)
c_conj(COMPLEX *c)
{
COMPLEX *r;
@@ -417,7 +417,7 @@ c_imag(COMPLEX *c)
* Add a real number to a complex number.
*/
COMPLEX *
caddq(COMPLEX *c, NUMBER *q)
c_addq(COMPLEX *c, NUMBER *q)
{
COMPLEX *r;
@@ -436,7 +436,7 @@ caddq(COMPLEX *c, NUMBER *q)
* Subtract a real number from a complex number.
*/
COMPLEX *
csubq(COMPLEX *c, NUMBER *q)
c_subq(COMPLEX *c, NUMBER *q)
{
COMPLEX *r;
@@ -456,7 +456,7 @@ csubq(COMPLEX *c, NUMBER *q)
* number of bits. Negative values shift to the right.
*/
COMPLEX *
cshift(COMPLEX *c, long n)
c_shift(COMPLEX *c, long n)
{
COMPLEX *r;
@@ -475,7 +475,7 @@ cshift(COMPLEX *c, long n)
* Scale a complex number by a power of two.
*/
COMPLEX *
cscale(COMPLEX *c, long n)
c_scale(COMPLEX *c, long n)
{
COMPLEX *r;
@@ -494,7 +494,7 @@ cscale(COMPLEX *c, long n)
* Multiply a complex number by a real number.
*/
COMPLEX *
cmulq(COMPLEX *c, NUMBER *q)
c_mulq(COMPLEX *c, NUMBER *q)
{
COMPLEX *r;
@@ -503,7 +503,7 @@ cmulq(COMPLEX *c, NUMBER *q)
if (qisone(q))
return clink(c);
if (qisnegone(q))
return cneg(c);
return c_neg(c);
r = comalloc();
qfree(r->real);
qfree(r->imag);
@@ -517,7 +517,7 @@ cmulq(COMPLEX *c, NUMBER *q)
* Divide a complex number by a real number.
*/
COMPLEX *
cdivq(COMPLEX *c, NUMBER *q)
c_divq(COMPLEX *c, NUMBER *q)
{
COMPLEX *r;
@@ -528,7 +528,7 @@ cdivq(COMPLEX *c, NUMBER *q)
if (qisone(q))
return clink(c);
if (qisnegone(q))
return cneg(c);
return c_neg(c);
r = comalloc();
qfree(r->real);
qfree(r->imag);
@@ -564,7 +564,7 @@ qqtoc(NUMBER *q1, NUMBER *q2)
* and TRUE if they differ.
*/
BOOL
ccmp(COMPLEX *c1, COMPLEX *c2)
c_cmp(COMPLEX *c1, COMPLEX *c2)
{
BOOL i;
@@ -581,7 +581,7 @@ ccmp(COMPLEX *c1, COMPLEX *c2)
* imaginary parts of the two numbers.
*/
COMPLEX *
crel(COMPLEX *c1, COMPLEX *c2)
c_rel(COMPLEX *c1, COMPLEX *c2)
{
COMPLEX *c;

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.14 $
* @(#) $Id: config.c,v 29.14 2004/02/25 23:56:13 chongo Exp $
* @(#) $Revision: 29.15 $
* @(#) $Id: config.c,v 29.15 2005/12/12 06:45:41 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -432,7 +432,7 @@ setconfig(int type, VALUE *vp)
NUMBER *q;
CONFIG *newconf; /* new configuration to set */
long temp;
LEN len;
LEN len = 0;
char *p;
switch (type) {

View File

@@ -19,7 +19,7 @@
*
* @(#) $Revision: 29.4 $
* @(#) $Id: custom.c,v 29.4 2004/02/25 23:54:40 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/../RCS/custom.c,v $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/custom.c,v $
*
* Under source code control: 1997/03/03 04:53:08
* File existed as early as: 1997

View File

@@ -41,7 +41,6 @@ Step 1: Do some background work
custom.c
custom.h
custom/custom.h
custom/custtbl.c
custom/c_*.[ch]
custom/*.cal
@@ -648,8 +647,8 @@ Step 12: Contribute
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.4 $
## @(#) $Id: HOW_TO_ADD,v 29.4 2004/07/29 08:38:05 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: HOW_TO_ADD,v 29.5 2005/10/18 11:18:34 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/HOW_TO_ADD,v $
##
## Under source code control: 1997/03/10 03:03:21

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: custtbl.c,v 29.3 2004/07/29 08:37:53 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: custtbl.c,v 29.4 2005/02/05 06:16:19 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/custtbl.c,v $
*
* Under source code control: 1997/03/09 02:28:54
@@ -106,7 +106,7 @@ CONST struct custom cust[] = {
{ "sysinfo", "return a calc #define value",
0, 1, c_sysinfo },
{ "pzasusb8", "print ZCALUE as USB8",
{ "pzasusb8", "print ZVALUE as USB8",
0, 1, c_pzasusb8 },
{ "pmodm127", "calculate q mod 2^(2^127-1)",

View File

@@ -19,7 +19,7 @@ DESCRIPTION
custom("sysinfo", "BASEB")
custom("sysinfo", "CALC_BYTE_ORDER")
foe details.
for details.
This custom function is intented for testing of the general
custom interface.
@@ -65,8 +65,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: pzasusb8,v 29.2 2000/06/07 14:03:03 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: pzasusb8,v 29.3 2005/10/18 11:18:34 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/pzasusb8,v $
##
## Under source code control: 1999/10/06 04:05:43

100
func.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.15 $
* @(#) $Id: func.c,v 29.15 2004/07/26 05:55:37 chongo Exp $
* @(#) $Revision: 29.16 $
* @(#) $Id: func.c,v 29.16 2005/10/18 10:43:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
*
* Under source code control: 1990/02/15 01:48:15
@@ -1974,7 +1974,7 @@ f_exp(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
c = cexp(vals[0]->v_com, eps);
c = c_exp(vals[0]->v_com, eps);
if (c == NULL)
return error_value(E_EXP3);
result.v_com = c;
@@ -2018,10 +2018,10 @@ f_ln(int count, VALUE **vals)
ctmp.real = vals[0]->v_num;
ctmp.imag = qlink(&_qzero_);
ctmp.links = 1;
c = cln(&ctmp, err);
c = c_ln(&ctmp, err);
break;
case V_COM:
c = cln(vals[0]->v_com, err);
c = c_ln(vals[0]->v_com, err);
break;
default:
return error_value(E_LN2);
@@ -2059,7 +2059,7 @@ f_cos(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
c = ccos(vals[0]->v_com, eps);
c = c_cos(vals[0]->v_com, eps);
if (c == NULL)
return error_value(E_COS3);
result.v_com = c;
@@ -2099,7 +2099,7 @@ f_sin(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
c = csin(vals[0]->v_com, eps);
c = c_sin(vals[0]->v_com, eps);
if (c == NULL)
return error_value(E_SIN3);
result.v_com = c;
@@ -2142,9 +2142,9 @@ f_tan(int count, VALUE **vals)
break;
case V_COM:
tmp1.v_type = V_COM;
tmp1.v_com = csin(vals[0]->v_com, err);
tmp1.v_com = c_sin(vals[0]->v_com, err);
tmp2.v_type = V_COM;
tmp2.v_com = ccos(vals[0]->v_com, err);
tmp2.v_com = c_cos(vals[0]->v_com, err);
divvalue(&tmp1, &tmp2, &result);
comfree(tmp1.v_com);
comfree(tmp2.v_com);
@@ -2179,7 +2179,7 @@ f_sec(int count, VALUE **vals)
break;
case V_COM:
tmp.v_type = V_COM;
tmp.v_com = ccos(vals[0]->v_com, err);
tmp.v_com = c_cos(vals[0]->v_com, err);
invertvalue(&tmp, &result);
comfree(tmp.v_com);
break;
@@ -2217,9 +2217,9 @@ f_cot(int count, VALUE **vals)
break;
case V_COM:
tmp1.v_type = V_COM;
tmp1.v_com = ccos(vals[0]->v_com, err);
tmp1.v_com = c_cos(vals[0]->v_com, err);
tmp2.v_type = V_COM;
tmp2.v_com = csin(vals[0]->v_com, err);
tmp2.v_com = c_sin(vals[0]->v_com, err);
divvalue(&tmp1, &tmp2, &result);
comfree(tmp1.v_com);
comfree(tmp2.v_com);
@@ -2257,7 +2257,7 @@ f_csc(int count, VALUE **vals)
break;
case V_COM:
tmp.v_type = V_COM;
tmp.v_com = csin(vals[0]->v_com, err);
tmp.v_com = c_sin(vals[0]->v_com, err);
invertvalue(&tmp, &result);
comfree(tmp.v_com);
break;
@@ -2293,7 +2293,7 @@ f_sinh(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
c = csinh(vals[0]->v_com, eps);
c = c_sinh(vals[0]->v_com, eps);
if (c == NULL)
return error_value(E_SINH3);
result.v_com = c;
@@ -2336,7 +2336,7 @@ f_cosh(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
c = ccosh(vals[0]->v_com, eps);
c = c_cosh(vals[0]->v_com, eps);
if (c == NULL)
return error_value(E_COSH3);
result.v_com = c;
@@ -2379,9 +2379,9 @@ f_tanh(int count, VALUE **vals)
break;
case V_COM:
tmp1.v_type = V_COM;
tmp1.v_com = csinh(vals[0]->v_com, err);
tmp1.v_com = c_sinh(vals[0]->v_com, err);
tmp2.v_type = V_COM;
tmp2.v_com = ccosh(vals[0]->v_com, err);
tmp2.v_com = c_cosh(vals[0]->v_com, err);
divvalue(&tmp1, &tmp2, &result);
comfree(tmp1.v_com);
comfree(tmp2.v_com);
@@ -2420,9 +2420,9 @@ f_coth(int count, VALUE **vals)
break;
case V_COM:
tmp1.v_type = V_COM;
tmp1.v_com = ccosh(vals[0]->v_com, err);
tmp1.v_com = c_cosh(vals[0]->v_com, err);
tmp2.v_type = V_COM;
tmp2.v_com = csinh(vals[0]->v_com, err);
tmp2.v_com = c_sinh(vals[0]->v_com, err);
divvalue(&tmp1, &tmp2, &result);
comfree(tmp1.v_com);
comfree(tmp2.v_com);
@@ -2458,7 +2458,7 @@ f_sech(int count, VALUE **vals)
break;
case V_COM:
tmp.v_type = V_COM;
tmp.v_com = ccosh(vals[0]->v_com, err);
tmp.v_com = c_cosh(vals[0]->v_com, err);
invertvalue(&tmp, &result);
comfree(tmp.v_com);
break;
@@ -2495,7 +2495,7 @@ f_csch(int count, VALUE **vals)
break;
case V_COM:
tmp.v_type = V_COM;
tmp.v_com = csinh(vals[0]->v_com, err);
tmp.v_com = c_sinh(vals[0]->v_com, err);
invertvalue(&tmp, &result);
comfree(tmp.v_com);
break;
@@ -2528,7 +2528,7 @@ f_atan(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
tmp = catan(vals[0]->v_com, err);
tmp = c_atan(vals[0]->v_com, err);
if (tmp == NULL)
return error_value(E_LOGINF);
result.v_type = V_COM;
@@ -2568,7 +2568,7 @@ f_acot(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
tmp = cacot(vals[0]->v_com, err);
tmp = c_acot(vals[0]->v_com, err);
if (tmp == NULL)
return error_value(E_LOGINF);
result.v_type = V_COM;
@@ -2611,12 +2611,12 @@ f_asin(int count, VALUE **vals)
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_type = V_COM;
result.v_com = casin(tmp, err);
result.v_com = c_asin(tmp, err);
comfree(tmp);
}
break;
case V_COM:
result.v_com = casin(vals[0]->v_com, err);
result.v_com = c_asin(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2657,12 +2657,12 @@ f_acos(int count, VALUE **vals)
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_type = V_COM;
result.v_com = cacos(tmp, err);
result.v_com = c_acos(tmp, err);
comfree(tmp);
}
break;
case V_COM:
result.v_com = cacos(vals[0]->v_com, err);
result.v_com = c_acos(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2705,13 +2705,13 @@ f_asec(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = casec(tmp, err);
result.v_com = c_asec(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = casec(vals[0]->v_com, err);
result.v_com = c_asec(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2758,13 +2758,13 @@ f_acsc(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cacsc(tmp, err);
result.v_com = c_acsc(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = cacsc(vals[0]->v_com, err);
result.v_com = c_acsc(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2806,7 +2806,7 @@ f_asinh(int count, VALUE **vals)
result.v_type = V_NUM;
break;
case V_COM:
tmp = casinh(vals[0]->v_com, err);
tmp = c_asinh(vals[0]->v_com, err);
result.v_type = V_COM;
result.v_com = tmp;
if (cisreal(tmp)) {
@@ -2847,13 +2847,13 @@ f_acosh(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cacosh(tmp, err);
result.v_com = c_acosh(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = cacosh(vals[0]->v_com, err);
result.v_com = c_acosh(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2894,13 +2894,13 @@ f_atanh(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = catanh(tmp, err);
result.v_com = c_atanh(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = catanh(vals[0]->v_com, err);
result.v_com = c_atanh(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2945,13 +2945,13 @@ f_acoth(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cacoth(tmp, err);
result.v_com = c_acoth(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = cacoth(vals[0]->v_com, err);
result.v_com = c_acoth(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -2998,13 +2998,13 @@ f_asech(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = casech(tmp, err);
result.v_com = c_asech(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = casech(vals[0]->v_com, err);
result.v_com = c_asech(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -3051,13 +3051,13 @@ f_acsch(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cacsch(tmp, err);
result.v_com = c_acsch(tmp, err);
result.v_type = V_COM;
comfree(tmp);
}
break;
case V_COM:
result.v_com = cacsch(vals[0]->v_com, err);
result.v_com = c_acsch(vals[0]->v_com, err);
result.v_type = V_COM;
break;
default:
@@ -3105,11 +3105,11 @@ f_gd(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cgd(tmp, eps);
result.v_com = c_gd(tmp, eps);
comfree(tmp);
break;
case V_COM:
result.v_com = cgd(vals[0]->v_com, eps);
result.v_com = c_gd(vals[0]->v_com, eps);
break;
default:
return error_value(E_GD2);
@@ -3154,11 +3154,11 @@ f_agd(int count, VALUE **vals)
tmp = comalloc();
qfree(tmp->real);
tmp->real = qlink(vals[0]->v_num);
result.v_com = cagd(tmp, eps);
result.v_com = c_agd(tmp, eps);
comfree(tmp);
break;
case V_COM:
result.v_com = cagd(vals[0]->v_com, eps);
result.v_com = c_agd(vals[0]->v_com, eps);
break;
default:
return error_value(E_AGD2);
@@ -3652,7 +3652,7 @@ f_polar(int count, VALUE **vals)
return error_value(E_POLAR1);
if ((vp->v_type != V_NUM) || qisneg(vp->v_num) || qiszero(vp->v_num))
return error_value(E_POLAR2);
c = cpolar(vals[0]->v_num, vals[1]->v_num, vp->v_num);
c = c_polar(vals[0]->v_num, vals[1]->v_num, vp->v_num);
result.v_com = c;
result.v_type = V_COM;
if (cisreal(c)) {
@@ -3678,7 +3678,7 @@ f_ilog(VALUE *v1, VALUE *v2)
res.v_num = qilog(v1->v_num, v2->v_num->num);
break;
case V_COM:
res.v_num = cilog(v1->v_com, v2->v_num->num);
res.v_num = c_ilog(v1->v_com, v2->v_num->num);
break;
default:
return error_value(E_ILOG);
@@ -3703,7 +3703,7 @@ f_ilog2(VALUE *vp)
res.v_num = qilog(vp->v_num, _two_);
break;
case V_COM:
res.v_num = cilog(vp->v_com, _two_);
res.v_num = c_ilog(vp->v_com, _two_);
break;
default:
return error_value(E_ILOG2);
@@ -3728,7 +3728,7 @@ f_ilog10(VALUE *vp)
res.v_num = qilog(vp->v_num, _ten_);
break;
case V_COM:
res.v_num = cilog(vp->v_com, _ten_);
res.v_num = c_ilog(vp->v_com, _ten_);
break;
default:
return error_value(E_ILOG10);

View File

@@ -51,7 +51,7 @@ LIMITS
none
LINK LIBRARY
COMPLEX *cagd(COMPLEX *x, NUMBER *eps)
COMPLEX *c_agd(COMPLEX *x, NUMBER *eps)
SEE ALSO
gd, exp, ln, sin, sinh, etc.
@@ -72,8 +72,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: agd,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: agd,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/agd,v $
##
## Under source code control: 1997/09/06 20:03:34

View File

@@ -30,7 +30,7 @@ LIMITS
LINK LIBRARY
NUMBER *qcos(NUMBER *x, NUMBER *eps)
COMPLEX *ccos(COMPLEX *x, NUMBER *eps)
COMPLEX *c_cos(COMPLEX *x, NUMBER *eps)
SEE ALSO
sin, tan, sec, csc, cot, epsilon
@@ -51,8 +51,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: cos,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: cos,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/cos,v $
##
## Under source code control: 1994/03/19 01:40:27

View File

@@ -35,7 +35,7 @@ LIMITS
LINK LIBRARY
NUMBER *qexp(NUMBER *x, NUMBER *eps)
COMPLEX *cexp(COMPLEX *x, NUMBER *eps)
COMPLEX *c_exp(COMPLEX *x, NUMBER *eps)
SEE ALSO
ln, cosh, sinh, tanh
@@ -56,8 +56,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: exp,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: exp,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/exp,v $
##
## Under source code control: 1995/10/11 04:41:26

View File

@@ -35,7 +35,7 @@ LIMITS
LINK LIBRARY
NUMBER *qfrac(NUMBER *x)
COMPLEX *cfrac(COMPLEX *x)
COMPLEX *c_frac(COMPLEX *x)
MATRIX *matfrac(MATRIX *x)
SEE ALSO
@@ -57,8 +57,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: frac,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: frac,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/frac,v $
##
## Under source code control: 1995/12/18 03:30:59

View File

@@ -45,7 +45,7 @@ LIMITS
none
LINK LIBRARY
COMPLEX *cgd(COMPLEX *x, NUMBER *eps)
COMPLEX *c_gd(COMPLEX *x, NUMBER *eps)
SEE ALSO
agd, exp, ln, sin, sinh, etc.
@@ -66,8 +66,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: gd,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: gd,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/gd,v $
##
## Under source code control: 1997/09/06 20:03:35

View File

@@ -34,7 +34,7 @@ LIMITS
LINK LIBRARY
NUMBER *qint(NUMBER *x)
COMPLEX *cint(COMPLEX *x)
COMPLEX *c_int(COMPLEX *x)
MATRIX *matint(MATRIX *x)
SEE ALSO
@@ -56,8 +56,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: int,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: int,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/int,v $
##
## Under source code control: 1994/09/30 00:57:18

View File

@@ -42,7 +42,7 @@ LIMITS
LINK LIBRARY
void invertvalue(VALUE *x, VALUE *vres)
NUMBER *qinv(NUMBER *x)
COMPLEX *cinv(COMPLEX *x)
COMPLEX *c_inv(COMPLEX *x)
MATRIX *matinv(MATRIX *x)
SEE ALSO
@@ -63,8 +63,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: inverse,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: inverse,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/inverse,v $
##
## Under source code control: 1996/03/12 23:10:01

View File

@@ -29,7 +29,7 @@ LIMITS
LINK LIBRARY
NUMBER *qln(NUMBER *x, NUMBER *eps)
COMPLEX *cln(COMPLEX *x, NUMBER *eps)
COMPLEX *c_ln(COMPLEX *x, NUMBER *eps)
SEE ALSO
exp, acosh, asinh, atanh
@@ -50,8 +50,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: ln,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: ln,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/ln,v $
##
## Under source code control: 1995/10/11 04:41:26

333
help/mat
View File

@@ -1,185 +1,200 @@
NAME
mat - keyword to create a matrix value
mat - keyword to create a matrix value
SYNOPSIS
mat [index-range-list] [ = {value_0. ...} ]
mat [] [= {value_0, ...}]
mat variable_1 ... [index-range-list] [ = {value_0, ...} ]
mat variable_1 ... [] [ = {value_0, ...} ]
mat [index-range-list] [ = {value_0. ...} ]
mat [] [= {value_0, ...}]
mat variable_1 ... [index-range-list] [ = {value_0, ...} ]
mat variable_1 ... [] [ = {value_0, ...} ]
mat [index-range-list_1[index-ranges-list_2] ... [ = { { ...} ...} ]
mat [index-range-list_1[index-ranges-list_2] ... [ = { { ...} ...} ]
decl id_1 id_2 ... [index-range-list] ...
decl id_1 id_2 ... [index-range-list] ...
TYPES
index-range-list range_1 [, range_2, ...] up to 4 ranges
range_1, ... integer, or integer_1 : integer_2
value, value_1, ... any
variable_1 ... lvalue
decl declarator = global, static or local
id_1, ... identifier
index-range-list range_1 [, range_2, ...] up to 4 ranges
range_1, ... integer, or integer_1 : integer_2
value, value_1, ... any
variable_1 ... lvalue
decl declarator = global, static or local
id_1, ... identifier
DESCRIPTION
The expression mat [index-range-list] returns a matrix value.
This may be assigned to one or more lvalues A, B, ... by either
The expression mat [index-range-list] returns a matrix value.
This may be assigned to one or more lvalues A, B, ... by either
mat A B ... [index-range-list]
or
or
A = B = ... = mat[index-range-list]
If a variable is specified by an expression that is not a symbol with
possibly object element specifiers, the expression should be enclosed
in parentheses. For example, parentheses are required in
mat (A[2]) [3] and mat (*p) [3] but mat P.x [3] is acceptable.
If a variable is specified by an expression that is not a symbol with
possibly object element specifiers, the expression should be enclosed
in parentheses. For example, parentheses are required in
mat (A[2]) [3] and mat (*p) [3] but mat P.x [3] is acceptable.
When an index-range is specified as integer_1 : integer_2, where
integer_1 and integer_2 are expressions which evaluate to integers,
the index-range consists of all integers from the minimum of the
two integers to the maximum of the two integers. For example,
mat[2:5, 0:4] and mat[5:2, 4:0] return the same matrix value.
When an index-range is specified as integer_1 : integer_2, where
integer_1 and integer_2 are expressions which evaluate to integers,
the index-range consists of all integers from the minimum of the
two integers to the maximum of the two integers. For example,
mat[2:5, 0:4] and mat[5:2, 4:0] return the same matrix value.
If an index-range is an expression which evaluates to an integer,
the range is as if specified by 0 : integer - 1. For example,
mat[4] and mat[0:3] return the same 4-element matrix; mat[-2] and
mat[-3:0] return the same 4-element matrix.
If an index-range is an expression which evaluates to an integer,
the range is as if specified by 0 : integer - 1. For example,
mat[4] and mat[0:3] return the same 4-element matrix; mat[-2] and
mat[-3:0] return the same 4-element matrix.
If the variable A has a matrix value, then for integer indices
i_1, i_2, ..., equal in number to the number of ranges specified at
its creation, and such that each index is in the corresponding range,
the matrix element associated with those index list is given as an
lvalue by the expressions A[i_1, i_2, ...].
If the variable A has a matrix value, then for integer indices
i_1, i_2, ..., equal in number to the number of ranges specified at
its creation, and such that each index is in the corresponding range,
the matrix element associated with those index list is given as an
lvalue by the expressions A[i_1, i_2, ...].
The elements of the matrix are stored internally as a linear array
in which locations are arranged in order of increasing indices.
For example, in order of location, the six element of A = mat [2,3]
are
The elements of the matrix are stored internally as a linear array
in which locations are arranged in order of increasing indices.
For example, in order of location, the six element of A = mat [2,3]
are
A[0,0], A[0,1], A[0,2], A[1,0], A[1,,1], A[1,2].
These elements may also be specified using the double-bracket operator
with a single integer index as in A[[0]], A[[1]], ..., A[[5]].
If p is assigned the value &A[0.0], the address of A[[i]] for 0 <= i < 6
is p + i as long as A exists and a new value is not assigned to A.
These elements may also be specified using the double-bracket operator
with a single integer index as in A[[0]], A[[1]], ..., A[[5]].
If p is assigned the value &A[0.0], the address of A[[i]] for 0 <= i < 6
is p + i as long as A exists and a new value is not assigned to A.
When a matrix is created, each element is initially assigned the
value zero. Other values may be assigned then or later using the
"= {...}" assignment operation. Thus
When a matrix is created, each element is initially assigned the
value zero. Other values may be assigned then or later using the
"= {...}" assignment operation. Thus
A = {value_0, value_1, ...}
assigns the values value_0, value_1, ... to the elements A[[0]],
A[[1]], ... Any blank "value" is passed over. For example,
assigns the values value_0, value_1, ... to the elements A[[0]],
A[[1]], ... Any blank "value" is passed over. For example,
A = {1, , 2}
will assign the value 1 to A[[0]], 2 to A[[2]] and leave all other
elements unchanged. Values may also be assigned to elements by
simple assignments, as in A[0,0] = 1, A[0,2] = 2;
will assign the value 1 to A[[0]], 2 to A[[2]] and leave all other
elements unchanged. Values may also be assigned to elements by
simple assignments, as in A[0,0] = 1, A[0,2] = 2;
If the index-range is left blank but an initializer list is specified
as in
If the index-range is left blank but an initializer list is specified
as in
mat A[] = {1, 2 }
B = mat[] = {1, , 3, }
the matrix created is one-dimensional. If the list contains a
positive number n of values or blanks, the result is as if the
range were specified by [n], i.e. the range of indices is from
0 to n - 1. In the above examples, A is of size 2 with A[0] = 1
and A[1] = 2; B is of size 4 with B[0] = 1, B[1] = B[3] = 0,
B[2] = 3. The specification mat[] = { } creates the same as mat[1].
the matrix created is one-dimensional. If the list contains a
positive number n of values or blanks, the result is as if the
range were specified by [n], i.e. the range of indices is from
0 to n - 1. In the above examples, A is of size 2 with A[0] = 1
and A[1] = 2; B is of size 4 with B[0] = 1, B[1] = B[3] = 0,
B[2] = 3. The specification mat[] = { } creates the same as mat[1].
If the index-range is left blank and no initializer list is specified,
as in mat C[] or C = mat[], the matrix assigned to C has zero
dimension; this has one element C[]. To assign a value using "= { ...}"
at the same time as creating C, parentheses are required as in
(mat[]) = {value} or (mat C[]) = {value}. Later a value may be
assigned to C[] by C[] = value or C = {value}.
If the index-range is left blank and no initializer list is specified,
as in mat C[] or C = mat[], the matrix assigned to C has zero
dimension; this has one element C[]. To assign a value using "= { ...}"
at the same time as creating C, parentheses are required as in
(mat[]) = {value} or (mat C[]) = {value}. Later a value may be
assigned to C[] by C[] = value or C = {value}.
The value assigned at any time to any element of a matrix can be of
any type - number, string, list, matrix, object of previously specified
type, etc. For some matrix operations there are of course conditions
that elements may have to satisfy: for example, addition of matrices
requires that addition of corresponding elements be possible.
If an element of a matrix is a structure for which indices or an
object element specifier is required, an element of that structure is
referred to by appropriate uses of [ ] or ., and so on if an element
of that element is required. For example, one may have an expressions
like
The value assigned at any time to any element of a matrix can be of
any type - number, string, list, matrix, object of previously specified
type, etc. For some matrix operations there are of course conditions
that elements may have to satisfy: for example, addition of matrices
requires that addition of corresponding elements be possible.
If an element of a matrix is a structure for which indices or an
object element specifier is required, an element of that structure is
referred to by appropriate uses of [ ] or ., and so on if an element
of that element is required. For example, one may have an expressions
like
A[1,2][3].alpha[2];
if A[1,2][3].alpha is a list with at least three elements, A[1,2][3] is
an object of a type like obj {alpha, beta}, A[1,2] is a matrix of
type mat[4] and A is a mat[2,3] matrix. When an element of a matrix
is a matrix and the total number of indices does not exceed 4, the
indices can be combined into one list, e.g. the A[1,2][3] in the
above example can be shortened to A[1,2,3]. (Unlike C, A[1,2] cannot
be expressed as A[1][2].)
if A[1,2][3].alpha is a list with at least three elements, A[1,2][3] is
an object of a type like obj {alpha, beta}, A[1,2] is a matrix of
type mat[4] and A is a mat[2,3] matrix. When an element of a matrix
is a matrix and the total number of indices does not exceed 4, the
indices can be combined into one list, e.g. the A[1,2][3] in the
above example can be shortened to A[1,2,3]. (Unlike C, A[1,2] cannot
be expressed as A[1][2].)
The function ismat(V) returns 1 if V is a matrix, 0 otherwise.
The function ismat(V) returns 1 if V is a matrix, 0 otherwise.
isident(V) returns 1 if V is a square matrix with diagonal elements 1,
off-diagonal elements zero, or a zero- or one-dimensional matrix with
every element 1; otherwise zero is returned. Thus isident(V) = 1
indicates that for V * A and A * V where A is any matrix of
for which either product is defined and the elements of A are real
or complex numbers, that product will equal A.
isident(V) returns 1 if V is a square matrix with diagonal elements 1,
off-diagonal elements zero, or a zero- or one-dimensional matrix with
every element 1; otherwise zero is returned. Thus isident(V) = 1
indicates that for V * A and A * V where A is any matrix of
for which either product is defined and the elements of A are real
or complex numbers, that product will equal A.
If V is matrix-valued, test(V) returns 0 if every element of V tests
as zero; otherwise 1 is returned.
If V is matrix-valued, test(V) returns 0 if every element of V tests
as zero; otherwise 1 is returned.
The dimension of a matrix A, i.e. the number of index-ranges in the
initial creation of the matrix, is returned by the function matdim(A).
For 1 <= i <= matdim(A), the minimum and maximum values for the i-th
index range are returned by matmin(A, i) and matmax(A,i), respectively.
The total number of elements in the matrix is returned by size(A).
The sum of the elements in the matrix is returned by matsum(A).
The dimension of a matrix A, i.e. the number of index-ranges in the
initial creation of the matrix, is returned by the function matdim(A).
For 1 <= i <= matdim(A), the minimum and maximum values for the i-th
index range are returned by matmin(A, i) and matmax(A,i), respectively.
The total number of elements in the matrix is returned by size(A).
The sum of the elements in the matrix is returned by matsum(A).
The default method of printing matrices is to give a line of information
about the matrix, and to list on separate lines up to 15 elements,
the indices and either the value (for numbers, strings, objects) or
some descriptive information for lists or matrices, etc.
Numbers are displayed in the current number-printing mode.
The maximum number of elements to be printed can be assigned
any nonnegative integer value m by config("maxprint", m).
The default method of printing matrices is to give a line of information
about the matrix, and to list on separate lines up to 15 elements,
the indices and either the value (for numbers, strings, objects) or
some descriptive information for lists or matrices, etc.
Numbers are displayed in the current number-printing mode.
The maximum number of elements to be printed can be assigned
any nonnegative integer value m by config("maxprint", m).
Users may define another method of printing matrices by defining a
function mat_print(M); for example, for a not too big 2-dimensional
matrix A it is a common practice to use a loop like:
Users may define another method of printing matrices by defining a
function mat_print(M); for example, for a not too big 2-dimensional
matrix A it is a common practice to use a loop like:
define mat_print(A) {
local i,j;
for (i = matmin(A,1); i <= matmax(A,1); i++) {
if (i != matmin(A,1))
printf("\t");
for (j = matmin(A,2); j <= matmax(A,2); j++)
printf("%8d", A[i,j];
print;
}
printf(" [%d,%d]: %e", i, j, A[i,j]);
if (i != matmax(A,1))
printf("\n");
}
}
The default printing may be restored by
So that when one defines a 2D matrix such as:
mat X[2,3] = {1,2,3,4,5,6}
then printing X results in:
[0,0]: 1 [0,1]: 2 [0,2]: 3
[1,0]: 4 [1,1]: 5 [1,2]: 6
The default printing may be restored by
undefine mat_print;
The keyword "mat" followed by two or more index-range-lists returns a
matrix with indices specified by the first list, whose elements are
matrices as determined by the later index-range-lists. For
example mat[2][3] is a 2-element matrix, each of whose elements has
as its value a 3-element matrix. Values may be assigned to the
elements of the innermost matrices by nested = {...} operations as in
The keyword "mat" followed by two or more index-range-lists returns a
matrix with indices specified by the first list, whose elements are
matrices as determined by the later index-range-lists. For
example mat[2][3] is a 2-element matrix, each of whose elements has
as its value a 3-element matrix. Values may be assigned to the
elements of the innermost matrices by nested = {...} operations as in
mat [2][3] = {{1,2,3},{4,5,6}}
An example of the use of mat with a declarator is
An example of the use of mat with a declarator is
global mat A B [2,3], C [4]
This creates, if they do not already exist, three global variables with
names A, B, C, and assigns to A and B the value mat[2,3] and to C mat[4].
This creates, if they do not already exist, three global variables with
names A, B, C, and assigns to A and B the value mat[2,3] and to C mat[4].
Some operations are defined for matrices.
Some operations are defined for matrices.
A == B
A == B
Returns 1 if A and B are of the same "shape" and "corresponding"
elements are equal; otherwise 0 is returned. Being of the same
shape means they have the same dimension d, and for each i <= d,
@@ -191,14 +206,14 @@ DESCRIPTION
double-bracket indices; thus A == B implies that A[[i]] == B[[i]]
for 0 <= i < size(A) == size(B).
A + B
A - B
A + B
A - B
These are defined A and B have the same shape, the element
with double-bracket index j being evaluated by A[[j]] + B[[j]] and
A[[j]] - B[[j]], respectively. The index-ranges for the results
are those for the matrix A.
A[i,j]
A[i,j]
If A is two-dimensional, it is customary to speak of the indices
i, j in A[i,j] as referring to rows and columns; the number of
rows is matmax(A,1) - matmin(A,1) + 1; the number of columns if
@@ -206,7 +221,7 @@ DESCRIPTION
if it is two-dimensional and the number of rows is equal to the
number of columns.
A * B
A * B
Multiplication is defined provided certain conditions by the
dimensions and shapes of A and B are satisfied. If both have
dimension 2 and the column-index-list for A is the same as
@@ -263,7 +278,7 @@ DESCRIPTION
a matrix indexed in the same way as A with each element inverted.
The following functions are defined to return matrices with the same
The following functions are defined to return matrices with the same
index-ranges as A and the specified operations performed on all
elements of A. Here num is an arbitrary complex number (nonzero
when it is a divisor), int an integer, rnd a rounding-type
@@ -285,52 +300,52 @@ DESCRIPTION
A % real
A ^ int
If A and B are one-dimensional of the same size dp(A, B) returns
If A and B are one-dimensional of the same size dp(A, B) returns
their dot-product, i.e. the sum of the products of corresponding
elements.
If A and B are one-dimension and of size 3, cp(A, B) returns their
If A and B are one-dimension and of size 3, cp(A, B) returns their
cross-product.
randperm(A) returns a matrix indexed the same as A in which the elements
randperm(A) returns a matrix indexed the same as A in which the elements
of A have been randomly permuted.
sort(A) returns a matrix indexed the same as A in which the elements
sort(A) returns a matrix indexed the same as A in which the elements
of A have been sorted.
If A is an lvalue whose current value is a matrix, matfill(A, v)
If A is an lvalue whose current value is a matrix, matfill(A, v)
assigns the value v to every element of A, and if also, A is
square, matfill(A, v1, v2) assigns v1 to the off-diagonal elements,
v2 to the diagonal elements. To create and assign to A the unit
n * n matrix, one may use matfill(mat A[n,n], 0, 1).
For a square matrix A, mattrace(A) returns the trace of A, i.e. the
For a square matrix A, mattrace(A) returns the trace of A, i.e. the
sum of the diagonal elements. For zero- or one-dimensional A,
mattrace(A) returns the sum of the elements of A.
For a two-dimensional matrix A, mattrans(A) returns the transpose
For a two-dimensional matrix A, mattrans(A) returns the transpose
of A, i.e. if A is mat[m,n], it returns a mat[n,m] matrix with
[i,j] element equal to A[j,i]. For zero- or one-dimensional A,
mattrace(A) returns a matrix with the same value as A.
The functions search(A, value, start, end]) and
rsearch(A, value, start, end]) return the first or last index i
for which A[[i]] == value and start <= i < end, or if there is
no such index, the null value. For further information on default
values and the use of an "accept" function, see the help files for
search and rsearch.
The functions search(A, value, start, end]) and
rsearch(A, value, start, end]) return the first or last index i
for which A[[i]] == value and start <= i < end, or if there is
no such index, the null value. For further information on default
values and the use of an "accept" function, see the help files for
search and rsearch.
reverse(A) returns a matrix with the same index-lists as A but the
elements in reversed order.
reverse(A) returns a matrix with the same index-lists as A but the
elements in reversed order.
The copy and blkcpy functions may be used to copy data to a matrix from
a matrix or list, or from a matrix to a list. In copying from a
matrix to a matrix the matrices need not have the same dimension;
in effect they are treated as linear arrays.
The copy and blkcpy functions may be used to copy data to a matrix from
a matrix or list, or from a matrix to a list. In copying from a
matrix to a matrix the matrices need not have the same dimension;
in effect they are treated as linear arrays.
EXAMPLE
> obj point {x,y}
> mat A[5] = {1, 2+3i, "ab", mat[2] = {4,5}. obj point = {6,7}}
> mat A[5] = {1, 2+3i, "ab", mat[2] = {4,5}, obj point = {6,7}}
> A
mat [5] (5 elements, 5 nonzero):
[0] = 1
@@ -381,20 +396,20 @@ EXAMPLE
[3] = 4
LIMITS
The theoretical upper bound for the absolute values of indices is
2^31 - 1, but the size of matrices that can be handled in practice will
be limited by the availability of memory and what is an acceptable
runtime. For example, although it may take only a fraction of a
second to invert a 10 * 10 matrix, it will probably take about 1000
times as long to invert a 100 * 100 matrix.
The theoretical upper bound for the absolute values of indices is
2^31 - 1, but the size of matrices that can be handled in practice will
be limited by the availability of memory and what is an acceptable
runtime. For example, although it may take only a fraction of a
second to invert a 10 * 10 matrix, it will probably take about 1000
times as long to invert a 100 * 100 matrix.
LINK LIBRARY
n/a
n/a
SEE ALSO
ismat, matdim, matmax, matmin, mattrans, mattrace, matsum, det, inverse,
isident, test, config, search, rsearch, reverse, copy, blkcpy, dp, cp,
randperm, sort
ismat, matdim, matmax, matmin, mattrans, mattrace, matsum, det, inverse,
isident, test, config, search, rsearch, reverse, copy, blkcpy, dp, cp,
randperm, sort
## Copyright (C) 1999 Landon Curt Noll
##
@@ -412,8 +427,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: mat,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: mat,v 29.4 2005/10/18 10:08:45 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/mat,v $
##
## Under source code control: 1991/07/21 04:37:22

View File

@@ -29,7 +29,7 @@ LIMITS
none
LINK LIBRARY
COMPLEX * cpolar(NUMBER *r, NUMBER *t, NUMBER *eps);
COMPLEX *c_polar(NUMBER *r, NUMBER *t, NUMBER *eps);
SEE ALSO
abs, arg, re, im
@@ -50,8 +50,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: polar,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: polar,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/polar,v $
##
## Under source code control: 1995/10/25 04:03:46

View File

@@ -50,7 +50,7 @@ LIMITS
LINK LIBRARY
void powervalue(VALUE *x, VALUE *y, VALUE *eps, VALUE *result)
NUMBER *qpower(NUMBER *x, NUMBER *y, NUMBER *eps)
COMPLEX *cpower(COMPLEX *x, COMPLEX *y, NUMBER *eps)
COMPLEX *c_power(COMPLEX *x, COMPLEX *y, NUMBER *eps)
SEE ALSO
root
@@ -71,8 +71,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: power,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: power,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/power,v $
##
## Under source code control: 1995/10/25 04:03:46

View File

@@ -47,7 +47,7 @@ LIMITS
LINK LIBRARY
void rootvalue(VALUE *x, VALUE *n, VALUE *eps, VALUE *result)
NUMBER *qroot(NUMBER *x, NUMBER *n, NUMBER *eps)
COMPLEX *qroot(COMPLEX *x, NUMBER *n, NUMBER *eps)
COMPLEX *c_root(COMPLEX *x, NUMBER *n, NUMBER *eps)
SEE ALSO
power
@@ -68,8 +68,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: root,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: root,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/root,v $
##
## Under source code control: 1995/10/25 04:03:46

View File

@@ -31,7 +31,7 @@ LIMITS
LINK LIBRARY
NUMBER *qscale(NUMBER *x, long n)
COMPLEX *cscale(COMPLEX *x, long n)
COMPLEX *c_scale(COMPLEX *x, long n)
MATRIX *matscale(MATRIX *x, long n)
SEE ALSO
@@ -53,8 +53,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: scale,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: scale,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/scale,v $
##
## Under source code control: 1995/12/18 12:34:58

View File

@@ -30,7 +30,7 @@ LIMITS
LINK LIBRARY
NUMBER *qsin(NUMBER *x, NUMBER *eps)
COMPLEX *csin(COMPLEX *x, NUMBER *eps)
COMPLEX *c_sin(COMPLEX *x, NUMBER *eps)
SEE ALSO
cos, tan, sec, csc, cot, epsilon
@@ -51,8 +51,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: sin,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: sin,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sin,v $
##
## Under source code control: 1994/03/19 01:40:28

View File

@@ -123,7 +123,7 @@ LIMITS
none
LINK LIBRARY
COMPLEX *csqrt(COMPLEX *x, NUMBER *ep, long z)
COMPLEX *c_sqrt(COMPLEX *x, NUMBER *ep, long z)
NUMBER *qisqrt(NUMBER *q)
NUMBER *qsqrt(NUMBER *x, NUMBER *ep, long z)
FLAG zsqrt(ZVALUE x, ZVALUE *result, long z)
@@ -147,8 +147,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.2 $
## @(#) $Id: sqrt,v 29.2 2000/06/07 14:02:33 chongo Exp $
## @(#) $Revision: 29.3 $
## @(#) $Id: sqrt,v 29.3 2005/10/18 10:48:29 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sqrt,v $
##
## Under source code control: 1995/09/18 03:54:32

66
value.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: value.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: value.c,v 29.4 2005/10/18 10:43:49 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.c,v $
*
* Under source code control: 1990/02/15 01:48:25
@@ -320,7 +320,7 @@ negvalue(VALUE *vp, VALUE *vres)
vres->v_num = qneg(vp->v_num);
return;
case V_COM:
vres->v_com = cneg(vp->v_com);
vres->v_com = c_neg(vp->v_com);
return;
case V_MAT:
vres->v_mat = matneg(vp->v_mat);
@@ -386,14 +386,14 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qqadd(v1->v_num, v2->v_num);
return;
case TWOVAL(V_COM, V_NUM):
vres->v_com = caddq(v1->v_com, v2->v_num);
vres->v_com = c_addq(v1->v_com, v2->v_num);
return;
case TWOVAL(V_NUM, V_COM):
vres->v_com = caddq(v2->v_com, v1->v_num);
vres->v_com = c_addq(v2->v_com, v1->v_num);
vres->v_type = V_COM;
return;
case TWOVAL(V_COM, V_COM):
vres->v_com = cadd(v1->v_com, v2->v_com);
vres->v_com = c_add(v1->v_com, v2->v_com);
c = vres->v_com;
if (!cisreal(c))
return;
@@ -463,16 +463,16 @@ subvalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qsub(v1->v_num, v2->v_num);
return;
case TWOVAL(V_COM, V_NUM):
vres->v_com = csubq(v1->v_com, v2->v_num);
vres->v_com = c_subq(v1->v_com, v2->v_num);
return;
case TWOVAL(V_NUM, V_COM):
c = csubq(v2->v_com, v1->v_num);
c = c_subq(v2->v_com, v1->v_num);
vres->v_type = V_COM;
vres->v_com = cneg(c);
vres->v_com = c_neg(c);
comfree(c);
return;
case TWOVAL(V_COM, V_COM):
vres->v_com = csub(v1->v_com, v2->v_com);
vres->v_com = c_sub(v1->v_com, v2->v_com);
c = vres->v_com;
if (!cisreal(c))
return;
@@ -549,14 +549,14 @@ mulvalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qmul(v1->v_num, v2->v_num);
return;
case TWOVAL(V_COM, V_NUM):
vres->v_com = cmulq(v1->v_com, v2->v_num);
vres->v_com = c_mulq(v1->v_com, v2->v_num);
break;
case TWOVAL(V_NUM, V_COM):
vres->v_com = cmulq(v2->v_com, v1->v_num);
vres->v_com = c_mulq(v2->v_com, v1->v_num);
vres->v_type = V_COM;
break;
case TWOVAL(V_COM, V_COM):
vres->v_com = cmul(v1->v_com, v2->v_com);
vres->v_com = c_mul(v1->v_com, v2->v_com);
break;
case TWOVAL(V_MAT, V_MAT):
vres->v_mat = matmul(v1->v_mat, v2->v_mat);
@@ -620,7 +620,7 @@ squarevalue(VALUE *vp, VALUE *vres)
vres->v_num = qsquare(vp->v_num);
return;
case V_COM:
vres->v_com = csquare(vp->v_com);
vres->v_com = c_square(vp->v_com);
c = vres->v_com;
if (!cisreal(c))
return;
@@ -664,7 +664,7 @@ invertvalue(VALUE *vp, VALUE *vres)
vres->v_num = qinv(vp->v_num);
return;
case V_COM:
vres->v_com = cinv(vp->v_com);
vres->v_com = c_inv(vp->v_com);
return;
case V_MAT:
vres->v_mat = matinv(vp->v_mat);
@@ -1270,7 +1270,7 @@ intvalue(VALUE *vp, VALUE *vres)
vres->v_com = clink(vp->v_com);
return;
}
vres->v_com = cint(vp->v_com);
vres->v_com = c_int(vp->v_com);
c = vres->v_com;
if (cisreal(c)) {
vres->v_num = qlink(c->real);
@@ -1317,7 +1317,7 @@ fracvalue(VALUE *vp, VALUE *vres)
vres->v_type = V_NUM;
return;
}
vres->v_com = cfrac(vp->v_com);
vres->v_com = c_frac(vp->v_com);
c = vres->v_com;
if (cisreal(c)) {
vres->v_num = qlink(c->real);
@@ -1353,7 +1353,7 @@ incvalue(VALUE *vp, VALUE *vres)
vres->v_num = qinc(vp->v_num);
break;
case V_COM:
vres->v_com = caddq(vp->v_com, &_qone_);
vres->v_com = c_addq(vp->v_com, &_qone_);
break;
case V_OBJ:
*vres = objcall(OBJ_INC, vp, NULL_VALUE, NULL_VALUE);
@@ -1389,7 +1389,7 @@ decvalue(VALUE *vp, VALUE *vres)
vres->v_num = qdec(vp->v_num);
break;
case V_COM:
vres->v_com = caddq(vp->v_com, &_qnegone_);
vres->v_com = c_addq(vp->v_com, &_qnegone_);
break;
case V_OBJ:
*vres = objcall(OBJ_DEC, vp, NULL_VALUE, NULL_VALUE);
@@ -1504,7 +1504,7 @@ sqrtvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
vres->v_type = V_COM;
break;
case V_COM:
vres->v_com = csqrt(v1->v_com, q, R);
vres->v_com = c_sqrt(v1->v_com, q, R);
break;
default:
*vres = error_value(E_SQRT);
@@ -1567,10 +1567,10 @@ rootvalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
ctmp.real = v1->v_num;
ctmp.imag = &_qzero_;
ctmp.links = 1;
c = croot(&ctmp, q2, q3);
c = c_root(&ctmp, q2, q3);
break;
case V_COM:
c = croot(v1->v_com, q2, q3);
c = c_root(v1->v_com, q2, q3);
break;
case V_OBJ:
*vres = objcall(OBJ_ROOT, v1, v2, v3);
@@ -1725,7 +1725,7 @@ shiftvalue(VALUE *v1, VALUE *v2, BOOL rightshift, VALUE *vres)
*vres = error_value(E_SHIFT);
return;
}
c = cshift(v1->v_com, n);
c = c_shift(v1->v_com, n);
if (!cisreal(c)) {
vres->v_com = c;
return;
@@ -1800,7 +1800,7 @@ scalevalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qscale(v1->v_num, n);
return;
case V_COM:
vres->v_com = cscale(v1->v_com, n);
vres->v_com = c_scale(v1->v_com, n);
return;
case V_MAT:
vres->v_mat = matscale(v1->v_mat, n);
@@ -1860,7 +1860,7 @@ powivalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qpowi(v1->v_num, q);
return;
case V_COM:
vres->v_com = cpowi(v1->v_com, q);
vres->v_com = c_powi(v1->v_com, q);
c = vres->v_com;
if (!cisreal(c))
return;
@@ -1916,7 +1916,7 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
ctmp2.real = v2->v_num;
ctmp2.imag = &_qzero_;
ctmp2.links = 1;
c = cpower(&ctmp1, &ctmp2, epsilon);
c = c_power(&ctmp1, &ctmp2, epsilon);
break;
}
vres->v_num = qpower(v1->v_num, v2->v_num, epsilon);
@@ -1928,16 +1928,16 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres)
ctmp1.real = v1->v_num;
ctmp1.imag = &_qzero_;
ctmp1.links = 1;
c = cpower(&ctmp1, v2->v_com, epsilon);
c = c_power(&ctmp1, v2->v_com, epsilon);
break;
case TWOVAL(V_COM, V_NUM):
ctmp2.real = v2->v_num;
ctmp2.imag = &_qzero_;
ctmp2.links = 1;
c = cpower(v1->v_com, &ctmp2, epsilon);
c = c_power(v1->v_com, &ctmp2, epsilon);
break;
case TWOVAL(V_COM, V_COM):
c = cpower(v1->v_com, v2->v_com, epsilon);
c = c_power(v1->v_com, v2->v_com, epsilon);
break;
default:
*vres = error_value(E_POWER);
@@ -1994,7 +1994,7 @@ divvalue(VALUE *v1, VALUE *v2, VALUE *vres)
vres->v_num = qqdiv(v1->v_num, v2->v_num);
return;
case TWOVAL(V_COM, V_NUM):
vres->v_com = cdivq(v1->v_com, v2->v_num);
vres->v_com = c_divq(v1->v_com, v2->v_num);
return;
case TWOVAL(V_NUM, V_COM):
if (qiszero(v1->v_num)) {
@@ -2004,11 +2004,11 @@ divvalue(VALUE *v1, VALUE *v2, VALUE *vres)
ctmp.real = v1->v_num;
ctmp.imag = &_qzero_;
ctmp.links = 1;
vres->v_com = cdiv(&ctmp, v2->v_com);
vres->v_com = c_div(&ctmp, v2->v_com);
vres->v_type = V_COM;
return;
case TWOVAL(V_COM, V_COM):
vres->v_com = cdiv(v1->v_com, v2->v_com);
vres->v_com = c_div(v1->v_com, v2->v_com);
c = vres->v_com;
if (cisreal(c)) {
vres->v_num = qlink(c->real);
@@ -2299,7 +2299,7 @@ comparevalue(VALUE *v1, VALUE *v2)
r = qcmp(v1->v_num, v2->v_num);
break;
case V_COM:
r = ccmp(v1->v_com, v2->v_com);
r = c_cmp(v1->v_com, v2->v_com);
break;
case V_STR:
r = stringcmp(v1->v_str, v2->v_str);

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.54 $
* @(#) $Id: version.c,v 29.54 2004/10/23 01:16:23 chongo Exp $
* @(#) $Revision: 29.55 $
* @(#) $Id: version.c,v 29.55 2005/12/12 06:47:21 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -47,8 +47,8 @@ static char *program;
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 10 /* patch level or 0 if no patch */
#define MINOR_PATCH 1 /* test number or 0 if no minor patch */
#define MAJOR_PATCH 11 /* patch level or 0 if no patch */
#define MINOR_PATCH 0 /* test number or 0 if no minor patch */
/*