[PATCH] Change input parser to accept pow(x, y) and power(x, y).
so symbol x("x"); lst syms(x); ex("pow(x, 2)", syms); does NOT trigger parser error any more. --- ginac/input_parser.yy | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/ginac/input_parser.yy b/ginac/input_parser.yy index 8601524..74beb4c 100644 --- a/ginac/input_parser.yy +++ b/ginac/input_parser.yy @@ -105,6 +105,10 @@ exp : T_NUMBER {$$ = $1;} if ($3.nops() != 1) throw (std::runtime_error("too many arguments to sqrt()")); $$ = sqrt($3.op(0)); + } else if (n == "pow" || n == "power") { + if ($3.nops() != 2) + throw std::invalid_argument("wrong number of arguments to pow()"); + $$ = power($3.op(0), $3.op(0)); } else { unsigned i = function::find_function(n, $3.nops()); $$ = function(i, ex_to<exprseq>($3)).eval(1); -- 1.4.4.4 Best regards, Alexei -- All science is either physics or stamp collecting.
participants (2)
-
Alexei Sheplyakov
-
Jens Vollinga