annotate lisp/calc/calc-map.el @ 105630:e2e6510fb5ca

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 16 Oct 2009 04:32:23 +0000
parents a9dc0e7c3f2b
children 05e547365764
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
1 ;;; calc-map.el --- higher-order functions for Calc
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
2
64325
1db49616ce05 Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62442
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 94654
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
5
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
6 ;; Author: David Gillespie <daveg@synaptics.com>
77465
1154f082efd9 Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 76595
diff changeset
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
94654
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
76595
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94654
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15
76595
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
19 ;; GNU General Public License for more details.
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
20
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94654
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
24 ;;; Commentary:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
26 ;;; Code:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;; This file is autoloaded from calc-ext.el.
58662
257705b8481e Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58549
diff changeset
29
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 (require 'calc-ext)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 (require 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 (defun calc-apply (&optional oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 (oper (or oper (calc-get-operator "Apply"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 (if (math-vectorp (calc-top 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 (1- (length (calc-top 1)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 -1))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44 (expr (calc-top-n (1+ calc-dollar-used))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 (calc-enter-result (1+ calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 (concat (substring "apl" 0 (- 4 (length (nth 2 oper))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 (list 'calcFunc-apply
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 (math-calcFunc-to-var (nth 1 oper))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
52 expr)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 (defun calc-reduce (&optional oper accum)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58 (nest (calc-is-hyperbolic))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (rev (calc-is-inverse))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 (nargs (if (and nest (not rev)) 2 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 (calc-mapping-dir (and (not accum) (not nest) ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65 (oper (or oper (calc-get-operator
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 (if nest
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 (concat (if accum "Accumulate " "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 (if rev "Fixed Point" "Nest"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 (concat (if rev "Inv " "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70 (if accum "Accumulate" "Reduce")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 (if nest 1 2)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 (calc-enter-result (+ calc-dollar-used nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75 (concat (substring (if nest
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 (if rev "fxp" "nst")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77 (if accum "acc" "red"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 0 (- 4 (length (nth 2 oper))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 (if nest
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 (cons (if rev
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 (if accum 'calcFunc-afixp 'calcFunc-fixp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 (if accum 'calcFunc-anest 'calcFunc-nest))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 (cons (math-calcFunc-to-var (nth 1 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 (calc-top-list-n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 nargs (1+ calc-dollar-used))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 (list (if accum
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 (if rev 'calcFunc-raccum 'calcFunc-accum)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 (intern (concat "calcFunc-"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 (if rev "r" "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 "reduce"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 calc-mapping-dir)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 (math-calcFunc-to-var (nth 1 oper))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
94 (calc-top-n (1+ calc-dollar-used))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 (defun calc-accumulate (&optional oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 (interactive)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
98 (calc-reduce oper t))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 (defun calc-map (&optional oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 (calc-mapping-dir "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 (oper (or oper (calc-get-operator "Map")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 (nargs (car oper)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 (calc-enter-result (+ nargs calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 (concat (substring "map" 0 (- 4 (length (nth 2 oper))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114 (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 (cons (intern (concat "calcFunc-map" calc-mapping-dir))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 (cons (math-calcFunc-to-var (nth 1 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 (calc-top-list-n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 nargs
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
119 (1+ calc-dollar-used))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 (defun calc-map-equation (&optional oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 (oper (or oper (calc-get-operator "Map-equation")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (nargs (car oper)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 (calc-enter-result (+ nargs calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (concat (substring "map" 0 (- 4 (length (nth 2 oper))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (cons (if (calc-is-inverse)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 'calcFunc-mapeqr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (if (calc-is-hyperbolic)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 'calcFunc-mapeqp 'calcFunc-mapeq))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (cons (math-calcFunc-to-var (nth 1 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (calc-top-list-n
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 nargs
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
142 (1+ calc-dollar-used))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
144 (defvar calc-verify-arglist t)
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
145 (defvar calc-mapping-dir nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (defun calc-map-stack ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 "This is meant to be called by calc-keypad mode."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (let ((calc-verify-arglist nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 (calc-unread-command ?\$)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
151 (calc-map)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 (defun calc-outer-product (&optional oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 (oper (or oper (calc-get-operator "Outer" 2))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 (calc-enter-result (+ 2 calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 (concat (substring "out" 0 (- 4 (length (nth 2 oper))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 (cons 'calcFunc-outer
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 (cons (math-calcFunc-to-var (nth 1 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 (calc-top-list-n
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
169 2 (1+ calc-dollar-used))))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 (defun calc-inner-product (&optional mul-oper add-oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 (let* ((sel-mode nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 (calc-dollar-values (mapcar 'calc-get-stack-element
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 (nthcdr calc-stack-top calc-stack)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 (mul-oper (or mul-oper (calc-get-operator "Inner (Mult)" 2)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 (mul-used calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 (calc-dollar-values (if (> mul-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 (cdr calc-dollar-values)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 calc-dollar-values))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 (add-oper (or add-oper (calc-get-operator "Inner (Add)" 2))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 (message "Working...")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 (calc-set-command-flag 'clear-message)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 (calc-enter-result (+ 2 mul-used calc-dollar-used)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 (concat "in"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 (substring (nth 2 mul-oper) 0 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 (substring (nth 2 add-oper) 0 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 (nconc (list 'calcFunc-inner
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 (math-calcFunc-to-var (nth 1 mul-oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 (math-calcFunc-to-var (nth 1 add-oper)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 (calc-top-list-n
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
195 2 (+ 1 mul-used calc-dollar-used)))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
197 (defconst calc-oper-keys '( ( ( ?+ 2 calcFunc-add )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
198 ( ?- 2 calcFunc-sub )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
199 ( ?* 2 calcFunc-mul )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
200 ( ?/ 2 calcFunc-div )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
201 ( ?^ 2 calcFunc-pow )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
202 ( ?| 2 calcFunc-vconcat )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
203 ( ?% 2 calcFunc-mod )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
204 ( ?\\ 2 calcFunc-idiv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
205 ( ?! 1 calcFunc-fact )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
206 ( ?& 1 calcFunc-inv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
207 ( ?n 1 calcFunc-neg )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
208 ( ?x user )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
209 ( ?z user )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
210 ( ?A 1 calcFunc-abs )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
211 ( ?J 1 calcFunc-conj )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
212 ( ?G 1 calcFunc-arg )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
213 ( ?Q 1 calcFunc-sqrt )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
214 ( ?N 2 calcFunc-min )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
215 ( ?X 2 calcFunc-max )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
216 ( ?F 1 calcFunc-floor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
217 ( ?R 1 calcFunc-round )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
218 ( ?S 1 calcFunc-sin )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
219 ( ?C 1 calcFunc-cos )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
220 ( ?T 1 calcFunc-tan )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
221 ( ?L 1 calcFunc-ln )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
222 ( ?E 1 calcFunc-exp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
223 ( ?B 2 calcFunc-log ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
224 ( ( ?F 1 calcFunc-ceil ) ; inverse
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
225 ( ?R 1 calcFunc-trunc )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
226 ( ?Q 1 calcFunc-sqr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
227 ( ?S 1 calcFunc-arcsin )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
228 ( ?C 1 calcFunc-arccos )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
229 ( ?T 1 calcFunc-arctan )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
230 ( ?L 1 calcFunc-exp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
231 ( ?E 1 calcFunc-ln )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
232 ( ?B 2 calcFunc-alog )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
233 ( ?^ 2 calcFunc-nroot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
234 ( ?| 2 calcFunc-vconcatrev ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
235 ( ( ?F 1 calcFunc-ffloor ) ; hyperbolic
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
236 ( ?R 1 calcFunc-fround )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
237 ( ?S 1 calcFunc-sinh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
238 ( ?C 1 calcFunc-cosh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
239 ( ?T 1 calcFunc-tanh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
240 ( ?L 1 calcFunc-log10 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
241 ( ?E 1 calcFunc-exp10 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
242 ( ?| 2 calcFunc-append ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
243 ( ( ?F 1 calcFunc-fceil ) ; inverse-hyperbolic
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
244 ( ?R 1 calcFunc-ftrunc )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
245 ( ?S 1 calcFunc-arcsinh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
246 ( ?C 1 calcFunc-arccosh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
247 ( ?T 1 calcFunc-arctanh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
248 ( ?L 1 calcFunc-exp10 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
249 ( ?E 1 calcFunc-log10 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
250 ( ?| 2 calcFunc-appendrev ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
251
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
252 (defconst calc-a-oper-keys '( ( ( ?a 3 calcFunc-apart )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
253 ( ?b 3 calcFunc-subst )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
254 ( ?c 2 calcFunc-collect )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
255 ( ?d 2 calcFunc-deriv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
256 ( ?e 1 calcFunc-esimplify )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
257 ( ?f 2 calcFunc-factor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
258 ( ?g 2 calcFunc-pgcd )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
259 ( ?i 2 calcFunc-integ )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
260 ( ?m 2 calcFunc-match )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
261 ( ?n 1 calcFunc-nrat )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
262 ( ?r 2 calcFunc-rewrite )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
263 ( ?s 1 calcFunc-simplify )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
264 ( ?t 3 calcFunc-taylor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
265 ( ?x 1 calcFunc-expand )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
266 ( ?M 2 calcFunc-mapeq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
267 ( ?N 3 calcFunc-minimize )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
268 ( ?P 2 calcFunc-roots )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
269 ( ?R 3 calcFunc-root )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
270 ( ?S 2 calcFunc-solve )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
271 ( ?T 4 calcFunc-table )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
272 ( ?X 3 calcFunc-maximize )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
273 ( ?= 2 calcFunc-eq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
274 ( ?\# 2 calcFunc-neq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
275 ( ?< 2 calcFunc-lt )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
276 ( ?> 2 calcFunc-gt )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
277 ( ?\[ 2 calcFunc-leq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
278 ( ?\] 2 calcFunc-geq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
279 ( ?{ 2 calcFunc-in )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
280 ( ?! 1 calcFunc-lnot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
281 ( ?& 2 calcFunc-land )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
282 ( ?\| 2 calcFunc-lor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
283 ( ?: 3 calcFunc-if )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
284 ( ?. 2 calcFunc-rmeq )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
285 ( ?+ 4 calcFunc-sum )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
286 ( ?- 4 calcFunc-asum )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
287 ( ?* 4 calcFunc-prod )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
288 ( ?_ 2 calcFunc-subscr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
289 ( ?\\ 2 calcFunc-pdiv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
290 ( ?% 2 calcFunc-prem )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
291 ( ?/ 2 calcFunc-pdivrem ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
292 ( ( ?m 2 calcFunc-matchnot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
293 ( ?M 2 calcFunc-mapeqr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
294 ( ?S 2 calcFunc-finv ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
295 ( ( ?d 2 calcFunc-tderiv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
296 ( ?f 2 calcFunc-factors )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
297 ( ?M 2 calcFunc-mapeqp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
298 ( ?N 3 calcFunc-wminimize )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
299 ( ?R 3 calcFunc-wroot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
300 ( ?S 2 calcFunc-fsolve )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
301 ( ?X 3 calcFunc-wmaximize )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
302 ( ?/ 2 calcFunc-pdivide ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
303 ( ( ?S 2 calcFunc-ffinv ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
304
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
305 (defconst calc-b-oper-keys '( ( ( ?a 2 calcFunc-and )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
306 ( ?o 2 calcFunc-or )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
307 ( ?x 2 calcFunc-xor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
308 ( ?d 2 calcFunc-diff )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
309 ( ?n 1 calcFunc-not )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
310 ( ?c 1 calcFunc-clip )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
311 ( ?l 2 calcFunc-lsh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
312 ( ?r 2 calcFunc-rsh )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
313 ( ?L 2 calcFunc-ash )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
314 ( ?R 2 calcFunc-rash )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
315 ( ?t 2 calcFunc-rot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
316 ( ?p 1 calcFunc-vpack )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
317 ( ?u 1 calcFunc-vunpack )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
318 ( ?D 4 calcFunc-ddb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
319 ( ?F 3 calcFunc-fv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
320 ( ?I 1 calcFunc-irr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
321 ( ?M 3 calcFunc-pmt )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
322 ( ?N 2 calcFunc-npv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
323 ( ?P 3 calcFunc-pv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
324 ( ?S 3 calcFunc-sln )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
325 ( ?T 3 calcFunc-rate )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
326 ( ?Y 4 calcFunc-syd )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
327 ( ?\# 3 calcFunc-nper )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
328 ( ?\% 2 calcFunc-relch ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
329 ( ( ?F 3 calcFunc-fvb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
330 ( ?I 1 calcFunc-irrb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
331 ( ?M 3 calcFunc-pmtb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
332 ( ?N 2 calcFunc-npvb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
333 ( ?P 3 calcFunc-pvb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
334 ( ?T 3 calcFunc-rateb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
335 ( ?\# 3 calcFunc-nperb ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
336 ( ( ?F 3 calcFunc-fvl )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
337 ( ?M 3 calcFunc-pmtl )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
338 ( ?P 3 calcFunc-pvl )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
339 ( ?T 3 calcFunc-ratel )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
340 ( ?\# 3 calcFunc-nperl ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
341
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
342 (defconst calc-c-oper-keys '( ( ( ?d 1 calcFunc-deg )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
343 ( ?r 1 calcFunc-rad )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
344 ( ?h 1 calcFunc-hms )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
345 ( ?f 1 calcFunc-float )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
346 ( ?F 1 calcFunc-frac ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
347
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
348 (defconst calc-f-oper-keys '( ( ( ?b 2 calcFunc-beta )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
349 ( ?e 1 calcFunc-erf )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
350 ( ?g 1 calcFunc-gamma )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
351 ( ?h 2 calcFunc-hypot )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
352 ( ?i 1 calcFunc-im )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
353 ( ?j 2 calcFunc-besJ )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
354 ( ?n 2 calcFunc-min )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
355 ( ?r 1 calcFunc-re )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
356 ( ?s 1 calcFunc-sign )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
357 ( ?x 2 calcFunc-max )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
358 ( ?y 2 calcFunc-besY )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
359 ( ?A 1 calcFunc-abssqr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
360 ( ?B 3 calcFunc-betaI )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
361 ( ?E 1 calcFunc-expm1 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
362 ( ?G 2 calcFunc-gammaP )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
363 ( ?I 2 calcFunc-ilog )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
364 ( ?L 1 calcFunc-lnp1 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
365 ( ?M 1 calcFunc-mant )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
366 ( ?Q 1 calcFunc-isqrt )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
367 ( ?S 1 calcFunc-scf )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
368 ( ?T 2 calcFunc-arctan2 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
369 ( ?X 1 calcFunc-xpon )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
370 ( ?\[ 2 calcFunc-decr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
371 ( ?\] 2 calcFunc-incr ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
372 ( ( ?e 1 calcFunc-erfc )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
373 ( ?E 1 calcFunc-lnp1 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
374 ( ?G 2 calcFunc-gammaQ )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
375 ( ?L 1 calcFunc-expm1 ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
376 ( ( ?B 3 calcFunc-betaB )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
377 ( ?G 2 calcFunc-gammag) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
378 ( ( ?G 2 calcFunc-gammaG ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
379
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
380 (defconst calc-k-oper-keys '( ( ( ?b 1 calcFunc-bern )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
381 ( ?c 2 calcFunc-choose )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
382 ( ?d 1 calcFunc-dfact )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
383 ( ?e 1 calcFunc-euler )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
384 ( ?f 1 calcFunc-prfac )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
385 ( ?g 2 calcFunc-gcd )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
386 ( ?h 2 calcFunc-shuffle )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
387 ( ?l 2 calcFunc-lcm )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
388 ( ?m 1 calcFunc-moebius )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
389 ( ?n 1 calcFunc-nextprime )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
390 ( ?r 1 calcFunc-random )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
391 ( ?s 2 calcFunc-stir1 )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
392 ( ?t 1 calcFunc-totient )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
393 ( ?B 3 calcFunc-utpb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
394 ( ?C 2 calcFunc-utpc )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
395 ( ?F 3 calcFunc-utpf )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
396 ( ?N 3 calcFunc-utpn )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
397 ( ?P 2 calcFunc-utpp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
398 ( ?T 2 calcFunc-utpt ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
399 ( ( ?n 1 calcFunc-prevprime )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
400 ( ?B 3 calcFunc-ltpb )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
401 ( ?C 2 calcFunc-ltpc )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
402 ( ?F 3 calcFunc-ltpf )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
403 ( ?N 3 calcFunc-ltpn )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
404 ( ?P 2 calcFunc-ltpp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
405 ( ?T 2 calcFunc-ltpt ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
406 ( ( ?b 2 calcFunc-bern )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
407 ( ?c 2 calcFunc-perm )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
408 ( ?e 2 calcFunc-euler )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
409 ( ?s 2 calcFunc-stir2 ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
410
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
411 (defconst calc-s-oper-keys '( ( ( ?: 2 calcFunc-assign )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
412 ( ?= 1 calcFunc-evalto ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
413
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
414 (defconst calc-t-oper-keys '( ( ( ?C 3 calcFunc-tzconv )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
415 ( ?D 1 calcFunc-date )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
416 ( ?I 2 calcFunc-incmonth )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
417 ( ?J 1 calcFunc-julian )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
418 ( ?M 1 calcFunc-newmonth )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
419 ( ?W 1 calcFunc-newweek )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
420 ( ?U 1 calcFunc-unixtime )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
421 ( ?Y 1 calcFunc-newyear ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
422
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
423 (defconst calc-u-oper-keys '( ( ( ?C 2 calcFunc-vcov )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
424 ( ?G 1 calcFunc-vgmean )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
425 ( ?M 1 calcFunc-vmean )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
426 ( ?N 1 calcFunc-vmin )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
427 ( ?S 1 calcFunc-vsdev )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
428 ( ?X 1 calcFunc-vmax ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
429 ( ( ?C 2 calcFunc-vpcov )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
430 ( ?M 1 calcFunc-vmeane )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
431 ( ?S 1 calcFunc-vpsdev ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
432 ( ( ?C 2 calcFunc-vcorr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
433 ( ?G 1 calcFunc-agmean )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
434 ( ?M 1 calcFunc-vmedian )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
435 ( ?S 1 calcFunc-vvar ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
436 ( ( ?M 1 calcFunc-vhmean )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
437 ( ?S 1 calcFunc-vpvar ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
438
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
439 (defconst calc-v-oper-keys '( ( ( ?a 2 calcFunc-arrange )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
440 ( ?b 2 calcFunc-cvec )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
441 ( ?c 2 calcFunc-mcol )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
442 ( ?d 2 calcFunc-diag )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
443 ( ?e 2 calcFunc-vexp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
444 ( ?f 2 calcFunc-find )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
445 ( ?h 1 calcFunc-head )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
446 ( ?k 2 calcFunc-cons )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
447 ( ?l 1 calcFunc-vlen )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
448 ( ?m 2 calcFunc-vmask )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
449 ( ?n 1 calcFunc-rnorm )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
450 ( ?p 2 calcFunc-pack )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
451 ( ?r 2 calcFunc-mrow )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
452 ( ?s 3 calcFunc-subvec )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
453 ( ?t 1 calcFunc-trn )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
454 ( ?u 1 calcFunc-unpack )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
455 ( ?v 1 calcFunc-rev )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
456 ( ?x 1 calcFunc-index )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
457 ( ?A 1 calcFunc-apply )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
458 ( ?C 1 calcFunc-cross )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
459 ( ?D 1 calcFunc-det )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
460 ( ?E 1 calcFunc-venum )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
461 ( ?F 1 calcFunc-vfloor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
462 ( ?G 1 calcFunc-grade )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
463 ( ?H 2 calcFunc-histogram )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
464 ( ?I 2 calcFunc-inner )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
465 ( ?L 1 calcFunc-lud )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
466 ( ?M 0 calcFunc-map )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
467 ( ?N 1 calcFunc-cnorm )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
468 ( ?O 2 calcFunc-outer )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
469 ( ?R 1 calcFunc-reduce )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
470 ( ?S 1 calcFunc-sort )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
471 ( ?T 1 calcFunc-tr )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
472 ( ?U 1 calcFunc-accum )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
473 ( ?V 2 calcFunc-vunion )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
474 ( ?X 2 calcFunc-vxor )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
475 ( ?- 2 calcFunc-vdiff )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
476 ( ?^ 2 calcFunc-vint )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
477 ( ?~ 1 calcFunc-vcompl )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
478 ( ?# 1 calcFunc-vcard )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
479 ( ?: 1 calcFunc-vspan )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
480 ( ?+ 1 calcFunc-rdup ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
481 ( ( ?h 1 calcFunc-tail )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
482 ( ?s 3 calcFunc-rsubvec )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
483 ( ?G 1 calcFunc-rgrade )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
484 ( ?R 1 calcFunc-rreduce )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
485 ( ?S 1 calcFunc-rsort )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
486 ( ?U 1 calcFunc-raccum ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
487 ( ( ?e 3 calcFunc-vexp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
488 ( ?h 1 calcFunc-rhead )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
489 ( ?k 2 calcFunc-rcons )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
490 ( ?H 3 calcFunc-histogram )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
491 ( ?R 2 calcFunc-nest )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
492 ( ?U 2 calcFunc-anest ) )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
493 ( ( ?h 1 calcFunc-rtail )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
494 ( ?R 1 calcFunc-fixp )
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
495 ( ?U 1 calcFunc-afixp ) )))
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
496
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
497
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 ;;; Return a list of the form (nargs func name)
72039
51e3097b320a (calc-get-operator-history): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
499 (defvar calc-get-operator-history nil
51e3097b320a (calc-get-operator-history): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
500 "History for calc-get-operator.")
51e3097b320a (calc-get-operator-history): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
501
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 (defun calc-get-operator (msg &optional nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 (setq calc-aborted-prefix nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504 (let ((inv nil) (hyp nil) (prefix nil) (forcenargs nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 done key oper (which 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 (msgs '( "(Press ? for help)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 "+, -, *, /, ^, %, \\, :, &, !, |, Neg"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 "SHIFT + Abs, conJ, arG; maX, miN; Floor, Round; sQrt"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509 "SHIFT + Inv, Hyp; Sin, Cos, Tan; Exp, Ln, logB"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 "Algebra + Simp, Esimp, Deriv, Integ, !, =, etc."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 "Binary + And, Or, Xor, Diff; l/r/t/L/R shifts; Not, Clip"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512 "Conversions + Deg, Rad, HMS; Float; SHIFT + Fraction"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513 "Functions + Re, Im; Hypot; Mant, Expon, Scale; etc."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514 "Kombinatorics + Dfact, Lcm, Gcd, Choose; Random; etc."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 "Time/date + newYear, Incmonth, etc."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 "Vectors + Length, Row, Col, Diag, Mask, etc."
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517 "_ = mapr/reducea, : = mapc/reduced, = = reducer"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518 "X or Z = any function by name; ' = alg entry; $ = stack")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
519 (while (not done)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
520 (message "%s%s: %s: %s%s%s"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 msg
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
522 (cond ((equal calc-mapping-dir "r") " rows")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 ((equal calc-mapping-dir "c") " columns")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
524 ((equal calc-mapping-dir "a") " across")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 ((equal calc-mapping-dir "d") " down")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526 (t ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527 (if forcenargs
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 (format "(%d arg%s)"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529 forcenargs (if (= forcenargs 1) "" "s"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 (nth which msgs))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 (if inv "Inv " "") (if hyp "Hyp " "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532 (if prefix (concat (char-to-string prefix) "-") ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
533 (setq key (read-char))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534 (if (>= key 128) (setq key (- key 128)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
535 (cond ((memq key '(?\C-g ?q))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
536 (keyboard-quit))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537 ((memq key '(?\C-u ?\e)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 ((= key ??)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
539 (setq which (% (1+ which) (length msgs))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540 ((and (= key ?I) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541 (setq inv (not inv)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 ((and (= key ?H) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543 (setq hyp (not hyp)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
544 ((and (eq key prefix) (not (eq key ?v)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 (setq prefix nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
546 ((and (memq key '(?a ?b ?c ?f ?k ?s ?t ?u ?v ?V))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547 (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
548 (setq prefix (downcase key)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
549 ((and (eq key ?\=) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550 (if calc-mapping-dir
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
551 (setq calc-mapping-dir (if (equal calc-mapping-dir "r")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552 "" "r"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
553 (beep)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 ((and (eq key ?\_) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555 (if calc-mapping-dir
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 (if (string-match "map$" msg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
557 (setq calc-mapping-dir (if (equal calc-mapping-dir "r")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
558 "" "r"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
559 (setq calc-mapping-dir (if (equal calc-mapping-dir "a")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
560 "" "a")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
561 (beep)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
562 ((and (eq key ?\:) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
563 (if calc-mapping-dir
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
564 (if (string-match "map$" msg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
565 (setq calc-mapping-dir (if (equal calc-mapping-dir "c")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
566 "" "c"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
567 (setq calc-mapping-dir (if (equal calc-mapping-dir "d")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
568 "" "d")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
569 (beep)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570 ((and (>= key ?0) (<= key ?9) (null prefix))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 (setq forcenargs (if (eq forcenargs (- key ?0)) nil (- key ?0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572 (and nargs forcenargs (/= nargs forcenargs) (>= nargs 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
573 (error "Must be a %d-argument operator" nargs)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
574 ((memq key '(?\$ ?\'))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 (let* ((arglist nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576 (has-args nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577 (record-entry nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 (expr (if (eq key ?\$)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
579 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
580 (setq calc-dollar-used 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
581 (if calc-dollar-values
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 (car calc-dollar-values)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
583 (error "Stack underflow")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
584 (let* ((calc-dollar-values calc-arg-values)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 (calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 (calc-hashes-used 0)
72039
51e3097b320a (calc-get-operator-history): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
587 (func (calc-do-alg-entry "" "Function: " nil
51e3097b320a (calc-get-operator-history): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 68636
diff changeset
588 'calc-get-operator-history)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
589 (setq record-entry t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
590 (or (= (length func) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
591 (error "Bad format"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
592 (if (> calc-dollar-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
593 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 (setq has-args calc-dollar-used
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595 arglist (calc-invent-args has-args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
596 (math-multi-subst (car func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
597 (reverse arglist)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
598 arglist))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
599 (if (> calc-hashes-used 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
600 (setq has-args calc-hashes-used
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601 arglist (calc-invent-args has-args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
602 (car func))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603 (if (eq (car-safe expr) 'calcFunc-lambda)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
604 (setq oper (list "$" (- (length expr) 2) expr)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
605 done t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
606 (or has-args
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
607 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
608 (calc-default-formula-arglist expr)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
609 (setq record-entry t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
610 arglist (sort arglist 'string-lessp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
611 (if calc-verify-arglist
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
612 (setq arglist (read-from-minibuffer
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
613 "Function argument list: "
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
614 (if arglist
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
615 (prin1-to-string arglist)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
616 "()")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
617 minibuffer-local-map
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
618 t)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
619 (setq arglist (mapcar (function
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
620 (lambda (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
621 (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
622 x
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
623 (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
624 (concat
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
625 "var-"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
626 (symbol-name x))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
627 arglist))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
628 (setq oper (list "$"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
629 (length arglist)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
630 (append '(calcFunc-lambda) arglist
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
631 (list expr)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
632 done t))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
633 (if record-entry
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
634 (calc-record (nth 2 oper) "oper"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
635 ((setq oper (assq key (nth (if inv (if hyp 3 1) (if hyp 2 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
636 (if prefix
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
637 (symbol-value
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
638 (intern (format "calc-%c-oper-keys"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
639 prefix)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
640 calc-oper-keys))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
641 (if (eq (nth 1 oper) 'user)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
642 (let ((func (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
643 (completing-read "Function name: "
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
644 obarray 'fboundp
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
645 nil "calcFunc-"))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
646 (if (or forcenargs nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
647 (setq oper (list "z" (or forcenargs nargs) func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
648 done t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
649 (if (fboundp func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
650 (let* ((defn (symbol-function func)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
651 (and (symbolp defn)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
652 (setq defn (symbol-function defn)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
653 (if (eq (car-safe defn) 'lambda)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
654 (let ((args (nth 1 defn))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
655 (nargs 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
656 (while (not (memq (car args) '(&optional
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
657 &rest nil)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
658 (setq nargs (1+ nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
659 args (cdr args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
660 (setq oper (list "z" nargs func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
661 done t))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
662 (error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
663 "Function is not suitable for this operation")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
664 (message "Number of arguments: ")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
665 (let ((nargs (read-char)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
666 (if (and (>= nargs ?0) (<= nargs ?9))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
667 (setq oper (list "z" (- nargs ?0) func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
668 done t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
669 (beep))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
670 (if (or (and (eq prefix ?v) (memq key '(?A ?I ?M ?O ?R ?U)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
671 (and (eq prefix ?a) (eq key ?M)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
672 (let* ((dir (cond ((and (equal calc-mapping-dir "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
673 (string-match "map$" msg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
674 (setq calc-mapping-dir "r")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
675 " rows")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
676 ((equal calc-mapping-dir "r") " rows")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
677 ((equal calc-mapping-dir "c") " columns")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
678 ((equal calc-mapping-dir "a") " across")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
679 ((equal calc-mapping-dir "d") " down")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
680 (t "")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
681 (calc-mapping-dir (and (memq (nth 2 oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
682 '(calcFunc-map
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
683 calcFunc-reduce
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
684 calcFunc-rreduce))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
685 ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
686 (oper2 (calc-get-operator
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
687 (format "%s%s, %s%s" msg dir
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
688 (substring (symbol-name (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
689 9)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
690 (if (eq key ?I) " (mult)" ""))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
691 (cdr (assq (nth 2 oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
692 '((calcFunc-reduce . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
693 (calcFunc-rreduce . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
694 (calcFunc-accum . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
695 (calcFunc-raccum . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
696 (calcFunc-nest . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
697 (calcFunc-anest . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
698 (calcFunc-fixp . 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
699 (calcFunc-afixp . 2))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
700 (oper3 (if (eq (nth 2 oper) 'calcFunc-inner)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
701 (calc-get-operator
53867
ee106e4fa2d8 (calc-get-operator): Remove extra format
Andreas Schwab <schwab@suse.de>
parents: 52401
diff changeset
702 (format "%s%s, inner (add)" msg dir))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
703 '(0 0 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
704 (args nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
705 (nargs (if (> (nth 1 oper) 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
706 (nth 1 oper)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
707 (car oper2)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
708 (n nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
709 (p calc-arg-values))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
710 (while (and p (> n 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
711 (or (math-expr-contains (nth 1 oper2) (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
712 (math-expr-contains (nth 1 oper3) (car p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
713 (setq args (nconc args (list (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
714 n (1- n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
715 (setq p (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
716 (setq oper (list "" nargs
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
717 (append
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
718 '(calcFunc-lambda)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
719 args
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
720 (list (math-build-call
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
721 (intern
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
722 (concat
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
723 (symbol-name (nth 2 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
724 calc-mapping-dir))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
725 (cons (math-calcFunc-to-var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
726 (nth 1 oper2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
727 (if (eq key ?I)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
728 (cons
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
729 (math-calcFunc-to-var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
730 (nth 1 oper3))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
731 args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
732 args))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
733 done t))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
734 (setq done t))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
735 (t (beep))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
736 (and nargs (>= nargs 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
737 (/= nargs (nth 1 oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
738 (error "Must be a %d-argument operator" nargs))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
739 (append (if forcenargs
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
740 (cons forcenargs (cdr (cdr oper)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
741 (cdr oper))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
742 (list
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
743 (let ((name (concat (if inv "I" "") (if hyp "H" "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
744 (if prefix (char-to-string prefix) "")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
745 (char-to-string key))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
746 (if (> (length name) 3)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
747 (substring name 0 3)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
748 name))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
749
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
750
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
751 ;;; Convert a variable name (as a formula) into a like-looking function name.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
752 (defun math-var-to-calcFunc (f)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
753 (if (eq (car-safe f) 'var)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
754 (if (fboundp (nth 2 f))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
755 (nth 2 f)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
756 (intern (concat "calcFunc-" (symbol-name (nth 1 f)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
757 (if (memq (car-safe f) '(lambda calcFunc-lambda))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
758 f
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
759 (math-reject-arg f "*Expected a function name"))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
760
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
761 ;;; Convert a function name into a like-looking variable name formula.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
762 (defun math-calcFunc-to-var (f)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
763 (if (symbolp f)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
764 (let* ((func (or (cdr (assq f '( ( + . calcFunc-add )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
765 ( - . calcFunc-sub )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
766 ( * . calcFunc-mul )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
767 ( / . calcFunc-div )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
768 ( ^ . calcFunc-pow )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
769 ( % . calcFunc-mod )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
770 ( neg . calcFunc-neg )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
771 ( | . calcFunc-vconcat ) )))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
772 f))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
773 (base (if (string-match "\\`calcFunc-\\(.+\\)\\'"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
774 (symbol-name func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
775 (math-match-substring (symbol-name func) 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
776 (symbol-name func))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
777 (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
778 (intern base)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
779 (intern (concat "var-" base))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
780 f))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
781
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
782 ;;; Expand a function call using "lambda" notation.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
783 (defun math-build-call (f args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
784 (if (eq (car-safe f) 'calcFunc-lambda)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
785 (if (= (length args) (- (length f) 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
786 (math-multi-subst (nth (1- (length f)) f) (cdr f) args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
787 (calc-record-why "*Wrong number of arguments" f)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
788 (cons 'calcFunc-call (cons (math-calcFunc-to-var f) args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
789 (if (and (eq f 'calcFunc-neg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
790 (= (length args) 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
791 (list 'neg (car args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
792 (let ((func (assq f '( ( calcFunc-add . + )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
793 ( calcFunc-sub . - )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
794 ( calcFunc-mul . * )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
795 ( calcFunc-div . / )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
796 ( calcFunc-pow . ^ )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
797 ( calcFunc-mod . % )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
798 ( calcFunc-vconcat . | ) ))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
799 (if (and func (= (length args) 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
800 (cons (cdr func) args)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
801 (cons f args))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
802
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
803 ;;; Do substitutions in parallel to avoid crosstalk.
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
804
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
805 ;; The variables math-ms-temp and math-ms-args are local to
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
806 ;; math-multi-subst, but are used by math-multi-subst-rec, which
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
807 ;; is called by math-multi-subst.
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
808 (defvar math-ms-temp)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
809 (defvar math-ms-args)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
810
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
811 (defun math-multi-subst (expr olds news)
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
812 (let ((math-ms-args nil)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
813 math-ms-temp)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
814 (while (and olds news)
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
815 (setq math-ms-args (cons (cons (car olds) (car news)) math-ms-args)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
816 olds (cdr olds)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
817 news (cdr news)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
818 (math-multi-subst-rec expr)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
819
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
820 (defun math-multi-subst-rec (expr)
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
821 (cond ((setq math-ms-temp (assoc expr math-ms-args))
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
822 (cdr math-ms-temp))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
823 ((Math-primp expr) expr)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
824 ((and (eq (car expr) 'calcFunc-lambda) (> (length expr) 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
825 (let ((new (list (car expr)))
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
826 (math-ms-args math-ms-args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
827 (while (cdr (setq expr (cdr expr)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
828 (setq new (cons (car expr) new))
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
829 (if (assoc (car expr) math-ms-args)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
830 (setq math-ms-args (cons (cons (car expr) (car expr))
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
831 math-ms-args))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
832 (nreverse (cons (math-multi-subst-rec (car expr)) new))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
833 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
834 (cons (car expr)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
835 (mapcar 'math-multi-subst-rec (cdr expr))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
836
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
837 (defun calcFunc-call (f &rest args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
838 (setq args (math-build-call (math-var-to-calcFunc f) args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
839 (if (eq (car-safe args) 'calcFunc-call)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
840 args
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
841 (math-normalize args)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
842
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
843 (defun calcFunc-apply (f args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
844 (or (Math-vectorp args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
845 (math-reject-arg args 'vectorp))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
846 (apply 'calcFunc-call (cons f (cdr args))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
847
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
848
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
849
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
850
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
851 ;;; Map a function over a vector symbolically. [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
852 (defun math-symb-map (f mode args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
853 (let* ((func (math-var-to-calcFunc f))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
854 (nargs (length args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
855 (ptrs (vconcat args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
856 (vflags (make-vector nargs nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
857 (heads '(vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
858 (head nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
859 (vec nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
860 (i -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
861 (math-working-step 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
862 (math-working-step-2 nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
863 len cols obj expr)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
864 (if (eq mode 'eqn)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
865 (setq mode 'elems
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
866 heads '(calcFunc-eq calcFunc-neq calcFunc-lt calcFunc-gt
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
867 calcFunc-leq calcFunc-geq))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
868 (while (and (< (setq i (1+ i)) nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
869 (not (math-matrixp (aref ptrs i)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
870 (if (< i nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
871 (if (eq mode 'elems)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
872 (setq func (list 'lambda '(&rest x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
873 (list 'math-symb-map
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
874 (list 'quote f) '(quote elems) 'x))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
875 mode 'rows)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
876 (if (eq mode 'cols)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
877 (while (< i nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
878 (if (math-matrixp (aref ptrs i))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
879 (aset ptrs i (math-transpose (aref ptrs i))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
880 (setq i (1+ i)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
881 (setq mode 'elems))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
882 (setq i -1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
883 (while (< (setq i (1+ i)) nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
884 (setq obj (aref ptrs i))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
885 (if (and (memq (car-safe obj) heads)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
886 (or (eq mode 'elems)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
887 (math-matrixp obj)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
888 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
889 (aset vflags i t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
890 (if head
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
891 (if (cdr heads)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
892 (setq head (nth
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
893 (aref (aref [ [0 1 2 3 4 5]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
894 [1 1 2 3 2 3]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
895 [2 2 2 1 2 1]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
896 [3 3 1 3 1 3]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
897 [4 2 2 1 4 1]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
898 [5 3 1 3 1 5] ]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
899 (- 6 (length (memq head heads))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
900 (- 6 (length (memq (car obj) heads))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
901 heads)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
902 (setq head (car obj)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
903 (if len
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
904 (or (= (length obj) len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
905 (math-dimension-error))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
906 (setq len (length obj))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
907 (or len
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
908 (if (= nargs 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
909 (math-reject-arg (aref ptrs 0) 'vectorp)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
910 (math-reject-arg nil "At least one argument must be a vector")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
911 (setq math-working-step-2 (1- len))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
912 (while (> (setq len (1- len)) 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
913 (setq expr nil
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
914 i -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
915 (while (< (setq i (1+ i)) nargs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
916 (if (aref vflags i)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
917 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
918 (aset ptrs i (cdr (aref ptrs i)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
919 (setq expr (nconc expr (list (car (aref ptrs i))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
920 (setq expr (nconc expr (list (aref ptrs i))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
921 (setq math-working-step (1+ math-working-step)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
922 vec (cons (math-normalize (math-build-call func expr)) vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
923 (setq vec (cons head (nreverse vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
924 (if (and (eq mode 'cols) (math-matrixp vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
925 (math-transpose vec)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
926 vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
927
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
928 (defun calcFunc-map (func &rest args)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
929 (math-symb-map func 'elems args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
930
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
931 (defun calcFunc-mapr (func &rest args)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
932 (math-symb-map func 'rows args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
933
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
934 (defun calcFunc-mapc (func &rest args)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
935 (math-symb-map func 'cols args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
936
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
937 (defun calcFunc-mapa (func arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
938 (if (math-matrixp arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
939 (math-symb-map func 'elems (cdr (math-transpose arg)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
940 (math-symb-map func 'elems arg)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
941
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
942 (defun calcFunc-mapd (func arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
943 (if (math-matrixp arg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
944 (math-symb-map func 'elems (cdr arg))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
945 (math-symb-map func 'elems arg)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
946
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
947 (defun calcFunc-mapeq (func &rest args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
948 (if (and (or (equal func '(var mul var-mul))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
949 (equal func '(var div var-div)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
950 (= (length args) 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
951 (if (math-negp (car args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
952 (let ((func (nth 1 (assq (car-safe (nth 1 args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
953 calc-tweak-eqn-table))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
954 (and func (setq args (list (car args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
955 (cons func (cdr (nth 1 args)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
956 (if (math-negp (nth 1 args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
957 (let ((func (nth 1 (assq (car-safe (car args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
958 calc-tweak-eqn-table))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
959 (and func (setq args (list (cons func (cdr (car args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
960 (nth 1 args))))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
961 (if (or (and (equal func '(var div var-div))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
962 (assq (car-safe (nth 1 args)) calc-tweak-eqn-table))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
963 (equal func '(var neg var-neg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
964 (equal func '(var inv var-inv)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
965 (apply 'calcFunc-mapeqr func args)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
966 (apply 'calcFunc-mapeqp func args)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
967
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
968 (defun calcFunc-mapeqr (func &rest args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
969 (setq args (mapcar (function (lambda (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
970 (let ((func (assq (car-safe x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
971 calc-tweak-eqn-table)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
972 (if func
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
973 (cons (nth 1 func) (cdr x))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
974 x))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
975 args))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
976 (apply 'calcFunc-mapeqp func args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
977
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
978 (defun calcFunc-mapeqp (func &rest args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
979 (if (or (and (memq (car-safe (car args)) '(calcFunc-lt calcFunc-leq))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
980 (memq (car-safe (nth 1 args)) '(calcFunc-gt calcFunc-geq)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
981 (and (memq (car-safe (car args)) '(calcFunc-gt calcFunc-geq))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
982 (memq (car-safe (nth 1 args)) '(calcFunc-lt calcFunc-leq))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
983 (setq args (cons (car args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
984 (cons (list (nth 1 (assq (car (nth 1 args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
985 calc-tweak-eqn-table))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
986 (nth 2 (nth 1 args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
987 (nth 1 (nth 1 args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
988 (cdr (cdr args))))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
989 (math-symb-map func 'eqn args))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
990
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
991
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
992
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
993 ;;; Reduce a function over a vector symbolically. [Public]
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
994 (defun calcFunc-reduce (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
995 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
996 (let (expr row)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
997 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
998 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
999 (setq row (car vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1000 (while (setq row (cdr row))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1001 (setq expr (if expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1002 (if (Math-numberp expr)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1003 (math-normalize
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1004 (math-build-call func (list expr (car row))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1005 (math-build-call func (list expr (car row))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1006 (car row)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1007 (math-normalize expr))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1008 (calcFunc-reducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1009
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1010 (defun calcFunc-rreduce (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1011 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1012 (let (expr row)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1013 (setq func (math-var-to-calcFunc func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1014 vec (reverse (cdr vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1015 (while vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1016 (setq row (reverse (cdr (car vec))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1017 (while row
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1018 (setq expr (if expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1019 (math-build-call func (list (car row) expr))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1020 (car row))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1021 row (cdr row)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1022 (setq vec (cdr vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1023 (math-normalize expr))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1024 (calcFunc-rreducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1025
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1026 (defun calcFunc-reducer (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1027 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1028 (or (math-vectorp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1029 (math-reject-arg vec 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1030 (let ((expr (car (setq vec (cdr vec)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1031 (if expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1032 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1033 (condition-case err
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1034 (and (symbolp func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1035 (let ((lfunc (or (cdr (assq func
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1036 '( (calcFunc-add . math-add)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1037 (calcFunc-sub . math-sub)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1038 (calcFunc-mul . math-mul)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1039 (calcFunc-div . math-div)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1040 (calcFunc-pow . math-pow)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1041 (calcFunc-mod . math-mod)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1042 (calcFunc-vconcat .
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1043 math-concat) )))
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1044 func)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1045 (while (cdr vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1046 (setq expr (funcall lfunc expr (nth 1 vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1047 vec (cdr vec)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1048 (error nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1049 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1050 (setq expr (math-build-call func (list expr (car vec)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1051 (math-normalize expr))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1052 (or (math-identity-value func)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1053 (math-reject-arg vec "*Vector is empty")))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1054
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1055 (defun math-identity-value (func)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1056 (cdr (assq func '( (calcFunc-add . 0) (calcFunc-sub . 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1057 (calcFunc-mul . 1) (calcFunc-div . 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1058 (calcFunc-idiv . 1) (calcFunc-fdiv . 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1059 (calcFunc-min . (var inf var-inf))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1060 (calcFunc-max . (neg (var inf var-inf)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1061 (calcFunc-vconcat . (vec))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1062 (calcFunc-append . (vec)) ))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1063
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1064 (defun calcFunc-rreducer (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1065 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1066 (or (math-vectorp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1067 (math-reject-arg vec 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1068 (if (eq func 'calcFunc-sub) ; do this in a way that looks nicer
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1069 (let ((expr (car (setq vec (cdr vec)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1070 (if expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1071 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1072 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1073 (setq expr (math-build-call func (list expr (car vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1074 func (if (eq func 'calcFunc-sub)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1075 'calcFunc-add 'calcFunc-sub)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1076 (math-normalize expr))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1077 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1078 (let ((expr (car (setq vec (reverse (cdr vec))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1079 (if expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1080 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1081 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1082 (setq expr (math-build-call func (list (car vec) expr))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1083 (math-normalize expr))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1084 (or (math-identity-value func)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1085 (math-reject-arg vec "*Vector is empty"))))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1086
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1087 (defun calcFunc-reducec (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1088 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1089 (calcFunc-reducer func (math-transpose vec))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1090 (calcFunc-reducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1091
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1092 (defun calcFunc-rreducec (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1093 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1094 (calcFunc-rreducer func (math-transpose vec))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1095 (calcFunc-rreducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1096
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1097 (defun calcFunc-reducea (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1098 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1099 (cons 'vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1100 (mapcar (function (lambda (x) (calcFunc-reducer func x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1101 (cdr vec)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1102 (calcFunc-reducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1103
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1104 (defun calcFunc-rreducea (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1105 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1106 (cons 'vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1107 (mapcar (function (lambda (x) (calcFunc-rreducer func x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1108 (cdr vec)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1109 (calcFunc-rreducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1110
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1111 (defun calcFunc-reduced (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1112 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1113 (cons 'vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1114 (mapcar (function (lambda (x) (calcFunc-reducer func x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1115 (cdr (math-transpose vec))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1116 (calcFunc-reducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1117
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1118 (defun calcFunc-rreduced (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1119 (if (math-matrixp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1120 (cons 'vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1121 (mapcar (function (lambda (x) (calcFunc-rreducer func x)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1122 (cdr (math-transpose vec))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1123 (calcFunc-rreducer func vec)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1124
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1125 (defun calcFunc-accum (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1126 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1127 (or (math-vectorp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1128 (math-reject-arg vec 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1129 (let* ((expr (car (setq vec (cdr vec))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1130 (res (list 'vec expr)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1131 (or expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1132 (math-reject-arg vec "*Vector is empty"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1133 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1134 (setq expr (math-build-call func (list expr (car vec)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1135 res (nconc res (list expr))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1136 (math-normalize res)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1137
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1138 (defun calcFunc-raccum (func vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1139 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1140 (or (math-vectorp vec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1141 (math-reject-arg vec 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1142 (let* ((expr (car (setq vec (reverse (cdr vec)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1143 (res (list expr)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1144 (or expr
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1145 (math-reject-arg vec "*Vector is empty"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1146 (while (setq vec (cdr vec))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1147 (setq expr (math-build-call func (list (car vec) expr))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1148 res (cons (list expr) res)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1149 (math-normalize (cons 'vec res))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1150
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1151
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1152 (defun math-nest-calls (func base iters accum tol)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1153 (or (symbolp tol)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1154 (if (math-realp tol)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1155 (or (math-numberp base) (math-reject-arg base 'numberp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1156 (math-reject-arg tol 'realp)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1157 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1158 (or (null iters)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1159 (if (equal iters '(var inf var-inf))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1160 (setq iters nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1161 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1162 (if (math-messy-integerp iters)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1163 (setq iters (math-trunc iters)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1164 (or (integerp iters) (math-reject-arg iters 'fixnump))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1165 (or (not tol) (natnump iters) (math-reject-arg iters 'fixnatnump))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1166 (if (< iters 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1167 (let* ((dummy '(var DummyArg var-DummyArg))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1168 (dummy2 '(var DummyArg2 var-DummyArg2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1169 (finv (math-solve-for (math-build-call func (list dummy2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1170 dummy dummy2 nil)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1171 (or finv (math-reject-arg nil "*Unable to find an inverse"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1172 (if (and (= (length finv) 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1173 (equal (nth 1 finv) dummy))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1174 (setq func (car finv))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1175 (setq func (list 'calcFunc-lambda dummy finv)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1176 (setq iters (- iters)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1177 (math-with-extra-prec 1
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1178 (let ((value base)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1179 (ovalue nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1180 (avalues (list base))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1181 (math-working-step 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1182 (math-working-step-2 iters))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1183 (while (and (or (null iters)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1184 (>= (setq iters (1- iters)) 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1185 (or (null tol)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1186 (null ovalue)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1187 (if (eq tol t)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1188 (not (if (and (Math-numberp value)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1189 (Math-numberp ovalue))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1190 (math-nearly-equal value ovalue)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1191 (Math-equal value ovalue)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1192 (if (math-numberp value)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1193 (Math-lessp tol (math-abs (math-sub value ovalue)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1194 (math-reject-arg value 'numberp)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1195 (setq ovalue value
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1196 math-working-step (1+ math-working-step)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1197 value (math-normalize (math-build-call func (list value))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1198 (if accum
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1199 (setq avalues (cons value avalues))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1200 (if accum
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1201 (cons 'vec (nreverse avalues))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1202 value))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1203
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1204 (defun calcFunc-nest (func base iters)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1205 (math-nest-calls func base iters nil nil))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1206
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1207 (defun calcFunc-anest (func base iters)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1208 (math-nest-calls func base iters t nil))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1209
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1210 (defun calcFunc-fixp (func base &optional iters tol)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1211 (math-nest-calls func base iters nil (or tol t)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1212
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1213 (defun calcFunc-afixp (func base &optional iters tol)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1214 (math-nest-calls func base iters t (or tol t)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1215
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1216
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1217 (defun calcFunc-outer (func a b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1218 (or (math-vectorp a) (math-reject-arg a 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1219 (or (math-vectorp b) (math-reject-arg b 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1220 (setq func (math-var-to-calcFunc func))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1221 (let ((mat nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1222 (while (setq a (cdr a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1223 (setq mat (cons (cons 'vec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1224 (mapcar (function (lambda (x)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1225 (math-build-call func
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1226 (list (car a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1227 x))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1228 (cdr b)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1229 mat)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1230 (math-normalize (cons 'vec (nreverse mat)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1231
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1232
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1233 ;; The variables math-inner-mul-func and math-inner-add-func are
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1234 ;; local to calcFunc-inner, but are used by math-inner-mats,
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1235 ;; which is called by math-inner-mats.
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1236 (defvar math-inner-mul-func)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1237 (defvar math-inner-add-func)
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1238
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1239 (defun calcFunc-inner (math-inner-mul-func math-inner-add-func a b)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1240 (or (math-vectorp a) (math-reject-arg a 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1241 (or (math-vectorp b) (math-reject-arg b 'vectorp))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1242 (if (math-matrixp a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1243 (if (math-matrixp b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1244 (if (= (length (nth 1 a)) (length b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1245 (math-inner-mats a b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1246 (math-dimension-error))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1247 (if (= (length (nth 1 a)) 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1248 (if (= (length a) (length b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1249 (math-inner-mats a (list 'vec b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1250 (math-dimension-error))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1251 (if (= (length (nth 1 a)) (length b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1252 (math-mat-col (math-inner-mats a (math-col-matrix b))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1253 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1254 (math-dimension-error))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1255 (if (math-matrixp b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1256 (nth 1 (math-inner-mats (list 'vec a) b))
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1257 (calcFunc-reduce math-inner-add-func (calcFunc-map math-inner-mul-func a b)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1258
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1259 (defun math-inner-mats (a b)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1260 (let ((mat nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1261 (cols (length (nth 1 b)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1262 row col ap bp accum)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1263 (while (setq a (cdr a))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1264 (setq col cols
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1265 row nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1266 (while (> (setq col (1- col)) 0)
58549
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1267 (setq row (cons (calcFunc-reduce math-inner-add-func
399026e59f7f (math-ms-temp, math-ms-args): New variables.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 53867
diff changeset
1268 (calcFunc-map math-inner-mul-func
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1269 (car a)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1270 (math-mat-col b col)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1271 row)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1272 (setq mat (cons (cons 'vec row) mat)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1273 (cons 'vec (nreverse mat))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1274
58662
257705b8481e Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58549
diff changeset
1275 (provide 'calc-map)
257705b8481e Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58549
diff changeset
1276
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79702
diff changeset
1277 ;; arch-tag: 980eac49-00e0-4870-b72a-e726b74c7990
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1278 ;;; calc-map.el ends here