Some functions don't get properly inlined, this patch
fixes that.

To be precise, in the definition of DOM1, in the function
call with signature contains DOM2(%), where DOM2 is the
domain that can be inlined.

This bug actually happens rarely, other than Maybe,
I find this in InnerPrimeField:

    coordinates(x) == new(1, x)$(Vector %)

In FriCAS-1.3.2 pre-generated:

(SDEFUN |IPF;coordinates;$V;18| ((|x| $) ($ |Vector| $))
        (SPADCALL 1 |x| (QREFELT $ 70)))

After my patch:

(SDEFUN |IPF;coordinates;$V;18| ((|x| $) ($ |Vector| $)) (MAKEARR1 1 |x|))


My previous patch is not quite correct,
the for loop is useful, but it should not replace '$,
it should only replace Domain parameter like 'R'.

https://github.com/oldk1331/fricas/commit/f2f2db18bbe166a4bf3a6d7c37d6d98ae9ebd5b2.patch

diff --git a/src/interp/nruncomp.boot b/src/interp/nruncomp.boot
index 323080a1..b5f18ba7 100644
--- a/src/interp/nruncomp.boot
+++ b/src/interp/nruncomp.boot
@@ -133,13 +133,16 @@ optDeltaEntry(op,sig,dc,eltOrConst) ==
   sig := substitute(ndc, dc, sig)
   not MEMQ(IFCAR ndc, $optimizableConstructorNames) => nil
   dcval := optCallEval ndc
+  ddcval := devaluate dcval
   -- substitute guarantees to use EQUAL testing
-  sig := substitute(devaluate dcval, ndc, sig)
+  sig := substitute(ddcval, ndc, sig)
   if rest ndc then
-     for new in rest devaluate dcval for old in rest ndc repeat
-       sig := substitute(new, old, sig)
+     for new in rest ddcval for old in rest ndc repeat
+         if old ~= '$ then sig := substitute(new, old, sig)
      -- optCallEval sends (List X) to (List (Integer)) etc,
      -- so we should make the same transformation
+     sig := substitute(CADR ddcval, "$$", sig)
+     -- also transform "$$" to CADR(ddcval) which is '(Integer)
   fn := compiledLookup(op,sig,dcval)
   if null fn then
     -- following code is to handle selectors like first, rest

-- 
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