1 ;;; calc-menu.el --- a menu for Calc
3 ;; Copyright (C) 2007 Free Software Foundation, Inc.
5 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
26 (defvar calc-arithmetic-menu
29 ["-(1:)" calc-change-sign
:keys
"n"]
30 ["(2:) + (1:)" calc-plus
:keys
"+"]
31 ["(2:) - (1:)" calc-minus
:keys
"-"]
32 ["(2:) * (1:)" calc-times
:keys
"*"]
33 ["(2:) / (1:)" calc-divide
:keys
"/"]
34 ["(2:) ^ (1:)" calc-power
:keys
"^"]
38 (let ((calc-inverse-flag t
))
39 (call-interactively 'calc-power
)))
41 :help
"The (1:)th root of (2:)"]
45 (call-interactively 'calc-abs
))
47 :help
"Absolute value"]
51 (call-interactively 'calc-inv
))
56 (call-interactively 'calc-sqrt
))
61 (call-interactively 'calc-idiv
))
63 :help
"The integer quotient of (2:) over (1:)"]
67 (call-interactively 'calc-mod
))
69 :help
"The remainder when (2:) is divided by (1:)"])
74 (call-interactively 'calc-floor
))
76 :help
"The greatest integer less than or equal to (1:)"]
80 (call-interactively 'calc-ceiling
))
82 :help
"The smallest integer greater than or equal to (1:)"]
86 (call-interactively 'calc-round
))
88 :help
"The nearest integer to (1:)"]
92 (call-interactively 'calc-trunc
))
94 :help
"The integer part of (1:)"])
95 (list "Complex Numbers"
99 (call-interactively 'calc-re
))
104 (call-interactively 'calc-im
))
109 (call-interactively 'calc-conj
))
111 :help
"The complex conjugate of (1:)"]
113 (progn (require 'calc-arith
)
114 (call-interactively 'calc-abs
))
116 :help
"The length (absolute value) of (1:)"]
120 (call-interactively 'calc-argument
))
122 :help
"The argument (polar angle) of (1:)"])
124 ["Convert (1:) to a float"
127 (call-interactively 'calc-float
))
129 ["Convert (1:) to a fraction"
132 (call-interactively 'calc-fraction
))
138 (call-interactively 'calc-word-size
))
140 ["Clip (1:) to word size"
143 (call-interactively 'calc-clip
))
145 :help
"Reduce (1:) modulo 2^wordsize"]
149 (call-interactively 'calc-and
))
151 :help
"Bitwise AND [modulo 2^wordsize]"]
155 (call-interactively 'calc-or
))
157 :help
"Bitwise inclusive OR [modulo 2^wordsize]"]
161 (call-interactively 'calc-xor
))
163 :help
"Bitwise exclusive OR [modulo 2^wordsize]"]
167 (call-interactively 'calc-diff
))
169 :help
"Bitwise difference [modulo 2^wordsize]"]
173 (call-interactively 'calc-not
))
175 :help
"Bitwise NOT [modulo 2^wordsize]"]
179 (call-interactively 'calc-lshift-binary
))
181 :help
"Shift (1:)[modulo 2^wordsize] one bit left"]
185 (call-interactively 'calc-rshift-binary
))
187 :help
"Shift (1:)[modulo 2^wordsize] one bit right, putting 0s on the left"]
188 ["arithmetic right shift(1:)"
191 (call-interactively 'calc-rshift-arith
))
193 :help
"Shift (1:)[modulo 2^wordsize] one bit right, duplicating the leftmost bit"]
197 (call-interactively 'calc-rotate-binary
))
199 :help
"Rotate (1:)[modulo 2^wordsize] one bit left"])
201 ["Help on Arithmetic"
202 (calc-info-goto-node "Arithmetic")])
203 "Menu for Calc's arithmetic functions.")
205 (defvar calc-scientific-function-menu
206 (list "Scientific Functions"
211 (call-interactively 'calc-pi
))
216 (let ((calc-hyperbolic-flag t
))
217 (call-interactively 'calc-pi
)))
222 (let ((calc-inverse-flag t
)
223 (calc-hyperbolic-flag t
))
224 (call-interactively 'calc-pi
)))
226 :help
"The golden ratio"]
230 (let ((calc-inverse-flag t
))
231 (call-interactively 'calc-pi
)))
233 :help
"Euler's constant"])
234 (list "Logs and Exps"
238 (call-interactively 'calc-ln
))
240 :help
"The natural logarithm"]
244 (call-interactively 'calc-exp
))
249 (call-interactively 'calc-log10
))
251 :help
"The common logarithm"]
255 (let ((calc-inverse-flag t
))
256 (call-interactively 'calc-log10
)))
258 ["log(2:) [base(1:)]"
261 (call-interactively 'calc-log
))
263 :help
"The logarithm with an arbitrary base"]
267 (list "Trigonometric Functions"
271 (call-interactively 'calc-sin
))
276 (call-interactively 'calc-cos
))
281 (call-interactively 'calc-tan
))
286 (call-interactively 'calc-arcsin
))
291 (call-interactively 'calc-arccos
))
296 (call-interactively 'calc-arctan
))
301 (call-interactively 'calc-arctan2
))
310 :selected
(eq calc-angle-mode
'rad
)]
317 :selected
(eq calc-angle-mode
'deg
)]
324 :selected
(eq calc-angle-mode
'hms
)])
325 (list "Hyperbolic Functions"
329 (call-interactively 'calc-sinh
))
334 (call-interactively 'calc-cosh
))
339 (call-interactively 'calc-tanh
))
344 (call-interactively 'calc-arcsinh
))
349 (call-interactively 'calc-arccosh
))
354 (call-interactively 'calc-arctanh
))
356 (list "Advanced Math Functions"
360 (call-interactively 'calc-gamma
))
362 :help
"The Euler Gamma function"]
365 (require 'calc-funcs
)
366 (call-interactively 'calc-inc-gamma
))
368 :help
"The lower incomplete Gamma function"]
371 (require 'calc-funcs
)
372 (call-interactively 'calc-beta
))
374 :help
"The Euler Beta function"]
377 (require 'calc-funcs
)
378 (call-interactively 'calc-inc-beta
))
380 :help
"The incomplete Beta function"]
383 (require 'calc-funcs
)
384 (call-interactively 'calc-erf
))
386 :help
"The error function"]
389 (require 'calc-funcs
)
390 (call-interactively 'calc-bessel-J
))
392 :help
"The Bessel function of the first kind (of order (2:))"]
395 (require 'calc-funcs
)
396 (call-interactively 'calc-bessel-Y
))
398 :help
"The Bessel function of the second kind (of order (2:))"])
399 (list "Combinatorial Functions"
403 (call-interactively 'calc-gcd
))
408 (call-interactively 'calc-lcm
))
413 (call-interactively 'calc-factorial
))
418 (call-interactively 'calc-choose
))
420 ["permutations(2:,1:)"
423 (call-interactively 'calc-perm
))
425 ["Primality test for (1:)"
428 (call-interactively 'calc-prime-test
))
430 :help
"For large (1:), a probabilistic test"]
431 ["Factor (1:) into primes"
434 (call-interactively 'calc-prime-factors
))
436 ["Next prime after (1:)"
439 (call-interactively 'calc-next-prime
))
441 ["Previous prime before (1:)"
444 (call-interactively 'calc-prev-prime
))
449 (call-interactively 'calc-totient
))
451 :help
"Euler's totient function"]
455 (call-interactively 'calc-random
))
457 :help
"A random number >=1 and < (1:)"])
459 ["Help on Scientific Functions"
460 (calc-info-goto-node "Scientific Functions")])
461 "Menu for Calc's scientific functions.")
463 (defvar calc-algebra-menu
465 (list "Simplification"
469 (call-interactively 'calc-simplify
))
471 ["Simplify (1:) with extended rules"
474 (call-interactively 'calc-simplify-extended
))
476 :help
"Apply possibly unsafe simplifications"])
478 ["Expand formula (1:)"
481 (call-interactively 'calc-expand-formula
))
483 :help
"Expand (1:) into its defining formula, if possible"]
484 ["Evaluate variables in (1:)"
487 (call-interactively 'calc-evaluate
))
489 ["Make substitution in (1:)"
492 (call-interactively 'calc-substitute
))
495 "Substitute all occurrences of a sub-expression with a new sub-expression"])
500 (call-interactively 'calc-factor
))
502 ["Collect terms in (1:)"
505 (call-interactively 'calc-collect
))
507 :help
"Arrange as a polynomial in a given variable"]
511 (call-interactively 'calc-expand
))
513 :help
"Apply distributive law everywhere"]
514 ["Find roots of (1:)"
517 (call-interactively 'calc-poly-roots
))
520 ["Differentiate (1:)"
523 (call-interactively 'calc-derivative
))
525 ["Integrate (1:) [indefinite]"
528 (call-interactively 'calc-integral
))
530 ["Integrate (1:) [definite]"
533 (let ((var (read-string "Integration variable: ")))
534 (calc-tabular-command 'calcFunc-integ
"Integration"
535 "intg" nil var nil nil
)))
537 ["Integrate (1:) [numeric]"
540 (call-interactively 'calc-num-integral
))
542 :help
"Integrate using the open Romberg method"]
543 ["Taylor expand (1:)"
546 (call-interactively 'calc-taylor
))
548 ["Minimize (2:) [initial guess = (1:)]"
551 (call-interactively 'calc-find-minimum
))
553 :help
"Find a local minimum"]
554 ["Maximize (2:) [initial guess = (1:)]"
557 (call-interactively 'calc-find-maximum
))
559 :help
"Find a local maximum"])
561 ["Solve equation (1:)"
564 (call-interactively 'calc-solve-for
))
566 ["Solve equation (2:) numerically [initial guess = (1:)]"
569 (call-interactively 'calc-find-root
))
571 ["Find roots of polynomial (1:)"
574 (call-interactively 'calc-poly-roots
))
576 (list "Curve Fitting"
577 ["Fit (1:)=[x values, y values] to a curve"
580 (call-interactively 'calc-curve-fit
))
584 (calc-info-goto-node "Algebra")])
585 "Menu for Calc's algebraic facilities.")
588 (defvar calc-graphics-menu
590 ["Graph 2D [(1:)= y values, (2:)= x values]"
592 (require 'calc-graph
)
593 (call-interactively 'calc-graph-fast
))
595 ["Graph 3D [(1:)= z values, (2:)= y values, (3:)= x values]"
597 (require 'calc-graph
)
598 (call-interactively 'calc-graph-fast-3d
))
602 (calc-info-goto-node "Graphics")])
603 "Menu for Calc's graphics.")
606 (defvar calc-vectors-menu
607 (list "Matrices/Vectors"
609 ["(2:) + (1:)" calc-plus
:keys
"+"]
610 ["(2:) - (1:)" calc-minus
:keys
"-"]
611 ["(2:) * (1:)" calc-times
:keys
"*"]
614 (require 'calc-arith
)
615 (call-interactively 'calc-inv
))
617 ["Create an identity matrix"
620 (call-interactively 'calc-ident
))
625 (call-interactively 'calc-transpose
))
630 (call-interactively 'calc-mdet
))
635 (call-interactively 'calc-mtrace
))
637 ["LUD decompose (1:)"
640 (call-interactively 'calc-mlud
))
642 ["Extract a row from (1:)"
645 (call-interactively 'calc-mrow
))
647 ["Extract a column from (1:)"
650 (call-interactively 'calc-mcol
))
653 ["Extract the first element of (1:)"
656 (call-interactively 'calc-head
))
658 ["Extract an element from (1:)"
661 (call-interactively 'calc-mrow
))
666 (call-interactively 'calc-reverse-vector
))
671 (call-interactively 'calc-unpack
))
673 :help
"Separate the elements of (1:)"]
677 (call-interactively 'calc-cross
))
679 :help
"The cross product in R^3"]
683 :help
"The dot product"]
684 ["Map a function across (1:)"
687 (call-interactively 'calc-map
))
689 :help
"Apply a function to each element"])
690 (list "Vectors As Sets"
691 ["Remove duplicates from (1:)"
694 (call-interactively 'calc-remove-duplicates
))
699 (call-interactively 'calc-set-union
))
701 ["(2:) intersect (1:)"
704 (call-interactively 'calc-set-intersect
))
709 (call-interactively 'calc-set-difference
))
711 :help
"Set difference"])
712 (list "Statistics On Vectors"
716 (call-interactively 'calc-vector-count
))
718 :help
"The number of data values"]
722 (call-interactively 'calc-vector-sum
))
724 :help
"The sum of the data values"]
728 (call-interactively 'calc-vector-max
))
730 :help
"The maximum of the data values"]
734 (call-interactively 'calc-vector-min
))
736 :help
"The minumum of the data values"]
740 (call-interactively 'calc-vector-mean
))
742 :help
"The average (arithmetic mean) of the data values"]
743 ["mean(1:) with error"
746 (call-interactively 'calc-vector-mean-error
))
748 :help
"The average (arithmetic mean) of the data values as an error form"]
752 (call-interactively 'calc-vector-sdev
))
754 :help
"The sample sdev, sqrt[sum((values - mean)^2)/(N-1)]"]
758 (call-interactively 'calc-vector-variance
))
760 :help
"The sample variance, sum((values - mean)^2)/(N-1)"]
761 ["population sdev(1:)"
764 (call-interactively 'calc-vector-pop-sdev
))
766 :help
"The population sdev, sqrt[sum((values - mean)^2)/N]"]
767 ["population variance(1:)"
770 (call-interactively 'calc-vector-pop-variance
))
772 :help
"The population variance, sum((values - mean)^2)/N"]
776 (call-interactively 'calc-vector-median
))
778 :help
"The median of the data values"]
782 (call-interactively 'calc-vector-harmonic-mean
))
784 ["geometric mean(1:)"
787 (call-interactively 'calc-vector-geometric-mean
))
789 ["arithmetic-geometric mean(1:)"
792 (let ((calc-hyperbolic-flag t
))
793 (call-interactively 'calc-vector-geometric-mean
)))
796 (progn (require 'calc-arith
)
797 (call-interactively 'calc-abs
))
799 :help
"The root-mean-square, or quadratic mean"])
800 ["Abbreviate long vectors"
803 (call-interactively 'calc-full-vectors
))
806 :selected
(not calc-full-vectors
)]
808 ["Help on Matrices/Vectors"
809 (calc-info-goto-node "Matrix Functions")])
810 "Menu for Calc's vector and matrix functions.")
812 (defvar calc-units-menu
814 ["Convert units in (1:)"
816 (require 'calc-units
)
817 (call-interactively 'calc-convert-units
))
819 ["Convert temperature in (1:)"
821 (require 'calc-units
)
822 (call-interactively 'calc-convert-temperature
))
824 ["Simplify units in (1:)"
826 (require 'calc-units
)
827 (call-interactively 'calc-simplify-units
))
831 (require 'calc-units
)
832 (call-interactively 'calc-view-units-table
))
836 (calc-info-goto-node "Units")])
837 "Menu for Calc's units functions.")
839 (defvar calc-variables-menu
841 ["Store (1:) into a variable"
843 (require 'calc-store
)
844 (call-interactively 'calc-store
))
846 ["Recall a variable value"
848 (require 'calc-store
)
849 (call-interactively 'calc-recall
))
851 ["Edit the value of a variable"
853 (require 'calc-store
)
854 (call-interactively 'calc-edit-variable
))
856 ["Exchange (1:) with a variable value"
858 (require 'calc-store
)
859 (call-interactively 'calc-store-exchange
))
861 ["Clear variable value"
863 (require 'calc-store
)
864 (call-interactively 'calc-unstore
))
866 ["Evaluate variables in (1:)"
869 (call-interactively 'calc-evaluate
))
871 ["Evaluate (1:), assigning a value to a variable"
873 (require 'calc-store
)
874 (call-interactively 'calc-let
))
876 :help
"Evaluate (1:) under a temporary assignment of a variable"]
879 (calc-info-goto-node "Store and Recall")])
880 "Menu for Calc's variables.")
882 (defvar calc-stack-menu
887 ["Switch (1:) and (2:)"
896 (call-interactively calc-edit
))
900 (calc-info-goto-node "Stack and Trail")])
901 "Menu for Calc's stack functions.")
903 (defvar calc-errors-menu
908 (call-interactively 'calc-undo
))
913 (call-interactively 'calc-redo
))
918 (calc-info-goto-node "Introduction")
919 (Info-goto-node "Undo"))]))
921 (defvar calc-modes-menu
926 (call-interactively 'calc-precision
))
928 :help
"Set the precision for floating point calculations"]
932 (call-interactively 'calc-frac-mode
))
935 :selected calc-prefer-frac
936 :help
"Leave integer quotients as fractions"]
941 (calc-symbolic-mode nil
))
944 :selected calc-symbolic-mode
945 :help
"Leave functions producing inexact answers in symbolic form"]
950 (calc-infinite-mode nil
))
953 :selected calc-infinite-mode
954 :help
"Let expressions like 1/0 produce infinite results"]
955 ["Abbreviate long vectors"
958 (call-interactively 'calc-full-vectors
))
961 :selected
(not calc-full-vectors
)]
962 (list "Angle Measure"
966 (call-interactively 'calc-radians-mode
))
969 :selected
(eq calc-angle-mode
'rad
)]
973 (call-interactively 'calc-degrees-mode
))
976 :selected
(eq calc-angle-mode
'deg
)]
980 (call-interactively 'calc-hms-mode
))
983 :selected
(eq calc-angle-mode
'hms
)])
988 (call-interactively 'calc-decimal-radix
))
991 :selected
(= calc-number-radix
10)]
995 (call-interactively 'calc-binary-radix
))
998 :selected
(= calc-number-radix
2)]
1002 (call-interactively 'calc-octal-radix
))
1005 :selected
(= calc-number-radix
8)]
1009 (call-interactively 'calc-hex-radix
))
1012 :selected
(= calc-number-radix
16)]
1016 (call-interactively 'calc-radix
))
1021 (= calc-number-radix
10)
1022 (= calc-number-radix
2)
1023 (= calc-number-radix
8)
1024 (= calc-number-radix
16)))])
1025 (list "Float Format"
1028 (require 'calc-mode
)
1029 (call-interactively 'calc-normal-notation
))
1032 :selected
(eq (car-safe calc-float-format
) 'float
)]
1035 (require 'calc-mode
)
1036 (call-interactively 'calc-fix-notation
))
1039 :selected
(eq (car-safe calc-float-format
) 'fix
)]
1040 ["Scientific notation"
1042 (require 'calc-mode
)
1043 (call-interactively 'calc-sci-notation
))
1046 :selected
(eq (car-safe calc-float-format
) 'sci
)]
1047 ["Engineering notation"
1049 (require 'calc-mode
)
1050 (call-interactively 'calc-eng-notation
))
1053 :selected
(eq (car-safe calc-float-format
) 'eng
)])
1057 (require 'calc-mode
)
1058 (call-interactively 'calc-algebraic-mode
))
1061 :selected
(eq calc-algebraic-mode t
)
1062 :help
"Keys which start numeric entry also start algebraic entry"]
1063 ["Total algebraic mode"
1065 (require 'calc-mode
)
1066 (call-interactively 'calc-total-algebraic-mode
))
1069 :selected
(eq calc-algebraic-mode
'total
)
1070 :help
"All regular letters and punctuation begin algebraic entry"])
1074 (require 'calc-lang
)
1075 (call-interactively 'calc-normal-language
))
1078 :selected
(eq calc-language nil
)]
1081 (require 'calc-lang
)
1082 (call-interactively 'calc-big-language
))
1085 :selected
(eq calc-language
'big
)
1086 :help
"Use textual approximations to various mathematical notations"]
1089 (require 'calc-lang
)
1090 (call-interactively 'calc-flat-language
))
1093 :selected
(eq calc-language
'flat
)
1094 :help
"Write matrices on a single line"]
1097 (require 'calc-lang
)
1098 (call-interactively 'calc-c-language
))
1101 :selected
(eq calc-language
'c
)]
1104 (require 'calc-lang
)
1105 (call-interactively 'calc-pascal-language
))
1108 :selected
(eq calc-language
'pascal
)]
1111 (require 'calc-lang
)
1112 (call-interactively 'calc-fortran-language
))
1115 :selected
(eq calc-language
'fortran
)]
1118 (require 'calc-lang
)
1119 (call-interactively 'calc-tex-language
))
1122 :selected
(eq calc-language
'tex
)]
1125 (require 'calc-lang
)
1126 (call-interactively 'calc-latex-language
))
1129 :selected
(eq calc-language
'latex
)]
1132 (require 'calc-lang
)
1133 (call-interactively 'calc-eqn-language
))
1136 :selected
(eq calc-language
'eqn
)])
1138 ["Save mode settings" calc-save-modes
:keys
"m m"]
1141 (calc-info-goto-node "Mode settings")])
1142 "Menu for Calc's mode settings.")
1144 (defvar calc-help-menu
1158 (calc-info-goto-node "Introduction")
1159 (Info-goto-node "Help Commands"))])
1160 "Menu for Calc's help functions.")
1162 (defvar calc-mode-map
)
1169 :visible
'(eq major-mode
'calc-mode
)
1170 calc-arithmetic-menu
1171 calc-scientific-function-menu
1184 (call-interactively 'calc-reset
))
1185 :help
"Reset Calc to its initial state"]
1186 ["Quit" calc-quit
]))
1188 (provide 'calc-menu
)
1190 ;; arch-tag: 9612c86a-cd4f-4baa-ab0b-40af7344d21f