summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-lang.el
diff options
context:
space:
mode:
authorRĂ¼diger Sonderfeld <ruediger@c-plusplus.de>2012-05-18 10:16:23 -0500
committerJay Belanger <jay.p.belanger@gmail.com>2012-05-18 10:16:23 -0500
commitb1a107166626f4d26399f828fba43b56d57ebeb8 (patch)
tree3083080b72716432403febad5601b2f050c2203c /lisp/calc/calc-lang.el
parentadf4198e98a7a664d2a624c06220210227a3c096 (diff)
downloademacs-b1a107166626f4d26399f828fba43b56d57ebeb8.tar.gz
calc/calc-lang.el (math-C-parse-bess, math-C-parse-fma): New functions.
(math-function-table): Add support for more C functions.
Diffstat (limited to 'lisp/calc/calc-lang.el')
-rw-r--r--lisp/calc/calc-lang.el35
1 files changed, 33 insertions, 2 deletions
diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index c53f59eb0f4..ec4c497a1c6 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -133,8 +133,39 @@
( asin . calcFunc-arcsin )
( asinh . calcFunc-arcsinh )
( atan . calcFunc-arctan )
- ( atan2 . calcFunc-arctan2 )
- ( atanh . calcFunc-arctanh )))
+ ( atan2 . calcFunc-arctan2 )
+ ( atanh . calcFunc-arctanh )
+ ( fma . (math-C-parse-fma))
+ ( fmax . calcFunc-max )
+ ( j0 . (math-C-parse-bess))
+ ( jn . calcFunc-besJ )
+ ( j1 . (math-C-parse-bess))
+ ( yn . calcFunc-besY )
+ ( y0 . (math-C-parse-bess))
+ ( y1 . (math-C-parse-bess))
+ ( tgamma . calcFunc-gamma )))
+
+(defun math-C-parse-bess (f val)
+ "Parse C's j0, j1, y0, y1 functions."
+ (let ((args (math-read-expr-list)))
+ (math-read-token)
+ (append
+ (cond ((eq val 'j0) '(calcFunc-besJ 0))
+ ((eq val 'j1) '(calcFunc-besJ 1))
+ ((eq val 'y0) '(calcFunc-besY 0))
+ ((eq val 'y1) '(calcFunc-besY 1)))
+ args)))
+
+(defun math-C-parse-fma (f val)
+ "Parse C's fma function fma(x,y,z) => (x * y + z)."
+ (let ((args (math-read-expr-list)))
+ (math-read-token)
+ (list 'calcFunc-add
+ (list 'calcFunc-mul
+ (nth 0 args)
+ (nth 1 args))
+ (nth 2 args))))
+
(put 'c 'math-variable-table
'( ( M_PI . var-pi )