On Fri, Feb 26, 2021 at 03:49:24PM +0100, Waldek Hebisch wrote:
> On Mon, Feb 22, 2021 at 06:38:49PM +0100, Ralf Hemmecke wrote:
> > Hello,
> >
> > I wrote some code that relies on univariate taylor series in q.
> > Since it was cumbersome to always carry the variable name 'q and the
> > center of expansion 0 in the type, I created a kind of wrapper domain.
> > (See attachement for something that demonstrates my problem.)
> >
> > My wrapper domain actually works nicely as long as I do not want to make
> > a connection back and forth to UnivariateTaylorSeries.
> >
> > My question is how can I coerce an element of QEtaTaylorSeries(Q) to an
> > element of UnivariateTaylorSeries(Q, 'q, 0$Q) and/or the other way round?
> >
> > I simply cannot find the error in the implementation.
> >
> > I am sure it has something to do with non-type-valued arguments, but how
> > can I make this code work nicely without tricks?
>
> Fix interpreter and compiler? At compiler level this is confusion
> between 0 and '(Zero)'. The second is needed to get proper
> evaluation, the first appears in types. Spad compiler prints offending
> types so one can see what the problem is.
The attached patch works around compiler problems, now one can
call corresponding functions from Spad. Interpreter problem
remains...
--
Waldek Hebisch
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/20210228034451.GA36536%40math.uni.wroc.pl.
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index da2d732..80a3a43 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -418,6 +421,12 @@ compSel1(domain, op, argl, m, e) ==
for x in argl]], m, e]
(op = "COLLECT") and coerceable(domain, m, e) =>
(T := comp([op, :argl], domain, e) or return nil; coerce(T, m))
+ -- FIXME: we should handle 0 and 1 in systematic way, instead
+ -- of renaming hacks like below
+ if op = 0 then
+ op := "Zero"
+ else if op = 1 then
+ op := "One"
-- Next clause added JHD 8/Feb/94: the clause after doesn't work
-- since addDomain refuses to add modemaps from Mapping
e :=
@@ -1228,7 +1240,19 @@ resolve(din,dout) ==
dout
modeEqual(x,y) ==
- atom x or atom y => x=y
+ EQ(x, y) => true
+ -- FIXME: we should eliminate confusion due to 0 and 1 instead
+ -- of hacks like below
+ atom x =>
+ x = y => true
+ x = 0 => y = ["Zero"]
+ x = 1 => y = ["One"]
+ false
+ atom y =>
+ x = y => true
+ y = 0 => x = ["Zero"]
+ y = 1 => x = ["One"]
+ false
#x ~=#y => nil
(and/[modeEqual(u,v) for u in x for v in y])