;;; calc-ext.el --- various extension functions for Calc
-;; Copyright (C) 1990-1993, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2012 Free Software Foundation, Inc.
;; Author: David Gillespie <daveg@synaptics.com>
;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
(declare-function math-vector-is-string "calccomp" (a))
(declare-function math-vector-to-string "calccomp" (a &optional quoted))
(declare-function math-format-radix-float "calc-bin" (a prec))
-(declare-function math-compose-expr "calccomp" (a prec))
+(declare-function math-compose-expr "calccomp" (a prec &optional div))
(declare-function math-abs "calc-arith" (a))
(declare-function math-format-bignum-binary "calc-bin" (a))
(declare-function math-format-bignum-octal "calc-bin" (a))
(define-key calc-mode-map "kT" 'calc-utpt)
(define-key calc-mode-map "l" nil)
- (define-key calc-mode-map "lq" 'calc-logunits-quantity)
- (define-key calc-mode-map "ld" 'calc-logunits-dblevel)
- (define-key calc-mode-map "ln" 'calc-logunits-nplevel)
- (define-key calc-mode-map "l+" 'calc-logunits-add)
- (define-key calc-mode-map "l-" 'calc-logunits-sub)
- (define-key calc-mode-map "l*" 'calc-logunits-mul)
- (define-key calc-mode-map "l/" 'calc-logunits-divide)
+ (define-key calc-mode-map "lq" 'calc-lu-quant)
+ (define-key calc-mode-map "ld" 'calc-db)
+ (define-key calc-mode-map "ln" 'calc-np)
+ (define-key calc-mode-map "l+" 'calc-lu-plus)
+ (define-key calc-mode-map "l-" 'calc-lu-minus)
+ (define-key calc-mode-map "l*" 'calc-lu-times)
+ (define-key calc-mode-map "l/" 'calc-lu-divide)
+ (define-key calc-mode-map "ls" 'calc-spn)
+ (define-key calc-mode-map "lm" 'calc-midi)
+ (define-key calc-mode-map "lf" 'calc-freq)
+
(define-key calc-mode-map "l?" 'calc-l-prefix-help)
(define-key calc-mode-map "m" nil)
(define-key calc-mode-map "mD" 'calc-default-simplify-mode)
(define-key calc-mode-map "mE" 'calc-ext-simplify-mode)
(define-key calc-mode-map "mF" 'calc-settings-file-name)
+ (define-key calc-mode-map "mI" 'calc-basic-simplify-mode)
(define-key calc-mode-map "mM" 'calc-more-recursion-depth)
(define-key calc-mode-map "mN" 'calc-num-simplify-mode)
(define-key calc-mode-map "mO" 'calc-no-simplify-mode)
("calc-stuff" calc-explain-why calcFunc-clean
calcFunc-pclean calcFunc-pfloat calcFunc-pfrac)
- ("calc-units" calcFunc-usimplify calcFunc-lufieldadd
-calcFunc-lupoweradd calcFunc-lufieldsub calcFunc-lupowersub
-calcFunc-lufieldmul calcFunc-lupowermul calcFunc-lufielddiv
-calcFunc-lupowerdiv calcFunc-fieldquant calcFunc-powerquant
-calcFunc-dbfieldlevel calcFunc-dbpowerlevel calcFunc-npfieldlevel
-calcFunc-nppowerlevel
+ ("calc-units" calcFunc-usimplify calcFunc-lufadd calcFunc-lupadd
+calcFunc-lufsub calcFunc-lupsub calcFunc-lufmul calcFunc-lupmul
+calcFunc-lufdiv calcFunc-lupdiv calcFunc-lufquant calcFunc-lupquant
+calcFunc-dbfield calcFunc-dbpower calcFunc-npfield
+calcFunc-nppower calcFunc-spn calcFunc-midi calcFunc-freq
math-build-units-table math-build-units-table-buffer
math-check-unit-name math-convert-temperature math-convert-units
math-extract-units math-remove-units math-simplify-units
calc-hyperbolic-prefix-help calc-inv-hyp-prefix-help calc-option-prefix-help
calc-inverse-prefix-help calc-j-prefix-help calc-k-prefix-help
calc-m-prefix-help calc-r-prefix-help calc-s-prefix-help
-calc-t-prefix-help calc-u-prefix-help calc-ul-prefix-help
+calc-t-prefix-help calc-u-prefix-help calc-l-prefix-help
calc-v-prefix-help)
("calc-incom" calc-begin-complex calc-begin-vector calc-comma
("calc-mode" calc-alg-simplify-mode calc-algebraic-mode
calc-always-load-extensions calc-auto-recompute calc-auto-why
-calc-bin-simplify-mode calc-break-vectors calc-center-justify
-calc-default-simplify-mode calc-display-raw calc-eng-notation
-calc-ext-simplify-mode calc-fix-notation calc-full-trail-vectors
-calc-full-vectors calc-get-modes calc-group-char calc-group-digits
-calc-infinite-mode calc-left-justify calc-left-label
+calc-basic-simplify-mode calc-bin-simplify-mode calc-break-vectors
+calc-center-justify calc-default-simplify-mode calc-display-raw
+calc-eng-notation calc-ext-simplify-mode calc-fix-notation
+calc-full-trail-vectors calc-full-vectors calc-get-modes calc-group-char
+calc-group-digits calc-infinite-mode calc-left-justify calc-left-label
calc-line-breaking calc-line-numbering calc-matrix-brackets
calc-matrix-center-justify calc-matrix-left-justify calc-matrix-mode
calc-matrix-right-justify calc-mode-record-mode calc-no-simplify-mode
calc-enter-units-table calc-explain-units calc-extract-units
calc-get-unit-definition calc-permanent-units calc-quick-units
calc-remove-units calc-simplify-units calc-undefine-unit
-calc-view-units-table calc-logunits-quantity calc-logunits-dblevel
-calc-logunits-nplevel calc-logunits-add calc-logunits-sub
-calc-logunits-mul calc-logunits-divide)
+calc-view-units-table calc-lu-quant calc-db
+calc-np calc-lu-plus calc-lu-minus
+calc-lu-times calc-lu-divide calc-spn calc-midi
+calc-freq)
("calc-vec" calc-arrange-vector calc-build-vector calc-cnorm
calc-conj-transpose calc-cons calc-cross calc-kron calc-diag
(cache-val (intern (concat (symbol-name name) "-cache")))
(last-prec (intern (concat (symbol-name name) "-last-prec")))
(last-val (intern (concat (symbol-name name) "-last"))))
- (list 'progn
-; (list 'defvar cache-prec (if init (math-numdigs (nth 1 init)) -100))
- (list 'defvar cache-prec
- `(cond
- ((consp ,init) (math-numdigs (nth 1 ,init)))
- (,init
- (nth 1 (math-numdigs (eval ,init))))
- (t
- -100)))
- (list 'defvar cache-val
- `(cond
- ((consp ,init) ,init)
- (,init (eval ,init))
- (t ,init)))
- (list 'defvar last-prec -100)
- (list 'defvar last-val nil)
- (list 'setq 'math-cache-list
- (list 'cons
- (list 'quote cache-prec)
- (list 'cons
- (list 'quote last-prec)
- 'math-cache-list)))
- (list 'defun
- name ()
- (list 'or
- (list '= last-prec 'calc-internal-prec)
- (list 'setq
- last-val
- (list 'math-normalize
- (list 'progn
- (list 'or
- (list '>= cache-prec
- 'calc-internal-prec)
- (list 'setq
- cache-val
- (list 'let
- '((calc-internal-prec
- (+ calc-internal-prec
- 4)))
- form)
- cache-prec
- '(+ calc-internal-prec 2)))
- cache-val))
- last-prec 'calc-internal-prec))
- last-val))))
+ `(progn
+; (defvar ,cache-prec ,(if init (math-numdigs (nth 1 init)) -100))
+ (defvar ,cache-prec (cond
+ ((consp ,init) (math-numdigs (nth 1 ,init)))
+ (,init
+ (nth 1 (math-numdigs (eval ,init))))
+ (t
+ -100)))
+ (defvar ,cache-val (cond ((consp ,init) ,init)
+ (,init (eval ,init))
+ (t ,init)))
+ (defvar ,last-prec -100)
+ (defvar ,last-val nil)
+ (setq math-cache-list
+ (cons ',cache-prec
+ (cons ',last-prec
+ math-cache-list)))
+ (defun ,name ()
+ (or (= ,last-prec calc-internal-prec)
+ (setq ,last-val
+ (math-normalize
+ (progn (or (>= ,cache-prec calc-internal-prec)
+ (setq ,cache-val
+ (let ((calc-internal-prec
+ (+ calc-internal-prec 4)))
+ ,form)
+ ,cache-prec (+ calc-internal-prec 2)))
+ ,cache-val))
+ ,last-prec calc-internal-prec))
+ ,last-val))))
(put 'math-defcache 'lisp-indent-hook 2)
;;; Betcha didn't know that pi = 16 atan(1/5) - 4 atan(1/239). [F] [Public]
(memq (nth 2 expr) '(var-inf var-uinf var-nan)))))
;; The variable math-integral-cache is originally declared in calcalg2.el,
-;; but is set by math-defintegral and math-definitegral2.
+;; but is set by math-defintegral and math-defintegral-2.
(defvar math-integral-cache)
(defmacro math-defintegral (funcs &rest code)
(setq math-integral-cache nil)
- (append '(progn)
- (mapcar (function
- (lambda (func)
- (list 'put (list 'quote func) ''math-integral
- (list 'nconc
- (list 'get (list 'quote func) ''math-integral)
- (list 'list
- (list 'function
- (append '(lambda (u))
- code)))))))
- (if (symbolp funcs) (list funcs) funcs))))
+ (cons 'progn
+ (mapcar #'(lambda (func)
+ `(put ',func 'math-integral
+ (nconc
+ (get ',func 'math-integral)
+ (list
+ #'(lambda (u) ,@code)))))
+ (if (symbolp funcs) (list funcs) funcs))))
(put 'math-defintegral 'lisp-indent-hook 1)
(defmacro math-defintegral-2 (funcs &rest code)
(setq math-integral-cache nil)
- (append '(progn)
- (mapcar (function
- (lambda (func)
- (list 'put (list 'quote func) ''math-integral-2
- (list 'nconc
- (list 'get (list 'quote func)
- ''math-integral-2)
- (list 'list
- (list 'function
- (append '(lambda (u v))
- code)))))))
- (if (symbolp funcs) (list funcs) funcs))))
+ (cons 'progn
+ (mapcar #'(lambda (func)
+ `(put ',func 'math-integral-2
+ (nconc
+ (get ',func 'math-integral-2)
+ (list #'(lambda (u v) ,@code)))))
+ (if (symbolp funcs) (list funcs) funcs))))
(put 'math-defintegral-2 'lisp-indent-hook 1)
(defvar var-IntegAfterRules 'calc-IntegAfterRules)
(substring str i))))
str))
-;;; Users can redefine this in their .emacs files.
+;;; Users can redefine this in their init files.
(defvar calc-keypad-user-menu nil
"If non-nil, this describes an additional menu for calc-keypad.
It should contain a list of three rows.