[GiNaC-devel] [PATCH] Change input parser to accept pow(x,
y) and power(x, y).
Alexei Sheplyakov
varg at theor.jinr.ru
Sun Aug 19 14:05:53 CEST 2007
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-devel/attachments/20070819/ee02718f/attachment.pgp
More information about the GiNaC-devel
mailing list