[gnu.emacs.sources] Patch for Gnu Emacs Calc, 1.05 -> 1.06, part 3/5

daveg@near.cs.caltech.edu (Dave Gillespie) (10/24/90)

#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file calc.patch continued
#
CurArch=3
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
sed 's/^X//' << 'SHAR_EOF' >> calc.patch
X*** 19736,19746 ****
X  			      (math-normalize
X  			       (list 'calcFunc-ln (nth 1 lhs)))))))
X  		 ((not (math-expr-depends (nth 2 lhs) solve-var))
X! 		  (cond ((math-equal-int (nth 2 lhs) 2)
X  			 (math-try-solve-for
X  			  (nth 1 lhs)
X! 			  (math-solve-get-sign
X! 			   (math-normalize (list 'calcFunc-sqrt rhs)))))
X  			(t (math-try-solve-for
X  			    (nth 1 lhs)
X  			    (math-mul
X--- 20274,20293 ----
X  			      (math-normalize
X  			       (list 'calcFunc-ln (nth 1 lhs)))))))
X  		 ((not (math-expr-depends (nth 2 lhs) solve-var))
X! 		  (cond ((and (integerp (nth 2 lhs))
X! 			      (>= (nth 2 lhs) 2)
X! 			      (setq t1 (math-integer-log2 (nth 2 lhs))))
X! 			 (setq t2 rhs)
X! 			 (while (>= (setq t1 (1- t1)) 0)
X! 			   (setq t2 (math-solve-get-sign
X! 				     (list 'calcFunc-sqrt t2))))
X  			 (math-try-solve-for
X  			  (nth 1 lhs)
X! 			  (math-normalize t2)))
X! 			((math-looks-negp (nth 2 lhs))
X! 			 (math-try-solve-for
X! 			  (list '^ (nth 1 lhs) (math-neg (nth 2 lhs)))
X! 			  (math-div 1 rhs)))
X  			(t (math-try-solve-for
X  			    (nth 1 lhs)
X  			    (math-mul
X***************
X*** 19750,19756 ****
X  					(math-div (math-mul
X  						   '(var pi var-pi)
X  						   (math-solve-get-int
X! 						    '(var i var-i)))
X  						  (math-div (nth 2 lhs) 2))
X  				      (math-div (math-mul
X  						 2
X--- 20297,20306 ----
X  					(math-div (math-mul
X  						   '(var pi var-pi)
X  						   (math-solve-get-int
X! 						    '(var i var-i)
X! 						    (and (integerp (nth 2 lhs))
X! 							 (math-abs
X! 							  (nth 2 lhs)))))
X  						  (math-div (nth 2 lhs) 2))
X  				      (math-div (math-mul
X  						 2
X***************
X*** 19757,19768 ****
X  						 (math-mul
X  						  '(var pi var-pi)
X  						  (math-solve-get-int
X! 						   '(var i var-i))))
X  						(nth 2 lhs)))))
X  			     (math-normalize
X! 			      (list '^
X  				    rhs
X! 				    (math-div 1 (nth 2 lhs)))))
X  			    (and sign
X  				 (math-oddp (nth 2 lhs))
X  				 (math-solve-sign sign (nth 2 lhs)))))))))
X--- 20307,20321 ----
X  						 (math-mul
X  						  '(var pi var-pi)
X  						  (math-solve-get-int
X! 						   '(var i var-i)
X! 						   (and (integerp (nth 2 lhs))
X! 							(math-abs
X! 							 (nth 2 lhs))))))
X  						(nth 2 lhs)))))
X  			     (math-normalize
X! 			      (list 'calcFunc-nroot
X  				    rhs
X! 				    (nth 2 lhs))))
X  			    (and sign
X  				 (math-oddp (nth 2 lhs))
X  				 (math-solve-sign sign (nth 2 lhs)))))))))
X***************
X*** 19793,19798 ****
X--- 20346,20512 ----
X  	   nil)))
X  )
X  
X+ (setq math-solve-ranges nil)
X+ 
X+ (defun math-solve-prod (lsoln rsoln)
X+   (cond ((null lsoln)
X+ 	 rsoln)
X+ 	((null rsoln)
X+ 	 lsoln)
X+ 	((eq solve-full 'all)
X+ 	 (cons 'vec (append (cdr lsoln) (cdr rsoln))))
X+ 	(solve-full
X+ 	 (list 'calcFunc-if
X+ 	       (list 'calcFunc-gt (math-solve-get-sign 1) 0)
X+ 	       lsoln
X+ 	       rsoln))
X+ 	(t lsoln))
X+ )
X+ 
X+ ;;; This converts "a x^8 + b x^5 + c x^2" to "(a (x^3)^2 + b (x^3) + c) * x^2".
X+ (defun math-solve-crunch-poly (max-degree)   ; uses "t1", "t3"
X+   (let ((count 0))
X+     (while (and t1 (Math-zerop (car t1)))
X+       (setq t1 (cdr t1)
X+ 	    count (1+ count)))
X+     (and t1
X+ 	 (let* ((degree (1- (length t1)))
X+ 		(scale degree))
X+ 	   (while (and (> scale 1) (= (car t3) 1))
X+ 	     (and (= (% degree scale) 0)
X+ 		  (let ((p t1)
X+ 			(n 0)
X+ 			(new-t1 nil)
X+ 			(okay t))
X+ 		    (while (and p okay)
X+ 		      (if (= (% n scale) 0)
X+ 			  (setq new-t1 (nconc new-t1 (list (car p))))
X+ 			(or (Math-zerop (car p))
X+ 			    (setq okay nil)))
X+ 		      (setq p (cdr p)
X+ 			    n (1+ n)))
X+ 		    (if okay
X+ 			(setq t3 (cons scale (cdr t3))
X+ 			      t1 new-t1))))
X+ 	     (setq scale (1- scale)))
X+ 	   (setq t3 (list (car t3) count))
X+ 	   (<= (1- (length t1)) max-degree))))
X+ )
X+ 
X+ (defun math-solve-linear (var sign b a)
X+   (math-try-solve-for var
X+ 		      (math-div (math-neg b) a)
X+ 		      (math-solve-sign sign a)
X+ 		      t)
X+ )
X+ 
X+ (defun math-solve-quadratic (var c b a)
X+   (math-try-solve-for
X+    var
X+    (if (math-looks-evenp b)
X+        (let ((halfb (math-div b 2)))
X+ 	 (math-div
X+ 	  (math-add
X+ 	   (math-neg halfb)
X+ 	   (math-solve-get-sign
X+ 	    (math-normalize
X+ 	     (list 'calcFunc-sqrt
X+ 		   (math-add (math-sqr halfb)
X+ 			     (math-mul (math-neg c) a))))))
X+ 	  a))
X+      (math-div
X+       (math-add
X+        (math-neg b)
X+        (math-solve-get-sign
X+ 	(math-normalize
X+ 	 (list 'calcFunc-sqrt
X+ 	       (math-add (math-sqr b)
X+ 			 (math-mul 4 (math-mul (math-neg c) a)))))))
X+       (math-mul 2 a)))
X+    nil t)
X+ )
X+ 
X+ (defun math-solve-cubic (var d c b a)
X+   (math-try-solve-for
X+    var
X+    (let* ((p (math-div b a))
X+ 	  (q (math-div c a))
X+ 	  (r (math-div d a))
X+ 	  (psqr (math-sqr p))
X+ 	  (aa (math-sub q (math-div psqr 3)))
X+ 	  (bb (math-add r
X+ 			(math-div (math-sub (math-mul 2 (math-mul psqr p))
X+ 					    (math-mul 9 (math-mul p q)))
X+ 				  27)))
X+ 	  (m (math-mul 2 (list 'calcFunc-sqrt (math-div aa -3)))))
X+      (math-sub
X+       (math-normalize
X+        (math-mul
X+ 	m
X+ 	(list 'calcFunc-cos
X+ 	      (math-div
X+ 	       (math-sub (list 'calcFunc-arccos
X+ 			       (math-div (math-mul 3 bb)
X+ 					 (math-mul aa m)))
X+ 			 (math-mul 2
X+ 				   (math-mul
X+ 				    (math-add 1 (math-solve-get-int
X+ 						 1 3))
X+ 				    (math-half-circle t))))
X+ 	       3))))
X+       (math-div p 3)))
X+    nil t)
X+ )
X+ 
X+ (defun math-solve-quartic (var d c b a aa)
X+   (setq a (math-div a aa))
X+   (setq b (math-div b aa))
X+   (setq c (math-div c aa))
X+   (setq d (math-div d aa))
X+   (math-try-solve-for
X+    var
X+    (let* ((asqr (math-sqr a))
X+ 	  (asqr4 (math-div asqr 4))
X+ 	  (y (let ((solve-full nil))
X+ 	       (math-solve-cubic solve-var
X+ 				 (math-sub (math-sub
X+ 					    (math-mul 4 (math-mul b d))
X+ 					    (math-mul asqr d))
X+ 					   (math-sqr c))
X+ 				 (math-sub (math-mul a c)
X+ 					   (math-mul 4 d))
X+ 				 (math-neg b)
X+ 				 1)))
X+ 	  (rsqr (math-add (math-sub asqr4 b) y))
X+ 	  (r (list 'calcFunc-sqrt rsqr))
X+ 	  (sign1 (math-solve-get-sign 1))
X+ 	  (de (list 'calcFunc-sqrt
X+ 		    (math-add
X+ 		     (math-sub (math-mul 3 asqr4)
X+ 			       (math-mul 2 b))
X+ 		     (if (Math-zerop rsqr)
X+ 			 (math-mul
X+ 			  2
X+ 			  (math-mul sign1
X+ 				    (list 'calcFunc-sqrt
X+ 					  (math-sub (math-sqr y)
X+ 						    (math-mul 4 d)))))
X+ 		       (math-sub
X+ 			(math-mul sign1
X+ 				  (math-div
X+ 				   (math-sub (math-sub
X+ 					      (math-mul 4 (math-mul a b))
X+ 					      (math-mul 8 c))
X+ 					     (math-mul asqr a))
X+ 				   (math-mul 4 r)))
X+ 			rsqr))))))
X+      (math-normalize
X+       (math-sub (math-add (math-mul sign1 (math-div r 2))
X+ 			  (math-solve-get-sign (math-div de 2)))
X+ 		(math-div a 4))))
X+    nil t)
X+ )
X+ 
X  (defun math-get-from-counter (name)
X    (let ((ctr (assq name calc-command-flags)))
X      (if ctr
X***************
X*** 19804,19821 ****
X  
X  (defun math-solve-get-sign (val)
X    (if solve-full
X!       (let ((var (concat "s" (math-get-from-counter 'solve-sign))))
X! 	(math-mul (list 'var (intern var) (intern (concat "var-" var)))
X! 		  val))
X      (calc-record-why "Choosing positive solution")
X      val)
X  )
X  
X! (defun math-solve-get-int (val)
X    (if solve-full
X!       (let ((var (concat "n" (math-get-from-counter 'solve-int))))
X! 	(math-mul val
X! 		  (list 'var (intern var) (intern (concat "var-" var)))))
X      (calc-record-why "Choosing 0 for arbitrary integer in solution")
X      0)
X  )
X--- 20518,20542 ----
X  
X  (defun math-solve-get-sign (val)
X    (if solve-full
X!       (let* ((var (concat "s" (math-get-from-counter 'solve-sign)))
X! 	     (var2 (list 'var (intern var) (intern (concat "var-" var)))))
X! 	(if (eq solve-full 'all)
X! 	    (setq math-solve-ranges (cons (list var2 1 -1)
X! 					  math-solve-ranges)))
X! 	(math-mul var2 val))
X      (calc-record-why "Choosing positive solution")
X      val)
X  )
X  
X! (defun math-solve-get-int (val &optional range)
X    (if solve-full
X!       (let* ((var (concat "n" (math-get-from-counter 'solve-int)))
X! 	     (var2 (list 'var (intern var) (intern (concat "var-" var)))))
X! 	(if (and range (eq solve-full 'all))
X! 	    (setq math-solve-ranges (cons (cons var2
X! 						(cdr (math-vec-index range 0)))
X! 					  math-solve-ranges)))
X! 	(math-mul val var2))
X      (calc-record-why "Choosing 0 for arbitrary integer in solution")
X      0)
X  )
X***************
X*** 19839,19845 ****
X    (if (math-expr-contains rhs solve-var)
X        (math-solve-for (math-sub lhs rhs) 0 solve-var solve-full)
X      (and (math-expr-contains lhs solve-var)
X! 	 (math-try-solve-for lhs rhs sign)))
X  )
X  
X  (defun math-solve-eqn (expr var full)
X--- 20560,20567 ----
X    (if (math-expr-contains rhs solve-var)
X        (math-solve-for (math-sub lhs rhs) 0 solve-var solve-full)
X      (and (math-expr-contains lhs solve-var)
X! 	 (math-with-extra-prec 1
X! 	   (math-try-solve-for lhs rhs sign))))
X  )
X  
X  (defun math-solve-eqn (expr var full)
X***************
X*** 19854,19860 ****
X  	       (if (eq math-solve-sign -1)
X  		   (list (car expr) res var)
X  		 (or (eq (car expr) 'calcFunc-neq)
X! 		     (calc-record-why "Can't determine direction of inequality"))
X  		 (and (memq (car expr) '(calcFunc-neq calcFunc-lt
X  						      calcFunc-gt))
X  		      (list 'calcFunc-neq var res))))))
X--- 20576,20583 ----
X  	       (if (eq math-solve-sign -1)
X  		   (list (car expr) res var)
X  		 (or (eq (car expr) 'calcFunc-neq)
X! 		     (calc-record-why
X! 		      "Can't determine direction of inequality"))
X  		 (and (memq (car expr) '(calcFunc-neq calcFunc-lt
X  						      calcFunc-gt))
X  		      (list 'calcFunc-neq var res))))))
X***************
X*** 19873,19878 ****
X--- 20596,20607 ----
X        (list 'calcFunc-fsolve expr var))
X  )
X  
X+ (defun calcFunc-roots (expr var)
X+   (let ((math-solve-ranges nil))
X+     (or (math-solve-for expr 0 var 'all)
X+ 	(list 'calcfunc-roots expr var)))
X+ )
X+ 
X  (defun calcFunc-finv (expr var)
X    (let ((res (math-solve-for expr math-integ-var var nil)))
X      (if res
X***************
X*** 22574,22580 ****
X  	'(vec))
X      (let ((vals (let ((exp-keep-spaces space-sep))
X  		  (math-read-vector))))
X!       (if (equal exp-data "\\dots")
X  	  (progn
X  	    (math-read-token)
X  	    (setq vals (if (> (length vals) 2)
X--- 23303,23310 ----
X  	'(vec))
X      (let ((vals (let ((exp-keep-spaces space-sep))
X  		  (math-read-vector))))
X!       (if (or (equal exp-data "\\dots")
X! 	      (equal exp-data "\\ldots"))
X  	  (progn
X  	    (math-read-token)
X  	    (setq vals (if (> (length vals) 2)
X***************
X*** 22621,22627 ****
X  	     (and (not (eq exp-token 'end))
X  		  (not (equal exp-data ";"))
X  		  (not (equal exp-data close))
X! 		  (not (equal exp-data "\\dots"))))
X        (if (equal exp-data ",")
X  	  (math-read-token))
X        (while (eq exp-token 'space)
X--- 23351,23358 ----
X  	     (and (not (eq exp-token 'end))
X  		  (not (equal exp-data ";"))
X  		  (not (equal exp-data close))
X! 		  (not (equal exp-data "\\dots"))
X! 		  (not (equal exp-data "\\ldots"))))
X        (if (equal exp-data ",")
X  	  (math-read-token))
X        (while (eq exp-token 'space)
X***************
X*** 23097,23103 ****
X  		      left-bracket
X  		      (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a))
X  					   (concat comma " "))
X! 		      comma (if (eq calc-language 'tex) " \\dots" " ...")
X  		      comma " "
X  		      (list 'break math-compose-level)
X  		      (math-compose-expr (nth (1- (length a)) a) 0)
X--- 23828,23834 ----
X  		      left-bracket
X  		      (math-compose-vector (list (nth 1 a) (nth 2 a) (nth 3 a))
X  					   (concat comma " "))
X! 		      comma (if (eq calc-language 'tex) " \\ldots" " ...")
X  		      comma " "
X  		      (list 'break math-compose-level)
X  		      (math-compose-expr (nth (1- (length a)) a) 0)
X***************
X*** 23140,23146 ****
X        (list 'horiz
X  	    (if (memq (nth 1 a) '(0 1)) "(" "[")
X  	    (math-compose-expr (nth 2 a) 0)
X! 	    (if (eq calc-language 'tex) " \\dots " " .. ")
X  	    (math-compose-expr (nth 3 a) 0)
X  	    (if (memq (nth 1 a) '(0 2)) ")" "]")))
X       ((and (eq (car a) 'calcFunc-subscr)
X--- 23871,23877 ----
X        (list 'horiz
X  	    (if (memq (nth 1 a) '(0 1)) "(" "[")
X  	    (math-compose-expr (nth 2 a) 0)
X! 	    (if (eq calc-language 'tex) " \\ldots " " .. ")
X  	    (math-compose-expr (nth 3 a) 0)
X  	    (if (memq (nth 1 a) '(0 2)) ")" "]")))
X       ((and (eq (car a) 'calcFunc-subscr)
X***************
X*** 23341,23346 ****
X--- 24072,24078 ----
X  			      right " \\right)"))
X  		       ((and (eq calc-language 'tex)
X  			     (eq (aref func 0) ?\\)
X+ 			     (not (string-match "\\hbox{" func))
X  			     (= (length a) 2)
X  			     (or (Math-realp (nth 1 a))
X  				 (memq (car (nth 1 a)) '(var *))))
X***************
X*** 23419,23425 ****
X        (if (<= count 0)
X  	  (if (< count 0)
X  	      (math-compose-rows (cdr a) -1)
X! 	    (cons (concat (if (eq calc-language 'tex) "\\dots" "...") comma)
X  		  (math-compose-rows (cdr a) -1)))
X  	(cons (list 'horiz
X  		    (math-compose-expr (car a) 0)
X--- 24151,24157 ----
X        (if (<= count 0)
X  	  (if (< count 0)
X  	      (math-compose-rows (cdr a) -1)
X! 	    (cons (concat (if (eq calc-language 'tex) "\\ldots" "...") comma)
X  		  (math-compose-rows (cdr a) -1)))
X  	(cons (list 'horiz
X  		    (math-compose-expr (car a) 0)
X***************
X*** 23800,23805 ****
X--- 24532,25141 ----
X      "")
X  )
X  
X+ 
X+ 
X+ 
X+ ;;;; [calc-keypd.el]
X+ 
X+ 
X+ ;;; Pictorial interface to Calc using the X window system mouse.
X+ 
X+ (defvar calc-keypad-buffer nil)
X+ (defvar calc-keypad-menu 0)
X+ (defvar calc-keypad-full-layout nil)
X+ (defvar calc-keypad-input nil)
X+ (defvar calc-keypad-prev-input nil)
X+ (defvar calc-keypad-prev-x-left-click nil)
X+ (defvar calc-keypad-prev-x-middle-click nil)
X+ (defvar calc-keypad-prev-x-right-click nil)
X+ (defvar calc-keypad-said-hello nil)
X+ 
X+ (defun calc-do-keypad ()
X+   (calc-create-buffer)
X+   (let ((calcbuf (current-buffer)))
X+     (or (and calc-keypad-buffer
X+ 	     (buffer-name calc-keypad-buffer))
X+ 	(progn
X+ 	  (setq calc-keypad-buffer (get-buffer-create "*Calc Keypad*"))
X+ 	  (set-buffer calc-keypad-buffer)
X+ 	  (setq major-mode 'calc-keypad)
X+ 	  (setq mode-name "Calculator")
X+ 	  (make-local-variable 'calc-main-buffer)
X+ 	  (setq calc-main-buffer calcbuf)
X+ 	  (calc-keypad-redraw)))
X+     (let ((width 29)
X+ 	  (height 17)
X+ 	  win old-win)
X+       (if (setq win (get-buffer-window "*Calculator*"))
X+ 	  (delete-window win))
X+       (if (setq win (get-buffer-window "*Calc Trail*"))
X+ 	  (delete-window win))
X+       (if (setq win (get-buffer-window calc-keypad-buffer))
X+ 	  (progn
X+ 	    (delete-window win)
X+ 	    (if calc-keypad-prev-x-left-click
X+ 		(progn
X+ 		  (aset mouse-map 0 calc-keypad-prev-x-right-click)
X+ 		  (aset mouse-map 1 calc-keypad-prev-x-middle-click)
X+ 		  (aset mouse-map 2 calc-keypad-prev-x-left-click)
X+ 		  (setq calc-keypad-prev-x-left-click nil))))
X+ 	(setq old-win (get-largest-window))
X+ 	(if (or (< (window-height old-win) (+ height 6))
X+ 		(< (window-width old-win) (+ width 15)))
X+ 	    (delete-other-windows old-win))
X+ 	(if (< (window-height old-win) (+ height 4))
X+ 	    (error "Screen is not tall for this mode"))
X+ 	(if (or t  ; left-side keypad not yet fully implemented
X+ 		(< (save-excursion
X+ 		     (set-buffer (window-buffer old-win))
X+ 		     (current-column))
X+ 		   (/ (window-width) 2)))
X+ 	    (setq win (split-window old-win (- (window-width old-win)
X+ 					       width 2)
X+ 				    t))
X+ 	  (setq old-win (split-window old-win (+ width 2) t)))
X+ 	(set-window-buffer win calc-keypad-buffer)
X+ 	(set-window-start win 1)
X+ 	(split-window win (- (window-height win) height 1))
X+ 	(set-window-buffer win calcbuf)
X+ 	(select-window old-win)
X+ 	(if (eq window-system 'x)
X+ 	    (progn
X+ 	      (or calc-keypad-prev-x-left-click
X+ 		  (setq calc-keypad-prev-x-right-click (aref mouse-map 0)
X+ 			calc-keypad-prev-x-middle-click (aref mouse-map 1)
X+ 			calc-keypad-prev-x-left-click (aref mouse-map 2)))
X+ 	      (aset mouse-map 0 'calc-keypad-x-right-click)
X+ 	      (aset mouse-map 1 'calc-keypad-x-middle-click)
X+ 	      (aset mouse-map 2 'calc-keypad-x-left-click)))
X+ 	(message "Welcome to GNU Emacs Calc!  Use the left and right mouse buttons.")
X+ 	(run-hooks 'calc-keypad-start-hook)
X+ 	(and calc-keypad-said-hello
X+ 	     (progn
X+ 	       (sit-for 2)
X+ 	       (message "")))
X+ 	(setq calc-keypad-said-hello t))))
X+   (setq calc-keypad-input nil)
X+ )
X+ 
X+ (defun calc-keypad-redraw ()
X+   (set-buffer calc-keypad-buffer)
X+   (setq buffer-read-only t)
X+   (setq calc-keypad-full-layout (append (symbol-value (nth calc-keypad-menu
X+ 							   calc-keypad-menus))
X+ 					calc-keypad-layout))
X+   (let ((buffer-read-only nil)
X+ 	(row calc-keypad-full-layout)
X+ 	(y 0))
X+     (erase-buffer)
X+     (insert "\n")
X+     (while row
X+       (let ((col (car row)))
X+ 	(while col
X+ 	  (let* ((key (car col))
X+ 		 (cwid (if (>= y 4)
X+ 			   5
X+ 			 (if (and (= y 3) (eq col (car row)))
X+ 			     (progn (setq col (cdr col)) 9)
X+ 			   4)))
X+ 		 (name (if (> (length (car key)) cwid)
X+ 			   (substring (car key) 0 cwid)
X+ 			 (car key)))
X+ 		 (wid (length (car key)))
X+ 		 (pad (- cwid (/ wid 2))))
X+ 	    (insert (make-string (/ (- cwid wid) 2) 32)
X+ 		    name
X+ 		    (make-string (/ (- cwid wid -1) 2) 32)
X+ 		    (if (equal name "MENU")
X+ 			(int-to-string (1+ calc-keypad-menu))
X+ 		      "|")))
X+ 	  (or (setq col (cdr col))
X+ 	      (insert "\n")))
X+ 	(insert (if (>= y 4)
X+ 		    "-----+-----+-----+-----+-----"
X+ 		  (if (= y 3)
X+ 		      "-----+---+-+--+--+-+---++----"
X+ 		    "----+----+----+----+----+----"))
X+ 		(if (= y 7) "+\n" "|\n"))
X+ 	(setq y (1+ y)
X+ 	      row (cdr row)))))
X+   (setq calc-keypad-prev-input t)
X+   (calc-keypad-show-input)
X+   (goto-char (point-min))
X+ )
X+ 
X+ (defun calc-keypad-show-input ()
X+   (or (equal calc-keypad-input calc-keypad-prev-input)
X+       (let ((buffer-read-only nil))
X+ 	(save-excursion
X+ 	  (goto-char (point-min))
X+ 	  (forward-line 1)
X+ 	  (delete-region (point-min) (point))
X+ 	  (if calc-keypad-input
X+ 	      (insert "Calc: " calc-keypad-input "\n")
X+ 	    (insert "----+-----Calc 1.06-----+----"
X+ 		    (int-to-string (1+ calc-keypad-menu))
X+ 		    "\n")))))
X+   (setq calc-keypad-prev-input calc-keypad-input)
X+ )
X+ 
X+ (defun calc-keypad-press ()
X+   "Press the Calc \"button\" at the current position."
X+   (interactive)
X+   (or (eq major-mode 'calc-keypad)
X+       (error "Must be in *Calc Keypad* buffer for this command"))
X+   (let* ((row (save-excursion
X+ 		(beginning-of-line)
X+ 		(count-lines (point-min) (point))))
X+ 	 (y (/ row 2))
X+ 	 (x (/ (current-column) (if (>= y 4) 6 5)))
X+ 	 radix frac inv
X+ 	 (hyp (save-excursion
X+ 		(set-buffer calc-main-buffer)
X+ 		(setq radix calc-number-radix
X+ 		      frac calc-prefer-frac
X+ 		      inv calc-inverse-flag)
X+ 		calc-hyperbolic-flag))
X+ 	 (invhyp t)
X+ 	 (menu (symbol-value (nth calc-keypad-menu calc-keypad-menus)))
X+ 	 (input calc-keypad-input)
X+ 	 (key (nth x (nth y calc-keypad-full-layout)))
X+ 	 (cmd (or (nth (if inv (if hyp 4 2) (if hyp 3 99)) key)
X+ 		  (setq invhyp nil)
X+ 		  (nth 1 key)))
X+ 	 (isstring (and (consp cmd) (stringp (car cmd)))))
X+     (if invhyp (calc-wrapper))  ; clear Inv and Hyp flags
X+     (unwind-protect
X+ 	(cond ((or (null cmd)
X+ 		   (= (% row 2) 0))
X+ 	       (beep))
X+ 	      ((and (> (minibuffer-depth) 0))
X+ 	       (cond (isstring
X+ 		      (setq unread-command-char (aref (car cmd) 0)))
X+ 		     ((eq cmd 'calc-pop)
X+ 		      (setq unread-command-char ?\177))
X+ 		     ((eq cmd 'calc-enter)
X+ 		      (setq unread-command-char 13))
X+ 		     ((eq cmd 'calc-undo)
X+ 		      (setq unread-command-char 7))
X+ 		     (t
X+ 		      (beep))))
X+ 	      ((and input (string-match "STO\\|RCL" input))
X+ 	       (cond ((and isstring (string-match "[0-9]" (car cmd)))
X+ 		      (setq calc-keypad-input nil)
X+ 		      (if (string-match "STO" input)
X+ 			  (calc-store nil (concat (substring input 3)
X+ 						  (car cmd)))
X+ 			(calc-recall (car cmd))))
X+ 		     ((memq cmd '(calc-pop calc-undo))
X+ 		      (setq calc-keypad-input nil))
X+ 		     ((and (equal input "STO")
X+ 			   (setq frac (assq cmd '( ( calc-plus . "+" )
X+ 						   ( calc-minus . "-" )
X+ 						   ( calc-times . "*" )
X+ 						   ( calc-divide . "/" )
X+ 						   ( calc-power . "^") ))))
X+ 		      (setq calc-keypad-input (concat input (cdr frac))))
X+ 		     (t
X+ 		      (beep))))
X+ 	      (isstring
X+ 	       (setq cmd (car cmd))
X+ 	       (if (or (and (equal cmd ".")
X+ 			    input
X+ 			    (string-match "[.:e]" input))
X+ 		       (and (equal cmd "e")
X+ 			    input
X+ 			    (string-match "e\\|[-.:]\\'" input))
X+ 		       (and (/= radix 10)
X+ 			    (or (equal cmd ".") (equal cmd "e")))
X+ 		       (and (not (equal cmd "."))
X+ 			    (let ((case-fold-search nil))
X+ 			      (string-match cmd "0123456789ABCDEF" radix))))
X+ 		   (beep)
X+ 		 (setq calc-keypad-input (concat
X+ 					  (and (/= radix 10)
X+ 					       (or (not input)
X+ 						   (equal input "-"))
X+ 					       (format "%d#" radix))
X+ 					  (and (or (not input)
X+ 						   (equal input "-"))
X+ 					       (or (and (equal cmd "e") "1")
X+ 						   (and (equal cmd ".")
X+ 							(if frac "1" "0"))))
X+ 					  input
X+ 					  (if (and (equal cmd ".") frac)
X+ 					      ":"
X+ 					    cmd)))))
X+ 	      ((and (eq cmd 'calc-change-sign)
X+ 		    input)
X+ 	       (let* ((epos (1+ (or (and (not (string-match "#" input))
X+ 					 (string-match "e" input))
X+ 				    -1)))
X+ 		      (suffix (substring input epos)))
X+ 		 (setq calc-keypad-input (concat
X+ 					  (substring input 0 epos)
X+ 					  (if (string-match "\\`-" suffix)
X+ 					      (substring suffix 1)
X+ 					    (concat "-" suffix))))))
X+ 	      ((and (eq cmd 'calc-pop)
X+ 		    input)
X+ 	       (if (equal input "")
X+ 		   (beep)
X+ 		 (setq calc-keypad-input (substring input 0 -1))))
X+ 	      ((and (eq cmd 'calc-undo)
X+ 		    input)
X+ 	       (setq calc-keypad-input nil))
X+ 	      (t
X+ 	       (if input
X+ 		   (let ((val (math-read-number input)))
X+ 		     (setq calc-keypad-input nil)
X+ 		     (if val
X+ 			 (calc-wrapper
X+ 			  (calc-push-list (list val)))
X+ 		       (or (equal input "")
X+ 			   (beep))
X+ 		       (setq cmd nil))
X+ 		     (if (eq cmd 'calc-enter) (setq cmd nil))))
X+ 	       (setq prefix-arg current-prefix-arg)
X+ 	       (if cmd
X+ 		   (if (and (consp cmd) (eq (car cmd) 'progn))
X+ 		       (while (setq cmd (cdr cmd))
X+ 			 (if (integerp (car cmd))
X+ 			     (setq prefix-arg (car cmd))
X+ 			   (command-execute (car cmd))))
X+ 		     (command-execute cmd)))))
X+       (set-buffer calc-keypad-buffer)
X+       (calc-keypad-show-input)))
X+ )
X+ 
X+ (defun calc-keypad-x-left-click (arg)
X+   "Handle a left-button mouse click in Calc Keypad window."
X+   (let (coords)
X+     (if (and calc-keypad-buffer
X+ 	     (buffer-name calc-keypad-buffer)
X+ 	     (setq coords (coordinates-in-window-p
X+ 			   arg (get-buffer-window calc-keypad-buffer))))
X+ 	(let ((win (selected-window)))
X+ 	  (unwind-protect
X+ 	      (progn
X+ 		(x-mouse-set-point arg)
X+ 		(calc-keypad-press))
X+ 	    (and (window-point win)
X+ 		 (select-window win))))
X+       (funcall calc-keypad-prev-x-left-click arg)))
X+ )
X+ 
X+ (defun calc-keypad-x-right-click (arg)
X+   "Handle a right-button mouse click in Calc Keypad window."
X+   (if (and calc-keypad-buffer
X+ 	   (buffer-name calc-keypad-buffer)
X+ 	   (coordinates-in-window-p
X+ 	    arg (get-buffer-window calc-keypad-buffer)))
X+       (save-excursion
X+ 	(set-buffer calc-keypad-buffer)
X+ 	(calc-keypad-menu))
X+     (funcall calc-keypad-prev-x-right-click arg))
X+ )
X+ 
X+ (defun calc-keypad-x-middle-click (arg)
X+   "Handle a middle-button mouse click in Calc Keypad window."
X+   (if (and calc-keypad-buffer
X+ 	   (buffer-name calc-keypad-buffer)
X+ 	   (coordinates-in-window-p
X+ 	    arg (get-buffer-window calc-keypad-buffer)))
X+       (save-excursion
X+ 	(set-buffer calc-keypad-buffer)
X+ 	(calc-keypad-menu-back))
X+     (funcall calc-keypad-prev-x-middle-click arg))
X+ )
X+ 
X+ (defun calc-keypad-menu ()
X+   (interactive)
X+   (or (eq major-mode 'calc-keypad)
X+       (error "Must be in *Calc Keypad* buffer for this command"))
X+   (while (progn (setq calc-keypad-menu (% (1+ calc-keypad-menu)
X+ 					  (length calc-keypad-menus)))
X+ 		(not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
X+   (calc-keypad-redraw)
X+ )
X+ 
X+ (defun calc-keypad-menu-back ()
X+   (interactive)
X+   (or (eq major-mode 'calc-keypad)
X+       (error "Must be in *Calc Keypad* buffer for this command"))
X+   (while (progn (setq calc-keypad-menu (% (1- (+ calc-keypad-menu
X+ 						 (length calc-keypad-menus)))
X+ 					  (length calc-keypad-menus)))
X+ 		(not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
X+   (calc-keypad-redraw)
X+ )
X+ 
X+ (defun calc-keypad-store ()
X+   (interactive)
X+   (setq calc-keypad-input "STO")
X+ )
X+ 
X+ (defun calc-keypad-recall ()
X+   (interactive)
X+   (setq calc-keypad-input "RCL")
X+ )
X+ 
X+ (defun calc-pack-interval (mode)
X+   (interactive "p")
X+   (if (or (< mode 0) (> mode 3))
X+       (error "Open/close code should be in the range from 0 to 3."))
X+   (calc-pack (- -6 mode))
X+ )
X+ 
X+ (defun calc-keypad-execute ()
X+   "Execute a Calc key sequence (like `C-u 2 I Q') from outside the Calc buffer."
X+   (interactive)
X+   (let* ((prompt "Calc keystrokes: ")
X+ 	 (flush 'x-flush-mouse-queue)
X+ 	 (prefix nil)
X+ 	 keys cmd)
X+     (save-excursion
X+       (calc-select-buffer)
X+       (while (progn
X+ 	       (setq keys (read-key-sequence prompt))
X+ 	       (setq cmd (key-binding keys))
X+ 	       (if (or (memq cmd '(calc-inverse
X+ 				   calc-hyperbolic
X+ 				   universal-argument
X+ 				   digit-argument
X+ 				   negative-argument))
X+ 		       (and prefix (string-match "\\`\e?[-0-9]\\'" keys)))
X+ 		   (progn
X+ 		     (setq last-command-char (aref keys (1- (length keys))))
X+ 		     (command-execute cmd)
X+ 		     (setq flush 'not-any-more
X+ 			   prefix t
X+ 			   prompt (concat prompt (key-description keys) " ")))
X+ 		 (eq cmd flush)))))  ; skip mouse-up event
X+     (message "")
X+     (if (commandp cmd)
X+ 	(command-execute cmd)
X+       (error "Not a Calc command: %s" (key-description keys))))
X+ )
X+ 
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |  ENTER  |+/- |EEX |UNDO| <- |
X+ ;;; |-----+---+-+--+--+-+---++----|
X+ ;;; | INV |  7  |  8  |  9  |  /  |
X+ ;;; |-----+-----+-----+-----+-----|
X+ ;;; | HYP |  4  |  5  |  6  |  *  |
X+ ;;; |-----+-----+-----+-----+-----|
X+ ;;; |EXEC |  1  |  2  |  3  |  -  |
X+ ;;; |-----+-----+-----+-----+-----|
X+ ;;; | OFF |  0  |  .  | PI  |  +  |
X+ ;;; |-----+-----+-----+-----+-----|
X+ 
X+ (defvar calc-keypad-layout
X+   '( ( ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
X+        ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
X+        ( "+/-"	 calc-change-sign calc-inv (progn -4 calc-pack) )
X+        ( "EEX"	 ("e") (progn calc-num-prefix calc-pack-interval)
X+                  (progn -5 calc-pack)  )
X+        ( "UNDO"	 calc-undo calc-redo calc-last-x )
X+        ( "<-"	 calc-pop (progn 0 calc-pop)
X+ 	         (progn calc-num-prefix calc-pop) ) )
X+      ( ( "INV"   calc-inverse )
X+        ( "7"	 ("7") calc-round )
X+        ( "8"	 ("8") (progn 2 calc-clean-num) )
X+        ( "9"	 ("9") calc-float )
X+        ( "/"	 calc-divide (progn calc-inverse calc-power) ) )
X+      ( ( "HYP"   calc-hyperbolic )
X+        ( "4"	 ("4") calc-ln calc-log10 )
X+        ( "5"	 ("5") calc-exp calc-exp10 )
X+        ( "6"	 ("6") calc-abs )
X+        ( "*"	 calc-times calc-power ) )
X+      ( ( "EXEC"	 calc-keypad-execute )
X+        ( "1"	 ("1") calc-arcsin calc-sin )
X+        ( "2"	 ("2") calc-arccos calc-cos )
X+        ( "3"	 ("3") calc-arctan calc-tan )
X+        ( "-"	 calc-minus calc-conj ) )
X+      ( ( "OFF"   calc-keypad )
X+        ( "0"	 ("0") calc-imaginary )
X+        ( "."	 (".") calc-precision )
X+        ( "PI"	 calc-pi )
X+        ( "+"	 calc-plus calc-sqrt ) ) )
X+ )
X+ 
X+ (defvar calc-keypad-menus '( calc-keypad-math-menu
X+ 			     calc-keypad-funcs-menu
X+ 			     calc-keypad-binary-menu
X+ 			     calc-keypad-vector-menu
X+ 			     calc-keypad-modes-menu
X+ 			     calc-keypad-user-menu ) )
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |FLR |CEIL|RND |TRNC|CLN2|FLT |
X+ ;;; |----+----+----+----+----+----|
X+ ;;; | LN |EXP |    |ABS |IDIV|MOD |
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |SIN |COS |TAN |SQRT|y^x |1/x |
X+ 
X+ (defvar calc-keypad-math-menu
X+   '( ( ( "FLR"   calc-floor )
X+        ( "CEIL"  calc-ceiling )
X+        ( "RND"   calc-round )
X+        ( "TRNC"  calc-trunc )
X+        ( "CLN2"  (progn 2 calc-clean-num) )
X+        ( "FLT"   calc-float ) )
X+      ( ( "LN"    calc-ln )
X+        ( "EXP"   calc-exp )
X+        ( ""	 nil )
X+        ( "ABS"   calc-abs )
X+        ( "IDIV"  calc-idiv )
X+        ( "MOD"   calc-mod ) )
X+      ( ( "SIN"   calc-sin )
X+        ( "COS"   calc-cos )
X+        ( "TAN"   calc-tan )
X+        ( "SQRT"  calc-sqrt )
X+        ( "y^x"   calc-power )
X+        ( "1/x"   calc-inv ) ) )
X+ )
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |IGAM|BETA|IBET|ERF |BESJ|BESY|
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |IMAG|CONJ| RE |ATN2|RAND|RAGN|
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |GCD |FACT|DFCT|BNOM|PERM|NXTP|
X+ 
X+ (defvar calc-keypad-funcs-menu
X+   '( ( ( "IGAM"  calc-inc-gamma )
X+        ( "BETA"  calc-beta )
X+        ( "IBET"  calc-inc-beta )
X+        ( "ERF"   calc-erf )
X+        ( "BESJ"  calc-bessel-J )
X+        ( "BESY"  calc-bessel-Y ) )
X+      ( ( "IMAG"  calc-imaginary )
X+        ( "CONJ"  calc-conj )
X+        ( "RE"	 calc-re calc-im )
X+        ( "ATN2"  calc-arctan2 )
X+        ( "RAND"  calc-random )
X+        ( "RAGN"  calc-random-again ) )
X+      ( ( "GCD"   calc-gcd calc-lcm )
X+        ( "FACT"  calc-factorial calc-gamma )
X+        ( "DFCT"  calc-double-factorial )
X+        ( "BNOM"  calc-choose )
X+        ( "PERM"  calc-perm )
X+        ( "NXTP"	 calc-next-prime calc-prev-prime ) ) )
X+ )
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |AND | OR |XOR |NOT |LSH |RSH |
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |DEC |HEX |OCT |BIN |WSIZ|ARSH|
X+ ;;; |----+----+----+----+----+----|
X+ ;;; | A  | B  | C  | D  | E  | F  |
X+ 
X+ (defvar calc-keypad-binary-menu
X+   '( ( ( "AND"   calc-and calc-diff )
X+        ( "OR"    calc-or )
X+        ( "XOR"   calc-xor )
X+        ( "NOT"   calc-not calc-clip )
X+        ( "LSH"   calc-lshift-binary calc-rotate-binary )
X+        ( "RSH"   calc-rshift-binary ) )
X+      ( ( "DEC"   calc-decimal-radix )
X+        ( "HEX"   calc-hex-radix )
X+        ( "OCT"   calc-octal-radix )
X+        ( "BIN"   calc-binary-radix )
X+        ( "WSIZ"  (progn
X+ 		   (lambda (arg) (interactive "nWord size: ")
X+ 		     (setq prefix-arg arg))
X+ 		   calc-word-size) calc-word-size )
X+        ( "ARSH"  calc-rshift-arith ) )
X+      ( ( "A"     ("A") )
X+        ( "B"     ("B") )
X+        ( "C"     ("C") )
X+        ( "D"     ("D") )
X+        ( "E"     ("E") )
X+        ( "F"     ("F") ) ) )
X+ )
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |SUM |PROD|MAX |MAP*|MAP^|MAP$|
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |INV |DET |TRN |IDNT|CRSS|"x" |
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |PACK|UNPK|INDX|BLD |LEN |... |
X+ 
X+ (defvar calc-keypad-vector-menu
X+   '( ( ( "SUM"   (lambda () (interactive)
X+ 		   (calc-reduce '(2 calcFunc-add "+")))
X+ 	         (lambda () (interactive)
X+ 		   (calc-is-inverse)
X+ 		   (calc-reduce '(2 calcFunc-sub "-"))) )
X+        ( "PROD"  (lambda () (interactive)
X+ 		   (calc-reduce '(2 calcFunc-mul "*"))) )
X+        ( "MAX"   (lambda () (interactive)
X+ 		   (calc-reduce '(2 calcFunc-max "X")))
X+ 	         (lambda () (interactive)
X+ 		   (calc-reduce '(2 calcFunc-max "N"))) )
X+        ( "MAP*"  (lambda () (interactive)
X+ 		   (calc-map '(2 calcFunc-mul "*"))) )
X+        ( "MAP^"  (lambda () (interactive)
X+ 		   (calc-map '(2 calcFunc-pow "^"))) )
X+        ( "MAP$"  "\excalc-map\r$\r" ) )
X+      ( ( "MINV"  calc-inv )
X+        ( "MDET"  calc-mdet )
X+        ( "MTRN"  calc-transpose calc-conj-transpose )
X+        ( "IDNT"  (progn calc-num-prefix calc-ident) )
X+        ( "CRSS"  calc-cross )
X+        ( "\"x\"" "\excalc-alg-entry\rx\r"
X+ 	         "\excalc-alg-entry\ry\r"
X+ 		 "\excalc-alg-entry\rz\r"
X+ 		 "\excalc-alg-entry\rt\r") )
X+      ( ( "PACK"  (progn calc-num-prefix calc-pack) )
X+        ( "UNPK"  calc-unpack )
X+        ( "INDX"  (progn calc-num-prefix calc-index) "\C-u\excalc-index\r" )
X+        ( "BLD"   (progn calc-num-prefix calc-build-vector) )
X+        ( "LEN"   calc-vlength )
X+        ( "..."   calc-full-vectors ) ) )
X+ )
X+ 
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |FLT |FIX |SCI |ENG |GRP |    |
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |RAD |DEG |FRAC|POLR|SYMB|PREC|
X+ ;;; |----+----+----+----+----+----|
X+ ;;; |SWAP|RLL3|RLL4|OVER|STO |RCL |
X+ 
X+ (defvar calc-keypad-modes-menu
X+   '( ( ( "FLT"   calc-normal-notation )
X+        ( "FIX"   calc-fix-notation )
X+        ( "SCI"   calc-sci-notation )
X+        ( "ENG"   calc-eng-notation )
X+        ( "GRP"   calc-group-digits "\C-u-3\excalc-group-digits\r" )
X+        ( ""	 nil ) )
X+      ( ( "RAD"   calc-radians-mode )
X+        ( "DEG"   calc-degrees-mode )
X+        ( "FRAC"  calc-frac-mode )
X+        ( "POLR"  calc-polar-mode )
X+        ( "SYMB"	 calc-symbolic-mode )
X+        ( "PREC"  calc-precision ) )
X+      ( ( "SWAP"  calc-roll-down )
X+        ( "RLL3"  (progn 3 calc-roll-up) (progn 3 calc-roll-down) )
X+        ( "RLL4"  (progn 4 calc-roll-up) (progn 4 calc-roll-down) )
X+        ( "OVER"  calc-over )
X+        ( "STO"   calc-keypad-store )
X+        ( "RCL"   calc-keypad-recall ) ) )
X+ )
X+ 
X+ ;;;; [calc-ext.el]
X+ 
X+ ;;; Users can redefine this in their .emacs files.
X+ (defvar calc-keypad-user-menu nil
X+   "If not NIL, this describes an additional menu for calc-keypad.
X+ It should contain a list of three rows.
X+ Each row should be a list of six keys.
X+ Each key should be a list of a label string, plus a Calc command name spec.
X+ A command spec is a command name symbol, a keyboard macro string, a
X+ list containing a numeric entry string, or nil.
X+ A key may contain additional specs for Inverse, Hyperbolic, and Inv+Hyp.")
X  
X  
X  
X*** calc-INSTALL	Tue Oct  9 16:58:47 1990
X--- ../dist/calc-INSTALL	Wed Oct 24 02:18:32 1990
X***************
X*** 2,8 ****
X  Installation
X  ************
X  
X! Calc 1.05 comes as a pair of Emacs Lisp files, generally called
X  `calc.el' and `calc-ext.el'.  The first contains the basic foundations
X  of the Calculator, and is as small as possible to promote quick loading.
X  The second contains all the more advanced commands and functions.  Calc
X--- 2,8 ----
X  Installation
X  ************
X  
X! Calc 1.06 comes as a pair of Emacs Lisp files, generally called
X  `calc.el' and `calc-ext.el'.  The first contains the basic foundations
X  of the Calculator, and is as small as possible to promote quick loading.
X  The second contains all the more advanced commands and functions.  Calc
X***************
X*** 82,87 ****
X--- 82,88 ----
X       (autoload 'calc-extensions  ".../calc-ext.elc" nil)
X       (autoload 'quick-calc       ".../calc.elc"     "Quick Calculator" t)
X       (autoload 'full-calc        ".../calc.elc"     "Full-screen Calculator" t)
X+      (autoload 'calc-keypad      ".../calc.elc"     "X windows Calculator" t)
X       (autoload 'calc-eval        ".../calc.elc"     "Use Calculator from Lisp")
X       (autoload 'calc-grab-region ".../calc-ext.elc" nil t)
X       (autoload 'defmath          ".../calc-ext.elc" nil t t)
X***************
X*** 99,105 ****
X  brings in the extensions module; Calc takes care to call the
X  `calc-extensions' function (which doesn't actually do anything)
X  before any operation that requires the extensions to be present.
X! The other five `autoload' commands are for functions which might
X  reasonably be used before the user has typed `M-x calc' for the
X  first time.
X  
X--- 100,106 ----
X  brings in the extensions module; Calc takes care to call the
X  `calc-extensions' function (which doesn't actually do anything)
X  before any operation that requires the extensions to be present.
X! The other six `autoload' commands are for functions which might
X  reasonably be used before the user has typed `M-x calc' for the
X  first time.
X  
X*** calc.texinfo	Tue Oct  9 16:58:45 1990
X--- ../dist/calc.texinfo	Wed Oct 24 02:16:15 1990
X***************
X*** 1,7 ****
X  \input texinfo                  @c -*-texinfo-*-
X  @comment %**start of header (This is for running Texinfo on a region.)
X  @setfilename calc-info
X! @settitle GNU Emacs Calc 1.05 Manual
X  @setchapternewpage odd
X  @comment %**end of header (This is for running Texinfo on a region.)
X  
X--- 1,7 ----
X  \input texinfo                  @c -*-texinfo-*-
X  @comment %**start of header (This is for running Texinfo on a region.)
X  @setfilename calc-info
X! @settitle GNU Emacs Calc 1.06 Manual
X  @setchapternewpage odd
X  @comment %**end of header (This is for running Texinfo on a region.)
X  
X***************
X*** 38,44 ****
X  @sp 6
X  @center @titlefont{Calc Manual}
X  @sp 4
X! @center GNU Emacs Calc Version 1.05
X  @sp 1
X  @center October 1990
X  @sp 5
X--- 38,44 ----
X  @sp 6
X  @center @titlefont{Calc Manual}
X  @sp 4
X! @center GNU Emacs Calc Version 1.06
X  @sp 1
X  @center October 1990
X  @sp 5
X***************
X*** 76,82 ****
X  @node Top, Quick Overview,, (dir)
X  @ichapter The GNU Emacs Calculator
X  
X! @dfn{Calc 1.05} is an advanced desk calculator and mathematical tool
X  that runs as part of the GNU Emacs environment.
X  
X  This manual is divided into two major parts, the Tutorial and the
X--- 76,82 ----
X  @node Top, Quick Overview,, (dir)
X  @ichapter The GNU Emacs Calculator
X  
X! @dfn{Calc 1.06} is an advanced desk calculator and mathematical tool
X  that runs as part of the GNU Emacs environment.
X  
X  This manual is divided into two major parts, the Tutorial and the
X***************
X*** 440,446 ****
X  If the argument is positive, the extensions are also loaded if necessary.
X  User-written Lisp code that wishes to make use of Calc's arithmetic
X  routines can use @samp{(calc 0)} or @samp{(calc 1)} to auto-load the
X! Calculator.  (Also, @pxref{Grabbing From Buffers}.)@refill
X  
X  @pindex full-calc
X  You can also type @kbd{M-x full-calc} to get a Calculator that uses
X--- 440,447 ----
X  If the argument is positive, the extensions are also loaded if necessary.
X  User-written Lisp code that wishes to make use of Calc's arithmetic
X  routines can use @samp{(calc 0)} or @samp{(calc 1)} to auto-load the
X! Calculator.  (Negative arguments have other effects;
X! @pxref{Grabbing From Buffers}, and @pxref{Keypad Mode}.)@refill
X  
X  @pindex full-calc
X  You can also type @kbd{M-x full-calc} to get a Calculator that uses
X***************
X*** 448,453 ****
X--- 449,459 ----
X  type @samp{emacs -f full-calc} to start a new Emacs specifically for
X  use as a calculator.
X  
X+ Finally, if you are using the X window system you may want to try
X+ @kbd{M-x calc-keypad} which runs Calc with a ``calculator keypad''
X+ picture as well as a stack display.  Click on the keys with the
X+ mouse to operate the calculator.  @xref{Keypad Mode}.
X+ 
X  @kindex ?
X  @kindex h
X  @kindex i
X***************
X*** 506,511 ****
X--- 512,518 ----
X  * Numeric Entry::
X  * Algebraic Entry::
X  * Quick Calculator::
X+ * Keypad Mode::
X  * Prefix Arguments::
X  * Undo::
X  * Error Messages::
X***************
X*** 522,527 ****
X--- 529,535 ----
X  @cindex Overview
X  Type @kbd{M-x calc} or @kbd{M-#} to start the Calculator; type @kbd{q} to quit.
X  Type @kbd{M-x quick-calc} to do one quick calculation in the minibuffer.
X+ Type @kbd{M-x calc-keypad} for a visual calculator in the X window system.
X  
X  Calc normally uses RPN notation.  @xref{RPN Tutorial}, for a discussion
X  of RPN for the beginner.  The @kbd{RET} or @kbd{SPC} key enters a number
X***************
X*** 698,703 ****
X--- 706,720 ----
X  Thus if you quit Emacs and start it again, @kbd{M-#} will give you
X  a fresh Stack and Trail.
X  
X+ If you use the X window system (which allows you to click the mouse to
X+ move the Emacs cursor around), you may wish to try @kbd{M-x calc-keypad}.
X+ This runs Calc with a picture of a calculator keypad on the screen.
X+ Just click the calculator ``keys'' using the left mouse button to
X+ operate the calculator.  Click the right mouse button to see other
X+ sets of calculator buttons.  @xref{Keypad Mode}.  Not all Calc commands
X+ are available through the keypad; this tutorial will assume you are
X+ using regular Calc as invoked by @kbd{M-#}.
X+ 
X  @node RPN Tutorial, Algebraic Tutorial, On and Off Tutorial, Basic Tutorial
X  @subsection RPN Calculations and the Stack
X  
X***************
X*** 828,834 ****
X  @example
X  1:  3          2:  3          1:  9          2:  9          1:  81
X      .          1:  3              .          1:  9              .
X!                    .                             .          
X  
X    3 RET           RET             *             RET             *
X  @end example
X--- 845,851 ----
X  @example
X  1:  3          2:  3          1:  9          2:  9          1:  81
X      .          1:  3              .          1:  9              .
X!                    .                             .
X  
X    3 RET           RET             *             RET             *
X  @end example
X***************
X*** 1160,1167 ****
X  @example
X  1:  (2, 3)     2:  (2, 3)     1:  (8, -1)    2:  (8, -1)    1:  (9, -1)
X      .          1:  (1, -2)        .          1:  1              .
X!                    .                             .          
X!                                                             
X   (2,3) RET      (1,-2) RET        *              1 RET          +
X  @end example
X  @end group
X--- 1177,1184 ----
X  @example
X  1:  (2, 3)     2:  (2, 3)     1:  (8, -1)    2:  (8, -1)    1:  (9, -1)
X      .          1:  (1, -2)        .          1:  1              .
X!                    .                             .
X! 
X   (2,3) RET      (1,-2) RET        *              1 RET          +
X  @end example
X  @end group
X***************
X*** 1750,1756 ****
X  @example
X  1:  3.14159265359   1:  0.785398163398   1:  0.707106781187
X      .                   .                .
X!                                         
X      P                   4 /       m r    S
X  @end example
X  @end group
X--- 1767,1773 ----
X  @example
X  1:  3.14159265359   1:  0.785398163398   1:  0.707106781187
X      .                   .                .
X! 
X      P                   4 /       m r    S
X  @end example
X  @end group
X***************
X*** 1762,1768 ****
X  @example
X  1:  0.707106781187   1:  0.785398163398   1:  45.
X      .                    .                .
X!                                         
X      .5 Q        m r      I S      m d     U I S
X  @end example
X  @end group
X--- 1779,1785 ----
X  @example
X  1:  0.707106781187   1:  0.785398163398   1:  45.
X      .                    .                .
X! 
X      .5 Q        m r      I S      m d     U I S
X  @end example
X  @end group
X***************
X*** 2628,2634 ****
X  for the dot product as before.
X  
X  A slight variant of vector reduction is the @dfn{accumulate} operation,
X! @kbd{H V R}.  This produces a vector of the intermediate results from
X  a corresponding reduction.  Here we compute a table of factorials:
X  
X  @group
X--- 2645,2651 ----
X  for the dot product as before.
X  
X  A slight variant of vector reduction is the @dfn{accumulate} operation,
X! @kbd{V U}.  This produces a vector of the intermediate results from
X  a corresponding reduction.  Here we compute a table of factorials:
X  
X  @group
X***************
X*** 2636,2642 ****
X  1:  [1, 2, 3, 4, 5, 6]    1:  [1, 2, 6, 24, 120, 720]
X      .                         .
X  
X!     v x 6 RET                 H V R *
X  @end example
X  @end group
X  
X--- 2653,2659 ----
X  1:  [1, 2, 3, 4, 5, 6]    1:  [1, 2, 6, 24, 120, 720]
X      .                         .
X  
X!     v x 6 RET                 V U *
X  @end example
X  @end group
X  
X***************
X*** 2680,2686 ****
X  
X  Position the cursor at the upper-left corner of this table, just
X  to the left of the @samp{1.34}.  Press @kbd{C-@@} to set the mark.
X! (This may also be found on @kbd{C-2}, @kbd{C-SPC}, or @kbd{C-NUL}.)
X  Now position the cursor to the lower-right, just after the @samp{1.354}.
X  You have now defined this region as an Emacs ``rectangle.''  Still
X  in the Info buffer, type @kbd{M-x calc-grab-region}.  This command
X--- 2697,2703 ----
X  
X  Position the cursor at the upper-left corner of this table, just
X  to the left of the @samp{1.34}.  Press @kbd{C-@@} to set the mark.
X! (On your system this may be @kbd{C-2}, @kbd{C-SPC}, or @kbd{C-NUL}.)
X  Now position the cursor to the lower-right, just after the @samp{1.354}.
X  You have now defined this region as an Emacs ``rectangle.''  Still
X  in the Info buffer, type @kbd{M-x calc-grab-region}.  This command
X***************
X*** 2740,2746 ****
X  @group
X  @example
X  1:  41.63                 1:  98.0003
X!     .                         .              
X  
X   r 1 V R +   s 3 DEL       r 1 2 V M ^ V R +   s 4 DEL
X  @end example
X--- 2757,2763 ----
X  @group
X  @example
X  1:  41.63                 1:  98.0003
X!     .                         .
X  
X   r 1 V R +   s 3 DEL       r 1 2 V M ^ V R +   s 4 DEL
X  @end example
X***************
X*** 2800,2806 ****
X  @example
X  1:  13.613     2:  13.613     1:  -8.09358   1:  -0.425978
X      .          1:  21.70658       .              .
X!                    .               
X  
X     r 5            r 8 r 3 *       -              r 7 /   s 9
X  @end example
X--- 2817,2823 ----
X  @example
X  1:  13.613     2:  13.613     1:  -8.09358   1:  -0.425978
X      .          1:  21.70658       .              .
X!                    .
X  
X     r 5            r 8 r 3 *       -              r 7 /   s 9
X  @end example
X***************
X*** 3576,3581 ****
X--- 3593,3607 ----
X  If there had been several different values, we could have used
X  @kbd{V R X} to find the global maximum.
X  
X+ Calc has a built-in @kbd{a P} command that solves an equation using
X+ @kbd{H a S} and returns a vector of all the solutions.  It simply
X+ automates the job we just did by hand.
X+ 
X+ (@bullet) @strong{Exercise 2.}  Find the values for which the
X+ original formula @samp{17 x^2 - 6 x^4 + 3} is zero.  (There are
X+ four, two of which are complex numbers.)  Verify that these
X+ solutions are in fact correct.  @xref{Algebra Answer 2, 2}. (@bullet)
X+ 
X  @cindex Area under a curve
X  What is the area under the portion of this curve from @samp{x} = 1 to 2?
X  This is simply the integral of the function:
X***************
X*** 3601,3610 ****
X  @end example
X  @end group
X  
X- (@bullet) @strong{Exercise 2.}  Find the values for which the
X- original formula @samp{17 x^2 - 6 x^4 + 3} is zero.  (There are
X- four, two of which are complex numbers.)  @xref{Algebra Answer 2, 2}. (@bullet)
X- 
X  (@bullet) @strong{Exercise 3.}  Find the integral from 1 to @samp{y}
X  of @samp{x sin(pi x)} (where the sine is calculated in radians).
X  Find the values of the integral for integer @samp{y} from 1 to 5.
X--- 3627,3632 ----
X***************
X*** 3805,3813 ****
X  the item in level 3 of the stack, without disturbing the rest of
X  the stack.  @xref{Programming Answer 1, 1}. (@bullet)
X  
X! (@bullet) @strong{Exercise 2.}  Define a keyboard macro to compute
X! @samp{sin(x) / x}, where @samp{x} is the number on the top of the
X! stack.  @xref{Programming Answer 2, 2}. (@bullet)
X  
X  (@bullet) @strong{Exercise 3.}  Define a keyboard macro to compute
X  the average (mean) value of a list of numbers.
X--- 3827,3849 ----
X  the item in level 3 of the stack, without disturbing the rest of
X  the stack.  @xref{Programming Answer 1, 1}. (@bullet)
X  
X! (@bullet) @strong{Exercise 2.}  Define keyboard macros to compute
X! the following functions:
X! 
X! @enumerate
X! @item
X! Compute @samp{sin(x) / x}, where @samp{x} is the number on the
X! top of the stack.
X! 
X! @item
X! Compute the base-@samp{b} logarithm, just like the @kbd{B} key except
X! the arguments are taken in the opposite order.
X! 
X! @item
X! Produce a vector of integers from 1 to the integer on the top of
X! the stack.
X! @end enumerate
X! @xref{Programming Answer 2, 2}. (@bullet)
X  
X  (@bullet) @strong{Exercise 3.}  Define a keyboard macro to compute
X  the average (mean) value of a list of numbers.
X***************
X*** 3920,3926 ****
X  1:  0         2:  1                 .                 1:  3.597739
X      .         1:  20                                      .
X                    .
X!              
X   0 s 7 DEL      1 RET 20     Z ( & s + 7 DEL 1 Z )        r 7
X  @end example
X  @end group
X--- 3956,3962 ----
X  1:  0         2:  1                 .                 1:  3.597739
X      .         1:  20                                      .
X                    .
X! 
X   0 s 7 DEL      1 RET 20     Z ( & s + 7 DEL 1 Z )        r 7
X  @end example
X  @end group
X***************
X*** 4253,4259 ****
X  * Algebra Answer 3::       Integral of x sin(pi x)
X  * Algebra Answer 4::       Simpson's rule
X  * Programming Answer 1::   Negate third stack element
X! * Programming Answer 2::   Compute sin(x) / x
X  * Programming Answer 3::   Average value of a list
X  * Programming Answer 4::   Continued fraction phi
X  * Programming Answer 5::   Matrix Fibonacci numbers
X--- 4289,4295 ----
X  * Algebra Answer 3::       Integral of x sin(pi x)
X  * Algebra Answer 4::       Simpson's rule
X  * Programming Answer 1::   Negate third stack element
X! * Programming Answer 2::   Compute sin(x) / x, etc.
X  * Programming Answer 3::   Average value of a list
X  * Programming Answer 4::   Continued fraction phi
X  * Programming Answer 5::   Matrix Fibonacci numbers
X***************
X*** 4363,4369 ****
X  @example
X  1:  ( ...      2:  ( ...      1:  (2, ...    2:  (2, ...    2:  (2, ...
X      .          1:  2              .          1:  (2, ...    1:  (2, 3)
X!                    .                             .              . 
X  
X      (              2              ,             SPC            3 )
X  @end example
X--- 4399,4405 ----
X  @example
X  1:  ( ...      2:  ( ...      1:  (2, ...    2:  (2, ...    2:  (2, ...
X      .          1:  2              .          1:  (2, ...    1:  (2, 3)
X!                    .                             .              .
X  
X      (              2              ,             SPC            3 )
X  @end example
X***************
X*** 4900,4906 ****
X  @end group
X  
X  If we did not know the formula for triangular numbers, we could have
X! computed them using an @kbd{H V R +} command.  We could also have
X  gotten them the hard way by mapping a reduction across the original
X  triangular list.
X  
X--- 4936,4942 ----
X  @end group
X  
X  If we did not know the formula for triangular numbers, we could have
X! computed them using an @kbd{V U +} command.  We could also have
X  gotten them the hard way by mapping a reduction across the original
X  triangular list.
X  
X***************
X*** 4986,4992 ****
X  @example
X  2:  [0, 0, 0, ... ]         1:  [0, 0., 0., ... ]    1:  1.75
X  1:  [0, 0.25, 0.5, ... ]        .                        .
X!     .  
X  
X      r 1                         V M *                    V R +
X  @end example
X--- 5022,5028 ----
X  @example
X  2:  [0, 0, 0, ... ]         1:  [0, 0., 0., ... ]    1:  1.75
X  1:  [0, 0.25, 0.5, ... ]        .                        .
X!     .
X  
X      r 1                         V M *                    V R +
X  @end example
X***************
X*** 5055,5066 ****
X  1:  [1, 1, 1, 0, 0, 0, ... ]   1:  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
X      .                              .
X  
X!     H V R *                        v v 1 |
X  @end example
X  @end group
X  
X  Accumulating @kbd{*} across a vector of ones and zeros will preserve
X! only the leftmost run of ones.  These are the carries into all digits
X  except the rightmost digit.  Concatenating a one on the right takes
X  care of aligning the carries properly, and also adding one to the
X  rightmost digit.
X--- 5091,5102 ----
X  1:  [1, 1, 1, 0, 0, 0, ... ]   1:  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
X      .                              .
X  
X!     V U *                          v v 1 |
X  @end example
X  @end group
X  
X  Accumulating @kbd{*} across a vector of ones and zeros will preserve
X! only the initial run of ones.  These are the carries into all digits
X  except the rightmost digit.  Concatenating a one on the right takes
X  care of aligning the carries properly, and also adding one to the
X  rightmost digit.
X***************
X*** 5138,5144 ****
X  
X  @group
X  @example
X! 1:  1.26508260337    1:  0.509433962268   1:  2486645810:4881193627  
X      .                    .                    .
X  
X                           2 ^ P /              c F
X--- 5174,5180 ----
X  
X  @group
X  @example
X! 1:  1.26508260337    1:  0.509433962268   1:  2486645810:4881193627
X      .                    .                    .
X  
X                           2 ^ P /              c F
X***************
X*** 5217,5226 ****
X  
X  @group
X  @example
X! 1:  39.4784176044    1:  789.56 +/- 39.478    1:  12633. +/- 1412.4
X      .                    .                        .
X  
X!     4 P 2 ^ *            20 p 1 *                 4 p .2 RET 2 ^ *
X  @end example
X  @end group
X  
X--- 5253,5262 ----
X  
X  @group
X  @example
X! 1:  19.7392088022    1:  394.78 +/- 19.739    1:  6316.5 +/- 706.21
X      .                    .                        .
X  
X!     2 P 2 ^ *            20 p 1 *                 4 p .2 RET 2 ^ *
X  @end example
X  @end group
X  
X***************
X*** 5229,5237 ****
X  
X  @group
X  @example
X! 3:  12633. +/- 1412.4     2:  12633 +/- 1412.4
X! 2:  12633.                1:  0.1118
X! 1:  1412.4                    .
X      .
X  
X      RET v u                   TAB /
X--- 5265,5273 ----
X  
X  @group
X  @example
X! 3:  6316.5 +/- 706.21     2:  6316.5+/- 706.21
X! 2:  6316.5                1:  0.1118
X! 1:  706.21                    .
X      .
X  
X      RET v u                   TAB /
X***************
X*** 5238,5244 ****
X  @end example
X  @end group
X  
X! Thus the volume is 12633 cubic centimeters, within about 11 percent.
X  
X  @node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
X  @subsection Types Tutorial Exercise 4
X--- 5274,5280 ----
X  @end example
X  @end group
X  
X! Thus the volume is 6316 cubic centimeters, within about 11 percent.
X  
X  @node Types Answer 4, Types Answer 5, Types Answer 3, Answers to Exercises
X  @subsection Types Tutorial Exercise 4
X***************
X*** 5461,5517 ****
X  @node Algebra Answer 2, Algebra Answer 3, Algebra Answer 1, Answers to Exercises
SHAR_EOF
echo "End of part 3, continue with part 4"
echo "4" > s2_seq_.tmp
exit 0
--
Dave Gillespie
  256-80 Caltech Pasadena CA USA 91125
  daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg