I have fixed those eval in fspace.spad. Note that I only make minimal changes, including a big macro to avoid code duplication.
I didn't change the calls to 'eval' from 'simplify', that should be a different topic, and I'll study the performance impact first. -- 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 6094ca95..0df1f1b3 100644 --- a/src/algebra/fspace.spad +++ b/src/algebra/fspace.spad @@ -176,11 +176,12 @@ ExpressionSpace() : Category == Defn where import from List(Symbol) DUMMYVAR := '%dummyVar --- the 7 functions not provided are: +-- the 8 functions not provided are: -- kernels minPoly definingPolynomial -- coerce: K -> % eval: (%, List K, List %) -> % -- subst: (%, List K, List %) -> % -- eval: (%, List Symbol, List(List % -> %)) -> % +-- eval: (%, List BasicOperator, List(List % -> %)) -> % allKernels : % -> Set K listk : % -> List K @@ -232,7 +233,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 : %, op : OP, f : List % -> %) == eval(x, [op], [f]) eval(x : %, s : SY, f : % -> %) == eval(x, [s], [(y : List %) : % +-> f(first y)]) eval(x : %, s : OP, f : % -> %) == @@ -245,9 +246,6 @@ 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) - map(fn, k) == (l := [fn x for x in argument k]$List(%)) = argument k => k::% (operator k) l @@ -509,6 +507,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, [op1, ..., opm], [n1, ..., nm], [f1, ..., fm]) replaces + ++ every \spad{opi(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. @@ -585,6 +587,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 @@ -664,6 +667,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 @@ -677,7 +681,7 @@ FunctionSpace(R : Comparable) : Category == Definition where eval(x, s, n, [y +-> f(first(y)) for f in l]$List(List % -> %)) -- op(arg)^m ==> func(arg)^(m quo n) * op(arg)^(m rem n) - smprep(lop, lexp, lfunc, p) == + SMPREP(ARG) ==> (v := mainVariable p) case "failed" => p::% -- symbolIfCan(k := v::K) case SY => p::% k := v::K @@ -685,7 +689,7 @@ FunctionSpace(R : Comparable) : Category == Definition where (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(name op, lop)) < minIndex lop => q g + (n := position(ARG, lop)) < minIndex lop => q g a : % := 0 f := eval((lfunc.n) arg, lop, lexp, lfunc) e := lexp.n @@ -698,6 +702,9 @@ FunctionSpace(R : Comparable) : Category == Definition where q := reductum q a + smprep(lop, lexp, lfunc, p) == SMPREP(name op) + smprep2(lop, lexp, lfunc, p) == SMPREP(op) + dispdiff l == s := second(l)::O t := third(l)::O @@ -1028,6 +1035,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 : %, lop : List OP, n : List N, f : List(List % -> %)) == + smprep2(lop, n, f, numer x) + isPlus x == (u := isPlus numer x) case "failed" => "failed" [p::% for p in u::List(MP)] @@ -1129,6 +1139,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 : %, lop : List OP, n : List N, f : List(List % -> %)) == + smprep2(lop, n, f, numer x) / smprep2(lop, n, f, denom x) + differentiate(f : %, x : SY) == (smpderiv(numer f, x) * denom(f)::% - numer(f)::% * smpderiv(denom f, x))