]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
mentioned ncpow()
[ginac.git] / ginac / function.pl
index d381ea69f3754ab68e5b21e7ba416d05f177c690..b0564e6e45f105422029acccdf6c108a95323979 100755 (executable)
@@ -264,6 +264,7 @@ public:
        ~function_options();
        void initialize(void);
        function_options & set_name(std::string const & n, std::string const & tn=std::string());
+       function_options & latex_name(std::string const & tn);
 // the following lines have been generated for max. ${maxargs} parameters
 $eval_func_interface
 $evalf_func_interface
@@ -334,6 +335,7 @@ $constructors_interface
        // functions overriding virtual functions from bases classes
 public:
        void print(const print_context & c, unsigned level = 0) const;
+       unsigned precedence(void) const {return 70;}
        int degree(const ex & s) const;
        int ldegree(const ex & s) const;
        ex coeff(const ex & s, int n = 1) const;
@@ -342,6 +344,7 @@ public:
        ex evalf(int level=0) const;
        unsigned calchash(void) const;
        ex series(const relational & r, int order, unsigned options = 0) const;
+       bool match(const ex & pattern, lst & repl_lst) const;
        ex thisexprseq(const exvector & v) const;
        ex thisexprseq(exvector * vp) const;
 protected:
@@ -451,7 +454,7 @@ function_options::~function_options()
 
 void function_options::initialize(void)
 {
-       set_name("unnamed_function","\\\\operatorname{unnamed}");
+       set_name("unnamed_function","\\\\mbox{unnamed}");
        nparams=0;
        eval_f=evalf_f=derivative_f=series_f=0;
        evalf_params_first=true;
@@ -465,13 +468,19 @@ function_options & function_options::set_name(std::string const & n,
 {
        name=n;
        if (tn==std::string()) {
-               TeX_name="\\\\operatorname{"+name+"}";
+               TeX_name="\\\\mbox{"+name+"}";
        } else {
                TeX_name=tn;
        }
        return *this;
 }
 
+function_options & function_options::latex_name(std::string const & tn)
+{
+       TeX_name=tn;
+       return *this;
+}
+
 // the following lines have been generated for max. ${maxargs} parameters
 $eval_func_implementation
 $evalf_func_implementation
@@ -669,9 +678,12 @@ void function::print(const print_context & c, unsigned level) const
                }
                c.s << ")";
 
+       } else if is_of_type(c, print_latex) {
+               c.s << registered_functions()[serial].TeX_name;
+               printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
        } else {
                c.s << registered_functions()[serial].name;
-               printseq(c, '(', ',', ')', exprseq::precedence, function::precedence);
+               printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
        }
 }
 
@@ -790,6 +802,14 @@ ${series_switch_statement}
        throw(std::logic_error("function::series(): invalid nparams"));
 }
 
+bool function::match(const ex & pattern, lst & repl_lst) const
+{
+       // Serial number must match
+       if (is_ex_of_type(pattern, function) && serial != ex_to_function(pattern).serial)
+               return false;
+       return inherited::match(pattern, repl_lst);
+}
+
 // protected