Fix WorkSpace issues with expression optimization #535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.