aboutsummaryrefslogtreecommitdiff
path: root/src/maple
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-04-13 17:28:37 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-04-13 17:28:37 +0000
commit23a51f42643f8612d0e5482f08de864d129e0174 (patch)
tree55026948173bcf72bf28bcb8b2f73b039e029aa4 /src/maple
parent182cc532cf7c15019b4254ff747ff3849b542cfc (diff)
change fix_rationals() to preserve all integer factors in powers
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@514 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/maple')
-rw-r--r--src/maple/codegen2.maple22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/maple/codegen2.maple b/src/maple/codegen2.maple
index 0f1f761..84144be 100644
--- a/src/maple/codegen2.maple
+++ b/src/maple/codegen2.maple
@@ -445,9 +445,9 @@ end;
################################################################################
#
-# This function converts all {integer, rational} subexpressions of its
-# input except integer exponents and -1 factors in products, into function
-# calls RATIONAL(num,den) with num and den integers.
+# This function converts all integer or rational subexpressions of its
+# input except integer exponents and integer factors in products, into
+# function calls RATIONAL(num,den) with num and den integers.
#
# This is useful in conjunction with the C() library function, since
#
@@ -474,7 +474,7 @@ proc(expr::{algebraic, name = algebraic, list({algebraic, name = algebraic})})
local nn, k,
base, power, fbase, fpower,
fn, fn_args_list, fixed_fn_args_list,
- expr_sign, temp,
+ int_factors, nonint_factors,
num, den, mult;
# recurse over lists
@@ -507,10 +507,20 @@ if (type(expr, `+`))
fi;
# recurse over products
-# ... leaving -1 factors intact
+# ... leaving integer factors intact
if (type(expr, `*`))
then
- if (member(-1, [op(expr)]))
+ # compute lists of all integer/non-integer factors
+ int_factors,nonint_factors := selectremove(type, expr, integer);
+
+ if (nops(int_factors) > 0)
+ then return op(1,int_factors)
+ * product('fix_rationals(op(k,nonint_factors))',
+ 'k'=1..nops(nonint_factors));
+ else return product('fix_rationals(op(k,expr))', 'k'=1..nn);
+ fi;
+
+ if (select(type, [op(expr)], integer) <> [])
then
expr_sign := -1;
temp := -expr;