From f1dedbe2e079cc7aa0bf34445aa920e9a9046ee5 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Thu, 21 Apr 2005 15:38:36 +0000 Subject: [PATCH] Nicer output for factorial(). --- ginac/inifcns.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index b576ebcf..ad4e035a 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -467,6 +467,17 @@ static ex factorial_eval(const ex & x) return factorial(x).hold(); } +static void factorial_print_dflt_latex(const ex & x, const print_context & c) +{ + if (is_exactly_a(x) || + is_exactly_a(x) || + is_exactly_a(x)) { + x.print(c); c.s << "!"; + } else { + c.s << "("; x.print(c); c.s << ")!"; + } +} + static ex factorial_conjugate(const ex & x) { return factorial(x); @@ -474,6 +485,8 @@ static ex factorial_conjugate(const ex & x) REGISTER_FUNCTION(factorial, eval_func(factorial_eval). evalf_func(factorial_evalf). + print_func(factorial_print_dflt_latex). + print_func(factorial_print_dflt_latex). conjugate_func(factorial_conjugate)); ////////// -- 2.47.0