Commit 7e78debe authored by Hynek Baran's avatar Hynek Baran

Maybe working.

Jdeme domu.
parent be65fcae
......@@ -248,14 +248,24 @@ end:
fi
end:
`resolve/data/collect/remainder` := proc(b::algebraic, {source:='`?`'}, $)
local r := `resolve/data/collect/detect`(b, ':-source'=source);
r:-kind := 'remainder';
return Record[r, packed](
"koko" = "bobo"
`resolve/data/collect/remainder` := proc(b::algebraic, F::record, G::record, {source:='`?`'}, $)
return Record[packed](
"kind" = 'remainder',
"LV" = G:-LV,
"FailIndex"=NULL,
"FailParents" = [F,G]
);
end:
#`resolve/data/collect/remainder` := proc(b::algebraic, F::record, G::record, {source:='`?`'}, $)
# local r := `resolve/data/collect/detect`(b, ':-source'=source);
# r:-kind := 'remainder';
# return Record[r, packed](
# "FailParents" = [F,G]
# );
#end:
`resolve/data/get/expr` := proc(a) option inline; `if`(type(a, sequential), map(b->b:-expr, a), a:-expr) end:
`resolve/data/get/Vars` := proc(es::sequential(record))
......@@ -330,95 +340,67 @@ end;
if nops(bs) < 2 then
return NULL
else
rfg := op(map2((f,g) -> `resolve/nonlin/combine/2`(f:-expr, g:-expr) , bs[1], bs[2..-1]));
rgf := op(map2((f,g) -> `resolve/nonlin/combine/2`(g:-expr, f:-expr) , 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]));
rr := thisproc(bs[2..-1]);
return rfg, rgf, rr;
fi;
end:
`resolve/nonlin/combine/2` := proc(f,g)
`resolve/nonlin/combine/2` := proc(F::record,G::record)
global `resolve/nonlin/combine/2/tool`;
local Vsf, Vsg, LV, LCf, LCg, cf, cg, tf, tg, df, dg, res;
Vsf := VarL(f);
Vsg := VarL(g);
local f, g, LV, cf, cg, tf, tg, df, dg, res;
f := F:-expr; g := G:-expr;
Report(5, [f,g]);
# leading Var
if Vsf[1] <> Vsg[1] then
error ("Different leading Vars %1, %2",Vsf[1], Vsg[1]);
if F:-LV <> G:-LV then
error ("Different leading Vars %1, %2", F:-LV, G:-LV);
else
LV := Vsf[1];
LV := F:-LV;
fi;
# assuming Simpl(a, [V1]) is already done;
# coeficciens and terms
try
cf := coeffs(f, LV, tf);
catch "invalid arguments to coeffs":
Report(0, ["f not polynomial?", LV, f]);
return NULL;
end try;
try
cg := coeffs(g, LV, tg);
catch "invalid arguments to coeffs":
Report(0, ["g not polynomial?", LV, g]);
return NULL;
end try;
#if tf[1] = tg[1] then
# # polynomials of the same order
# LCf := collect(cf[1], Vf, simpl, distributed);
# LCg := collect(cg[1], Vg, simpl, distributed);
# return simpl(LCg*f - LCf*g);
#else
df := degree(tf[1], LV);
dg := degree(tg[1], LV);
LCf := collect(cf[1], Vf, simpl, distributed);
LCg := collect(cg[1], Vg, simpl, distributed);
if df >= dg then
Reportf(2, ["Combining polynomials in %a, %a", tf[1], tg[1]]);
res := `resolve/nonlin/combine/2/tool`(f, g, LCf, LCg, df, dg, LV, Vsg);
if F:-degree >= G:-degree then
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);
#res := collect(res, Vsf, simpl, distributed);
else
Reportf(2, ["Combining polynomials in %a, %a", tg[1], tf[1]]);
res := `resolve/nonlin/combine/2/tool`(g, f, LCg, LCg, dg, df, LV, Vsf);
Reportf(2, ["Combining polynomials in %a^%a*(%a), %a^%a*(%a)", (G:-LV), (G:-degree), (G:-LC), (F:-LV), (F:-degree), (F:-LC)]);
res := `resolve/nonlin/combine/2/tool`(F, G);
#res := collect(res, Vsg, simpl, distributed);
fi;
#fi;
return res;
end:
`resolve/nonlin/combine/2/tool` := `resolve/nonlin/combine/2/rem`:
`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";
local K;
K := LCg^(df-dg+1);
Reportf(5, ["Combining (%a) * (%a) and %a", K, f, g]);
frontend(rem, [K*f, g, LV])
end:
`resolve/nonlin/combine/2/redpseudorem` := proc (f, g, LCf, LCg, df::integer, dg::integer, LV, Vs::list, $)
description "Remainder of (appropriate multiple of f, gcd used) and (g) to avoid div by 0";
#### ??????????????????????????
local K, Kf, Kg;
frontend(gcd, [LCf,LCg^(df-dg+1), Kf, Kg]);
Reportf(5, ["Combining (%a) * (%a) and %a", Kg, f, g]);
frontend(rem, [Kg*f, g, LV])
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";
# local K;
# K := LCg^(df-dg+1);
# Reportf(5, ["Combining (%a) * (%a) and %a", K, f, g]);
# frontend(rem, [K*f, g, LV])
#end:
#
#`resolve/nonlin/combine/2/redpseudorem` := proc (f, g, LCf, LCg, df::integer, dg::integer, LV, Vs::list, $)
# description "Remainder of (appropriate multiple of f, gcd used) and (g) to avoid div by 0";
# #### ??????????????????????????
# local K, Kf, Kg;
# frontend(gcd, [LCf,LCg^(df-dg+1), Kf, Kg]);
# Reportf(5, ["Combining (%a) * (%a) and %a", Kg, f, g]);
# frontend(rem, [Kg*f, g, LV])
#end:
`resolve/nonlin/combine/2/rem` := proc (f, g, LCf, LCg, df::integer, dg::integer, LV, Vs::list, $)
`resolve/nonlin/combine/2/rem` := proc (F::record, G::record, $)
local res, resdata;
res := frontend(rem, [f, g, LV]);
if type(LCg, 'nonzero') then
res := frontend(rem, [F:-expr, G:-expr, F:-LV]);
if type(G:-LC, 'nonzero') then
return res;
else
Report(0, ["`resolve2/rem` failed for ", LV, "nonzero coeff is", LCg]);
Report(0, ["`resolve2/rem` failed for ", F:-LV, "nonzero coeff is", G:-LC]);
Report(3, ["...remainder is", res]);
#`resolve/fails/collect`('remainder', 'procname', res, LV, Vs, LCg, [df, dg]);
#BUG: musíme použít
resdata := `resolve/data/collect/remainder` (res, source=''procname'');
#resdata:-divcoeff := LCg;
#lprint(resdata);
`resolve/fails/collect`('remainder', resdata); ############# !!!!!!!!!!!
resdata := `resolve/data/collect/remainder` (res, F, G, source=''procname'');
`resolve/fails/collect`('remainder', resdata);
return NULL;
fi;
end:
......@@ -679,20 +661,19 @@ end:
`resolve/fails/table/counter`('set'=0);
end:
`resolve/fails/collect` := proc(kind::symbol, rec::uneval, $)
global RESOLVE, `resolve/fails/table`, `resolve/fails/table/counter`;
local i,r;
r := eval(rec);
`resolve/fails/collect` := proc(kind::symbol, r::record, $)
global RESOLVE, `resolve/fails/table`, `resolve/fails/table/counter`, `report/tab`;
local i;
i := `resolve/fails/table/counter`();
r:-FailIndex:= i;
Report(5, ["collecting", i, [args]]);
Reportf(5, ["collecting %a.: %a", i, [r]]);
# backward compatibility
if r:-kind='linear' then
RESOLVE := [op(RESOLVE), [r:-LC, r:-LV, r:-rest]]
elif r:-kind='nonlinear' then
RESOLVE := [op(RESOLVE), [r:-expr, r:-LV]]
elif r:-kind='remainder' then
RESOLVE := [op(RESOLVE), ["remainder"]] ### TODO!!!
RESOLVE := [op(RESOLVE), [["remainder", ((r:-FailParents)[2]):-LC ]]]
elif r:-kind='unknownless' then
lprint("Warning, `resolve/fails/collect` of unknownless expression", r);
else
......@@ -700,28 +681,34 @@ end:
fi;
# central fail storage
`resolve/fails/table`[i] := r;
rec := r;
return r;
end:
`resolve/fails/print/1` := proc(i)
global `resolve/fails/table`;
local T, kind, slv;
local T, F, G, kind, slv;
T := `resolve/fails/table`[op(i)];
kind := T[':-kind'];
tprint(sprintf("%a. %a solving by %a failed in %a",
op(i), kind, T['source'], T['LV']),
newline=false);
tprint(sprintf("%a. %a solving ", op(i), kind),newline=false);
if `report/tab`[ProcBaseSymbol()] > 1 then printf("by %a ", T['source']) fi;
printf(sprintf("failed in %a", T['LV']));
if type(T, record(FailParents)) then
F, G := op(T['FailParents']);
printf("\nwhile pseudodividing polynomials whose leading terms are\n%a^%a*(%a), %a^%a*(%a)", # F:-FailIndex, G:-FailIndex,
(F:-LV),(F:-degree),(F:-LC), (G:-LV),(G:-degree),(G:-LC));
### TODO: "parents:", F:-FailIndex, G:-FailIndex);
fi;
if kind = 'linear' then
if T['solvable']=true then printf(" (solvable) ") fi;
print (smash(T['LC'])*T['LV'] = -smash(T['rest']));
elif kind = 'remainder' then
#printf("^%a", T['degree']);
if T['solvable']=true then printf(" (solvable) ") fi;
printf(" on coefficient");
#printf(" on %a", T['divcoeff']);
print (smash(T['LC'])); # -smash(T['rest'])
print (smash(G:-LC));
elif kind = 'nonlinear' then
printf("^%a", T['degree']);
......
This diff is collapsed.
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