Commit 71e85e7f authored by Hynek Baran's avatar Hynek Baran

Maybe works for pair of polynomials.

TODO:
1. `resolve/nonlin/combine/2` must take records as arguments
2. `resolve/data/collect/remainder` must treat correct data, e. g. store parents
parent 876de2ef
......@@ -105,8 +105,11 @@
</Group>
<Group labelreference="L976" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">#jets_new_resolve_enable := true; </Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">jets_new_resolve_enable := true; </Text-field>
</Input>
<Output>
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVE4amV0c19uZXdfcmVzb2x2ZV9lbmFibGVGJy8lJ2l0YWxpY0dRJXRydWVGJy8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYtUSM6PUYnL0YzUSdub3JtYWxGJy8lJmZlbmNlR1EmZmFsc2VGJy8lKnNlcGFyYXRvckdGPS8lKXN0cmV0Y2h5R0Y9LyUqc3ltbWV0cmljR0Y9LyUobGFyZ2VvcEdGPS8lLm1vdmFibGVsaW1pdHNHRj0vJSdhY2NlbnRHRj0vJSdsc3BhY2VHUSwwLjI3Nzc3NzhlbUYnLyUncnNwYWNlR0ZMLUYsNiVGMUYvRjIvJStmb3JlZ3JvdW5kR1EoWzAsMCwwXUYnLyUpcmVhZG9ubHlHRj1GOQ==">SSV0cnVlRyUqcHJvdGVjdGVkRw==</Equation></Text-field>
</Output>
</Group>
<Group hide-input="false" hide-output="false" labelreference="L935" drawlabel="true">
<Input>
......@@ -114,6 +117,8 @@
</Input>
<Output>
<Text-field style="Line Printed Output" layout="Line Printed Output">`Jets 5.91 RC 1 as of Oct 15, 2018`</Text-field>
<Text-field style="Line Printed Output" layout="Line Printed Output">Jets.newresolve v 0.1 as of April 2018
Using the new implementation of resolve (not well tested yet!) </Text-field>
</Output>
</Group>
<Group hide-output="false" labelreference="L936" drawlabel="true">
......@@ -779,12 +784,21 @@
<Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output">STRDbGVhcmluZ35ub256ZXJvJ3MuRzYi</Equation></Text-field>
</Output>
</Group>
<Group labelreference="L977" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
<Input>
<Text-field style="Text" layout="Normal"># `resolve/lin`(ds::sequential(algebraic), unks::sequential, $) deprecated (unknowns must be set first by global var, cannot be specified by function argument)</Text-field>
</Input>
</Group>
<Group hide-output="false" labelreference="L36" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T (`resolve/lin`({a + b}, [a,b]), a = -b, `resolve 1`):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T ({`resolve/lin`({a + b, a + c}, [a,b,c])}, {a = -c, b = c},`resolve 2`): </Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T (`resolve/lin`({c*a + b + 2, b + 5}, [a,b]), b = -5, `resolve 3`):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
<Text-field style="Text" layout="Normal">T (`resolve/lin`({a + b}, [a,b]), a = -b, `resolve 1`):</Text-field>
<Text-field style="Text" layout="Normal">T ({`resolve/lin`({a + b, a + c}, [a,b,c])}, {a = -c, b = c},`resolve 2`): </Text-field>
<Text-field style="Text" layout="Normal">T (`resolve/lin`({c*a + b + 2, b + 5}, [a,b]), b = -5, `resolve 3`):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">dependence(a(),b(),c()):
unknowns(c,b,a):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T (resolve(a + b), a = -b, `resolve 1`):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T ({resolve(a + b, a + c)}, {a = -c, b = c},`resolve 2`): </Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal">T (resolve(c*a + b + 2, b + 5), b = -5, `resolve 3`):</Text-field>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group>
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ printf("\nUsing the new implementation of resolve (not well tested yet!) \n");
as := MaP(reduceprod,as) minus {0};
Report(2, cat(`reduceprod `, nops(as)));
A := MaP(`resolve/data/collect`, convert(as,list), source=''procname'');
A := MaP(`resolve/data/collect/detect`, convert(as,list), source=''procname'');
A := sizesort(A, a->a:-price);
AL, AN := selectremove(a->a:-kind <> 'nonlinear', A); # nonlin, lin
A1, A0 := selectremove(a->a:-solvable=true, AL); # resolvable, nonresolvable
......@@ -131,7 +131,7 @@ printf("\nUsing the new implementation of resolve (not well tested yet!) \n");
Reportf(2, ["...witch properties are [price, size, VarL, LC]:\n%s",
StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-Vars, a:-LC]), AE))]);
Reportf(0, ["Lets resolve combined %a linear eqs (out of %a nonlinear)...", nops(AE), nops(AN)]);
ans := `resolve/lin/r`(convert(AE, set), ForceFail=ff, keepfails);
ans := `resolve/lin/r`(convert(AE, set), ForceFail=ff);
fi;
#### if still no usable results, lets try to linearize nonlinear eqs by pd (linderive)
......@@ -143,7 +143,7 @@ printf("\nUsing the new implementation of resolve (not well tested yet!) \n");
### Reportf(2, ["...witch properties are [price, size, VarL, LC]:\n%s",
### StringTools:-Join(map(a -> sprintf("%q\n",[a:-price,a:-size,a:-Vars, a:-LC]), APD))]);
### Reportf(0, ["Derived %a linear eqs from %a nonlinear", nops(APD), nops(AN)]);
### ans := `resolve/lin/r`(convert(APD, set), ForceFail=ff, keepfails);
### ans := `resolve/lin/r`(convert(APD, set), ForceFail=ff);
###fi;
DoReports(resolve, [ans],comment=" resolve output");
......@@ -165,7 +165,7 @@ end:
# instead of algrebraic expressions, records are used to avoid multiple computations on the same expression
# the original expression is stored in r:-'expr' slot
`resolve/data/collect` := proc(b::algebraic, {source:='`?`'}, $)
`resolve/data/collect/detect` := proc(b::algebraic, {source:='`?`'}, $)
local a, Vs, LC, LCV, LM, r,s, Cs, Ms, deg;
a := Simpl(b);
if a=0 then return NULL fi;
......@@ -184,7 +184,8 @@ end:
"price"=0,
"size"=size(a),
"source"=source,
"solvable"=FAIL
"solvable"=FAIL,
"FailIndex"=NULL
)
fi;
......@@ -212,11 +213,8 @@ end:
"LV"=Vs[1],
"price"=infinity,
"size"=size(a),
"source"=source
#"coeffs"=[C], "monoms"=[M],
#":-leadLinCoeffVars"=FAIL
#"rest"=a,
#"subs"=FAIL
"source"=source,
"FailIndex"=NULL
)
else
# linear case
......@@ -244,12 +242,20 @@ end:
#'coeffs'=[C], 'monoms'=[M],
#'leadLinCoeffVars'=LCV
"solvable"=evalb(type(LC,nonzero)),
"rest"=r
#'subs'=s
"rest"=r,
"FailIndex"=NULL
)
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"
);
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))
......@@ -293,7 +299,7 @@ end:
`linderive/1` := overload([
proc (r::record, $) option overload(callseq_only);
map(`resolve/data/collect`@simpl, `linderive/1`(r:-expr, (r:-Vars)[1]))
map(`resolve/data/collect/detect`@simpl, `linderive/1`(r:-expr, (r:-Vars)[1]))
end,
proc (a::algebraic, LV := LVar(a))
map2(pd, a, vars(LV, forceError=true))
......@@ -310,7 +316,7 @@ end:
Vs := convert(map(proc(a) a:-Vars[1]; end, as), set);
# apply `resolve/nonlin/combine/V` on subclasses of as distinguished by leading Var
res := map(proc(LV) local bs := select(a -> a:-Vars[1] = LV, as); `resolve/nonlin/combine/LV`(LV, bs) end, Vs);
return sizesort(map(`resolve/data/collect`, res, source='procname'), a->a:-size);
return sizesort(map(`resolve/data/collect/detect`, res, source=''procname''), a->a:-size);
end:
`resolve/nonlin/combine/LV` := proc (LV, bs)
......@@ -409,7 +415,7 @@ end:
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` (res, source='procname');
resdata := `resolve/data/collect/remainder` (res, source=''procname'');
#resdata:-divcoeff := LCg;
#lprint(resdata);
`resolve/fails/collect`('remainder', resdata); ############# !!!!!!!!!!!
......@@ -420,7 +426,7 @@ end:
### linear resolve
`resolve/lin` := proc(ds::sequential(algebraic), $)
local rs := map(`resolve/data/collect`, ds, source='`resolve/lin`');
local rs := map(`resolve/data/collect/detect`, ds, source=''`resolve/lin`'');
`resolve/lin/r`(rs, _rest);
end:
......@@ -495,7 +501,7 @@ end:
if ans = {} then
map(proc(a)
`resolve/fails/collect`('linear', `resolve/data/collect`(a, source='`resolve/lin/r`'));
`resolve/fails/collect`('linear', `resolve/data/collect/detect`(a, source=''`resolve/lin/r`''));
end,
map2(op, 1, rs) union aux);
###`resolve/fails/print`();
......@@ -508,7 +514,7 @@ end:
`resolve/subs` := overload([
proc(a::record,v,q) option overload(callseq_only);
`resolve/data/collect`(Simpl(subs(v = q, a:-expr)))
`resolve/data/collect/detect`(Simpl(subs(v = q, a:-expr)))
end,
proc(a::algebraic,v,q) option overload(callseq_only);
Simpl(subs(v = q, a)) # Correction: Simpl added 9.7.2007
......@@ -673,16 +679,20 @@ end:
`resolve/fails/table/counter`('set'=0);
end:
`resolve/fails/collect` := proc(kind::symbol, r::record, $)
`resolve/fails/collect` := proc(kind::symbol, rec::uneval, $)
global RESOLVE, `resolve/fails/table`, `resolve/fails/table/counter`;
local i ;
local i,r;
r := eval(rec);
i := `resolve/fails/table/counter`();
r:-FailIndex:= i;
Report(5, ["collecting", i, [args]]);
# backward compatibility
if r:-kind='linear' or r:-kind ='remainder' then
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!!!
elif r:-kind='unknownless' then
lprint("Warning, `resolve/fails/collect` of unknownless expression", r);
else
......@@ -690,29 +700,36 @@ end:
fi;
# central fail storage
`resolve/fails/table`[i] := r;
rec := r;
end:
`resolve/fails/print/1` := proc(i)
global `resolve/fails/table`;
local T, kind, tail, slv;
local T, 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);
if kind = 'linear' then
if T['solvable']=true then printf(" (solvable) ") fi;
tail := T['expr'] - T['LC']*T['LV'];
print (smash(T['LC'])*T['LV'] = -smash(tail));
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 %a", T['divcoeff']);
print (smash(T['LC'])*T['LV'] = -smash(tail));
printf(" on coefficient");
#printf(" on %a", T['divcoeff']);
print (smash(T['LC'])); # -smash(T['rest'])
elif kind = 'nonlinear' then
printf("^%a", T['degree']);
print(smash(T['expr']));
elif kind = 'unknownless' then
print(smash(T['expr']));
else
error "Wrong kind %1", kind;
fi;
......
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