3 |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: David Gillespie <daveg@synaptics.com> |
;; Author: David Gillespie <daveg@synaptics.com> |
6 |
;; Maintainers: D. Goel <deego@gnufans.org> |
;; Maintainer: Jay Belanger <belanger@truman.edu> |
|
;; Colin Walters <walters@debian.org> |
|
7 |
|
|
8 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
9 |
|
|
27 |
;;; Code: |
;;; Code: |
28 |
|
|
29 |
;; This file is autoloaded from calc.el. |
;; This file is autoloaded from calc.el. |
|
(require 'calc) |
|
30 |
|
|
31 |
|
(require 'calc) |
32 |
(require 'calc-macs) |
(require 'calc-macs) |
33 |
|
|
|
(defun calc-Need-calc-misc () nil) |
|
|
|
|
|
|
|
34 |
(defun calc-dispatch-help (arg) |
(defun calc-dispatch-help (arg) |
35 |
"M-# is a prefix key; follow it with one of these letters: |
"M-# is a prefix key; follow it with one of these letters: |
36 |
|
|
228 |
|
|
229 |
;;;; Stack and buffer management. |
;;;; Stack and buffer management. |
230 |
|
|
231 |
|
;; The variable calc-last-why-command is set in calc-do-handly-whys |
232 |
|
;; and used in calc-why (in calc-stuff.el). |
233 |
|
(defvar calc-last-why-command) |
234 |
|
|
235 |
(defun calc-do-handle-whys () |
(defun calc-do-handle-whys () |
236 |
(setq calc-why (sort calc-next-why |
(setq calc-why (sort calc-next-why |
242 |
(and (eq (car (car calc-why)) '*) |
(and (eq (car (car calc-why)) '*) |
243 |
calc-auto-why))) |
calc-auto-why))) |
244 |
(progn |
(progn |
245 |
(calc-extensions) |
(require 'calc-ext) |
246 |
(calc-explain-why (car calc-why) |
(calc-explain-why (car calc-why) |
247 |
(if (eq calc-auto-why t) |
(if (eq calc-auto-why t) |
248 |
(cdr calc-why) |
(cdr calc-why) |
328 |
|
|
329 |
(defun calc-last-args-stub (arg) |
(defun calc-last-args-stub (arg) |
330 |
(interactive "p") |
(interactive "p") |
331 |
(calc-extensions) |
(require 'calc-ext) |
332 |
(calc-last-args arg)) |
(calc-last-args arg)) |
333 |
|
|
334 |
|
|
335 |
(defun calc-power (arg) |
(defun calc-power (arg) |
336 |
(interactive "P") |
(interactive "P") |
337 |
(calc-slow-wrapper |
(calc-slow-wrapper |
338 |
(if (and calc-extensions-loaded |
(if (and (featurep 'calc-ext) |
339 |
(calc-is-inverse)) |
(calc-is-inverse)) |
340 |
(calc-binary-op "root" 'calcFunc-nroot arg nil nil) |
(calc-binary-op "root" 'calcFunc-nroot arg nil nil) |
341 |
(calc-binary-op "^" 'calcFunc-pow arg nil nil '^)))) |
(calc-binary-op "^" 'calcFunc-pow arg nil nil '^)))) |
417 |
When this key is used, calc-ext (the Calculator extensions module) will be |
When this key is used, calc-ext (the Calculator extensions module) will be |
418 |
loaded and the keystroke automatically re-typed." |
loaded and the keystroke automatically re-typed." |
419 |
(interactive "P") |
(interactive "P") |
420 |
(calc-extensions) |
(require 'calc-ext) |
421 |
(if (keymapp (key-binding (char-to-string last-command-char))) |
(if (keymapp (key-binding (char-to-string last-command-char))) |
422 |
(message "%s%c-" (calc-num-prefix-name n) last-command-char)) |
(message "%s%c-" (calc-num-prefix-name n) last-command-char)) |
423 |
(calc-unread-command) |
(calc-unread-command) |
425 |
|
|
426 |
(defun calc-shift-Y-prefix-help () |
(defun calc-shift-Y-prefix-help () |
427 |
(interactive) |
(interactive) |
428 |
(calc-extensions) |
(require 'calc-ext) |
429 |
(calc-do-prefix-help calc-Y-help-msgs "other" ?Y)) |
(calc-do-prefix-help calc-Y-help-msgs "other" ?Y)) |
430 |
|
|
431 |
|
|
464 |
(defun math-concat (v1 v2) |
(defun math-concat (v1 v2) |
465 |
(if (stringp v1) |
(if (stringp v1) |
466 |
(concat v1 v2) |
(concat v1 v2) |
467 |
(calc-extensions) |
(require 'calc-ext) |
468 |
(if (and (or (math-objvecp v1) (math-known-scalarp v1)) |
(if (and (or (math-objvecp v1) (math-known-scalarp v1)) |
469 |
(or (math-objvecp v2) (math-known-scalarp v2))) |
(or (math-objvecp v2) (math-known-scalarp v2))) |
470 |
(append (if (and (math-vectorp v1) |
(append (if (and (math-vectorp v1) |
592 |
|
|
593 |
|
|
594 |
;;; Coerce A to be an integer (by truncation toward zero). [I N] [Public] |
;;; Coerce A to be an integer (by truncation toward zero). [I N] [Public] |
595 |
(defun math-trunc (a &optional prec) |
|
596 |
(cond (prec |
;; The variable math-trunc-prec is local to math-trunc, but used by |
597 |
(calc-extensions) |
;; math-trunc-fancy in calc-arith.el, which is called by math-trunc. |
598 |
(math-trunc-special a prec)) |
|
599 |
|
(defun math-trunc (a &optional math-trunc-prec) |
600 |
|
(cond (math-trunc-prec |
601 |
|
(require 'calc-ext) |
602 |
|
(math-trunc-special a math-trunc-prec)) |
603 |
((Math-integerp a) a) |
((Math-integerp a) a) |
604 |
((Math-looks-negp a) |
((Math-looks-negp a) |
605 |
(math-neg (math-trunc (math-neg a)))) |
(math-neg (math-trunc (math-neg a)))) |
606 |
((eq (car a) 'float) |
((eq (car a) 'float) |
607 |
(math-scale-int (nth 1 a) (nth 2 a))) |
(math-scale-int (nth 1 a) (nth 2 a))) |
608 |
(t (calc-extensions) |
(t (require 'calc-ext) |
609 |
(math-trunc-fancy a)))) |
(math-trunc-fancy a)))) |
610 |
(defalias 'calcFunc-trunc 'math-trunc) |
(defalias 'calcFunc-trunc 'math-trunc) |
611 |
|
|
612 |
;;; Coerce A to be an integer (by truncation toward minus infinity). [I N] |
;;; Coerce A to be an integer (by truncation toward minus infinity). [I N] |
613 |
(defun math-floor (a &optional prec) ; [Public] |
|
614 |
(cond (prec |
;; The variable math-floor-prec is local to math-floor, but used by |
615 |
(calc-extensions) |
;; math-floor-fancy in calc-arith.el, which is called by math-floor. |
616 |
(math-floor-special a prec)) |
|
617 |
|
(defun math-floor (a &optional math-floor-prec) ; [Public] |
618 |
|
(cond (math-floor-prec |
619 |
|
(require 'calc-ext) |
620 |
|
(math-floor-special a math-floor-prec)) |
621 |
((Math-integerp a) a) |
((Math-integerp a) a) |
622 |
((Math-messy-integerp a) (math-trunc a)) |
((Math-messy-integerp a) (math-trunc a)) |
623 |
((Math-realp a) |
((Math-realp a) |
624 |
(if (Math-negp a) |
(if (Math-negp a) |
625 |
(math-add (math-trunc a) -1) |
(math-add (math-trunc a) -1) |
626 |
(math-trunc a))) |
(math-trunc a))) |
627 |
(t (calc-extensions) |
(t (require 'calc-ext) |
628 |
(math-floor-fancy a)))) |
(math-floor-fancy a)))) |
629 |
(defalias 'calcFunc-floor 'math-floor) |
(defalias 'calcFunc-floor 'math-floor) |
630 |
|
|
640 |
(defun calcFunc-inv (m) |
(defun calcFunc-inv (m) |
641 |
(if (Math-vectorp m) |
(if (Math-vectorp m) |
642 |
(progn |
(progn |
643 |
(calc-extensions) |
(require 'calc-ext) |
644 |
(if (math-square-matrixp m) |
(if (math-square-matrixp m) |
645 |
(or (math-with-extra-prec 2 (math-matrix-inv-raw m)) |
(or (math-with-extra-prec 2 (math-matrix-inv-raw m)) |
646 |
(math-reject-arg m "*Singular matrix")) |
(math-reject-arg m "*Singular matrix")) |
670 |
(math-imod a b)) |
(math-imod a b)) |
671 |
((and (Math-anglep a) (Math-anglep b)) |
((and (Math-anglep a) (Math-anglep b)) |
672 |
(math-sub a (math-mul (math-floor (math-div a b)) b))) |
(math-sub a (math-mul (math-floor (math-div a b)) b))) |
673 |
(t (calc-extensions) |
(t (require 'calc-ext) |
674 |
(math-mod-fancy a b)))) |
(math-mod-fancy a b)))) |
675 |
|
|
676 |
|
|
683 |
((Math-zerop a) |
((Math-zerop a) |
684 |
(if (and (Math-scalarp b) (Math-posp b)) |
(if (and (Math-scalarp b) (Math-posp b)) |
685 |
(if (math-floatp b) (math-float a) a) |
(if (math-floatp b) (math-float a) a) |
686 |
(calc-extensions) |
(require 'calc-ext) |
687 |
(math-pow-of-zero a b))) |
(math-pow-of-zero a b))) |
688 |
((or (eq a 1) (eq b 1)) a) |
((or (eq a 1) (eq b 1)) a) |
689 |
((or (equal a '(float 1 0)) (equal b '(float 1 0))) a) |
((or (equal a '(float 1 0)) (equal b '(float 1 0))) a) |
691 |
(if (Math-scalarp a) |
(if (Math-scalarp a) |
692 |
(if (or (math-floatp a) (math-floatp b)) |
(if (or (math-floatp a) (math-floatp b)) |
693 |
'(float 1 0) 1) |
'(float 1 0) 1) |
694 |
(calc-extensions) |
(require 'calc-ext) |
695 |
(math-pow-zero a b))) |
(math-pow-zero a b))) |
696 |
((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a))) |
((and (Math-integerp b) (or (Math-numberp a) (Math-vectorp a))) |
697 |
(if (and (equal a '(float 1 1)) (integerp b)) |
(if (and (equal a '(float 1 1)) (integerp b)) |
699 |
(math-with-extra-prec 2 |
(math-with-extra-prec 2 |
700 |
(math-ipow a b)))) |
(math-ipow a b)))) |
701 |
(t |
(t |
702 |
(calc-extensions) |
(require 'calc-ext) |
703 |
(math-pow-fancy a b)))) |
(math-pow-fancy a b)))) |
704 |
|
|
705 |
(defun math-ipow (a n) ; [O O I] [Public] |
(defun math-ipow (a n) ; [O O I] [Public] |
757 |
" ))) |
" ))) |
758 |
(defalias 'calc-report-bug 'report-calc-bug) |
(defalias 'calc-report-bug 'report-calc-bug) |
759 |
|
|
760 |
|
(provide 'calc-misc) |
761 |
|
|
762 |
;;; arch-tag: 7984d9d0-62e5-41dc-afb8-e904b975f250 |
;;; arch-tag: 7984d9d0-62e5-41dc-afb8-e904b975f250 |
763 |
;;; calc-misc.el ends here |
;;; calc-misc.el ends here |