Conversation
|
Thanks for these changes. Running the tests now in the mean time. |
There was a problem hiding this comment.
Hello @meiyasan,
thanks for this request. I agree that it's logical to have all FindRoots methods const, since no internal state should be affected by it.
At the same time, before using mutable, I try to find another solution, so I inspected the code a bit and realised that the member fRoots doesn't "survive" across invocations, so it's actually unnecessary. (The vector is cleared on every invocation, so the values computed before don't seem to survive.)
So how about we go one step further, and remove the member entirely, return the vector of roots by value, and mark the FindRoot() methods const?
Since you discovered it, I'm happy to let you be the author of this improvement, but if you don't have the time to do it now, we could do it from the ROOT side. Let me know what you think.
|
Either approach (mutable or strictly const) works for me. I initially though the original implementation was intended for cache. I’ll push the const update shortly per your recommendations. Cheers, Marco |
Test Results 22 files 22 suites 3d 23h 3m 42s ⏱️ For more details on these failures, see this check. Results for commit 9efbf1b. |
Indeed, on first sight, it looks like it, but nothing is actually cached, since the vector is always cleared. So maybe there was an intention for caching at some point, or simply a misunderstanding. 🙂 |
This Pull request:
Hi @lmoneta @vepadulano ; we may benefit from introducing a
mutablekeyword tofRootsin the Polynomial.h methods. I would be grateful if you could consider such changes as described below.Changes or fixes:
I applied a mutable keywords to
fRootsallowing to use FindRoots in const context. Such keyword was already applied along the same line tofDerived_paramsvariable inmath/mathmore/inc/Math/Polynomial.h.Checklist:
Tests:
I ran the ROOT battery of tests with couple of issues (related to some stress test, vectorization & simultions), but those also happened on my Mac M3 ARM before my modifications. If you have any concern, I believe it wouldn't be an issue to run it in a more standard dev context.
Regarding the Polynomial class modifications, my use case output remains unchanged. (I use polynomials to compute digital filtering, biquad, etc..) I also paid attention in particular to those related to polynomials:
gtest-hist-hist-testTProfile2Poly, etc..