]> www.ginac.de Git - ginac.git/blobdiff - ginac/normal.cpp
synced to 1.1
[ginac.git] / ginac / normal.cpp
index 936957fe55e929df7bb58b647d184c097146c655..5139509c51c59835947a0bef3d9dcd9bb51da049 100644 (file)
@@ -6,7 +6,7 @@
  *  computation, square-free factorization and rational function normalization. */
 
 /*
- *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -2069,13 +2069,20 @@ static ex frac_cancel(const ex &n, const ex &d)
 
        // Make denominator unit normal (i.e. coefficient of first symbol
        // as defined by get_first_symbol() is made positive)
-       const symbol *x;
-       if (get_first_symbol(den, x)) {
-               GINAC_ASSERT(is_exactly_a<numeric>(den.unit(*x)));
-               if (ex_to<numeric>(den.unit(*x)).is_negative()) {
+       if (is_exactly_a<numeric>(den)) {
+               if (ex_to<numeric>(den).is_negative()) {
                        num *= _ex_1;
                        den *= _ex_1;
                }
+       } else {
+               const symbol *x;
+               if (get_first_symbol(den, x)) {
+                       GINAC_ASSERT(is_exactly_a<numeric>(den.unit(*x)));
+                       if (ex_to<numeric>(den.unit(*x)).is_negative()) {
+                               num *= _ex_1;
+                               den *= _ex_1;
+                       }
+               }
        }
 
        // Return result as list
@@ -2222,13 +2229,11 @@ ex power::normal(lst &sym_lst, lst &repl_lst, int level) const
                                // (a/b)^-x -> {sym((b/a)^x), 1}
                                return (new lst(replace_with_symbol(power(n_basis.op(1) / n_basis.op(0), -n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
                        }
-
-               } else {        // n_exponent not numeric
-
-                       // (a/b)^x -> {sym((a/b)^x, 1}
-                       return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
                }
        }
+
+       // (a/b)^x -> {sym((a/b)^x, 1}
+       return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
 }