• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/calc/

Lines Matching +defs:math +defs:read +defs:expr

48 ;; of the prefixes "math", "Math", or "calc", with the exceptions of
88 ;; Get math-read-big-expr to read sums, products, etc.
89 ;; Change calc-grab-region to use math-read-big-expr.
97 ;; Test accuracy of advanced math functions over whole complex plane.
99 ;; Extend advanced math functions to handle error forms and intervals.
100 ;; Provide a better implementation for math-sin-cos-raw.
101 ;; Provide a better implementation for math-hypot.
102 ;; Provide a better implementation for math-make-frac.
142 ;; Note: Probably a good idea to call math-simplify-extended before
602 math Use Mathematica(tm) notation.
625 If `binary', `math-clip' is applied if appropriate.
626 If `alg', `math-simplify' is applied.
627 If `ext', `math-simplify-extended' is applied.
628 If `units', `math-simplify-units' is applied.")
659 If nil, symbolic math routines make no assumptions about variables.")
856 ;; Define "math-overflow" and "math-underflow" as e-lisp error symbols.
857 (put 'math-overflow 'error-conditions '(error math-overflow calc-error))
858 (put 'math-overflow 'error-message "Floating-point overflow occurred")
859 (put 'math-underflow 'error-conditions '(error math-underflow calc-error))
860 (put 'math-underflow 'error-message "Floating-point underflow occurred")
906 (defvar math-eval-rules-cache-tag t)
907 (defvar math-radix-explicit-format t)
908 (defvar math-expr-function-mapping nil)
909 (defvar math-expr-special-function-mapping nil)
910 (defvar math-expr-variable-mapping nil)
911 (defvar math-read-expr-quotes nil)
912 (defvar math-working-step nil)
913 (defvar math-working-step-2 nil)
914 (defvar var-i '(special-const (math-imaginary 1)))
915 (defvar var-pi '(special-const (math-pi)))
916 (defvar var-e '(special-const (math-e)))
917 (defvar var-phi '(special-const (math-phi)))
918 (defvar var-gamma '(special-const (math-gamma-const)))
919 (defvar var-Modes '(special-const (math-get-modes-vec)))
1030 ( ?m . read-kbd-macro )
1066 calc-do-quick-calc calc-match-user-syntax math-build-parse-table
1067 math-find-user-tokens math-read-expr-list math-read-exprs math-read-if
1068 math-read-token math-remove-dashes math-read-preprocess-string)
1076 calcFunc-inv calcFunc-trunc math-concat math-constp math-div2
1077 math-div2-bignum math-do-working math-evenp math-fixnatnump
1078 math-fixnump math-floor math-imod math-ipow math-looks-negp math-mod
1079 math-negp math-posp math-pow math-read-radix-digit math-reject-arg
1080 math-trunc math-zerop)))
1120 (let ((key (calc-read-key-sequence
1134 (defun calc-read-key-sequence (prompt map)
1139 (let ((key (calc-read-key t)))
1145 (read-key-sequence nil))
1167 Press ? repeatedly for more complete help. Press `h i' to read the
1168 Calc manual on-line, `h s' to read the summary, or `h t' for the tutorial.
1198 (setq buffer-read-only t)
1259 (setq buffer-read-only t)
1265 (let ((buffer-read-only nil))
1470 (math-sub
1471 (calcFunc-unixtime (math-parse-date end-time) 0)
1472 (calcFunc-unixtime (math-parse-date calc-start-time)
1474 (if (math-lessp 1 time)
1675 (let ((buffer-read-only nil))
1676 (insert (math-format-stack-value entry) "\n"))
1719 (math-normalize val)
1741 (let ((buffer-read-only nil))
1776 (math-check-complete (calc-normalize (calc-top n sel-mode))))
1789 (mapcar 'math-check-complete
1798 (buffer-read-only nil)
1804 (let ((buffer-read-only nil))
1829 (let* ((buffer-read-only nil)
1844 (insert (math-format-stack-value (car thing)) "\n")
1898 (math-showing-full-precision
1899 (math-format-flat-expr val 0)))
1904 (buffer-read-only nil))
2000 (mapcar 'math-check-complete
2009 (math-check-complete (calc-top 1))))
2108 (read-from-minibuffer
2116 (read-from-minibuffer "Calc: " "" calc-digit-map))
2118 (or calc-digit-value (setq calc-digit-value (math-read-number buf)))
2140 (math-read-number str))))
2224 (insert (math-format-flat-expr calc-previous-modulo 0))
2238 (let ((dig (math-read-radix-digit
2373 (defvar math-eval-rules-cache)
2374 (defvar math-eval-rules-cache-other)
2377 (defvar math-normalize-a)
2378 (defun math-normalize (math-normalize-a)
2380 ((not (consp math-normalize-a))
2381 (if (integerp math-normalize-a)
2382 (if (or (>= math-normalize-a 1000000) (<= math-normalize-a -1000000))
2383 (math-bignum math-normalize-a)
2384 math-normalize-a)
2385 math-normalize-a))
2386 ((eq (car math-normalize-a) 'bigpos)
2387 (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0)
2388 (let* ((last (setq math-normalize-a
2389 (copy-sequence math-normalize-a))) (digs math-normalize-a))
2393 (if (cdr (cdr (cdr math-normalize-a)))
2394 math-normalize-a
2396 ((cdr (cdr math-normalize-a)) (+ (nth 1 math-normalize-a)
2397 (* (nth 2 math-normalize-a) 1000)))
2398 ((cdr math-normalize-a) (nth 1 math-normalize-a))
2400 ((eq (car math-normalize-a) 'bigneg)
2401 (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0)
2402 (let* ((last (setq math-normalize-a (copy-sequence math-normalize-a)))
2403 (digs math-normalize-a))
2407 (if (cdr (cdr (cdr math-normalize-a)))
2408 math-normalize-a
2410 ((cdr (cdr math-normalize-a)) (- (+ (nth 1 math-normalize-a)
2411 (* (nth 2 math-normalize-a) 1000))))
2412 ((cdr math-normalize-a) (- (nth 1 math-normalize-a)))
2414 ((eq (car math-normalize-a) 'float)
2415 (math-make-float (math-normalize (nth 1 math-normalize-a))
2416 (nth 2 math-normalize-a)))
2417 ((or (memq (car math-normalize-a)
2422 (integerp (car math-normalize-a))
2423 (and (consp (car math-normalize-a))
2424 (not (eq (car (car math-normalize-a)) 'lambda))))
2426 (math-normalize-fancy math-normalize-a))
2430 (math-normalize-nonstandard))
2431 (let ((args (mapcar 'math-normalize (cdr math-normalize-a))))
2434 (assq (car math-normalize-a) '( ( + . math-add )
2435 ( - . math-sub )
2436 ( * . math-mul )
2437 ( / . math-div )
2438 ( % . math-mod )
2439 ( ^ . math-pow )
2440 ( neg . math-neg )
2441 ( | . math-concat ) ))))
2444 (or (eq var-EvalRules math-eval-rules-cache-tag)
2447 (math-recompile-eval-rules)))
2448 (and (or math-eval-rules-cache-other
2449 (assq (car math-normalize-a)
2450 math-eval-rules-cache))
2451 (math-apply-rewrites
2452 (cons (car math-normalize-a) args)
2453 (cdr math-eval-rules-cache)
2454 nil math-eval-rules-cache))))
2457 (and (or (consp (car math-normalize-a))
2458 (fboundp (car math-normalize-a))
2461 (fboundp (car math-normalize-a))))
2462 (apply (car math-normalize-a) args)))))
2465 (cons (car math-normalize-a) args))
2470 (cons (car math-normalize-a) args)))
2474 (cons (car math-normalize-a) args))
2478 (cons (car math-normalize-a) args))
2480 (math-overflow
2482 (cons (car math-normalize-a) args))
2484 (math-underflow
2486 (cons (car math-normalize-a) args))
2492 (math-normalize (cons (car math-normalize-a) args)))
2494 (if (consp (car math-normalize-a))
2495 (math-dimension-error)
2496 (cons (car math-normalize-a) args))))))))
2501 (defun math-floatp (a)
2504 (or (math-floatp (nth 1 a))
2505 (math-floatp (nth 2 a))
2506 (and (eq (car a) 'intv) (math-floatp (nth 3 a)))))
2508 (math-floatp (nth 1 a)))))
2513 (defun math-check-complete (a)
2523 (defun math-bignum (a)
2525 (cons 'bigpos (math-bignum-big a))
2526 (cons 'bigneg (math-bignum-big (- a)))))
2528 (defun math-bignum-big (a) ; [L s]
2531 (cons (% a 1000) (math-bignum-big (/ a 1000)))))
2535 (defun math-make-float (mant exp)
2538 (let* ((ldiff (- calc-internal-prec (math-numdigs mant))))
2540 (setq mant (math-scale-rounding mant ldiff)
2550 (setq digs (math-div10-bignum digs)
2552 (setq mant (math-normalize (cons (car mant) digs))))))
2557 (<= (+ exp (math-numdigs mant) -1) -4000000))
2558 (signal 'math-underflow nil)
2560 (>= (+ exp (math-numdigs mant) -1) 4000000))
2561 (signal 'math-overflow nil)
2564 (defun math-div10-bignum (a) ; [l l]
2567 (math-div10-bignum (cdr a)))
2571 (defun math-float (a)
2572 (cond ((Math-integerp a) (math-make-float a 0))
2573 ((eq (car a) 'frac) (math-div (math-float (nth 1 a)) (nth 2 a)))
2576 (cons (car a) (mapcar 'math-float (cdr a))))
2577 (t (math-float-fancy a))))
2580 (defun math-neg (a)
2587 (cons (car a) (mapcar 'math-neg (cdr a))))
2588 (t (math-neg-fancy a))))
2592 (defun math-numdigs (a)
2599 (cond ((>= a 100) (+ (math-numdigs (/ a 1000)) 3))
2605 (t (math-numdigs (- a))))))
2608 (defun math-scale-int (a n)
2610 ((> n 0) (math-scale-left a n))
2611 (t (math-normalize (math-scale-right a (- n))))))
2613 (defun math-scale-left (a n) ; [I I S]
2617 (cons (car a) (math-scale-left-bignum (cdr a) n))
2620 (math-scale-left (math-bignum a) n)
2621 (math-scale-left (* a 1000) (- n 3)))
2624 (math-scale-left (math-bignum a) 2)
2627 (math-scale-left (math-bignum a) 1)
2630 (defun math-scale-left-bignum (a n)
2635 (math-mul-bignum-digit a (if (= n 2) 100 10) 0)
2638 (defun math-scale-right (a n) ; [i i S]
2642 (cons (car a) (math-scale-right-bignum (cdr a) n))
2646 (- (math-scale-right (- a) n)))
2656 (defun math-scale-right-bignum (a n) ; [L L S; l l S]
2661 (cdr (math-mul-bignum-digit a (if (= n 2) 10 100) 0))
2665 (defun math-scale-rounding (a n)
2667 (math-scale-left a n))
2669 (math-normalize
2672 (math-scale-right-bignum (cdr a) (- -3 n))
2674 (math-mul-bignum-digit (cdr a) 10 0)
2676 (math-mul-bignum-digit (cdr a) 100 0)
2681 (math-add-bignum (cdr val) '(1))
2687 (- (math-scale-rounding (- a) n))
2690 (/ (+ (math-scale-right a (- -1 n)) 5) 10))))))
2694 (defun math-add (a b)
2700 (math-bignum a)
2703 (if (and (math-floatp a) (Math-ratp b)) (math-float b) b))
2705 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a))
2710 (or (consp a) (setq a (math-bignum a)))
2711 (or (consp b) (setq b (math-bignum b)))
2714 (cons 'bigneg (math-add-bignum (cdr a) (cdr b)))
2715 (math-normalize
2716 (let ((diff (math-sub-bignum (cdr b) (cdr a))))
2718 (cons 'bigneg (math-sub-bignum (cdr a) (cdr b)))
2721 (math-normalize
2722 (let ((diff (math-sub-bignum (cdr a) (cdr b))))
2724 (cons 'bigneg (math-sub-bignum (cdr b) (cdr a)))
2726 (cons 'bigpos (math-add-bignum (cdr a) (cdr b)))))))
2733 (setq a (math-float a)))
2735 (setq b (math-float b)))
2736 (math-add-float a b)))
2738 (math-add-objects-fancy a b))))
2740 (math-add-symb-fancy a b))))
2742 (defun math-add-bignum (a b) ; [L L L; l l l]
2761 (nconc a (math-add-bignum b '(1)))
2776 (defun math-sub-bignum (a b) ; [l l l]
2814 (defun math-add-float (a b) ; [F F F]
2819 (math-make-float (math-add (nth 1 b)
2822 (math-scale-left (nth 1 a) ediff)))
2827 (math-make-float (math-add (nth 1 a)
2828 (math-scale-left (nth 1 b) ediff))
2832 (defun math-sub (a b)
2834 (math-add a (math-neg b))
2837 (math-bignum a)
2840 (defun math-sub-float (a b) ; [F F F]
2845 (math-make-float (math-add (Math-integer-neg (nth 1 b))
2848 (math-scale-left (nth 1 a) ediff)))
2853 (math-make-float (math-add (nth 1 a)
2855 (math-scale-left (nth 1 b) ediff)))
2860 (defun math-mul (a b)
2867 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a)
2869 (math-mul-zero a b)))
2872 (if (and (math-floatp a) (Math-ratp b)) (math-float b) b)
2874 (math-mul-zero b a)))
2879 (or (consp a) (setq a (math-bignum a)))
2880 (or (consp b) (setq b (math-bignum b)))
2881 (math-normalize
2885 (math-mul-bignum (cdr a) (cdr b))
2886 (math-mul-bignum-digit (cdr a) (nth 1 b) 0))
2887 (math-mul-bignum-digit (cdr b) (nth 1 a) 0))))))
2894 (setq a (math-float a)))
2896 (setq b (math-float b)))
2897 (math-make-float (math-mul (nth 1 a) (nth 1 b))
2900 (math-mul-objects-fancy a b))))
2902 (math-mul-symb-fancy a b))))
2904 (defun math-infinitep (a &optional undir)
2906 (if (or (not (eq (car a) '*)) (math-infinitep (nth 1 a)))
2917 (defun math-mul-bignum (a b)
2923 (math-mul-bignum-digit a (car b) 0)))
2943 (defun math-mul-bignum-digit (a d c)
2963 (defun math-idivmod (a b)
2965 (math-reject-arg a "*Division by zero"))
2968 (let ((res (math-div-bignum-digit (cdr a) b)))
2970 (math-normalize (cons (car a) (car res)))
2972 (or (consp a) (setq a (math-bignum a)))
2973 (or (consp b) (setq b (math-bignum b)))
2974 (let ((res (math-div-bignum (cdr a) (cdr b))))
2976 (math-normalize (cons (if (eq (car a) (car b)) 'bigpos 'bigneg)
2978 (math-normalize (cons (car a) (cdr res))))))
2981 (defun math-quotient (a b) ; [I I I] [Public]
2984 (math-reject-arg a "*Division by zero")
2988 (math-reject-arg a "*Division by zero")
2989 (math-normalize (cons (car a)
2990 (car (math-div-bignum-digit (cdr a) b)))))
2991 (or (consp a) (setq a (math-bignum a)))
2992 (or (consp b) (setq b (math-bignum b)))
2996 (res (math-div-bignum-big (math-mul-bignum-digit (cdr a) d 0)
2997 (math-mul-bignum-digit (cdr b) d 0)
2999 (math-normalize (cons (if (eq (car a) (car b)) 'bigpos 'bigneg)
3005 (defun math-div-bignum (a b)
3010 (res (math-div-bignum-big (math-mul-bignum-digit a d 0)
3011 (math-mul-bignum-digit b d 0)
3016 (car (math-div-bignum-digit (cdr res) d)))))
3017 (let ((res (math-div-bignum-digit a (car b))))
3021 (defun math-div-bignum-digit (a b)
3023 (let* ((res (math-div-bignum-digit (cdr a) b))
3030 (defun math-div-bignum-big (a b alen blen) ; [l.l l L]
3033 (let* ((res (math-div-bignum-big (cdr a) b (1- alen) blen))
3035 (res2 (math-div-bignum-part num b blen)))
3040 (defun math-div-bignum-part (a b blen) ; a < b*1000 [D.l l L]
3044 (math-div-bignum-try a b (math-mul-bignum-digit b guess 0) guess)))
3046 (defun math-div-bignum-try (a b c guess) ; [D.l l l D]
3047 (let ((rem (math-sub-bignum a c)))
3049 (math-div-bignum-try a b (math-sub-bignum c b) (1- guess))
3054 (defun math-div (a b)
3058 (math-div-by-zero a b))
3061 (if (and (math-floatp b) (Math-ratp a)) (math-float a) a)
3063 (math-div-zero a b)))
3067 (let ((q (math-idivmod a b)))
3073 (math-make-frac a b))
3074 (math-div-float (math-make-float a 0)
3075 (math-make-float b 0))))))
3082 (setq a (math-float a)))
3084 (setq b (math-float b)))
3085 (math-div-float a b)))
3087 (math-div-objects-fancy a b))))
3089 (math-div-symb-fancy a b))))
3091 (defun math-div-float (a b) ; [F F F]
3093 (- (math-numdigs (nth 1 a)) (math-numdigs (nth 1 b))))
3095 (math-make-float (math-quotient (math-scale-int (nth 1 a) ldiff) (nth 1 b))
3103 (defun math-format-stack-value (entry)
3106 (math-comp-selected (nth 2 entry))
3115 (null math-comp-selected))
3116 (math-format-number a))
3118 (math-compose-expr a 0))))
3119 (off (math-stack-value-offset c))
3121 (and math-comp-selected (setq calc-any-selections t))
3125 (setq c (math-comp-concat (make-string off ?\s) c)))
3127 (setq c (math-comp-concat (if (eq a 'top-of-stack)
3132 (setq c (math-comp-concat (if (eq calc-language 'big)
3133 (if math-comp-selected
3142 (make-string (max (- w (math-comp-width c)
3150 (math-composition-to-string c w)))
3160 ;; The variables math-svo-c, math-svo-wid and math-svo-off are local
3161 ;; to math-stack-value-offset, but are used by math-stack-value-offset-fancy
3164 (defun math-stack-value-offset (math-svo-c)
3166 (math-svo-wid (calc-window-width))
3167 math-svo-off)
3171 (math-stack-value-offset-fancy))
3172 (setq math-svo-off (or calc-display-origin 0))
3174 (setq math-svo-wid calc-line-breaking)))
3175 (cons (max (- math-svo-off (length calc-left-label)) 0)
3176 (+ math-svo-wid num))))
3186 (defun math-format-value (a &optional w)
3189 (math-format-number a)
3192 (math-composition-to-string (math-compose-expr a 0) w))))
3201 (defun math-comp-concat (c1 c2)
3210 (defun math-format-flat-expr (a prec)
3224 (math-format-number a)))
3227 (math-format-flat-expr-fancy a prec))))
3232 (defun math-format-number (a &optional prec) ; [X N] [Public]
3237 (math-format-number (math-adjust-fraction a)))
3243 (concat "-" (math-format-number (- a)))
3245 (if math-radix-explicit-format
3250 (math-format-binary a)
3251 (math-format-radix a)))
3254 (math-format-binary a)
3255 (math-format-radix a))))
3256 (math-format-radix a))))
3257 (math-format-number (math-bignum a))))
3260 ((eq (car a) 'bigpos) (math-format-bignum (cdr a)))
3261 ((eq (car a) 'bigneg) (concat "-" (math-format-bignum (cdr a))))
3264 (concat "-" (math-format-number (math-neg a)))
3273 (> (+ exp (math-numdigs mant)) (- figs))))
3275 (setq mant (math-scale-rounding mant (+ exp figs))
3278 (math-format-bignum-decimal (cdr mant))))
3288 (setq str (math-group-float str))))
3292 (let ((adj (- figs (math-numdigs mant))))
3294 (setq mant (math-scale-rounding mant adj)
3298 (math-format-bignum-decimal (cdr mant))))
3318 (setq str (math-group-float str))))
3321 (1+ (math-mod (+ eadj 300002) 3))
3331 (setq str (math-group-float str)))
3332 (setq str (format (if (memq calc-language '(math maple))
3340 (math-format-number-fancy a prec))))
3342 (defun math-format-bignum (a) ; [X L]
3346 (math-format-bignum-decimal a)
3348 (math-format-bignum-fancy a)))
3350 (defun math-format-bignum-decimal (a) ; [X L]
3362 (defun math-read-number (s)
3363 (math-normalize
3368 (let ((digs (math-match-substring s 1)))
3372 (math-read-number (concat "8#" digs))
3375 (cons 'bigpos (math-read-bignum digs))))))
3379 (math-read-number (concat (math-match-substring s 1)
3380 (math-match-substring s 2))))
3384 (let ((val (math-read-number (math-match-substring s 1))))
3385 (and val (if (eq (aref s 0) ?+) val (math-neg val)))))
3390 (math-read-number-fancy s))
3394 (let ((int (math-match-substring s 1))
3395 (frac (math-match-substring s 2)))
3398 (let ((int (if (> ilen 0) (math-read-number int) 0))
3399 (frac (if (> flen 0) (math-read-number frac) 0)))
3402 (math-add (math-scale-int int flen) frac)
3407 (let ((mant (math-match-substring s 1))
3408 (exp (math-match-substring s 2)))
3409 (let ((mant (if (> (length mant) 0) (math-read-number mant) 1))
3413 (let ((mant (math-float mant)))
3419 (defun math-match-substring (s n)
3424 (defun math-read-bignum (s) ; [l X]
3427 (math-read-bignum (substring s 0 -3)))
3431 (defconst math-tex-ignore-words
3446 (defconst math-latex-ignore-words
3447 (append math-tex-ignore-words
3450 (defconst math-eqn-ignore-words
3458 (defconst math-standard-opers
3487 ( "?" (math-read-if) 91 90 )
3495 (defvar math-expr-opers math-standard-opers)
3549 (math-do-defmath func args body))
3553 (defun calc-read-key (&optional optkey)
3560 (let ((key (read-event)))