Commit 2af15de3 authored by Hynek Baran's avatar Hynek Baran

v 0. 3 pseudidivision

jedeme na vikend
parent 904ccd27
......@@ -117,7 +117,7 @@
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets 5.92 test1 as of Oct 19, 2018 (2018-10-19 09:42:25)</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets.newresolve v 0.2 as of Oct 2018 (2018-10-25 18:24:56)</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets.newresolve v 0.3 as of Oct 2018 (2018-10-26 11:43:06)</Text-field>
</Output>
</Group>
<Group hide-output="false" labelreference="L936" drawlabel="true">
......
This diff is collapsed.
......@@ -2,9 +2,10 @@
# R e s o l v e - the new implementation (not well tested yet)
#
printf("Jets.newresolve v 0.2 as of Oct 2018 (%s)\n",
printf("Jets.newresolve v 0.3 as of Oct 2018 (%s)\n",
StringTools[FormatTime]("%Y-%m-%d %T", timestamp=FileTools[Status](__FILE__)[5]));
# v 0.3
# * Alhebraic:-pseudodivision used (`resolve/nonlin/combine/2/tool` := `resolve/nonlin/combine/2/pseudodivision`:)
# TODO:
# * in remainder fails, references to source nonlinear fails are missing
......@@ -13,9 +14,11 @@ printf("Jets.newresolve v 0.2 as of Oct 2018 (%s)\n",
#`resolve/nonresrat` := 3;
`resolve/opts/combine` := {'nonlinear', 'linear'}:
`resolve/1` := proc()
local as,bs,as1, as2, cs, ds, vl,i,ans, A, AL, AN, A1, A0, A1S, A1H, AE, APD, B, ff;
global `resolve/nonresrat`;
local as,bs,as1, as2, cs, ds, vl,i,ans, A, AL, AN, A1, A0, A0C, A0C0, A0C1, A1S, A1H, AE, APD, B, ff;
global `resolve/nonresrat`, `resolve/combine`;
Report(2, cat(`input `, nops([args])));
as := MaP(numer,{args}) minus {0};
Report(2, cat(`numer `, nops(as)));
......@@ -33,10 +36,26 @@ printf("Jets.newresolve v 0.2 as of Oct 2018 (%s)\n",
Report(2, cat(`reduceprod `, nops(as)));
A := MaP(`resolve/data/collect/detect`, convert(as,list), source=''procname'');
A := sizesort(A, a->a:-price);
if not has(`resolve/opts/combine`, 'linear') then
A := sizesort(A, a->a:-price);
fi;
AL, AN := selectremove(a->a:-kind <> 'nonlinear', A); # nonlin, lin
A1, A0 := selectremove(a->a:-solvable=true, AL); # resolvable, nonresolvable
if has(`resolve/opts/combine`, 'linear') then
Reportf(2, ["Combining %a linear nonresolvable eqs...", nops(A0)]);
A0C := `resolve/nonlin/combine`(A0);
A0C1, A0C0 := selectremove(a->a:-solvable=true, A0C); # resolvable, nonresolvable
Reportf(0, ["Combined %a new linear eqs (%a resolvable) from %a linear nonresolvable eqs", nops(A0C), nops(A0C1), nops(A0)]);
# extend input sets by combined eqs (all are linear)
A := sizesort([op({op(A), op(A0C1), op(A0C0)})], a->a:-price); # all
AL := sizesort([op({op(AL), op(A0C1), op(A0C0)})], a->a:-price); # linear
A1 := sizesort([op({op(A1), op(A0C1)})], a->a:-price); # resolvable
A0 := sizesort([op({op(A0), op(A0C0)})], a->a:-price); # nonresolvable
fi;
A1S, A1H :=`resolve/simplehard`(A1);
Reportf(1, ["There are %a linear resolvable (%a simple and %a hard),"
......@@ -93,11 +112,17 @@ printf("Jets.newresolve v 0.2 as of Oct 2018 (%s)\n",
# preselect eqs to be solved
if nops(A1) = 0 then # nothing solvable found, take ALL unsolvable (to be reported and treated by nonlinear tools)
B := A;
else # found solvable, restrict resolve to solvable cases
if nops(A1S)=0 and nops(A1H)>0 then # if no simple, take 1 hard (if exists)
# Reportf(2, ["Combining %a linear nonresolvable eqs...", nops(A0)]);
# A1C := `resolve/nonlin/combine`(A1S);
# Reportf(0, ["Combined %a new eqs from %a linear nonresolvable eqs", nops(A1C), nops(A0)]);
# B := [op(A), op(A1C)];
else
if nops(A1S)=0 and nops(A1H)>0 then # no simple, take 1 hard (if exists)
Reportf(2, ["No simple linear resolvable eqs found, taking hard linear resolvable (out of %a lin. solv. hard)", nops(A1H)]);
B := [A1H[1]]
else # all simple
B := A1S;
else # take all simple
B := A1S;
fi
fi;
......@@ -127,9 +152,14 @@ printf("Jets.newresolve v 0.2 as of Oct 2018 (%s)\n",
ans := `resolve/lin/r`(convert(B, set), vl, ForceFail=ff);
# if no usable results, lets try to generate pseudoremainders of polynomial pairs
if ans = FAIL and nops(AN)>=2 then
Reportf(2, ["No solvable linear eqs found, trying to combine nonlinear eqs pairs into linear"]);
AE := `resolve/nonlin/combine`(AN);
if has(`resolve/opts/combine`, 'nonlinear') and ans = FAIL and nops(AN)>=2 then
if has(`resolve/opts/combine`, 'linear') then
Reportf(2, ["No solvable linear eqs found, trying to combine all eqs pairs into linear"]);
AE := `resolve/nonlin/combine`(A);
else
Reportf(2, ["No solvable linear eqs found, trying to combine nonlinear eqs pairs into linear"]);
AE := `resolve/nonlin/combine`(AN);
fi;
Reportf(1, ["Combining %a nonlinear eqs given %a results", nops(AN), nops(AE)]);
Reportf(2, ["...witch properties are [price, size, LM, Vars, LC]:\n%s",
StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-LM, a:-Vars, a:-LC]), AE))]);
......@@ -330,10 +360,11 @@ end;
if nops(bs) < 2 then
return NULL
else
rfg := op(map2((f,g) -> `resolve/nonlin/combine/2`(f, g) , bs[1], bs[2..-1]));
rgf := op(map2((f,g) -> `resolve/nonlin/combine/2`(g, f) , bs[1], bs[2..-1]));
rfg := op(map2((F,G) -> `resolve/nonlin/combine/2`(F, G) , bs[1], bs[2..-1]));
#rgf := op(map2((F,G) -> `resolve/nonlin/combine/2`(G, F) , bs[1], bs[2..-1])); ### needed by `resolve/nonlin/combine/2/rem`
rr := thisproc(bs[2..-1]);
return rfg, rgf, rr;
#return rfg, rgf, rr; ###
return rfg, rr;
fi;
end:
......@@ -349,19 +380,25 @@ end:
LV := F:-LV;
fi;
if F:-degree >= G:-degree then
#if F:-degree >= G:-degree then ### needed by `resolve/nonlin/combine/2/rem`
Reportf(2, ["Combining polynomials in %a^%a*(%a), %a^%a*(%a)", (F:-LV), (F:-degree), (F:-LC), (G:-LV), (G:-degree), (G:-LC)]);
res := `resolve/nonlin/combine/2/tool`(F, G);
if res <> NULL then
res := divideout(numer(res));
fi;
else
res := NULL;
fi;
#else ###
# res := NULL;
#fi; ###
return res;
end:
`resolve/nonlin/combine/2/tool` := `resolve/nonlin/combine/2/rem`:
`resolve/nonlin/combine/2/tool` := `resolve/nonlin/combine/2/pseudodivision`:
`resolve/nonlin/combine/2/pseudodivision` := proc (F::record, G::record, $)
local res, resdata;
res := Algebraic:-PseudoDivision(F:-expr, G:-expr, F:-LV);
return res;
end:
#`resolve/nonlin/combine/2/pseudorem` := proc (f, g, LCf, LCg, df::integer, dg::integer, LV, Vs::list, $)
# description "Remainder of (appropriate multiple of f) and (g) to avoid div by 0";
......@@ -381,6 +418,8 @@ end:
#end:
`resolve/nonlin/combine/2/rem` := proc (F::record, G::record, $)
### see above "needed by `resolve/nonlin/combine/2/rem`"
### (remainder to be done for both [f,g] and [g,f] when degrees are equal)
local res, resdata;
res := frontend(rem, [F:-expr, G:-expr, F:-LV]);
if type(G:-LC, 'nonzero') then
......@@ -394,6 +433,9 @@ end:
fi;
end:
### linear resolve
`resolve/lin` := proc(ds::sequential(algebraic), $)
......@@ -454,8 +496,9 @@ end:
fi;
fi;
od;
Report(0, cat(`solved `, nops(ans), ` eq.`));
Report(1, cat(`rejected `, nops(rs), ` eq.`));
Report(0, cat(`solved `, nops(ans), ` eqs`));
Report(2, cat(`rejected `, nops(rs), ` eqs`));
Report(2, [`sizes: solved:`, op(sort(map(size,[op(ans)]))), `rejected:`, op(sort(map(size,[op(rs)]))), `left `, nops(bs), ` eq.`]);
ans := map(Simpl, map(eval,ans), vl);
......@@ -697,8 +740,12 @@ end:
printf("computing the remainder of polynomials failed in [%a^%a]/[%a^%a], leading terms are", F:-LV, F:-degree, G:-LV, G:-degree);
print(smash(F:-LC * F:-LV^F:-degree));
print(smash(G:-LC * G:-LV^G:-degree));
elif kind = 'pseudodivision' then
printf("pseudodivision %a", T);
error("implementation error, pseudodivision failed");
elif kind = 'unknownless' then
printf("implementation error, unknownless expression found");
print(smash(T['expr']));
else
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment