From 2db113296f65f8fd3a0d62781ddc9276ff07b487 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Mon, 20 Mar 2000 15:17:44 +0000 Subject: [PATCH 1/1] - fixed bug in normal(): normal(x^a) became (x^(-a))^(-1) - first shot at inert Diff() and Derivative() functions; still buggy! --- ginac/function.pl | 8 ++++++-- ginac/inifcns.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ ginac/inifcns.h | 6 ++++++ ginac/normal.cpp | 14 ++++++++++---- ginsh/ginsh_parser.yy | 1 - 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/ginac/function.pl b/ginac/function.pl index 4a218bbe..988206e9 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -508,7 +508,11 @@ protected: unsigned serial; }; -// utility macros +// utility functions/macros +inline const function &ex_to_function(const ex &e) +{ + return static_cast(*e.bp); +} #ifndef NO_NAMESPACE_GINAC @@ -1041,7 +1045,7 @@ ex function::pderivative(unsigned diff_param) const // partial differentiation GINAC_ASSERT(serial {a^n, b^n} return (new lst(power(n.op(0), exponent), power(n.op(1), exponent)))->setflag(status_flags::dynallocated); - } else if (exponent.info(info_flags::negint)) { + } else if (exponent.info(info_flags::negative)) { // (a/b)^-n -> {b^n, a^n} return (new lst(power(n.op(1), -exponent), power(n.op(0), -exponent)))->setflag(status_flags::dynallocated); } } else { + if (exponent.info(info_flags::positive)) { - // (a/b)^z -> {sym((a/b)^z), 1} + // (a/b)^x -> {sym((a/b)^x), 1} return (new lst(replace_with_symbol(power(n.op(0) / n.op(1), exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated); - } else { + } else if (exponent.info(info_flags::negative)) { if (n.op(1).is_equal(_ex1())) { @@ -1595,9 +1596,14 @@ ex power::normal(lst &sym_lst, lst &repl_lst, int level) const } else { - // (a/b)^-x -> {(b/a)^x, 1} + // (a/b)^-x -> {sym((b/a)^x), 1} return (new lst(replace_with_symbol(power(n.op(1) / n.op(0), -exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated); } + + } else { // exponent not numeric + + // (a/b)^x -> {sym((a/b)^x, 1} + return (new lst(replace_with_symbol(power(n.op(0) / n.op(1), exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated); } } } diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index fdb9bffa..6697d6f0 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -151,7 +151,6 @@ line : ';' cout << "You should have received a copy of the GNU General Public License along with\n"; cout << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n"; cout << "Cambridge, MA 02139, USA.\n"; - } | T_XYZZY {cout << "Nothing happens.\n";} | T_INVENTORY {cout << "You're not carrying anything.\n";} -- 2.44.0