Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inefficiency when both div_ and rem_ are needed #282

Open
spj101 opened this issue May 23, 2018 · 6 comments
Open

Inefficiency when both div_ and rem_ are needed #282

spj101 opened this issue May 23, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@spj101
Copy link
Contributor

spj101 commented May 23, 2018

There is an inefficiency when the user wants the result of both div_ and rem_. These are computed simultaneously by the divmod algorithms inside FORM but then only one is returned. This effectively doubles the time the user must wait.

Is it possible to add something like the following?

L q,r = divrem_(f,g);

or

divrem(f,g,q,r);

Thanks!

@tueda tueda added the enhancement New feature or request label May 24, 2018
@tueda
Copy link
Collaborator

tueda commented May 24, 2018

I really like the first syntax in which divrem_ returns a tuple, but probably FORM never gets such a cozy syntax. I'm not sure about the exact meaning of the second one, but I guess divrem_(f,g,q,r) that returns a product of the quotient and reminder that are hold in functions q and r, so q(...)*r(...). This would be fine but at some point one will encounter the MaxTermSize problem.

@vermaseren
Copy link
Owner

vermaseren commented May 24, 2018 via email

@vermaseren
Copy link
Owner

vermaseren commented May 24, 2018 via email

@spj101
Copy link
Contributor Author

spj101 commented May 24, 2018

Thanks a lot for thinking about this.

@tueda with my divrem_(f,g,q,r) suggestion all arguments would be expressions, the quotient and remainder would be written to the expressions q and r respectively.

@vermaseren I think the syntax

L F = div_(f,g,$rem);

is acceptable but I would be concerned about the the $rem dollar variable getting corrupted as discussed in issue #215 and #211 (comment). Could this corruption potentially happen if the remainder is large (especially if work is done to extend the size of polynomials that can be handled by the C++ part of FORM)?

@vermaseren
Copy link
Owner

vermaseren commented May 24, 2018 via email

@spj101
Copy link
Contributor Author

spj101 commented May 24, 2018

I agree, we can of course compute using a multiplication rather than calling rem_. This is slightly less efficient than if the function just returned the sorted(?) remainder which is already known to it.

Yes I see that poly_divmod only converts either the quotient or the remainder from the C++ poly class to the syntax needed by the C part of FORM. The thing I would be least sure how to implement is how to return an additional result in a dollar variable (or other expression).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants