aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJay Belanger2011-02-07 16:25:31 -0600
committerJay Belanger2011-02-07 16:25:31 -0600
commit226590f8d1247314abf913cc1bc77621f8a5bca9 (patch)
treeb29b5811f25ec5425452f96a876f33f10952093d /lisp
parent4ec28e14ba2d74743419aa17490064c77b42ad3e (diff)
downloademacs-226590f8d1247314abf913cc1bc77621f8a5bca9.tar.gz
emacs-226590f8d1247314abf913cc1bc77621f8a5bca9.zip
calc/calc-units.el (math-logunits-quant): Add support for
non-logarithmic units.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/calc/calc-units.el38
2 files changed, 25 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a55a656af80..8826f884560 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12011-02-07 Jay Belanger <jay.p.belanger@gmail.com>
2
3 * calc/calc-units.el (math-logunits-quant): Add support for
4 non-logarithmic units.
5
12011-02-07 Ken Manheimer <ken.manheimer@gmail.com> 62011-02-07 Ken Manheimer <ken.manheimer@gmail.com>
2 7
3 * allout.el (allout-after-copy-or-kill-hook): New hook for 8 * allout.el (allout-after-copy-or-kill-hook): New hook for
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el
index 65b3356b13a..569d5d3dc35 100644
--- a/lisp/calc/calc-units.el
+++ b/lisp/calc/calc-units.el
@@ -1737,26 +1737,28 @@ If EXPR is nil, return nil."
1737 (calc-binary-op "lu/" 'calcFunc-lupowerdiv arg))))) 1737 (calc-binary-op "lu/" 'calcFunc-lupowerdiv arg)))))
1738 1738
1739(defun math-logunits-quant (val ref power) 1739(defun math-logunits-quant (val ref power)
1740 (let ((lunit (math-simplify (math-extract-logunits val)))) 1740 (let* ((units (math-simplify (math-extract-units val)))
1741 (lunit (math-simplify (math-extract-logunits units))))
1741 (if (not (eq (car-safe lunit) 'var)) 1742 (if (not (eq (car-safe lunit) 'var))
1742 (calc-record-why "*Improper logarithmic unit" lunit) 1743 (calc-record-why "*Improper logarithmic unit" lunit)
1743 (if (not (eq 1 (math-simplify (math-extract-units (math-div val lunit))))) 1744 (let ((runits (math-simplify (math-div units lunit)))
1744 (calc-record-why "*Inappropriate units" nil) 1745 (coeff (math-simplify (math-div val units))))
1745 (let ((coeff (math-simplify (math-div val lunit)))) 1746 (math-mul
1746 (if (equal lunit '(var dB var-dB)) 1747 (if (equal lunit '(var dB var-dB))
1747 (math-mul 1748 (math-mul
1748 ref 1749 ref
1749 (math-pow 1750 (math-pow
1750 10 1751 10
1751 (math-div 1752 (math-div
1752 coeff 1753 coeff
1753 (if power 10 20)))) 1754 (if power 10 20))))
1754 (math-mul 1755 (math-mul
1755 ref 1756 ref
1756 (calcFunc-exp 1757 (calcFunc-exp
1757 (if power 1758 (if power
1758 (math-mul 2 coeff) 1759 (math-mul 2 coeff)
1759 coeff))))))))) 1760 coeff))))
1761 runits)))))
1760 1762
1761(defvar calc-logunits-field-reference) 1763(defvar calc-logunits-field-reference)
1762(defvar calc-logunits-power-reference) 1764(defvar calc-logunits-power-reference)