Comment #9 on issue 3715 by t.hi...@gmail.com: ufuncify with logarithms
http://code.google.com/p/sympy/issues/detail?id=3715
This patch fixes the original issue: ( ufuncify log(10) )
index 58445bd..9396589 100644
--- a/sympy/printing/fcode.py
+++ b/sympy/printing/fcode.py
@@ -192,6 +192,7 @@ def _print_Add(self, expr):
def _print_Function(self, expr):
name = self._settings["user_functions"].get(expr.__class__)
+ eargs = expr.args
if name is None:
from sympy.functions import conjugate
if expr.func == conjugate:
@@ -201,10 +202,14 @@ def _print_Function(self, expr):
if hasattr(expr, '_imp_') and isinstance(expr._imp_, C.Lambda):
# inlined function.
# the expression is printed with _print to avoid loops
- return self._print(expr._imp_(*expr.args))
+ return self._print(expr._imp_(*eargs))
if expr.func.__name__ not in self._implicit_functions:
self._not_supported.add(expr)
- return "%s(%s)" % (name, self.stringify(expr.args, ", "))
+ else:
+ # convert all args to floats
+ eargs = map(lambda x: float(x), expr.args)
+
+ return "%s(%s)" % (name, self.stringify(eargs, ", "))
_print_factorial = _print_Function
Note that with this patch the generated fortran code (by ufuncify(x,
x*log(10))) contains the unevaluated expression log(10.0) instead of its
numerical value. This is in contrast to ufuncify(x, x*log(10.)) (Note the
dot after the 10) where log(10.) is evaluated before it is written to the
fortan file.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.