mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.4.4
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# @(#) $Revision: 30.4 $
|
||||
# @(#) $Id: Makefile,v 30.4 2010/09/02 06:01:39 chongo Exp $
|
||||
# @(#) $Revision: 30.5 $
|
||||
# @(#) $Id: Makefile,v 30.5 2011/05/23 22:50:18 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1991/07/21 05:00:54
|
||||
@@ -194,7 +194,7 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
|
||||
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
|
||||
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal screen.cal \
|
||||
dotest.cal set8700.cal set8700.line alg_config.cal sumtimes.cal \
|
||||
dms.cal hms.cal
|
||||
dms.cal hms.cal gvec.cal
|
||||
|
||||
# These files are found (but not built) in the distribution
|
||||
#
|
||||
|
11
cal/README
11
cal/README
@@ -298,6 +298,13 @@ ellip.cal
|
||||
Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b.
|
||||
|
||||
|
||||
gvec.cal
|
||||
|
||||
gvec(function, vector)
|
||||
|
||||
Vectorize any single-input function or trailing operator.
|
||||
|
||||
|
||||
hello.cal
|
||||
|
||||
Calc's contribution to the Hello World! page:
|
||||
@@ -1058,8 +1065,8 @@ xx_print.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## @(#) $Revision: 30.2 $
|
||||
## @(#) $Id: README,v 30.2 2010/09/02 06:01:39 chongo Exp $
|
||||
## @(#) $Revision: 30.3 $
|
||||
## @(#) $Id: README,v 30.3 2011/05/23 22:50:32 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
|
107
cal/gvec.cal
Normal file
107
cal/gvec.cal
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* gvec - vectorize any single-input function or trailing operator
|
||||
*
|
||||
* This version accepts arbitrary number of arguments, but of course
|
||||
* they must all be same length vectors.
|
||||
*
|
||||
* The gvec function is for use in either a two-arg function or a two-arg
|
||||
* operation "function" must be first; calc doesn't care how many more
|
||||
* arguments there actually are.
|
||||
*
|
||||
* @(#) $Revision: 30.3 $
|
||||
* @(#) $Id: gvec.cal,v 30.3 2011/05/23 23:00:55 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/gvec.cal,v $
|
||||
*
|
||||
* Under source code control: 2011/03/31 17:54:55
|
||||
* File existed as early as: 2010
|
||||
*
|
||||
* By Carl Witthoft carl at witthoft dot com
|
||||
*/
|
||||
|
||||
define gvec(function, vector)
|
||||
{
|
||||
local xlen,y,foo;
|
||||
local precx = 1e-50; /* default for now */
|
||||
local argc = param(0)-1;
|
||||
local old_tilde; /* previous config("tilde") */
|
||||
|
||||
/*
|
||||
* parse args
|
||||
*/
|
||||
local plist = mat[argc];
|
||||
if (config("resource_debug") & 8) {
|
||||
print "plist=", plist;
|
||||
print "argc=", argc;
|
||||
}
|
||||
for(local i = 0; i< argc; i++) {
|
||||
local ii = i + 2;
|
||||
if (config("resource_debug") & 8) {
|
||||
print "ii=", ii;
|
||||
print "param(" : ii : "}=", param(ii);
|
||||
print "size(param(" : ii : ")=", size(param(ii));
|
||||
}
|
||||
plist[i] = size(param(ii));
|
||||
}
|
||||
local slist=sort(plist);
|
||||
if (config("resource_debug") & 8) {
|
||||
print "plist=", plist;
|
||||
}
|
||||
local argm = argc-1;
|
||||
if (config("resource_debug") & 8) {
|
||||
print "argm=", argm;
|
||||
}
|
||||
if (slist[0] != slist[argm]) {
|
||||
quit "lengths don't match";
|
||||
}
|
||||
xlen = size(vector);
|
||||
y = mat[xlen];
|
||||
|
||||
/*
|
||||
* We can't do str(vector[j]) outside loop, eval() petulantly refuses to
|
||||
* look at local variables.
|
||||
*
|
||||
* Also we need to config("tilde",0) to turn off lead tilde
|
||||
* (so str(vector[j]) looks like a number.
|
||||
*/
|
||||
old_tilde = config("tilde",0);
|
||||
|
||||
/*
|
||||
* Ok, now check to see if "function" is a function. If not, it's an
|
||||
* operation and it's up to user to make it valid
|
||||
*/
|
||||
if (isdefined(function)) {
|
||||
|
||||
/* yep, it's a function, either builtin or user-defined */
|
||||
for (local j=0; j<xlen; j++) {
|
||||
|
||||
/* build the function call */
|
||||
foo = strcat(function, "(");
|
||||
for (local jj = 0; jj<argc; jj++) {
|
||||
foo = strcat(foo , str(param(jj+2)[j]), ",");
|
||||
}
|
||||
foo = strcat(foo, str(precx), ")");
|
||||
if (config("resource_debug") & 8) {
|
||||
print "foo=", foo;
|
||||
}
|
||||
y[j] = eval(foo);
|
||||
}
|
||||
|
||||
/*
|
||||
* it is an operator -- multi-argument operator makes no sense
|
||||
*/
|
||||
} else {
|
||||
if (argc > 1) {
|
||||
quit "Error: operator can accept only one argument";
|
||||
}
|
||||
for (j=0; j<xlen; j++) {
|
||||
foo = strcat(str(vector[j]), function);
|
||||
y[j] = eval(foo);
|
||||
}
|
||||
}
|
||||
|
||||
/* restore tilde mode if needed */
|
||||
config("tilde", old_tilde);
|
||||
|
||||
/* return result */
|
||||
return y;
|
||||
}
|
Reference in New Issue
Block a user