Here are two changes to make the optimizer easier to use.
The first is to dynamically allocate memory in Horner_tree, if the WorkSpace does not have enough space. There is no particular reason that the workspace should be used for the sort, here, other than that it exists, and might have capacity.
The second, is to re-use the same WorkPointer for every call of Generator when the optimized expression is placed into FORM's output. Generator modifies AT.WorkPointer internally, so each term which was added here was placed further and further into the buffer, unnecessarily.
In principle, if you arrive in generate_expression with a very-nearly full WorkSpace there could still be a crash. But this should be rare (?) .
coverage: 49.977% (-0.02%) from 49.999%
when pulling 603737dc3ad1ec2b678de4cac73b16798cd572fc on jodavies:opt-dynamic-workspace
into 83e3d4185efca2e5938c665a6df9d67d6d9492ca on vermaseren:master.
Here are two changes to make the optimizer easier to use.
The first is to dynamically allocate memory in
Horner_tree
, if theWorkSpace
does not have enough space. There is no particular reason that the workspace should be used for the sort, here, other than that it exists, and might have capacity.The second, is to re-use the same
WorkPointer
for every call ofGenerator
when the optimized expression is placed into FORM's output.Generator
modifiesAT.WorkPointer
internally, so each term which was added here was placed further and further into the buffer, unnecessarily.In principle, if you arrive in
generate_expression
with a very-nearly full WorkSpace there could still be a crash. But this should be rare (?) .These changes pass
pySecDec
's test suite.