unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Rüdiger Sonderfeld" <ruediger@c-plusplus.de>
To: emacs-devel@gnu.org
Cc: jay.p.belanger@gmail.com
Subject: [PATCH] calc/calc-lang.el (c): Added support for more C (C99) functions.
Date: Wed, 01 Feb 2012 19:01:32 +0100	[thread overview]
Message-ID: <2197485.mNir3U5MpL@descartes> (raw)

I added support for more C (C99) functions to calc's C language mode. I have 
signed the fsf papers.

Regards,
Rüdiger

-- >8 --
Subject: [PATCH] calc/calc-lang.el (c): Added support for more C (C99) 
functions.

Support for fma (x*y+z), fmax (max), jn, j0, j1 (bessel 1st kind), yn,
y0, y1 (bessel 2nd kind), tgamma (gamma).

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
---
 lisp/calc/calc-lang.el |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index c53f59e..0463b6a 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -134,7 +134,37 @@
      ( asinh	   . calcFunc-arcsinh )
      ( atan	   . calcFunc-arctan )
      ( atan2	   . calcFunc-arctan2 )
-     ( atanh	   . calcFunc-arctanh )))
+     ( atanh	   . calcFunc-arctanh )
+     ( fma         . (math-C-parse-fma))
+     ( fmax        . calcFunc-max )
+     ( jn          . calcFunc-besJ )
+     ( j0          . (math-C-parse-bess))
+     ( 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 )
-- 
1.7.8.3




             reply	other threads:[~2012-02-01 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 18:01 Rüdiger Sonderfeld [this message]
2012-02-01 19:31 ` [PATCH] calc/calc-lang.el (c): Added support for more C (C99) functions Jay Belanger
2012-05-18 15:33 ` Jay Belanger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2197485.mNir3U5MpL@descartes \
    --to=ruediger@c-plusplus.de \
    --cc=emacs-devel@gnu.org \
    --cc=jay.p.belanger@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).