]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid ln(10) expression in calc units definition
authorUlrich Müller <ulm@gentoo.org>
Sat, 1 Feb 2025 22:10:53 +0000 (23:10 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Feb 2025 08:00:39 +0000 (09:00 +0100)
* lisp/calc/calc-ext.el (calc-init-extensions): Autoload calc-math
for math-ln-10.
* lisp/calc/calc-units.el (math-standard-units): Use new ln10
constant instead of ln(10) in the decibel definition.
(math-find-base-units-rec): Allow ln10 in expression.
(math-to-standard-rec): Recognize the ln10 constant.  (Bug#75861)

(cherry picked from commit 1639ad2814ae100c9f878a1388eb9ffc9d208b07)

lisp/calc/calc-ext.el
lisp/calc/calc-units.el

index ce3f43f87bf424db805aaae7948b6488613c848f..f0b69ac13b3ce1182b2fa977b12f295bcb3a451c 100644 (file)
@@ -877,7 +877,7 @@ calcFunc-tanh math-arccos-raw math-arcsin-raw math-arctan-raw
 math-arctan2-raw math-cos-raw math-cot-raw math-csc-raw
 math-exp-minus-1-raw math-exp-raw
 math-from-radians math-from-radians-2 math-hypot math-infinite-dir
-math-ln-raw math-nearly-equal math-nearly-equal-float
+math-ln-10 math-ln-raw math-nearly-equal math-nearly-equal-float
 math-nearly-zerop math-nearly-zerop-float math-nth-root
 math-sin-cos-raw math-sin-raw math-sqrt math-sqrt-float math-sqrt-raw
 math-tan-raw math-to-radians math-to-radians-2)
index e73b82fd033b558adf843046b3aaab2faf095231..b743fe68ca31bb4afb99e0e27e4a385cdb1c80d1 100644 (file)
 
     ;; Logarithmic units
     ( Np      nil    "*Neper")
-    ( dB      "(ln(10)/20) Np" "decibel"))
+    ( dB      "(ln10/20) Np" "Decibel" nil
+              "(ln(10)/20) Np"))
   "List of predefined units for Calc.
 
 Each element is (NAME DEF DESC TEMP-UNIT HUMAN-DEF), where:
@@ -948,10 +949,9 @@ If COMP or STD is non-nil, put that in the units table instead."
          ((eq (car expr) '+)
           (math-find-base-units-rec (nth 1 expr) pow))
          ((eq (car expr) 'var)
-          (or (eq (nth 1 expr) 'pi)
+          (or (memq (nth 1 expr) '(pi ln10))
               (error "Unknown name %s in defining expression for unit %s"
                      (nth 1 expr) (car math-fbu-entry))))
-          ((equal expr '(calcFunc-ln 10)))
          (t (error "Malformed defining expression for unit %s"
                     (car math-fbu-entry))))))
 
@@ -1055,9 +1055,9 @@ If COMP or STD is non-nil, put that in the units table instead."
                                                math-unit-prefixes))
                                   expr)))
              expr)
-         (if (eq base 'pi)
-             (math-pi)
-           expr)))
+         (cond ((eq base 'pi) (math-pi))
+               ((eq base 'ln10) (math-ln-10))
+               (t expr))))
     (if (or
          (Math-primp expr)
          (and (eq (car-safe expr) 'calcFunc-subscr)