2020-10-10 16:00:51 -04:00
|
|
|
;;; calc-vec.el --- vector functions for Calc -*- lexical-binding:t -*-
|
2001-11-19 07:44:56 +00:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
;; Copyright (C) 1990-1993, 2001-2020 Free Software Foundation, Inc.
|
2001-11-19 07:44:56 +00:00
|
|
|
|
|
|
|
;; Author: David Gillespie <daveg@synaptics.com>
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:16:00 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-03-19 20:59:53 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:16:00 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
2007-03-19 20:59:53 +00:00
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2007-03-19 20:59:53 +00:00
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
;;; Commentary:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
;;; Code:
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;; This file is autoloaded from calc-ext.el.
|
|
|
|
|
2004-11-30 17:28:25 +00:00
|
|
|
(require 'calc-ext)
|
2001-11-06 18:59:06 +00:00
|
|
|
(require 'calc-macs)
|
|
|
|
|
2007-11-27 04:08:41 +00:00
|
|
|
;; Declare functions which are defined elsewhere.
|
|
|
|
(declare-function math-read-expr-level "calc-aent" (exp-prec &optional exp-term))
|
|
|
|
|
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-display-strings (n)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(message (if (calc-change-mode 'calc-display-strings n t t)
|
2001-11-19 07:44:56 +00:00
|
|
|
"Displaying vectors of integers as quoted strings"
|
|
|
|
"Displaying vectors of integers normally"))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun calc-pack (n)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(let* ((nn (if n 1 2))
|
|
|
|
(mode (if n (prefix-numeric-value n) (calc-top-n 1)))
|
|
|
|
(mode (if (and (Math-vectorp mode) (cdr mode)) (cdr mode)
|
|
|
|
(if (integerp mode) mode
|
|
|
|
(error "Packing mode must be an integer or vector of integers"))))
|
|
|
|
(num (calc-pack-size mode))
|
|
|
|
(items (calc-top-list num nn)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-enter-result (+ nn num -1) "pack" (calc-pack-items mode items)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-pack-size (mode)
|
|
|
|
(cond ((consp mode)
|
|
|
|
(let ((size 1))
|
|
|
|
(while mode
|
|
|
|
(or (integerp (car mode)) (error "Vector of integers expected"))
|
|
|
|
(setq size (* size (calc-pack-size (car mode)))
|
|
|
|
mode (cdr mode)))
|
|
|
|
(if (= size 0)
|
|
|
|
(error "Zero dimensions not allowed")
|
|
|
|
size)))
|
|
|
|
((>= mode 0) mode)
|
|
|
|
(t (or (cdr (assq mode '((-3 . 3) (-13 . 1) (-14 . 3) (-15 . 6))))
|
2001-11-14 09:09:09 +00:00
|
|
|
2))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-pack-items (mode items)
|
|
|
|
(cond ((consp mode)
|
|
|
|
(if (cdr mode)
|
|
|
|
(let* ((size (calc-pack-size (cdr mode)))
|
|
|
|
(len (length items))
|
|
|
|
(new nil)
|
|
|
|
p row)
|
|
|
|
(while (> len 0)
|
|
|
|
(setq p (nthcdr (1- size) items)
|
|
|
|
row items
|
|
|
|
items (cdr p)
|
|
|
|
len (- len size))
|
|
|
|
(setcdr p nil)
|
|
|
|
(setq new (cons (calc-pack-items (cdr mode) row) new)))
|
|
|
|
(calc-pack-items (car mode) (nreverse new)))
|
|
|
|
(calc-pack-items (car mode) items)))
|
|
|
|
((>= mode 0)
|
|
|
|
(cons 'vec items))
|
|
|
|
((= mode -3)
|
|
|
|
(if (and (math-objvecp (car items))
|
|
|
|
(math-objvecp (nth 1 items))
|
|
|
|
(math-objvecp (nth 2 items)))
|
|
|
|
(if (and (math-num-integerp (car items))
|
|
|
|
(math-num-integerp (nth 1 items)))
|
|
|
|
(if (math-realp (nth 2 items))
|
|
|
|
(cons 'hms items)
|
|
|
|
(error "Seconds must be real"))
|
|
|
|
(error "Hours and minutes must be integers"))
|
|
|
|
(math-normalize (list '+
|
|
|
|
(list '+
|
|
|
|
(if (eq calc-angle-mode 'rad)
|
|
|
|
(list '* (car items)
|
|
|
|
'(hms 1 0 0))
|
|
|
|
(car items))
|
|
|
|
(list '* (nth 1 items) '(hms 0 1 0)))
|
|
|
|
(list '* (nth 2 items) '(hms 0 0 1))))))
|
|
|
|
((= mode -13)
|
|
|
|
(if (math-realp (car items))
|
|
|
|
(cons 'date items)
|
|
|
|
(if (eq (car-safe (car items)) 'date)
|
|
|
|
(car items)
|
|
|
|
(if (math-objvecp (car items))
|
|
|
|
(error "Date value must be real")
|
|
|
|
(cons 'calcFunc-date items)))))
|
|
|
|
((memq mode '(-14 -15))
|
|
|
|
(let ((p items))
|
|
|
|
(while (and p (math-objvecp (car p)))
|
|
|
|
(or (math-integerp (car p))
|
|
|
|
(error "Components must be integers"))
|
|
|
|
(setq p (cdr p)))
|
|
|
|
(if p
|
|
|
|
(cons 'calcFunc-date items)
|
|
|
|
(list 'date (math-dt-to-date items)))))
|
|
|
|
((or (eq (car-safe (car items)) 'vec)
|
|
|
|
(eq (car-safe (nth 1 items)) 'vec))
|
|
|
|
(let* ((x (car items))
|
|
|
|
(vx (eq (car-safe x) 'vec))
|
|
|
|
(y (nth 1 items))
|
|
|
|
(vy (eq (car-safe y) 'vec))
|
|
|
|
(z nil)
|
|
|
|
(n (1- (length (if vx x y)))))
|
|
|
|
(and vx vy
|
|
|
|
(/= n (1- (length y)))
|
|
|
|
(error "Vectors must be the same length"))
|
|
|
|
(while (>= (setq n (1- n)) 0)
|
|
|
|
(setq z (cons (calc-pack-items
|
|
|
|
mode
|
|
|
|
(list (if vx (car (setq x (cdr x))) x)
|
|
|
|
(if vy (car (setq y (cdr y))) y)))
|
|
|
|
z)))
|
|
|
|
(cons 'vec (nreverse z))))
|
|
|
|
((= mode -1)
|
|
|
|
(if (and (math-realp (car items)) (math-realp (nth 1 items)))
|
|
|
|
(cons 'cplx items)
|
|
|
|
(if (and (math-objectp (car items)) (math-objectp (nth 1 items)))
|
|
|
|
(error "Components must be real"))
|
|
|
|
(math-normalize (list '+ (car items)
|
|
|
|
(list '* (nth 1 items) '(cplx 0 1))))))
|
|
|
|
((= mode -2)
|
|
|
|
(if (and (math-realp (car items)) (math-anglep (nth 1 items)))
|
|
|
|
(cons 'polar items)
|
|
|
|
(if (and (math-objectp (car items)) (math-objectp (nth 1 items)))
|
|
|
|
(error "Components must be real"))
|
|
|
|
(math-normalize (list '* (car items)
|
|
|
|
(if (math-anglep (nth 1 items))
|
|
|
|
(list 'polar 1 (nth 1 items))
|
|
|
|
(list 'calcFunc-exp
|
|
|
|
(list '*
|
|
|
|
(math-to-radians-2
|
|
|
|
(nth 1 items))
|
|
|
|
(list 'polar
|
|
|
|
1
|
|
|
|
(math-quarter-circle
|
|
|
|
nil)))))))))
|
|
|
|
((= mode -4)
|
|
|
|
(let ((x (car items))
|
|
|
|
(sigma (nth 1 items)))
|
|
|
|
(if (or (math-scalarp x) (not (math-objvecp x)))
|
|
|
|
(if (or (math-anglep sigma) (not (math-objvecp sigma)))
|
|
|
|
(math-make-sdev x sigma)
|
|
|
|
(error "Error component must be real"))
|
|
|
|
(error "Mean component must be real or complex"))))
|
|
|
|
((= mode -5)
|
|
|
|
(let ((a (car items))
|
|
|
|
(m (nth 1 items)))
|
|
|
|
(if (and (math-anglep a) (math-anglep m))
|
|
|
|
(if (math-posp m)
|
|
|
|
(math-make-mod a m)
|
|
|
|
(error "Modulus must be positive"))
|
|
|
|
(if (and (math-objectp a) (math-objectp m))
|
|
|
|
(error "Components must be real"))
|
|
|
|
(list 'calcFunc-makemod a m))))
|
|
|
|
((memq mode '(-6 -7 -8 -9))
|
|
|
|
(let ((lo (car items))
|
|
|
|
(hi (nth 1 items)))
|
|
|
|
(if (and (or (math-anglep lo) (eq (car lo) 'date)
|
|
|
|
(not (math-objvecp lo)))
|
|
|
|
(or (math-anglep hi) (eq (car hi) 'date)
|
|
|
|
(not (math-objvecp hi))))
|
|
|
|
(math-make-intv (+ mode 9) lo hi)
|
|
|
|
(error "Components must be real"))))
|
|
|
|
((eq mode -10)
|
|
|
|
(if (math-zerop (nth 1 items))
|
|
|
|
(error "Denominator must not be zero")
|
|
|
|
(if (and (math-integerp (car items)) (math-integerp (nth 1 items)))
|
|
|
|
(math-normalize (cons 'frac items))
|
|
|
|
(if (and (math-objectp (car items)) (math-objectp (nth 1 items)))
|
|
|
|
(error "Components must be integers"))
|
|
|
|
(cons 'calcFunc-fdiv items))))
|
|
|
|
((memq mode '(-11 -12))
|
|
|
|
(if (and (math-realp (car items)) (math-integerp (nth 1 items)))
|
|
|
|
(calcFunc-scf (math-float (car items)) (nth 1 items))
|
|
|
|
(if (and (math-objectp (car items)) (math-objectp (nth 1 items)))
|
|
|
|
(error "Components must be integers"))
|
|
|
|
(math-normalize
|
|
|
|
(list 'calcFunc-scf
|
|
|
|
(list 'calcFunc-float (car items))
|
|
|
|
(nth 1 items)))))
|
|
|
|
(t
|
2001-11-14 09:09:09 +00:00
|
|
|
(error "Invalid packing mode: %d" mode))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2001-11-19 07:44:56 +00:00
|
|
|
(defvar calc-unpack-with-type nil)
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-unpack (mode)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(let ((calc-unpack-with-type t))
|
|
|
|
(calc-pop-push-record-list 1 "unpk" (calc-unpack-item
|
|
|
|
(and mode
|
|
|
|
(prefix-numeric-value mode))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-top))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-unpack-type (item)
|
|
|
|
(cond ((eq (car-safe item) 'vec)
|
|
|
|
(1- (length item)))
|
|
|
|
((eq (car-safe item) 'intv)
|
|
|
|
(- (nth 1 item) 9))
|
|
|
|
(t
|
|
|
|
(or (cdr (assq (car-safe item) '( (cplx . -1) (polar . -2)
|
|
|
|
(hms . -3) (sdev . -4) (mod . -5)
|
|
|
|
(frac . -10) (float . -11)
|
|
|
|
(date . -13) )))
|
2001-11-14 09:09:09 +00:00
|
|
|
(error "Argument must be a composite object")))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-unpack-item (mode item)
|
|
|
|
(cond ((not mode)
|
|
|
|
(if (or (and (not (memq (car-safe item) '(frac float cplx polar vec
|
|
|
|
hms date sdev mod
|
|
|
|
intv)))
|
|
|
|
(math-objvecp item))
|
|
|
|
(eq (car-safe item) 'var))
|
|
|
|
(error "Argument must be a composite object or function call"))
|
|
|
|
(if (eq (car item) 'intv)
|
|
|
|
(cdr (cdr item))
|
|
|
|
(cdr item)))
|
|
|
|
((> mode 0)
|
|
|
|
(let ((dims nil)
|
* lisp/calc/calc.el: Take advantage of native bignums.
Remove redundant :group args.
(calc-trail-mode): Use inhibit-read-only.
(math-bignum-digit-length, math-bignum-digit-size)
(math-small-integer-size): Delete constants.
(math-normalize): Use native bignums.
(math-bignum, math-bignum-big): Delete functions.
(math-make-float): The mantissa can't be a calc bignum any more.
(math-neg, math-scale-left, math-scale-right, math-scale-rounding)
(math-add, math-sub, math-mul, math-idivmod, math-quotient)
(math-format-number, math-read-number, math-read-number-simple):
Don't bother handling calc bignums.
(math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum)
(math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit)
(math-div-bignum, math-div-bignum-digit, math-div-bignum-big)
(math-div-bignum-part, math-div-bignum-try, math-format-bignum)
(math-format-bignum-decimal, math-read-bignum): Delete functions.
(math-numdigs): Don't presume that native ints are small enough to use
a slow algorithm.
* lisp/calc/calc-aent.el (calc-do-quick-calc):
* lisp/calc/calc-vec.el (calcFunc-vunpack):
* lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums.
* lisp/calc/calc-bin.el (math-bignum-logb-digit-size)
(math-bignum-digit-power-of-two): Remove constants.
(calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor)
(calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement):
Use Emacs's builtin bignums.
(math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum)
(math-not-bignum, math-clip-bignum)
(math-format-bignum-radix, math-format-bignum-binary)
(math-format-bignum-octal, math-format-bignum-hex): Delete functions.
(math-format-binary): Fix old copy&paste error.
* lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg.
(math-prime-test): math-fixnum is now the identity.
* lisp/calc/calc-ext.el: Require cl-lib.
(math-oddp): Use cl-oddp. Don't bother with calc bignums.
(math-integerp, math-natnump, math-ratp, math-realp, math-anglep)
(math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp)
(math-num-natnump, math-objectp, math-check-integer, math-compare):
Don't bother handling calc bignums.
(math-check-fixnum): Use fixnump.
(math-fixnum, math-fixnum-big, math-bignum-test): Remove functions.
(math--format-integer-fancy): Rename from math-format-bignum-fancy.
Adjust for internal bignums.
* lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt.
* lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp)
(Math-integer-posp, Math-negp, Math-posp, Math-integerp)
(Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp)
(Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp)
(Math-integer-neg, Math-primp, Math-num-integerp):
Don't bother handling calc bignums.
(Math-bignum-test): Delete function.
* lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`.
(math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums.
(math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small):
Delete function.
* lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump.
(math-evenp): Use cl-evenp.
(math-zerop, math-negp, math-posp, math-div2): Don't bother handling
calc bignums.
(math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
|
|
|
type new)
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq item (list item))
|
|
|
|
(while (> mode 0)
|
|
|
|
(setq type (calc-unpack-type (car item))
|
|
|
|
dims (cons type dims)
|
|
|
|
new (calc-unpack-item nil (car item)))
|
|
|
|
(while (setq item (cdr item))
|
|
|
|
(or (= (calc-unpack-type (car item)) type)
|
|
|
|
(error "Inconsistent types or dimensions in vector elements"))
|
|
|
|
(setq new (append new (calc-unpack-item nil (car item)))))
|
|
|
|
(setq item new
|
|
|
|
mode (1- mode)))
|
|
|
|
(if (cdr dims) (setq dims (list (cons 'vec (nreverse dims)))))
|
|
|
|
(cond ((eq calc-unpack-with-type 'pair)
|
|
|
|
(list (car dims) (cons 'vec item)))
|
|
|
|
(calc-unpack-with-type
|
|
|
|
(append item dims))
|
|
|
|
(t item))))
|
|
|
|
((eq calc-unpack-with-type 'pair)
|
|
|
|
(let ((calc-unpack-with-type nil))
|
|
|
|
(list mode (cons 'vec (calc-unpack-item mode item)))))
|
|
|
|
((= mode -3)
|
|
|
|
(if (eq (car-safe item) 'hms)
|
|
|
|
(cdr item)
|
|
|
|
(error "Argument must be an HMS form")))
|
|
|
|
((= mode -13)
|
|
|
|
(if (eq (car-safe item) 'date)
|
|
|
|
(cdr item)
|
|
|
|
(error "Argument must be a date form")))
|
|
|
|
((= mode -14)
|
|
|
|
(if (eq (car-safe item) 'date)
|
|
|
|
(math-date-to-dt (math-floor (nth 1 item)))
|
|
|
|
(error "Argument must be a date form")))
|
|
|
|
((= mode -15)
|
|
|
|
(if (eq (car-safe item) 'date)
|
|
|
|
(append (math-date-to-dt (nth 1 item))
|
|
|
|
(and (not (math-integerp (nth 1 item)))
|
|
|
|
(list 0 0 0)))
|
|
|
|
(error "Argument must be a date form")))
|
|
|
|
((eq (car-safe item) 'vec)
|
|
|
|
(let ((x nil)
|
|
|
|
(y nil)
|
|
|
|
res)
|
|
|
|
(while (setq item (cdr item))
|
|
|
|
(setq res (calc-unpack-item mode (car item))
|
|
|
|
x (cons (car res) x)
|
|
|
|
y (cons (nth 1 res) y)))
|
|
|
|
(list (cons 'vec (nreverse x))
|
|
|
|
(cons 'vec (nreverse y)))))
|
|
|
|
((= mode -1)
|
|
|
|
(if (eq (car-safe item) 'cplx)
|
|
|
|
(cdr item)
|
|
|
|
(if (eq (car-safe item) 'polar)
|
|
|
|
(cdr (math-complex item))
|
|
|
|
(if (Math-realp item)
|
|
|
|
(list item 0)
|
|
|
|
(error "Argument must be a complex number")))))
|
|
|
|
((= mode -2)
|
|
|
|
(if (or (memq (car-safe item) '(cplx polar))
|
|
|
|
(Math-realp item))
|
|
|
|
(cdr (math-polar item))
|
|
|
|
(error "Argument must be a complex number")))
|
|
|
|
((= mode -4)
|
|
|
|
(if (eq (car-safe item) 'sdev)
|
|
|
|
(cdr item)
|
|
|
|
(list item 0)))
|
|
|
|
((= mode -5)
|
|
|
|
(if (eq (car-safe item) 'mod)
|
|
|
|
(cdr item)
|
|
|
|
(error "Argument must be a modulo form")))
|
|
|
|
((memq mode '(-6 -7 -8 -9))
|
|
|
|
(if (eq (car-safe item) 'intv)
|
|
|
|
(cdr (cdr item))
|
|
|
|
(list item item)))
|
|
|
|
((= mode -10)
|
|
|
|
(if (eq (car-safe item) 'frac)
|
|
|
|
(cdr item)
|
|
|
|
(if (Math-integerp item)
|
|
|
|
(list item 1)
|
|
|
|
(error "Argument must be a rational number"))))
|
|
|
|
((= mode -11)
|
|
|
|
(if (eq (car-safe item) 'float)
|
|
|
|
(list (nth 1 item) (math-normalize (nth 2 item)))
|
|
|
|
(error "Expected a floating-point number")))
|
|
|
|
((= mode -12)
|
|
|
|
(if (eq (car-safe item) 'float)
|
|
|
|
(list (calcFunc-mant item) (calcFunc-xpon item))
|
|
|
|
(error "Expected a floating-point number")))
|
|
|
|
(t
|
2001-11-14 09:09:09 +00:00
|
|
|
(error "Invalid unpacking mode: %d" mode))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-diag (n)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(calc-enter-result 1 "diag" (if n
|
|
|
|
(list 'calcFunc-diag (calc-top-n 1)
|
|
|
|
(prefix-numeric-value n))
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-diag (calc-top-n 1))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-ident (n)
|
|
|
|
(interactive "NDimension of identity matrix = ")
|
|
|
|
(calc-wrapper
|
|
|
|
(calc-enter-result 0 "idn" (if (eq n 0)
|
|
|
|
'(calcFunc-idn 1)
|
|
|
|
(list 'calcFunc-idn 1
|
2001-11-14 09:09:09 +00:00
|
|
|
(prefix-numeric-value n))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-index (n &optional stack)
|
|
|
|
(interactive "NSize of vector = \nP")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (consp stack)
|
|
|
|
(calc-enter-result 3 "indx" (cons 'calcFunc-index (calc-top-list-n 3)))
|
|
|
|
(calc-enter-result 0 "indx" (list 'calcFunc-index
|
2001-11-14 09:09:09 +00:00
|
|
|
(prefix-numeric-value n))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-build-vector (n)
|
|
|
|
(interactive "NSize of vector = ")
|
|
|
|
(calc-wrapper
|
|
|
|
(calc-enter-result 1 "bldv" (list 'calcFunc-cvec
|
|
|
|
(calc-top-n 1)
|
2001-11-14 09:09:09 +00:00
|
|
|
(prefix-numeric-value n)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-cons (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-hyperbolic)
|
|
|
|
(calc-binary-op "rcns" 'calcFunc-rcons arg)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "cons" 'calcFunc-cons arg))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun calc-head (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-inverse)
|
|
|
|
(if (calc-is-hyperbolic)
|
|
|
|
(calc-unary-op "rtai" 'calcFunc-rtail arg)
|
|
|
|
(calc-unary-op "tail" 'calcFunc-tail arg))
|
|
|
|
(if (calc-is-hyperbolic)
|
|
|
|
(calc-unary-op "rhed" 'calcFunc-rhead arg)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "head" 'calcFunc-head arg)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-tail (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-invert-func)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-head arg))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-vlength (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-hyperbolic)
|
|
|
|
(calc-unary-op "dims" 'calcFunc-mdims arg)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "len" 'calcFunc-vlen arg))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-arrange-vector (n)
|
|
|
|
(interactive "NNumber of columns = ")
|
|
|
|
(calc-wrapper
|
|
|
|
(calc-enter-result 1 "arng" (list 'calcFunc-arrange (calc-top-n 1)
|
2001-11-14 09:09:09 +00:00
|
|
|
(prefix-numeric-value n)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-vector-find (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(let ((func (cons 'calcFunc-find (calc-top-list-n 2))))
|
|
|
|
(calc-enter-result
|
|
|
|
2 "find"
|
2001-11-14 09:09:09 +00:00
|
|
|
(if arg (append func (list (prefix-numeric-value arg))) func)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-subvector ()
|
|
|
|
(interactive)
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-inverse)
|
|
|
|
(calc-enter-result 3 "rsvc" (cons 'calcFunc-rsubvec
|
|
|
|
(calc-top-list-n 3)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-enter-result 3 "svec" (cons 'calcFunc-subvec (calc-top-list-n 3))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-reverse-vector (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "rev" 'calcFunc-rev arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-mask-vector (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "vmsk" 'calcFunc-vmask arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-expand-vector (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-hyperbolic)
|
|
|
|
(calc-enter-result 3 "vexp" (cons 'calcFunc-vexp (calc-top-list-n 3)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "vexp" 'calcFunc-vexp arg))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-sort ()
|
|
|
|
(interactive)
|
|
|
|
(calc-slow-wrapper
|
|
|
|
(if (calc-is-inverse)
|
|
|
|
(calc-enter-result 1 "rsrt" (list 'calcFunc-rsort (calc-top-n 1)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-enter-result 1 "sort" (list 'calcFunc-sort (calc-top-n 1))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-grade ()
|
|
|
|
(interactive)
|
|
|
|
(calc-slow-wrapper
|
|
|
|
(if (calc-is-inverse)
|
|
|
|
(calc-enter-result 1 "rgrd" (list 'calcFunc-rgrade (calc-top-n 1)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-enter-result 1 "grad" (list 'calcFunc-grade (calc-top-n 1))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-histogram (n)
|
2010-05-15 23:43:09 -05:00
|
|
|
(interactive "P")
|
|
|
|
(unless (natnump n)
|
|
|
|
(setq n (math-read-expr (read-string "Centers of bins: "))))
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-slow-wrapper
|
|
|
|
(if calc-hyperbolic-flag
|
|
|
|
(calc-enter-result 2 "hist" (list 'calcFunc-histogram
|
|
|
|
(calc-top-n 2)
|
|
|
|
(calc-top-n 1)
|
2010-05-15 23:43:09 -05:00
|
|
|
n))
|
2001-11-06 18:59:06 +00:00
|
|
|
(calc-enter-result 1 "hist" (list 'calcFunc-histogram
|
|
|
|
(calc-top-n 1)
|
2010-05-15 23:43:09 -05:00
|
|
|
n)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-transpose (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "trn" 'calcFunc-trn arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-conj-transpose (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "ctrn" 'calcFunc-ctrn arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-cross (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "cros" 'calcFunc-cross arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2008-04-07 21:55:05 +00:00
|
|
|
(defun calc-kron (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(calc-binary-op "kron" 'calcFunc-kron arg)))
|
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
(defun calc-remove-duplicates (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "rdup" 'calcFunc-rdup arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-union (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "unio" 'calcFunc-vunion arg '(vec) 'calcFunc-rdup)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-intersect (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "intr" 'calcFunc-vint arg '(vec) 'calcFunc-rdup)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-difference (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "diff" 'calcFunc-vdiff arg '(vec) 'calcFunc-rdup)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-xor (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-binary-op "xor" 'calcFunc-vxor arg '(vec) 'calcFunc-rdup)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-complement (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "cmpl" 'calcFunc-vcompl arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-floor (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "vflr" 'calcFunc-vfloor arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-enumerate (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "enum" 'calcFunc-venum arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-span (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "span" 'calcFunc-vspan arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-set-cardinality (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "card" 'calcFunc-vcard arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-unpack-bits (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (calc-is-inverse)
|
|
|
|
(calc-unary-op "bpck" 'calcFunc-vpack arg)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "bupk" 'calcFunc-vunpack arg))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-pack-bits (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-invert-func)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unpack-bits arg))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun calc-rnorm (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "rnrm" 'calcFunc-rnorm arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-cnorm (arg)
|
|
|
|
(interactive "P")
|
|
|
|
(calc-wrapper
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-unary-op "cnrm" 'calcFunc-cnorm arg)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-mrow (n &optional nn)
|
|
|
|
(interactive "NRow number: \nP")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (consp nn)
|
|
|
|
(calc-enter-result 2 "mrow" (cons 'calcFunc-mrow (calc-top-list-n 2)))
|
|
|
|
(setq n (prefix-numeric-value n))
|
|
|
|
(if (= n 0)
|
|
|
|
(calc-enter-result 1 "getd" (list 'calcFunc-getdiag (calc-top-n 1)))
|
|
|
|
(if (< n 0)
|
|
|
|
(calc-enter-result 1 "rrow" (list 'calcFunc-mrrow
|
|
|
|
(calc-top-n 1) (- n)))
|
|
|
|
(calc-enter-result 1 "mrow" (list 'calcFunc-mrow
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-top-n 1) n)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calc-mcol (n &optional nn)
|
|
|
|
(interactive "NColumn number: \nP")
|
|
|
|
(calc-wrapper
|
|
|
|
(if (consp nn)
|
|
|
|
(calc-enter-result 2 "mcol" (cons 'calcFunc-mcol (calc-top-list-n 2)))
|
|
|
|
(setq n (prefix-numeric-value n))
|
|
|
|
(if (= n 0)
|
|
|
|
(calc-enter-result 1 "getd" (list 'calcFunc-getdiag (calc-top-n 1)))
|
|
|
|
(if (< n 0)
|
|
|
|
(calc-enter-result 1 "rcol" (list 'calcFunc-mrcol
|
|
|
|
(calc-top-n 1) (- n)))
|
|
|
|
(calc-enter-result 1 "mcol" (list 'calcFunc-mcol
|
2001-11-14 09:09:09 +00:00
|
|
|
(calc-top-n 1) n)))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;;; Vectors.
|
|
|
|
|
|
|
|
(defun calcFunc-mdims (m)
|
|
|
|
(or (math-vectorp m)
|
|
|
|
(math-reject-arg m 'vectorp))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec (math-mat-dimens m)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Apply a function elementwise to vector A. [V X V; N X N] [Public]
|
|
|
|
(defun math-map-vec (f a)
|
|
|
|
(if (math-vectorp a)
|
|
|
|
(cons 'vec (mapcar f (cdr a)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(funcall f a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-dimension-error ()
|
|
|
|
(calc-record-why "*Dimension error")
|
2001-11-14 09:09:09 +00:00
|
|
|
(signal 'wrong-type-argument nil))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Build a vector out of a list of objects. [Public]
|
|
|
|
(defun calcFunc-vec (&rest objs)
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec objs))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Build a constant vector or matrix. [Public]
|
|
|
|
(defun calcFunc-cvec (obj &rest dims)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-make-vec-dimen obj dims))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-make-vec-dimen (obj dims)
|
|
|
|
(if dims
|
|
|
|
(if (natnump (car dims))
|
|
|
|
(if (or (cdr dims)
|
|
|
|
(not (math-numberp obj)))
|
|
|
|
(cons 'vec (copy-sequence
|
|
|
|
(make-list (car dims)
|
|
|
|
(math-make-vec-dimen obj (cdr dims)))))
|
|
|
|
(cons 'vec (make-list (car dims) obj)))
|
|
|
|
(math-reject-arg (car dims) 'fixnatnump))
|
2001-11-14 09:09:09 +00:00
|
|
|
obj))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-head (vec)
|
|
|
|
(if (and (Math-vectorp vec)
|
|
|
|
(cdr vec))
|
|
|
|
(nth 1 vec)
|
|
|
|
(calc-record-why 'vectorp vec)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-head vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-tail (vec)
|
|
|
|
(if (and (Math-vectorp vec)
|
|
|
|
(cdr vec))
|
|
|
|
(cons 'vec (cdr (cdr vec)))
|
|
|
|
(calc-record-why 'vectorp vec)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-tail vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-cons (head tail)
|
|
|
|
(if (Math-vectorp tail)
|
|
|
|
(cons 'vec (cons head (cdr tail)))
|
|
|
|
(calc-record-why 'vectorp tail)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-cons head tail)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-rhead (vec)
|
|
|
|
(if (and (Math-vectorp vec)
|
|
|
|
(cdr vec))
|
|
|
|
(let ((vec (copy-sequence vec)))
|
|
|
|
(setcdr (nthcdr (- (length vec) 2) vec) nil)
|
|
|
|
vec)
|
|
|
|
(calc-record-why 'vectorp vec)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-rhead vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-rtail (vec)
|
|
|
|
(if (and (Math-vectorp vec)
|
|
|
|
(cdr vec))
|
|
|
|
(nth (1- (length vec)) vec)
|
|
|
|
(calc-record-why 'vectorp vec)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-rtail vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-rcons (head tail)
|
|
|
|
(if (Math-vectorp head)
|
|
|
|
(append head (list tail))
|
|
|
|
(calc-record-why 'vectorp head)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-rcons head tail)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Apply a function elementwise to vectors A and B. [O X O O] [Public]
|
|
|
|
(defun math-map-vec-2 (f a b)
|
|
|
|
(if (math-vectorp a)
|
|
|
|
(if (math-vectorp b)
|
|
|
|
(let ((v nil))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(or (setq b (cdr b))
|
|
|
|
(math-dimension-error))
|
|
|
|
(setq v (cons (funcall f (car a) (car b)) v)))
|
|
|
|
(if a (math-dimension-error))
|
|
|
|
(cons 'vec (nreverse v)))
|
|
|
|
(let ((v nil))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(setq v (cons (funcall f (car a) b) v)))
|
|
|
|
(cons 'vec (nreverse v))))
|
|
|
|
(if (math-vectorp b)
|
|
|
|
(let ((v nil))
|
|
|
|
(while (setq b (cdr b))
|
|
|
|
(setq v (cons (funcall f a (car b)) v)))
|
|
|
|
(cons 'vec (nreverse v)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(funcall f a b))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; "Reduce" a function over a vector (left-associatively). [O X V] [Public]
|
|
|
|
(defun math-reduce-vec (f a)
|
|
|
|
(if (math-vectorp a)
|
|
|
|
(if (cdr a)
|
|
|
|
(let ((accum (car (setq a (cdr a)))))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(setq accum (funcall f accum (car a))))
|
|
|
|
accum)
|
|
|
|
0)
|
2001-11-14 09:09:09 +00:00
|
|
|
a))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Reduce a function over the columns of matrix A. [V X V] [Public]
|
|
|
|
(defun math-reduce-cols (f a)
|
|
|
|
(if (math-matrixp a)
|
|
|
|
(cons 'vec (math-reduce-cols-col-step f (cdr a) 1 (length (nth 1 a))))
|
2001-11-14 09:09:09 +00:00
|
|
|
a))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-reduce-cols-col-step (f a col cols)
|
|
|
|
(and (< col cols)
|
|
|
|
(cons (math-reduce-cols-row-step f (nth col (car a)) col (cdr a))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reduce-cols-col-step f a (1+ col) cols))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-reduce-cols-row-step (f tot col a)
|
|
|
|
(if a
|
|
|
|
(math-reduce-cols-row-step f
|
|
|
|
(funcall f tot (nth col (car a)))
|
|
|
|
col
|
|
|
|
(cdr a))
|
2001-11-14 09:09:09 +00:00
|
|
|
tot))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun math-dot-product (a b)
|
|
|
|
(if (setq a (cdr a) b (cdr b))
|
|
|
|
(let ((accum (math-mul (car a) (car b))))
|
|
|
|
(while (setq a (cdr a) b (cdr b))
|
|
|
|
(setq accum (math-add accum (math-mul (car a) (car b)))))
|
|
|
|
accum)
|
2001-11-14 09:09:09 +00:00
|
|
|
0))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Return the number of elements in vector V. [Public]
|
|
|
|
(defun calcFunc-vlen (v)
|
|
|
|
(if (math-vectorp v)
|
|
|
|
(1- (length v))
|
|
|
|
(if (math-objectp v)
|
|
|
|
0
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-vlen v))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Get the Nth row of a matrix.
|
|
|
|
(defun calcFunc-mrow (mat n) ; [Public]
|
|
|
|
(if (Math-vectorp n)
|
|
|
|
(math-map-vec (function (lambda (x) (calcFunc-mrow mat x))) n)
|
|
|
|
(if (and (eq (car-safe n) 'intv) (math-constp n))
|
|
|
|
(calcFunc-subvec mat
|
|
|
|
(math-add (nth 2 n) (if (memq (nth 1 n) '(2 3)) 0 1))
|
|
|
|
(math-add (nth 3 n) (if (memq (nth 1 n) '(1 3)) 1 0)))
|
|
|
|
(or (and (integerp (setq n (math-check-integer n)))
|
|
|
|
(> n 0))
|
|
|
|
(math-reject-arg n 'fixposintp))
|
|
|
|
(or (Math-vectorp mat)
|
|
|
|
(math-reject-arg mat 'vectorp))
|
|
|
|
(or (nth n mat)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg n "*Index out of range")))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-subscr (mat n &optional m)
|
2011-02-26 19:55:29 -06:00
|
|
|
(if (eq (car-safe mat) 'var) nil
|
|
|
|
(setq mat (calcFunc-mrow mat n))
|
|
|
|
(if m
|
|
|
|
(if (math-num-integerp n)
|
|
|
|
(calcFunc-mrow mat m)
|
|
|
|
(calcFunc-mcol mat m))
|
|
|
|
mat)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Get the Nth column of a matrix.
|
|
|
|
(defun math-mat-col (mat n)
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec (mapcar (function (lambda (x) (elt x n))) (cdr mat))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-mcol (mat n) ; [Public]
|
|
|
|
(if (Math-vectorp n)
|
|
|
|
(calcFunc-trn
|
|
|
|
(math-map-vec (function (lambda (x) (calcFunc-mcol mat x))) n))
|
|
|
|
(if (and (eq (car-safe n) 'intv) (math-constp n))
|
|
|
|
(if (math-matrixp mat)
|
|
|
|
(math-map-vec (function (lambda (x) (calcFunc-mrow x n))) mat)
|
|
|
|
(calcFunc-mrow mat n))
|
|
|
|
(or (and (integerp (setq n (math-check-integer n)))
|
|
|
|
(> n 0))
|
|
|
|
(math-reject-arg n 'fixposintp))
|
|
|
|
(or (Math-vectorp mat)
|
|
|
|
(math-reject-arg mat 'vectorp))
|
|
|
|
(or (if (math-matrixp mat)
|
|
|
|
(and (< n (length (nth 1 mat)))
|
|
|
|
(math-mat-col mat n))
|
|
|
|
(nth n mat))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg n "*Index out of range")))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Remove the Nth row from a matrix.
|
|
|
|
(defun math-mat-less-row (mat n)
|
|
|
|
(if (<= n 0)
|
|
|
|
(cdr mat)
|
|
|
|
(cons (car mat)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-mat-less-row (cdr mat) (1- n)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-mrrow (mat n) ; [Public]
|
|
|
|
(and (integerp (setq n (math-check-integer n)))
|
|
|
|
(> n 0)
|
|
|
|
(< n (length mat))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-mat-less-row mat n)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Remove the Nth column from a matrix.
|
|
|
|
(defun math-mat-less-col (mat n)
|
|
|
|
(cons 'vec (mapcar (function (lambda (x) (math-mat-less-row x n)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cdr mat))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-mrcol (mat n) ; [Public]
|
|
|
|
(and (integerp (setq n (math-check-integer n)))
|
|
|
|
(> n 0)
|
|
|
|
(if (math-matrixp mat)
|
|
|
|
(and (< n (length (nth 1 mat)))
|
|
|
|
(math-mat-less-col mat n))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-mat-less-row mat n))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-getdiag (mat) ; [Public]
|
|
|
|
(if (math-square-matrixp mat)
|
|
|
|
(cons 'vec (math-get-diag-step (cdr mat) 1))
|
|
|
|
(calc-record-why 'square-matrixp mat)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-getdiag mat)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-get-diag-step (row n)
|
|
|
|
(and row
|
|
|
|
(cons (nth n (car row))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-get-diag-step (cdr row) (1+ n)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-transpose (mat) ; [Public]
|
|
|
|
(let ((m nil)
|
|
|
|
(col (length (nth 1 mat))))
|
|
|
|
(while (> (setq col (1- col)) 0)
|
|
|
|
(setq m (cons (math-mat-col mat col) m)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec m)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-trn (mat)
|
|
|
|
(if (math-vectorp mat)
|
|
|
|
(if (math-matrixp mat)
|
|
|
|
(math-transpose mat)
|
|
|
|
(math-col-matrix mat))
|
|
|
|
(if (math-numberp mat)
|
|
|
|
mat
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg mat 'matrixp))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-ctrn (mat)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-conj (calcFunc-trn mat)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-pack (mode els)
|
|
|
|
(or (Math-vectorp els) (math-reject-arg els 'vectorp))
|
|
|
|
(if (and (Math-vectorp mode) (cdr mode))
|
|
|
|
(setq mode (cdr mode))
|
|
|
|
(or (integerp mode) (math-reject-arg mode 'fixnump)))
|
|
|
|
(condition-case err
|
|
|
|
(if (= (calc-pack-size mode) (1- (length els)))
|
|
|
|
(calc-pack-items mode (cdr els))
|
|
|
|
(math-reject-arg els "*Wrong number of elements"))
|
2001-11-14 09:09:09 +00:00
|
|
|
(error (math-reject-arg els (nth 1 err)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-unpack (mode thing)
|
|
|
|
(or (integerp mode) (math-reject-arg mode 'fixnump))
|
|
|
|
(condition-case err
|
|
|
|
(cons 'vec (calc-unpack-item mode thing))
|
2001-11-14 09:09:09 +00:00
|
|
|
(error (math-reject-arg thing (nth 1 err)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-unpackt (mode thing)
|
|
|
|
(let ((calc-unpack-with-type 'pair))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-unpack mode thing)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-arrange (vec cols) ; [Public]
|
|
|
|
(setq cols (math-check-fixnum cols t))
|
|
|
|
(if (math-vectorp vec)
|
|
|
|
(let* ((flat (math-flatten-vector vec))
|
|
|
|
(mat (list 'vec))
|
|
|
|
next)
|
|
|
|
(if (<= cols 0)
|
|
|
|
(nconc mat flat)
|
|
|
|
(while (>= (length flat) cols)
|
|
|
|
(setq next (nthcdr cols flat))
|
|
|
|
(setcdr (nthcdr (1- cols) flat) nil)
|
|
|
|
(setq mat (nconc mat (list (cons 'vec flat)))
|
|
|
|
flat next))
|
|
|
|
(if flat
|
|
|
|
(setq mat (nconc mat (list (cons 'vec flat)))))
|
2001-11-14 09:09:09 +00:00
|
|
|
mat))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-flatten-vector (vec) ; [L V]
|
|
|
|
(if (math-vectorp vec)
|
|
|
|
(apply 'append (mapcar 'math-flatten-vector (cdr vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(list vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vconcat (a b)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-normalize (list '| a b)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vconcatrev (a b)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-normalize (list '| b a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-append (v1 v2)
|
|
|
|
(if (and (math-vectorp v1) (math-vectorp v2))
|
|
|
|
(append v1 (cdr v2))
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-append v1 v2)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-appendrev (v1 v2)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-append v2 v1))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Copy a matrix. [Public]
|
|
|
|
(defun math-copy-matrix (m)
|
|
|
|
(if (math-vectorp (nth 1 m))
|
|
|
|
(cons 'vec (mapcar 'copy-sequence (cdr m)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(copy-sequence m)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Convert a scalar or vector into an NxN diagonal matrix. [Public]
|
|
|
|
(defun calcFunc-diag (a &optional n)
|
|
|
|
(and n (not (integerp n))
|
|
|
|
(setq n (math-check-fixnum n)))
|
|
|
|
(if (math-vectorp a)
|
|
|
|
(if (and n (/= (length a) (1+ n)))
|
|
|
|
(list 'calcFunc-diag a n)
|
|
|
|
(if (math-matrixp a)
|
|
|
|
(if (and n (/= (length (elt a 1)) (1+ n)))
|
|
|
|
(list 'calcFunc-diag a n)
|
|
|
|
a)
|
|
|
|
(cons 'vec (math-diag-step (cdr a) 0 (1- (length a))))))
|
|
|
|
(if n
|
|
|
|
(cons 'vec (math-diag-step (make-list n a) 0 n))
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-diag a))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-idn (a &optional n)
|
|
|
|
(if n
|
|
|
|
(if (math-vectorp a)
|
|
|
|
(math-reject-arg a 'numberp)
|
|
|
|
(calcFunc-diag a n))
|
|
|
|
(if (integerp calc-matrix-mode)
|
|
|
|
(calcFunc-idn a calc-matrix-mode)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-idn a))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-mimic-ident (a m)
|
|
|
|
(if (math-square-matrixp m)
|
|
|
|
(calcFunc-idn a (1- (length m)))
|
|
|
|
(if (math-vectorp m)
|
|
|
|
(if (math-zerop a)
|
|
|
|
(cons 'vec (mapcar (function (lambda (x)
|
|
|
|
(if (math-vectorp x)
|
|
|
|
(math-mimic-ident a x)
|
|
|
|
a)))
|
|
|
|
(cdr m)))
|
|
|
|
(math-dimension-error))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-idn a))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-diag-step (a n m)
|
|
|
|
(if (< n m)
|
|
|
|
(cons (cons 'vec
|
|
|
|
(nconc (make-list n 0)
|
|
|
|
(cons (car a)
|
|
|
|
(make-list (1- (- m n)) 0))))
|
|
|
|
(math-diag-step (cdr a) (1+ n) m))
|
2001-11-14 09:09:09 +00:00
|
|
|
nil))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Create a vector of consecutive integers. [Public]
|
|
|
|
(defun calcFunc-index (n &optional start incr)
|
|
|
|
(if (math-messy-integerp n)
|
|
|
|
(math-float (calcFunc-index (math-trunc n) start incr))
|
|
|
|
(and (not (integerp n))
|
|
|
|
(setq n (math-check-fixnum n)))
|
|
|
|
(let ((vec nil))
|
|
|
|
(if start
|
|
|
|
(progn
|
|
|
|
(if (>= n 0)
|
|
|
|
(while (>= (setq n (1- n)) 0)
|
|
|
|
(setq vec (cons start vec)
|
|
|
|
start (math-add start (or incr 1))))
|
|
|
|
(while (<= (setq n (1+ n)) 0)
|
|
|
|
(setq vec (cons start vec)
|
|
|
|
start (math-mul start (or incr 2)))))
|
|
|
|
(setq vec (nreverse vec)))
|
|
|
|
(if (>= n 0)
|
|
|
|
(while (> n 0)
|
|
|
|
(setq vec (cons n vec)
|
|
|
|
n (1- n)))
|
|
|
|
(let ((i -1))
|
|
|
|
(while (>= i n)
|
|
|
|
(setq vec (cons i vec)
|
|
|
|
i (1- i))))))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec vec))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Find an element in a vector.
|
|
|
|
(defun calcFunc-find (vec x &optional start)
|
|
|
|
(setq start (if start (math-check-fixnum start t) 1))
|
|
|
|
(if (< start 1) (math-reject-arg start 'posp))
|
|
|
|
(setq vec (nthcdr start vec))
|
|
|
|
(let ((n start))
|
|
|
|
(while (and vec (not (Math-equal x (car vec))))
|
|
|
|
(setq n (1+ n)
|
|
|
|
vec (cdr vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(if vec n 0)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Return a subvector of a vector.
|
|
|
|
(defun calcFunc-subvec (vec start &optional end)
|
|
|
|
(setq start (math-check-fixnum start t)
|
|
|
|
end (math-check-fixnum (or end 0) t))
|
|
|
|
(or (math-vectorp vec) (math-reject-arg vec 'vectorp))
|
|
|
|
(let ((len (1- (length vec))))
|
|
|
|
(if (<= start 0)
|
|
|
|
(setq start (+ len start 1)))
|
|
|
|
(if (<= end 0)
|
|
|
|
(setq end (+ len end 1)))
|
|
|
|
(if (or (> start len)
|
|
|
|
(<= end start))
|
|
|
|
'(vec)
|
|
|
|
(setq vec (nthcdr start vec))
|
|
|
|
(if (<= end len)
|
|
|
|
(let ((chop (nthcdr (- end start 1) (setq vec (copy-sequence vec)))))
|
|
|
|
(setcdr chop nil)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec vec))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Remove a subvector from a vector.
|
|
|
|
(defun calcFunc-rsubvec (vec start &optional end)
|
|
|
|
(setq start (math-check-fixnum start t)
|
|
|
|
end (math-check-fixnum (or end 0) t))
|
|
|
|
(or (math-vectorp vec) (math-reject-arg vec 'vectorp))
|
|
|
|
(let ((len (1- (length vec))))
|
|
|
|
(if (<= start 0)
|
|
|
|
(setq start (+ len start 1)))
|
|
|
|
(if (<= end 0)
|
|
|
|
(setq end (+ len end 1)))
|
|
|
|
(if (or (> start len)
|
|
|
|
(<= end start))
|
|
|
|
vec
|
|
|
|
(let ((tail (nthcdr end vec))
|
|
|
|
(chop (nthcdr (1- start) (setq vec (copy-sequence vec)))))
|
|
|
|
(setcdr chop nil)
|
2001-11-14 09:09:09 +00:00
|
|
|
(append vec tail)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Reverse the order of the elements of a vector.
|
|
|
|
(defun calcFunc-rev (vec)
|
|
|
|
(if (math-vectorp vec)
|
|
|
|
(cons 'vec (reverse (cdr vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg vec 'vectorp)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Compress a vector according to a mask vector.
|
|
|
|
(defun calcFunc-vmask (mask vec)
|
|
|
|
(if (math-numberp mask)
|
|
|
|
(if (math-zerop mask)
|
|
|
|
'(vec)
|
|
|
|
vec)
|
|
|
|
(or (math-vectorp mask) (math-reject-arg mask 'vectorp))
|
|
|
|
(or (math-constp mask) (math-reject-arg mask 'constp))
|
|
|
|
(or (math-vectorp vec) (math-reject-arg vec 'vectorp))
|
|
|
|
(or (= (length mask) (length vec)) (math-dimension-error))
|
|
|
|
(let ((new nil))
|
|
|
|
(while (setq mask (cdr mask) vec (cdr vec))
|
|
|
|
(or (math-zerop (car mask))
|
|
|
|
(setq new (cons (car vec) new))))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec (nreverse new)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
;;; Expand a vector according to a mask vector.
|
|
|
|
(defun calcFunc-vexp (mask vec &optional filler)
|
|
|
|
(or (math-vectorp mask) (math-reject-arg mask 'vectorp))
|
|
|
|
(or (math-constp mask) (math-reject-arg mask 'constp))
|
|
|
|
(or (math-vectorp vec) (math-reject-arg vec 'vectorp))
|
|
|
|
(let ((new nil)
|
|
|
|
(fvec (and filler (math-vectorp filler))))
|
|
|
|
(while (setq mask (cdr mask))
|
|
|
|
(if (math-zerop (car mask))
|
|
|
|
(setq new (cons (or (if fvec
|
|
|
|
(car (setq filler (cdr filler)))
|
|
|
|
filler)
|
|
|
|
(car mask)) new))
|
|
|
|
(setq vec (cdr vec)
|
|
|
|
new (cons (or (car vec) (car mask)) new))))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec (nreverse new))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Compute the row and column norms of a vector or matrix. [Public]
|
|
|
|
(defun calcFunc-rnorm (a)
|
|
|
|
(if (and (Math-vectorp a)
|
|
|
|
(math-constp a))
|
|
|
|
(if (math-matrixp a)
|
|
|
|
(math-reduce-vec 'math-max (math-map-vec 'calcFunc-cnorm a))
|
|
|
|
(math-reduce-vec 'math-max (math-map-vec 'math-abs a)))
|
|
|
|
(calc-record-why 'vectorp a)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-rnorm a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-cnorm (a)
|
|
|
|
(if (and (Math-vectorp a)
|
|
|
|
(math-constp a))
|
|
|
|
(if (math-matrixp a)
|
|
|
|
(math-reduce-vec 'math-max
|
|
|
|
(math-reduce-cols 'math-add-abs a))
|
|
|
|
(math-reduce-vec 'math-add-abs a))
|
|
|
|
(calc-record-why 'vectorp a)
|
2001-11-14 09:09:09 +00:00
|
|
|
(list 'calcFunc-cnorm a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-add-abs (a b)
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-add (math-abs a) (math-abs b)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Sort the elements of a vector into increasing order.
|
|
|
|
(defun calcFunc-sort (vec) ; [Public]
|
|
|
|
(if (math-vectorp vec)
|
|
|
|
(cons 'vec (sort (copy-sequence (cdr vec)) 'math-beforep))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg vec 'vectorp)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-rsort (vec) ; [Public]
|
|
|
|
(if (math-vectorp vec)
|
|
|
|
(cons 'vec (nreverse (sort (copy-sequence (cdr vec)) 'math-beforep)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg vec 'vectorp)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2015-08-21 06:31:54 -07:00
|
|
|
;; The variable math-grade-vec is local to calcFunc-grade and
|
2004-11-26 22:33:49 +00:00
|
|
|
;; calcFunc-rgrade, but is used by math-grade-beforep, which is called
|
|
|
|
;; by calcFunc-grade and calcFunc-rgrade.
|
|
|
|
(defvar math-grade-vec)
|
|
|
|
|
2020-10-10 16:00:51 -04:00
|
|
|
(defun calcFunc-grade (grade-vec)
|
|
|
|
(if (math-vectorp grade-vec)
|
|
|
|
(let* ((math-grade-vec grade-vec)
|
|
|
|
(len (1- (length grade-vec))))
|
|
|
|
(cons 'vec (sort (cdr (calcFunc-index len)) #'math-grade-beforep)))
|
|
|
|
(math-reject-arg grade-vec #'vectorp)))
|
|
|
|
|
|
|
|
(defun calcFunc-rgrade (grade-vec)
|
|
|
|
(if (math-vectorp grade-vec)
|
|
|
|
(let* ((math-grade-vec grade-vec)
|
|
|
|
(len (1- (length grade-vec))))
|
2001-11-06 18:59:06 +00:00
|
|
|
(cons 'vec (nreverse (sort (cdr (calcFunc-index len))
|
2020-10-10 16:00:51 -04:00
|
|
|
#'math-grade-beforep))))
|
|
|
|
(math-reject-arg grade-vec #'vectorp)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-grade-beforep (i j)
|
2004-11-26 22:33:49 +00:00
|
|
|
(math-beforep (nth i math-grade-vec) (nth j math-grade-vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Compile a histogram of data from a vector.
|
|
|
|
(defun calcFunc-histogram (vec wts &optional n)
|
|
|
|
(or n (setq n wts wts 1))
|
|
|
|
(or (Math-vectorp vec)
|
|
|
|
(math-reject-arg vec 'vectorp))
|
|
|
|
(if (Math-vectorp wts)
|
|
|
|
(or (= (length vec) (length wts))
|
|
|
|
(math-dimension-error)))
|
2010-05-15 23:43:09 -05:00
|
|
|
(cond ((natnump n)
|
|
|
|
(let ((res (make-vector n 0))
|
|
|
|
(vp vec)
|
|
|
|
(wvec (Math-vectorp wts))
|
|
|
|
(wp wts)
|
|
|
|
bin)
|
|
|
|
(while (setq vp (cdr vp))
|
|
|
|
(setq bin (car vp))
|
|
|
|
(or (natnump bin)
|
|
|
|
(setq bin (math-floor bin)))
|
|
|
|
(and (natnump bin)
|
|
|
|
(< bin n)
|
2015-08-21 06:31:54 -07:00
|
|
|
(aset res bin
|
2010-05-15 23:43:09 -05:00
|
|
|
(math-add (aref res bin)
|
|
|
|
(if wvec (car (setq wp (cdr wp))) wts)))))
|
|
|
|
(cons 'vec (append res nil))))
|
|
|
|
((Math-vectorp n) ;; n is a vector of midpoints
|
|
|
|
(let* ((bds (math-vector-avg n))
|
|
|
|
(res (make-vector (1- (length n)) 0))
|
|
|
|
(vp (cdr vec))
|
|
|
|
(wvec (Math-vectorp wts))
|
|
|
|
(wp wts)
|
|
|
|
num)
|
|
|
|
(while vp
|
|
|
|
(setq num (car vp))
|
|
|
|
(let ((tbds (cdr bds))
|
|
|
|
(i 0))
|
|
|
|
(while (and tbds (Math-lessp (car tbds) num))
|
|
|
|
(setq i (1+ i))
|
|
|
|
(setq tbds (cdr tbds)))
|
2015-08-21 06:31:54 -07:00
|
|
|
(aset res i
|
2010-05-15 23:43:09 -05:00
|
|
|
(math-add (aref res i)
|
|
|
|
(if wvec (car (setq wp (cdr wp))) wts))))
|
|
|
|
(setq vp (cdr vp)))
|
|
|
|
(cons 'vec (append res nil))))
|
|
|
|
(t
|
|
|
|
(math-reject-arg n "*Expecting an integer or vector"))))
|
|
|
|
|
|
|
|
;;; Replace a vector [a b c ...] with a vector of averages
|
|
|
|
;;; [(a+b)/2 (b+c)/2 ...]
|
|
|
|
(defun math-vector-avg (vec)
|
2010-05-16 23:16:29 -05:00
|
|
|
(let ((vp (sort (copy-sequence (cdr vec)) 'math-beforep))
|
2010-05-15 23:43:09 -05:00
|
|
|
(res nil))
|
|
|
|
(while (and vp (cdr vp))
|
|
|
|
(setq res (cons (math-div (math-add (car vp) (cadr vp)) 2) res)
|
|
|
|
vp (cdr vp)))
|
|
|
|
(cons 'vec (reverse res))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
;;; Set operations.
|
|
|
|
|
|
|
|
(defun calcFunc-vunion (a b)
|
|
|
|
(if (Math-objectp a)
|
|
|
|
(setq a (list 'vec a))
|
|
|
|
(or (math-vectorp a) (math-reject-arg a 'vectorp)))
|
|
|
|
(if (Math-objectp b)
|
|
|
|
(setq b (list b))
|
|
|
|
(or (math-vectorp b) (math-reject-arg b 'vectorp))
|
|
|
|
(setq b (cdr b)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-rdup (append a b)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vint (a b)
|
|
|
|
(if (and (math-simple-set a) (math-simple-set b))
|
|
|
|
(progn
|
|
|
|
(setq a (cdr (calcFunc-rdup a)))
|
|
|
|
(setq b (cdr (calcFunc-rdup b)))
|
|
|
|
(let ((vec (list 'vec)))
|
|
|
|
(while (and a b)
|
|
|
|
(if (math-beforep (car a) (car b))
|
|
|
|
(setq a (cdr a))
|
|
|
|
(if (Math-equal (car a) (car b))
|
|
|
|
(setq vec (cons (car a) vec)
|
|
|
|
a (cdr a)))
|
|
|
|
(setq b (cdr b))))
|
|
|
|
(nreverse vec)))
|
|
|
|
(calcFunc-vcompl (calcFunc-vunion (calcFunc-vcompl a)
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-vcompl b)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vdiff (a b)
|
|
|
|
(if (and (math-simple-set a) (math-simple-set b))
|
|
|
|
(progn
|
|
|
|
(setq a (cdr (calcFunc-rdup a)))
|
|
|
|
(setq b (cdr (calcFunc-rdup b)))
|
|
|
|
(let ((vec (list 'vec)))
|
|
|
|
(while a
|
|
|
|
(while (and b (math-beforep (car b) (car a)))
|
|
|
|
(setq b (cdr b)))
|
|
|
|
(if (and b (Math-equal (car a) (car b)))
|
|
|
|
(setq a (cdr a)
|
|
|
|
b (cdr b))
|
|
|
|
(setq vec (cons (car a) vec)
|
|
|
|
a (cdr a))))
|
|
|
|
(nreverse vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-vcompl (calcFunc-vunion (calcFunc-vcompl a) b))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vxor (a b)
|
|
|
|
(if (and (math-simple-set a) (math-simple-set b))
|
|
|
|
(progn
|
|
|
|
(setq a (cdr (calcFunc-rdup a)))
|
|
|
|
(setq b (cdr (calcFunc-rdup b)))
|
|
|
|
(let ((vec (list 'vec)))
|
|
|
|
(while (or a b)
|
|
|
|
(if (and a
|
|
|
|
(or (not b)
|
|
|
|
(math-beforep (car a) (car b))))
|
|
|
|
(setq vec (cons (car a) vec)
|
|
|
|
a (cdr a))
|
|
|
|
(if (and a (Math-equal (car a) (car b)))
|
|
|
|
(setq a (cdr a))
|
|
|
|
(setq vec (cons (car b) vec)))
|
|
|
|
(setq b (cdr b))))
|
|
|
|
(nreverse vec)))
|
|
|
|
(let ((ca (calcFunc-vcompl a))
|
|
|
|
(cb (calcFunc-vcompl b)))
|
|
|
|
(calcFunc-vunion (calcFunc-vcompl (calcFunc-vunion ca b))
|
2001-11-14 09:09:09 +00:00
|
|
|
(calcFunc-vcompl (calcFunc-vunion a cb))))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vcompl (a)
|
|
|
|
(setq a (math-prepare-set a))
|
|
|
|
(let ((vec (list 'vec))
|
|
|
|
(prev '(neg (var inf var-inf)))
|
|
|
|
(closed 2))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(or (and (equal (nth 2 (car a)) '(neg (var inf var-inf)))
|
|
|
|
(memq (nth 1 (car a)) '(2 3)))
|
|
|
|
(setq vec (cons (list 'intv
|
|
|
|
(+ closed
|
|
|
|
(if (memq (nth 1 (car a)) '(0 1)) 1 0))
|
|
|
|
prev
|
|
|
|
(nth 2 (car a)))
|
|
|
|
vec)))
|
|
|
|
(setq prev (nth 3 (car a))
|
|
|
|
closed (if (memq (nth 1 (car a)) '(0 2)) 2 0)))
|
|
|
|
(or (and (equal prev '(var inf var-inf))
|
|
|
|
(= closed 0))
|
|
|
|
(setq vec (cons (list 'intv (+ closed 1)
|
|
|
|
prev '(var inf var-inf))
|
|
|
|
vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-clean-set (nreverse vec))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vspan (a)
|
|
|
|
(setq a (math-prepare-set a))
|
|
|
|
(if (cdr a)
|
|
|
|
(let ((last (nth (1- (length a)) a)))
|
|
|
|
(math-make-intv (+ (logand (nth 1 (nth 1 a)) 2)
|
|
|
|
(logand (nth 1 last) 1))
|
|
|
|
(nth 2 (nth 1 a))
|
|
|
|
(nth 3 last)))
|
2001-11-14 09:09:09 +00:00
|
|
|
'(intv 2 0 0)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vfloor (a &optional always-vec)
|
|
|
|
(setq a (math-prepare-set a))
|
|
|
|
(let ((vec (list 'vec)) (p a) (prev nil) b mask)
|
|
|
|
(while (setq p (cdr p))
|
|
|
|
(setq mask (nth 1 (car p))
|
|
|
|
a (nth 2 (car p))
|
|
|
|
b (nth 3 (car p)))
|
|
|
|
(and (memq mask '(0 1))
|
|
|
|
(not (math-infinitep a))
|
|
|
|
(setq mask (logior mask 2))
|
|
|
|
(math-num-integerp a)
|
|
|
|
(setq a (math-add a 1)))
|
|
|
|
(setq a (math-ceiling a))
|
|
|
|
(and (memq mask '(0 2))
|
|
|
|
(not (math-infinitep b))
|
|
|
|
(setq mask (logior mask 1))
|
|
|
|
(math-num-integerp b)
|
|
|
|
(setq b (math-sub b 1)))
|
|
|
|
(setq b (math-floor b))
|
|
|
|
(if (and prev (Math-equal (math-sub a 1) (nth 3 prev)))
|
|
|
|
(setcar (nthcdr 3 prev) b)
|
|
|
|
(or (Math-lessp b a)
|
|
|
|
(setq vec (cons (setq prev (list 'intv mask a b)) vec)))))
|
|
|
|
(setq vec (nreverse vec))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-clean-set vec always-vec)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vcard (a)
|
|
|
|
(setq a (calcFunc-vfloor a t))
|
|
|
|
(or (math-constp a) (math-reject-arg a "*Set must be finite"))
|
|
|
|
(let ((count 0))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(if (eq (car-safe (car a)) 'intv)
|
|
|
|
(setq count (math-add count (math-sub (nth 3 (car a))
|
|
|
|
(nth 2 (car a))))))
|
|
|
|
(setq count (math-add count 1)))
|
2001-11-14 09:09:09 +00:00
|
|
|
count))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-venum (a)
|
|
|
|
(setq a (calcFunc-vfloor a t))
|
|
|
|
(or (math-constp a) (math-reject-arg a "*Set must be finite"))
|
2008-09-20 22:09:39 +00:00
|
|
|
(let* ((prev a) (this (cdr prev)) this-val next this-last)
|
|
|
|
(while this
|
|
|
|
(setq next (cdr this)
|
|
|
|
this-val (car this))
|
|
|
|
(if (eq (car-safe this-val) 'intv)
|
|
|
|
(progn
|
|
|
|
(setq this (cdr (calcFunc-index (math-add
|
|
|
|
(math-sub (nth 3 this-val)
|
|
|
|
(nth 2 this-val))
|
|
|
|
1)
|
|
|
|
(nth 2 this-val))))
|
|
|
|
(setq this-last (last this))
|
|
|
|
(setcdr this-last next)
|
|
|
|
(setcdr prev this)
|
|
|
|
(setq prev this-last))
|
|
|
|
(setq prev this))
|
|
|
|
(setq this next)))
|
|
|
|
a)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vpack (a)
|
|
|
|
(setq a (calcFunc-vfloor a t))
|
|
|
|
(if (and (cdr a)
|
|
|
|
(math-negp (if (eq (car-safe (nth 1 a)) 'intv)
|
|
|
|
(nth 2 (nth 1 a))
|
|
|
|
(nth 1 a))))
|
|
|
|
(math-reject-arg (nth 1 a) 'posp))
|
|
|
|
(let ((accum 0))
|
|
|
|
(while (setq a (cdr a))
|
|
|
|
(if (eq (car-safe (car a)) 'intv)
|
|
|
|
(if (equal (nth 3 (car a)) '(var inf var-inf))
|
|
|
|
(setq accum (math-sub accum
|
|
|
|
(math-power-of-2 (nth 2 (car a)))))
|
|
|
|
(setq accum (math-add accum
|
|
|
|
(math-sub
|
|
|
|
(math-power-of-2 (1+ (nth 3 (car a))))
|
|
|
|
(math-power-of-2 (nth 2 (car a)))))))
|
|
|
|
(setq accum (math-add accum (math-power-of-2 (car a))))))
|
2001-11-14 09:09:09 +00:00
|
|
|
accum))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-vunpack (a &optional w)
|
|
|
|
(or (math-num-integerp a) (math-reject-arg a 'integerp))
|
|
|
|
(if w (setq a (math-clip a w)))
|
|
|
|
(if (math-messy-integerp a) (setq a (math-trunc a)))
|
|
|
|
(let* ((calc-number-radix 2)
|
2009-11-20 01:00:27 +00:00
|
|
|
(calc-twos-complement-mode nil)
|
2001-11-06 18:59:06 +00:00
|
|
|
(neg (math-negp a))
|
|
|
|
(aa (if neg (math-sub -1 a) a))
|
|
|
|
(str (if (eq aa 0)
|
|
|
|
""
|
* lisp/calc/calc.el: Take advantage of native bignums.
Remove redundant :group args.
(calc-trail-mode): Use inhibit-read-only.
(math-bignum-digit-length, math-bignum-digit-size)
(math-small-integer-size): Delete constants.
(math-normalize): Use native bignums.
(math-bignum, math-bignum-big): Delete functions.
(math-make-float): The mantissa can't be a calc bignum any more.
(math-neg, math-scale-left, math-scale-right, math-scale-rounding)
(math-add, math-sub, math-mul, math-idivmod, math-quotient)
(math-format-number, math-read-number, math-read-number-simple):
Don't bother handling calc bignums.
(math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum)
(math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit)
(math-div-bignum, math-div-bignum-digit, math-div-bignum-big)
(math-div-bignum-part, math-div-bignum-try, math-format-bignum)
(math-format-bignum-decimal, math-read-bignum): Delete functions.
(math-numdigs): Don't presume that native ints are small enough to use
a slow algorithm.
* lisp/calc/calc-aent.el (calc-do-quick-calc):
* lisp/calc/calc-vec.el (calcFunc-vunpack):
* lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums.
* lisp/calc/calc-bin.el (math-bignum-logb-digit-size)
(math-bignum-digit-power-of-two): Remove constants.
(calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor)
(calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement):
Use Emacs's builtin bignums.
(math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum)
(math-not-bignum, math-clip-bignum)
(math-format-bignum-radix, math-format-bignum-binary)
(math-format-bignum-octal, math-format-bignum-hex): Delete functions.
(math-format-binary): Fix old copy&paste error.
* lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg.
(math-prime-test): math-fixnum is now the identity.
* lisp/calc/calc-ext.el: Require cl-lib.
(math-oddp): Use cl-oddp. Don't bother with calc bignums.
(math-integerp, math-natnump, math-ratp, math-realp, math-anglep)
(math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp)
(math-num-natnump, math-objectp, math-check-integer, math-compare):
Don't bother handling calc bignums.
(math-check-fixnum): Use fixnump.
(math-fixnum, math-fixnum-big, math-bignum-test): Remove functions.
(math--format-integer-fancy): Rename from math-format-bignum-fancy.
Adjust for internal bignums.
* lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt.
* lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp)
(Math-integer-posp, Math-negp, Math-posp, Math-integerp)
(Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp)
(Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp)
(Math-integer-neg, Math-primp, Math-num-integerp):
Don't bother handling calc bignums.
(Math-bignum-test): Delete function.
* lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`.
(math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums.
(math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small):
Delete function.
* lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump.
(math-evenp): Use cl-evenp.
(math-zerop, math-negp, math-posp, math-div2): Don't bother handling
calc bignums.
(math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
|
|
|
(math-format-binary aa)))
|
2001-11-06 18:59:06 +00:00
|
|
|
(zero (if neg ?1 ?0))
|
|
|
|
(one (if neg ?0 ?1))
|
|
|
|
(len (length str))
|
|
|
|
(vec (list 'vec))
|
|
|
|
(pos (1- len)) pos2)
|
|
|
|
(while (>= pos 0)
|
|
|
|
(if (eq (aref str pos) zero)
|
|
|
|
(setq pos (1- pos))
|
|
|
|
(setq pos2 pos)
|
|
|
|
(while (and (>= pos 0) (eq (aref str pos) one))
|
|
|
|
(setq pos (1- pos)))
|
|
|
|
(setq vec (cons (if (= pos (1- pos2))
|
|
|
|
(- len pos2 1)
|
|
|
|
(list 'intv 3 (- len pos2 1) (- len pos 2)))
|
|
|
|
vec))))
|
|
|
|
(if neg
|
|
|
|
(setq vec (cons (list 'intv 2 len '(var inf var-inf)) vec)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-clean-set (nreverse vec))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun calcFunc-rdup (a)
|
|
|
|
(if (math-simple-set a)
|
|
|
|
(progn
|
|
|
|
(and (Math-objectp a) (setq a (list 'vec a)))
|
|
|
|
(or (math-vectorp a) (math-reject-arg a 'vectorp))
|
|
|
|
(setq a (sort (copy-sequence (cdr a)) 'math-beforep))
|
|
|
|
(let ((p a))
|
|
|
|
(while (cdr p)
|
|
|
|
(if (Math-equal (car p) (nth 1 p))
|
|
|
|
(setcdr p (cdr (cdr p)))
|
|
|
|
(setq p (cdr p)))))
|
|
|
|
(cons 'vec a))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-clean-set (math-prepare-set a))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-prepare-set (a)
|
|
|
|
(if (Math-objectp a)
|
|
|
|
(setq a (list 'vec a))
|
|
|
|
(or (math-vectorp a) (math-reject-arg a 'vectorp))
|
|
|
|
(setq a (cons 'vec (sort (copy-sequence (cdr a)) 'math-beforep))))
|
|
|
|
(let ((p a) res)
|
|
|
|
|
|
|
|
;; Convert all elements to non-empty intervals.
|
|
|
|
(while (cdr p)
|
|
|
|
(if (eq (car-safe (nth 1 p)) 'intv)
|
|
|
|
(if (math-intv-constp (nth 1 p))
|
|
|
|
(if (and (memq (nth 1 (nth 1 p)) '(0 1 2))
|
|
|
|
(Math-equal (nth 2 (nth 1 p)) (nth 3 (nth 1 p))))
|
|
|
|
(setcdr p (cdr (cdr p)))
|
|
|
|
(setq p (cdr p)))
|
|
|
|
(math-reject-arg (nth 1 p) 'constp))
|
|
|
|
(or (Math-anglep (nth 1 p))
|
|
|
|
(eq (car (nth 1 p)) 'date)
|
|
|
|
(equal (nth 1 p) '(var inf var-inf))
|
|
|
|
(equal (nth 1 p) '(neg (var inf var-inf)))
|
|
|
|
(math-reject-arg (nth 1 p) 'realp))
|
|
|
|
(setcar (cdr p) (list 'intv 3 (nth 1 p) (nth 1 p)))
|
|
|
|
(setq p (cdr p))))
|
|
|
|
|
|
|
|
;; Combine redundant intervals.
|
|
|
|
(setq p a)
|
|
|
|
(while (cdr (cdr p))
|
|
|
|
(if (or (memq (setq res (math-compare (nth 3 (nth 1 p))
|
|
|
|
(nth 2 (nth 2 p))))
|
|
|
|
'(-1 2))
|
|
|
|
(and (eq res 0)
|
|
|
|
(memq (nth 1 (nth 1 p)) '(0 2))
|
|
|
|
(memq (nth 1 (nth 2 p)) '(0 1))))
|
|
|
|
(setq p (cdr p))
|
|
|
|
(setq res (math-compare (nth 3 (nth 1 p)) (nth 3 (nth 2 p))))
|
|
|
|
(setcdr p (cons (list 'intv
|
|
|
|
(+ (logand (logior (nth 1 (nth 1 p))
|
|
|
|
(if (Math-equal
|
|
|
|
(nth 2 (nth 1 p))
|
|
|
|
(nth 2 (nth 2 p)))
|
|
|
|
(nth 1 (nth 2 p))
|
|
|
|
0))
|
|
|
|
2)
|
|
|
|
(logand (logior (if (memq res '(1 0 2))
|
|
|
|
(nth 1 (nth 1 p)) 0)
|
|
|
|
(if (memq res '(-1 0 2))
|
|
|
|
(nth 1 (nth 2 p)) 0))
|
|
|
|
1))
|
|
|
|
(nth 2 (nth 1 p))
|
|
|
|
(if (eq res 1)
|
|
|
|
(nth 3 (nth 1 p))
|
|
|
|
(nth 3 (nth 2 p))))
|
|
|
|
(cdr (cdr (cdr p))))))))
|
2001-11-14 09:09:09 +00:00
|
|
|
a)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-clean-set (a &optional always-vec)
|
* lisp/calc/calc.el: Take advantage of native bignums.
Remove redundant :group args.
(calc-trail-mode): Use inhibit-read-only.
(math-bignum-digit-length, math-bignum-digit-size)
(math-small-integer-size): Delete constants.
(math-normalize): Use native bignums.
(math-bignum, math-bignum-big): Delete functions.
(math-make-float): The mantissa can't be a calc bignum any more.
(math-neg, math-scale-left, math-scale-right, math-scale-rounding)
(math-add, math-sub, math-mul, math-idivmod, math-quotient)
(math-format-number, math-read-number, math-read-number-simple):
Don't bother handling calc bignums.
(math-div10-bignum, math-scale-left-bignum, math-scale-right-bignum)
(math-add-bignum, math-sub-bignum, math-mul-bignum, math-mul-bignum-digit)
(math-div-bignum, math-div-bignum-digit, math-div-bignum-big)
(math-div-bignum-part, math-div-bignum-try, math-format-bignum)
(math-format-bignum-decimal, math-read-bignum): Delete functions.
(math-numdigs): Don't presume that native ints are small enough to use
a slow algorithm.
* lisp/calc/calc-aent.el (calc-do-quick-calc):
* lisp/calc/calc-vec.el (calcFunc-vunpack):
* lisp/calc/calc-alg.el (math-beforep): Don't bother handling calc bignums.
* lisp/calc/calc-bin.el (math-bignum-logb-digit-size)
(math-bignum-digit-power-of-two): Remove constants.
(calcFunc-and, math-binary-arg, calcFunc-or, calcFunc-xor)
(calcFunc-diff, calcFunc-not, math-clip, math-format-twos-complement):
Use Emacs's builtin bignums.
(math-and-bignum, math-or-bignum, math-xor-bignum, math-diff-bignum)
(math-not-bignum, math-clip-bignum)
(math-format-bignum-radix, math-format-bignum-binary)
(math-format-bignum-octal, math-format-bignum-hex): Delete functions.
(math-format-binary): Fix old copy&paste error.
* lisp/calc/calc-comb.el (calc-prime-factors): Adjust for unused arg.
(math-prime-test): math-fixnum is now the identity.
* lisp/calc/calc-ext.el: Require cl-lib.
(math-oddp): Use cl-oddp. Don't bother with calc bignums.
(math-integerp, math-natnump, math-ratp, math-realp, math-anglep)
(math-numberp, math-scalarp, math-vectorp, math-objvecp, math-primp)
(math-num-natnump, math-objectp, math-check-integer, math-compare):
Don't bother handling calc bignums.
(math-check-fixnum): Use fixnump.
(math-fixnum, math-fixnum-big, math-bignum-test): Remove functions.
(math--format-integer-fancy): Rename from math-format-bignum-fancy.
Adjust for internal bignums.
* lisp/calc/calc-funcs.el (calcFunc-besJ): Use cl-isqrt.
* lisp/calc/calc-macs.el (Math-zerop, Math-integer-negp)
(Math-integer-posp, Math-negp, Math-posp, Math-integerp)
(Math-natnump, Math-ratp, Math-realp, Math-anglep, Math-numberp)
(Math-scalarp, Math-vectorp, Math-objectp, Math-objvecp)
(Math-integer-neg, Math-primp, Math-num-integerp):
Don't bother handling calc bignums.
(Math-bignum-test): Delete function.
* lisp/calc/calc-math.el (math-use-emacs-fn): Remove unused `fx`.
(math-isqrt, math-sqrt): Use cl-isqrt. Don't bother handling calc bignums.
(math-isqrt-bignum, math-isqrt-bignum-iter, math-isqrt-small):
Delete function.
* lisp/calc/calc-misc.el (math-fixnump, math-fixnatnump): Use fixnump.
(math-evenp): Use cl-evenp.
(math-zerop, math-negp, math-posp, math-div2): Don't bother handling
calc bignums.
(math-div2-bignum): Delete function.
2019-06-25 23:05:11 -04:00
|
|
|
(let ((p a))
|
2001-11-06 18:59:06 +00:00
|
|
|
(while (cdr p)
|
|
|
|
(if (and (eq (car-safe (nth 1 p)) 'intv)
|
|
|
|
(Math-equal (nth 2 (nth 1 p)) (nth 3 (nth 1 p))))
|
|
|
|
(setcar (cdr p) (nth 2 (nth 1 p))))
|
|
|
|
(setq p (cdr p)))
|
|
|
|
(if (and (not (cdr (cdr a)))
|
|
|
|
(eq (car-safe (nth 1 a)) 'intv)
|
|
|
|
(not always-vec))
|
|
|
|
(nth 1 a)
|
2001-11-14 09:09:09 +00:00
|
|
|
a)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-simple-set (a)
|
|
|
|
(or (and (Math-objectp a)
|
|
|
|
(not (eq (car-safe a) 'intv)))
|
|
|
|
(and (Math-vectorp a)
|
|
|
|
(progn
|
|
|
|
(while (and (setq a (cdr a))
|
|
|
|
(not (eq (car-safe (car a)) 'intv))))
|
2001-11-14 09:09:09 +00:00
|
|
|
(null a)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Compute a right-handed vector cross product. [O O O] [Public]
|
|
|
|
(defun calcFunc-cross (a b)
|
|
|
|
(if (and (eq (car-safe a) 'vec)
|
|
|
|
(= (length a) 4))
|
|
|
|
(if (and (eq (car-safe b) 'vec)
|
|
|
|
(= (length b) 4))
|
|
|
|
(list 'vec
|
|
|
|
(math-sub (math-mul (nth 2 a) (nth 3 b))
|
|
|
|
(math-mul (nth 3 a) (nth 2 b)))
|
|
|
|
(math-sub (math-mul (nth 3 a) (nth 1 b))
|
|
|
|
(math-mul (nth 1 a) (nth 3 b)))
|
|
|
|
(math-sub (math-mul (nth 1 a) (nth 2 b))
|
|
|
|
(math-mul (nth 2 a) (nth 1 b))))
|
|
|
|
(math-reject-arg b "*Three-vector expected"))
|
2001-11-14 09:09:09 +00:00
|
|
|
(math-reject-arg a "*Three-vector expected")))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
|
2008-04-07 21:55:05 +00:00
|
|
|
;;; Compute a Kronecker product
|
|
|
|
(defun calcFunc-kron (x y &optional nocheck)
|
|
|
|
"The Kronecker product of objects X and Y.
|
|
|
|
The objects X and Y may be scalars, vectors or matrices.
|
|
|
|
The type of the result depends on the types of the operands;
|
|
|
|
the product of two scalars is a scalar,
|
|
|
|
of one scalar and a vector is a vector,
|
|
|
|
of two vectors is a vector.
|
|
|
|
of one vector and a matrix is a matrix,
|
|
|
|
of two matrices is a matrix."
|
|
|
|
(unless nocheck
|
|
|
|
(cond ((or (math-matrixp x)
|
|
|
|
(math-matrixp y))
|
|
|
|
(unless (math-matrixp x)
|
|
|
|
(setq x (if (math-vectorp x)
|
|
|
|
(list 'vec x)
|
|
|
|
(list 'vec (list 'vec x)))))
|
|
|
|
(unless (math-matrixp y)
|
|
|
|
(setq y (if (math-vectorp y)
|
|
|
|
(list 'vec y)
|
|
|
|
(list 'vec (list 'vec y))))))
|
|
|
|
((or (math-vectorp x)
|
|
|
|
(math-vectorp y))
|
|
|
|
(unless (math-vectorp x)
|
|
|
|
(setq x (list 'vec x)))
|
|
|
|
(unless (math-vectorp y)
|
|
|
|
(setq y (list 'vec y))))))
|
|
|
|
(if (math-vectorp x)
|
|
|
|
(let (ret)
|
|
|
|
(dolist (v (cdr x))
|
|
|
|
(dolist (w (cdr y))
|
|
|
|
(setq ret (cons (calcFunc-kron v w t) ret))))
|
|
|
|
(cons 'vec (nreverse ret)))
|
|
|
|
(math-mul x y)))
|
|
|
|
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2004-11-26 22:33:49 +00:00
|
|
|
;; The variable math-rb-close is local to math-read-brackets, but
|
|
|
|
;; is used by math-read-vector, which is called (directly and
|
|
|
|
;; indirectly) by math-read-brackets.
|
|
|
|
(defvar math-rb-close)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2015-08-21 06:31:54 -07:00
|
|
|
;; The next few variables are local to math-read-exprs in calc-aent.el
|
2004-11-27 04:11:13 +00:00
|
|
|
;; and math-read-expr in calc-ext.el, but are set in functions they call.
|
|
|
|
(defvar math-exp-pos)
|
|
|
|
(defvar math-exp-str)
|
|
|
|
(defvar math-exp-old-pos)
|
|
|
|
(defvar math-exp-token)
|
|
|
|
(defvar math-exp-keep-spaces)
|
|
|
|
(defvar math-expr-data)
|
|
|
|
|
2020-10-10 16:00:51 -04:00
|
|
|
(defun math-read-brackets (space-sep rb-close)
|
|
|
|
(let ((math-rb-close rb-close))
|
2001-11-06 18:59:06 +00:00
|
|
|
(and space-sep (setq space-sep (not (math-check-for-commas))))
|
|
|
|
(math-read-token)
|
2004-11-11 05:53:19 +00:00
|
|
|
(while (eq math-exp-token 'space)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
2004-11-26 22:33:49 +00:00
|
|
|
(if (or (equal math-expr-data math-rb-close)
|
2004-11-11 05:53:19 +00:00
|
|
|
(eq math-exp-token 'end))
|
2001-11-06 18:59:06 +00:00
|
|
|
(progn
|
|
|
|
(math-read-token)
|
|
|
|
'(vec))
|
2004-11-11 05:53:19 +00:00
|
|
|
(let ((save-exp-pos math-exp-pos)
|
|
|
|
(save-exp-old-pos math-exp-old-pos)
|
|
|
|
(save-exp-token math-exp-token)
|
2004-11-09 20:31:40 +00:00
|
|
|
(save-exp-data math-expr-data)
|
2004-11-11 05:53:19 +00:00
|
|
|
(vals (let ((math-exp-keep-spaces space-sep))
|
2004-11-09 20:31:40 +00:00
|
|
|
(if (or (equal math-expr-data "\\dots")
|
|
|
|
(equal math-expr-data "\\ldots"))
|
2001-11-06 18:59:06 +00:00
|
|
|
'(vec (neg (var inf var-inf)))
|
|
|
|
(catch 'syntax (math-read-vector))))))
|
|
|
|
(if (stringp vals)
|
|
|
|
(if space-sep
|
2004-11-11 05:53:19 +00:00
|
|
|
(let ((error-exp-pos math-exp-pos)
|
|
|
|
(error-exp-old-pos math-exp-old-pos)
|
2001-11-06 18:59:06 +00:00
|
|
|
vals2)
|
2004-11-11 05:53:19 +00:00
|
|
|
(setq math-exp-pos save-exp-pos
|
|
|
|
math-exp-old-pos save-exp-old-pos
|
|
|
|
math-exp-token save-exp-token
|
2004-11-09 20:31:40 +00:00
|
|
|
math-expr-data save-exp-data)
|
2004-11-11 05:53:19 +00:00
|
|
|
(let ((math-exp-keep-spaces nil))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq vals2 (catch 'syntax (math-read-vector))))
|
|
|
|
(if (and (not (stringp vals2))
|
2004-11-09 20:31:40 +00:00
|
|
|
(or (assoc math-expr-data '(("\\ldots") ("\\dots") (";")))
|
2004-11-26 22:33:49 +00:00
|
|
|
(equal math-expr-data math-rb-close)
|
2004-11-11 05:53:19 +00:00
|
|
|
(eq math-exp-token 'end)))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq space-sep nil
|
|
|
|
vals vals2)
|
2004-11-11 05:53:19 +00:00
|
|
|
(setq math-exp-pos error-exp-pos
|
|
|
|
math-exp-old-pos error-exp-old-pos)
|
2001-11-06 18:59:06 +00:00
|
|
|
(throw 'syntax vals)))
|
|
|
|
(throw 'syntax vals)))
|
2004-11-09 20:31:40 +00:00
|
|
|
(if (or (equal math-expr-data "\\dots")
|
|
|
|
(equal math-expr-data "\\ldots"))
|
2001-11-06 18:59:06 +00:00
|
|
|
(progn
|
|
|
|
(math-read-token)
|
|
|
|
(setq vals (if (> (length vals) 2)
|
|
|
|
(cons 'calcFunc-mul (cdr vals)) (nth 1 vals)))
|
2004-11-26 22:33:49 +00:00
|
|
|
(let ((exp2 (if (or (equal math-expr-data math-rb-close)
|
2004-11-09 20:31:40 +00:00
|
|
|
(equal math-expr-data ")")
|
2004-11-11 05:53:19 +00:00
|
|
|
(eq math-exp-token 'end))
|
2001-11-06 18:59:06 +00:00
|
|
|
'(var inf var-inf)
|
|
|
|
(math-read-expr-level 0))))
|
|
|
|
(setq vals
|
|
|
|
(list 'intv
|
2004-11-09 20:31:40 +00:00
|
|
|
(if (equal math-expr-data ")") 2 3)
|
2001-11-06 18:59:06 +00:00
|
|
|
vals
|
|
|
|
exp2)))
|
2004-11-26 22:33:49 +00:00
|
|
|
(if (not (or (equal math-expr-data math-rb-close)
|
2004-11-09 20:31:40 +00:00
|
|
|
(equal math-expr-data ")")
|
2004-11-11 05:53:19 +00:00
|
|
|
(eq math-exp-token 'end)))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 08:41:44 -07:00
|
|
|
(throw 'syntax "Expected `]'")))
|
2004-11-09 20:31:40 +00:00
|
|
|
(if (equal math-expr-data ";")
|
2004-11-11 05:53:19 +00:00
|
|
|
(let ((math-exp-keep-spaces space-sep))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq vals (cons 'vec (math-read-matrix (list vals))))))
|
2004-11-26 22:33:49 +00:00
|
|
|
(if (not (or (equal math-expr-data math-rb-close)
|
2004-11-11 05:53:19 +00:00
|
|
|
(eq math-exp-token 'end)))
|
Go back to grave quoting in source-code docstrings etc.
This reverts almost all my recent changes to use curved quotes
in docstrings and/or strings used for error diagnostics.
There are a few exceptions, e.g., Bahá’í proper names.
* admin/unidata/unidata-gen.el (unidata-gen-table):
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/align.el (align-region):
* lisp/allout.el (allout-mode, allout-solicit-alternate-bullet)
(outlineify-sticky):
* lisp/apropos.el (apropos-library):
* lisp/bookmark.el (bookmark-default-annotation-text):
* lisp/button.el (button-category-symbol, button-put)
(make-text-button):
* lisp/calc/calc-aent.el (math-read-if, math-read-factor):
* lisp/calc/calc-embed.el (calc-do-embedded):
* lisp/calc/calc-ext.el (calc-user-function-list):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-describe-key)
(calc-describe-thing, calc-full-help):
* lisp/calc/calc-lang.el (calc-c-language)
(math-parse-fortran-vector-end, math-parse-tex-sum)
(math-parse-eqn-matrix, math-parse-eqn-prime)
(calc-yacas-language, calc-maxima-language, calc-giac-language)
(math-read-giac-subscr, math-read-math-subscr)
(math-read-big-rec, math-read-big-balance):
* lisp/calc/calc-misc.el (calc-help, report-calc-bug):
* lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes)
(calc-auto-recompute):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-read-parse-table-part, calc-user-define-invocation)
(math-do-arg-check):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-vec.el (math-read-brackets):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calc/calc.el (calc, calc-do, calc-user-invocation):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/diary-lib.el (diary-check-diary-file)
(diary-mail-entries, diary-from-outlook):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--convert-float-to-ical)
(icalendar--convert-date-to-ical)
(icalendar--convert-ical-to-diary)
(icalendar--convert-recurring-to-diary)
(icalendar--add-diary-entry):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/timeclock.el (timeclock-mode-line-display)
(timeclock-make-hours-explicit, timeclock-log-data):
* lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category)
(todo-item-mark, todo-check-format)
(todo-insert-item--next-param, todo-edit-item--next-key)
(todo-mode):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/mode-local.el (describe-mode-local-overload)
(mode-local-print-binding, mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-displayor-show-request):
* lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
* lisp/cus-start.el (standard):
* lisp/cus-theme.el (describe-theme-1):
* lisp/custom.el (custom-add-dependencies, custom-check-theme)
(custom--sort-vars-1, load-theme):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dired-x.el (dired-do-run-mail):
* lisp/dired.el (dired-log):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-enable-advice)
(ad-disable-advice, ad-remove-advice, ad-set-argument)
(ad-set-arguments, ad--defalias-fset, ad-activate)
(ad-deactivate):
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand)
(byte-compile-unfold-lambda, byte-optimize-form-code-walker)
(byte-optimize-while, byte-optimize-apply):
* lisp/emacs-lisp/byte-run.el (defun, defsubst):
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode)
(byte-compile-log-file, byte-compile-format-warn)
(byte-compile-nogroup-warn, byte-compile-arglist-warn)
(byte-compile-cl-warn)
(byte-compile-warn-about-unresolved-functions)
(byte-compile-file, byte-compile--declare-var)
(byte-compile-file-form-defmumble, byte-compile-form)
(byte-compile-normal-call, byte-compile-check-variable)
(byte-compile-variable-ref, byte-compile-variable-set)
(byte-compile-subr-wrong-args, byte-compile-setq-default)
(byte-compile-negation-optimizer)
(byte-compile-condition-case--old)
(byte-compile-condition-case--new, byte-compile-save-excursion)
(byte-compile-defvar, byte-compile-autoload)
(byte-compile-lambda-form)
(byte-compile-make-variable-buffer-local, display-call-tree)
(batch-byte-compile):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use):
* lisp/emacs-lisp/chart.el (chart-space-usage):
* lisp/emacs-lisp/check-declare.el (check-declare-scan)
(check-declare-warn, check-declare-file)
(check-declare-directory):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine)
(checkdoc-message-text-engine):
* lisp/emacs-lisp/cl-extra.el (cl-parse-integer)
(cl--describe-class):
* lisp/emacs-lisp/cl-generic.el (cl-defgeneric)
(cl--generic-describe, cl-generic-generalizers):
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody)
(cl-symbol-macrolet):
* lisp/emacs-lisp/cl.el (cl-unload-function, flet):
* lisp/emacs-lisp/copyright.el (copyright)
(copyright-update-directory):
* lisp/emacs-lisp/edebug.el (edebug-read-list):
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-core.el (eieio--slot-override)
(eieio-oref):
* lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
* lisp/emacs-lisp/eieio-speedbar.el:
(eieio-speedbar-child-make-tag-lines)
(eieio-speedbar-child-description):
* lisp/emacs-lisp/eieio.el (defclass, change-class):
* lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms)
(elint-init-form, elint-check-defalias-form)
(elint-check-let-form):
* lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu)
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-describe-test):
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol)
(find-function-library):
* lisp/emacs-lisp/generator.el (iter-yield):
* lisp/emacs-lisp/gv.el (gv-define-simple-setter):
* lisp/emacs-lisp/lisp-mnt.el (lm-verify):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring)
(advice--make, define-advice):
* lisp/emacs-lisp/package-x.el (package-upload-file):
* lisp/emacs-lisp/package.el (package-version-join)
(package-disabled-p, package-activate-1, package-activate)
(package--download-one-archive)
(package--download-and-read-archives)
(package-compute-transaction, package-install-from-archive)
(package-install, package-install-selected-packages)
(package-delete, package-autoremove, describe-package-1)
(package-install-button-action, package-delete-button-action)
(package-menu-hide-package, package-menu--list-to-prompt)
(package-menu--perform-transaction)
(package-menu--find-and-notify-upgrades):
* lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/emacs-lisp/ring.el (ring-previous, ring-next):
* lisp/emacs-lisp/rx.el (rx-check, rx-anything)
(rx-check-any-string, rx-check-any, rx-check-not, rx-=)
(rx-repeat, rx-check-backref, rx-syntax, rx-check-category)
(rx-form):
* lisp/emacs-lisp/smie.el (smie-config-save):
* lisp/emacs-lisp/subr-x.el (internal--check-binding):
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag):
* lisp/emacs-lisp/testcover.el (testcover-1value):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments)
(viper-toggle-search-style, viper-kill-buffer)
(viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/env.el (setenv):
* lisp/erc/erc-button.el (erc-nick-popup):
* lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english):
* lisp/eshell/em-dirs.el (eshell/cd):
* lisp/eshell/em-glob.el (eshell-glob-regexp)
(eshell-glob-entries):
* lisp/eshell/em-pred.el (eshell-parse-modifiers):
* lisp/eshell/esh-opt.el (eshell-show-usage):
* lisp/facemenu.el (facemenu-add-new-face)
(facemenu-add-new-color):
* lisp/faces.el (read-face-name, read-face-font, describe-face)
(x-resolve-font-name):
* lisp/files-x.el (modify-file-local-variable):
* lisp/files.el (locate-user-emacs-file, find-alternate-file)
(set-auto-mode, hack-one-local-variable--obsolete)
(dir-locals-set-directory-class, write-file, basic-save-buffer)
(delete-directory, copy-directory, recover-session)
(recover-session-finish, insert-directory)
(file-modes-char-to-who, file-modes-symbolic-to-number)
(move-file-to-trash):
* lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer):
* lisp/find-cmd.el (find-generic, find-to-string):
* lisp/finder.el (finder-commentary):
* lisp/font-lock.el (font-lock-fontify-buffer):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/frame.el (get-device-terminal, select-frame-by-name):
* lisp/fringe.el (fringe--check-style):
* lisp/gnus/nnmairix.el (nnmairix-widget-create-query):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--parent-mode)
(help-fns--obsolete, help-fns--interactive-only)
(describe-function-1, describe-variable):
* lisp/help.el (describe-mode)
(describe-minor-mode-from-indicator):
* lisp/image.el (image-type):
* lisp/international/ccl.el (ccl-dump):
* lisp/international/fontset.el (x-must-resolve-font-name):
* lisp/international/mule-cmds.el (prefer-coding-system)
(select-safe-coding-system-interactively)
(select-safe-coding-system, activate-input-method)
(toggle-input-method, describe-current-input-method)
(describe-language-environment):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/mail/feedmail.el (feedmail-run-the-queue):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc-playlist-rename):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-shell-command):
* lisp/net/imap.el (imap-interactive-login):
* lisp/net/mairix.el (mairix-widget-create-query):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/rlogin.el (rlogin):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/obsolete/otodo-mode.el (todo-more-important-p):
* lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region):
* lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region):
* lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region):
* lisp/org/ob-core.el (org-babel-goto-named-src-block)
(org-babel-goto-named-result):
* lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap):
* lisp/org/ob-ref.el (org-babel-ref-resolve):
* lisp/org/org-agenda.el (org-agenda-prepare):
* lisp/org/org-clock.el (org-clock-notify-once-if-expired)
(org-clock-resolve):
* lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/org/org-feed.el (org-feed-parse-atom-entry):
* lisp/org/org-habit.el (org-habit-parse-todo):
* lisp/org/org-mouse.el (org-mouse-popup-global-menu)
(org-mouse-context-menu):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/org/ox.el (org-export-async-start):
* lisp/proced.el (proced-log):
* lisp/progmodes/ada-mode.el (ada-get-indent-case)
(ada-check-matching-start, ada-goto-matching-start):
* lisp/progmodes/ada-prj.el (ada-prj-display-page):
* lisp/progmodes/ada-xref.el (ada-find-executable):
* lisp/progmodes/ebrowse.el (ebrowse-tags-apropos):
* lisp/progmodes/etags.el (etags-tags-apropos-additional):
* lisp/progmodes/flymake.el (flymake-parse-err-lines)
(flymake-start-syntax-check-process):
* lisp/progmodes/python.el (python-shell-get-process-or-error)
(python-define-auxiliary-skeleton):
* lisp/progmodes/sql.el (sql-comint):
* lisp/progmodes/verilog-mode.el (verilog-load-file-at-point):
* lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate):
* lisp/recentf.el (recentf-open-files):
* lisp/replace.el (query-replace-read-from)
(occur-after-change-function, occur-1):
* lisp/scroll-bar.el (scroll-bar-columns):
* lisp/server.el (server-get-auth-key):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, list-processes--refresh)
(compose-mail, set-variable, choose-completion-string)
(define-alternatives):
* lisp/startup.el (site-run-file, tty-handle-args, command-line)
(command-line-1):
* lisp/subr.el (noreturn, define-error, add-to-list)
(read-char-choice, version-to-list):
* lisp/term/common-win.el (x-handle-xrm-switch)
(x-handle-name-switch, x-handle-args):
* lisp/term/x-win.el (x-handle-parent-id, x-handle-smid):
* lisp/textmodes/reftex-ref.el (reftex-label):
* lisp/textmodes/reftex-toc.el (reftex-toc-rename-label):
* lisp/textmodes/two-column.el (2C-split):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* lisp/type-break.el (type-break-noninteractive-query):
* lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes)
(wdired-do-perm-changes):
* lisp/whitespace.el (whitespace-report-region):
Prefer grave quoting in source-code strings used to generate help
and diagnostics.
* lisp/faces.el (face-documentation):
No need to convert quotes, since the result is a docstring.
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
Simplify by generating only curved quotes, since info files are
typically that ways nowadays anyway.
* lisp/international/mule-diag.el (list-input-methods):
Don’t assume text quoting style is curved.
* lisp/org/org-bibtex.el (org-bibtex-fields):
Revert my recent changes, going back to the old quoting style.
2015-09-07 08:41:44 -07:00
|
|
|
(throw 'syntax "Expected `]'")))
|
2004-11-11 05:53:19 +00:00
|
|
|
(or (eq math-exp-token 'end)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
2020-10-10 16:00:51 -04:00
|
|
|
vals))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-check-for-commas (&optional balancing)
|
|
|
|
(let ((count 0)
|
2004-11-11 05:53:19 +00:00
|
|
|
(pos (1- math-exp-pos)))
|
2001-11-06 18:59:06 +00:00
|
|
|
(while (and (>= count 0)
|
|
|
|
(setq pos (string-match
|
|
|
|
(if balancing "[],[{}()<>]" "[],[{}()]")
|
2004-11-11 05:53:19 +00:00
|
|
|
math-exp-str (1+ pos)))
|
|
|
|
(or (/= (aref math-exp-str pos) ?,) (> count 0) balancing))
|
|
|
|
(cond ((memq (aref math-exp-str pos) '(?\[ ?\{ ?\( ?\<))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq count (1+ count)))
|
2004-11-11 05:53:19 +00:00
|
|
|
((memq (aref math-exp-str pos) '(?\] ?\} ?\) ?\>))
|
2001-11-06 18:59:06 +00:00
|
|
|
(setq count (1- count)))))
|
|
|
|
(if balancing
|
|
|
|
pos
|
2004-11-11 05:53:19 +00:00
|
|
|
(and pos (= (aref math-exp-str pos) ?,)))))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-read-vector ()
|
|
|
|
(let* ((val (list (math-read-expr-level 0)))
|
|
|
|
(last val))
|
|
|
|
(while (progn
|
2004-11-11 05:53:19 +00:00
|
|
|
(while (eq math-exp-token 'space)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
2004-11-11 05:53:19 +00:00
|
|
|
(and (not (eq math-exp-token 'end))
|
2004-11-09 20:31:40 +00:00
|
|
|
(not (equal math-expr-data ";"))
|
2004-11-26 22:33:49 +00:00
|
|
|
(not (equal math-expr-data math-rb-close))
|
2004-11-09 20:31:40 +00:00
|
|
|
(not (equal math-expr-data "\\dots"))
|
|
|
|
(not (equal math-expr-data "\\ldots"))))
|
|
|
|
(if (equal math-expr-data ",")
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
2004-11-11 05:53:19 +00:00
|
|
|
(while (eq math-exp-token 'space)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
|
|
|
(let ((rest (list (math-read-expr-level 0))))
|
|
|
|
(setcdr last rest)
|
|
|
|
(setq last rest)))
|
2001-11-14 09:09:09 +00:00
|
|
|
(cons 'vec val)))
|
2001-11-06 18:59:06 +00:00
|
|
|
|
|
|
|
(defun math-read-matrix (mat)
|
2004-11-09 20:31:40 +00:00
|
|
|
(while (equal math-expr-data ";")
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token)
|
2004-11-11 05:53:19 +00:00
|
|
|
(while (eq math-exp-token 'space)
|
2001-11-06 18:59:06 +00:00
|
|
|
(math-read-token))
|
|
|
|
(setq mat (nconc mat (list (math-read-vector)))))
|
2001-11-14 09:09:09 +00:00
|
|
|
mat)
|
2001-11-06 18:59:06 +00:00
|
|
|
|
2004-11-30 17:28:25 +00:00
|
|
|
(provide 'calc-vec)
|
|
|
|
|
2001-11-14 09:09:09 +00:00
|
|
|
;;; calc-vec.el ends here
|