Some operations of Integer is not inlined, I'm
very suprised at that.

An example from integ.input:

)time on
f := sqrt(tan(x)^2 + 2*tan(x) + 2);
g := integrate(sqrt(tan(x)^2 + 2*tan(x) + 2),x);
h := D(g,x);
normalize(h-f)

Profile shows most time is spent at symmetricRemainder,
which is implemented in INS, not INT.

After this patch, the example is 30% faster.

diff --git a/src/algebra/integer.spad b/src/algebra/integer.spad
index 15aefa22..55d3da20 100644
--- a/src/algebra/integer.spad
+++ b/src/algebra/integer.spad
@@ -59,7 +59,6 @@
       ZP ==> SparseUnivariatePolynomial %
       ZZP ==> SparseUnivariatePolynomial Integer
       x, y : %
-      n : NonNegativeInteger

       writeOMInt(dev : OpenMathDevice, x : %) : Void ==
         if x < 0 then
@@ -87,6 +86,7 @@
       dec  x  == x - 1
       hashUpdate!(hs, s) == update!(hs, SXHASH(s)$Lisp)$HashState
       negative? x == MINUSP(x)$Lisp
+      positive? x == PLUSP(x)$Lisp
       coerce(x) : OutputForm == outputForm(x pretend Integer)
       coerce(m : Integer) : % == m pretend %
       convert(x : %) : Integer == x pretend Integer
@@ -125,14 +125,17 @@
       random(x) == RANDOM(x)$Lisp
       x = y == EQL(x, y)$Lisp
       x < y == (x<y)$Lisp
+      x > y == (x>y)$Lisp
       -- critical for coercions to NonNegativeInteger
       x >= y == (x >= y)$Lisp
+      x <= y == (x <= y)$Lisp
       - x == (-x)$Lisp
       x + y == (x+y)$Lisp
       x - y == (x-y)$Lisp
       x * y == (x*y)$Lisp
       (m : Integer) * (y : %) == (m*y)$Lisp -- for subsumption problem
-      x ^ n == EXPT(x, n)$Lisp
+      (x : %) ^ (n : NonNegativeInteger) == EXPT(x, n)$Lisp
+      (x : %) ^ (n : PositiveInteger) == EXPT(x, n)$Lisp
       odd? x == ODDP(x)$Lisp
       max(x, y) == MAX(x, y)$Lisp
       min(x, y) == MIN(x, y)$Lisp
@@ -184,6 +187,15 @@
 --    TT := InnerModularGcd(%, ZP, 67108859 pretend %, myNextPrime)
 --    gcdPolynomial(p, q) == modularGcd(p, q)$TT

+      symmetricRemainder(x, n) ==
+          r := x rem n
+          r = 0 => 0
+          if n < 0 then n := -n
+          r > 0 =>
+              2::% * r > n => r - n
+              r
+          2::% * r + n <= 0 => r + n
+          r

 )abbrev domain NNI NonNegativeInteger
 ++ Author:

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to