> Clearly the alternatives are not equvalent.  AFAICS Symbol
> version catches all operators with given name.  Operator
> will catch some.  Have to think which one behaves better.

This attachment is a preliminary patch that fixes 'eval' for
BasicOperator arguments.

I found this bug from cos2sec (and etc.) of manip.spad.
There are many usages of 'eval' that take Symbol as argument.

-- 
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 fricas-devel+unsubscr...@googlegroups.com.
To post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/algebra/fspace.spad b/src/algebra/fspace.spad
index 6cd8bab2..e96de163 100644
--- a/src/algebra/fspace.spad
+++ b/src/algebra/fspace.spad
@@ -226,7 +226,7 @@ ExpressionSpace() : Category == Defn where
     elt(op : OP, x : %, y : %, z : %, t : %, s : %, r : %, q : %,
         p : %, o : %) == op [x, y, z, t, s, r, q, p, o]
     eval(x : %, s : SY, f : List % -> %) == eval(x, [s], [f])
-    eval(x : %, s : OP, f : List % -> %) == eval(x, [name s], [f])
+    eval(x : %, s : OP, f : List % -> %) == eval(x, [s], [f])
     eval(x : %, s : SY, f : % -> %)      ==
         eval(x, [s], [(y : List %) : % +-> f(first y)])
     eval(x : %, s : OP, f : % -> %)      ==
@@ -239,8 +239,8 @@ ExpressionSpace() : Category == Defn where
     eval(x : %, ls : List SY, lf : List(% -> %)) ==
       eval(x, ls, [y +-> f(first y) for f in lf]$List(List % -> %))
 
-    eval(x : %, ls : List OP, lf : List(List % -> %)) ==
-      eval(x, [name s for s in ls]$List(SY), lf)
+    --eval(x : %, ls : List OP, lf : List(List % -> %)) ==
+    --  eval(x, [name s for s in ls]$List(SY), lf)  -- wrong
 
     map(fn, k) ==
       (l := [fn x for x in argument k]$List(%)) = argument k => k::%
@@ -503,6 +503,10 @@ FunctionSpace(R : Comparable) : Category == Definition where
            ++ eval(x, [s1, ..., sm], [n1, ..., nm], [f1, ..., fm]) replaces
            ++ every \spad{si(a1, ..., an)^ni} in x by \spad{fi(a1, ..., an)}
            ++ for any a1, ..., am.
+         eval : (%, List OP, List N, List(List % -> %)) -> %
+           ++ eval(x, [s1, ..., sm], [n1, ..., nm], [f1, ..., fm]) replaces
+           ++ every \spad{si(a1, ..., an)^ni} in x by \spad{fi(a1, ..., an)}
+           ++ for any a1, ..., am.
          eval : (%, SY, N, List % -> %) -> %
            ++ eval(x, s, n, f) replaces every \spad{s(a1, ..., am)^n} in x
            ++ by \spad{f(a1, ..., am)} for any a1, ..., am.
@@ -579,6 +583,7 @@ FunctionSpace(R : Comparable) : Category == Definition where
     diffEval  : List % -> %
     dfeval    : (List %, K) -> %
     smprep    : (List SY, List N, List(List % -> %), MP) -> %
+    smprep2   : (List OP, List N, List(List % -> %), MP) -> %
     diffdiff  : (List %, SY) -> %
     subs      : (% -> %, K) -> %
     symsub    : (SY, Z) -> SY
@@ -658,6 +663,7 @@ FunctionSpace(R : Comparable) : Category == Definition where
           eval(x, [s], [n], [(y : List %) : % +-> f(first(y))])
       eval(x : %, s : SY, n : N, f : List % -> %) == eval(x, [s], [n], [f])
       eval(x : %, l : List SY, f : List(List % -> %)) == eval(x, l, new(#l, 1), f)
+      eval(x : %, l : List OP, f : List(List % -> %)) == eval(x, l, new(#l, 1), f)
 
       elt(op : OP, args : List %) ==
         unary? op and ((od? := has?(op, ODD)) or has?(op, EVEN)) and
@@ -692,6 +698,27 @@ FunctionSpace(R : Comparable) : Category == Definition where
           q  := reductum q
         a
 
+      smprep2(lop, lexp, lfunc, p) ==
+        (v := mainVariable p) case "failed" => p::%
+        -- symbolIfCan(k := v::K) case SY => p::%
+        k := v::K
+        g := (op := operator k)
+           (arg := [eval(a, lop, lexp, lfunc) for a in argument k]$List(%))
+        q := map(y +-> eval(y::%, lop, lexp, lfunc),
+                 univariate(p, k))$SparseUnivariatePolynomialFunctions2(MP, %)
+        (n := position(op, lop)) < minIndex lop => q g
+        a : %  := 0
+        f    := eval((lfunc.n) arg, lop, lexp, lfunc)
+        e    := lexp.n
+        while q ~= 0 repeat
+          m  := degree q
+          qr := divide(m, e)
+          t1 := f ^ (qr.quotient)::N
+          t2 := g ^ (qr.remainder)::N
+          a  := a + leadingCoefficient(q) * t1 * t2
+          q  := reductum q
+        a
+
       dispdiff l ==
         s := second(l)::O
         t := third(l)::O
@@ -1022,6 +1049,9 @@ FunctionSpace(R : Comparable) : Category == Definition where
         eval(x : %, s : List SY, n : List N, f : List(List % -> %)) ==
           smprep(s, n, f, numer x)
 
+        eval(x : %, s : List OP, n : List N, f : List(List % -> %)) ==
+          smprep2(s, n, f, numer x)
+
         isPlus x ==
           (u := isPlus numer x) case "failed" => "failed"
           [p::% for p in u::List(MP)]
@@ -1123,6 +1153,9 @@ FunctionSpace(R : Comparable) : Category == Definition where
         eval(x : %, s : List SY, n : List N, f : List(List % -> %)) ==
           smprep(s, n, f, numer x) / smprep(s, n, f, denom x)
 
+        eval(x : %, s : List OP, n : List N, f : List(List % -> %)) ==
+          smprep2(s, n, f, numer x) / smprep2(s, n, f, denom x)
+
       differentiate(f : %, x : SY) ==
         (smpderiv(numer f, x) * denom(f)::% -
           numer(f)::% * smpderiv(denom f, x))

Reply via email to