There are many places in the code that calculating the Pythagorean addition is needed, which is defined as: a ⊕ b = sqrt(a^2+b^2) This is hypotenuse, or the length of the longest side of a right-angled triangle, that we know the other 2 sides, a and b. https://en.wikipedia.org/wiki/Pythagorean_addition Theoretically, this calculation could be done using sqrt(a * a + b * b), but there are problems with this approach. For large a or b, there is a possibility of overflow, although the result itself is not that big to cause overflow. To overcome this problem, there are implementations of hypotenuse that do not use power of 2, and use other methods to calculate the result. One of them which is usable in C++ is the std::hypot. To calculate a ⊕ b, you can easily use std::hypot(a,b). https://en.cppreference.com/w/cpp/numeric/math/hypot As an example, you can see this commit from Mike: https://git.libreoffice.org/core/+/4cbaaf21fe1c22b36dd72798cecfa59e73d0f8c3 How to find instances Among the result of this output, you can find some instances: git grep sqrt but then you should look for things like 'statement * statement' in the results.
Gautham Krishnan committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/67fcd8f268fd04ca2012470af2257b394b77b8fc tdf#147906 used std::hypot for Pythagorean addition It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
VaibhavMalik4187 committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/d0055ac076c61d24c505c2ffa4f99e36c97b1266 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
offtkp committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/ab9896bfda4d2ef16f3cbb373edced33f9021492 tdf#147906 change all sqrt(a * a + b * b) occurences to std::hypot(a, b) It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
It seems that std::hypot is much slower that square root: https://stackoverflow.com/questions/32435796/when-to-use-stdhypotx-y-over-stdsqrtxx-yy I am wondering if this change is worth implementing (possible performance drop).
Bartosz Kosiorek committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/a2d49b680cd026c3d64683f6ee3ba97e9834a7f7 tdf#147906 change sqrt(a * a + b * b) occurences to std::hypot(a, b) It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
At core/filter/source/svg/svgwriter.cxx:304 "const double fRadius = sqrt( static_cast< double >( rObjRect.GetWidth() ) * rObjRect.GetWidth() + rObjRect.GetHeight()*rObjRect.GetHeight() ) * 0.5;" Is it a candidate for changing it to: "const double fRadius = std::hypot(rObjRect.GetWidth(), rObjRect.GetHeight()) * 0.5" If yes, then why it's not letting me make a commit containing this lines of code ? If no, Some explanations will be great :)!!
(In reply to Libreoffice user SSO from comment #6) > At core/filter/source/svg/svgwriter.cxx:304 "const double fRadius = sqrt( > static_cast< double >( rObjRect.GetWidth() ) * rObjRect.GetWidth() + > rObjRect.GetHeight()*rObjRect.GetHeight() ) * 0.5;" > > Is it a candidate for changing it to: > "const double fRadius = std::hypot(rObjRect.GetWidth(), > rObjRect.GetHeight()) * 0.5" > > If yes, then why it's not letting me make a commit containing this lines of > code ? The change itself is OK, if you add ; in the end. Let's discuss this in the dev IRC.
pragat-pandya committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/a31aadb1ef7dfdd4ae76a15707ab51a82c95d868 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Re-evaluating the EasyHack in 2022 This issue is still relevant, as there are many places in the code that a Pythagorean addition is done, and std::hypot can be used instead.
Aleksa Savic committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/519dae19abddaedaf0d3d109186eeb4a08471a92 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
OmkarAcharekar committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/bcf333309f9a9bde21aac1302cbead2b23822458 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Bogdan B committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1e9ace4c35e4206c24ded230433915850a1f04d1 tdf#147906 used std::hypot for Pythagorean addition It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Bogdan B committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6bf5dd8faea420aa0dbc7c429952c9868bcadb9e tdf#147906 used std::hypot for Pythagorean addition It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Bogdan B committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/5b18eebc2c95321ce7e6edf10f4df81557382a48 tdf#147906 used std::hypot for Pythagorean addition It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Leonid Ryzhov committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1b44a4c558fdf597bf66c1c671248ca58e145e9e tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
ektagoel12 committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/841ab19fb3f68dbab6295459ef11a257f0f022e8 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
This EasyHack was previously about C++ std::hypot, but I think it would be fine to use the similar method Math.hypot() from Java, or math.hypot() from Python. Hereby I rename the title to have a more coverage, and I also add the appropriate tag accordingly.
Yomnasalama committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/08cfcea7fef6cde9eddcfa461fe1edff99dadafe tdf#147906 Use Math.hypot() for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Hi Hossein Can you please review my change, gerrit: https://gerrit.libreoffice.org/c/core/+/148547 It's been some time since it's open.
adityasingh22 committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1f22d01b7ae96a7efa91c9285f3d2f8c37f05237 tdf#147906: Use python's math.hypot() for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
I have understood the problem and I want to fix this issue.
Multi-hacker task, don't assign
Yousef_Rabia committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6700f7f5b4eae31bf020e7d073c496c6e67a2397 tdf#147906 Use Math.hypot() for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
buldi committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c6755955aeaddb14bd3ad231f78cda47a0a5aeaa tdf#147906 Use std::hypot for Pythagorean addition It will be available in 7.6.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
sahil committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/6e12b7f296930c6f37e036407e9fb832d9a9f027 tdf#147906 used std::hypot for Pythagorean addition It will be available in 24.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
apurvapriyadarshi committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/9844a197bfe91e7adb74e9e5859c7fbfaaf99e28 tdf#147906 used StrictMath.hypot for Pythagorean addition It will be available in 24.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Ankit_Jaipuriar committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/89367021a4c960b6873370ea9472b36457c51ef3 tdf#147906 Use std::hypot for Pythagorean addition It will be available in 24.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Started working on it.
Multi-hacks are not assigned.
RMZeroFour committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/45d951492a34d8d4134a518662377fa4c1e08395 tdf#147906 Use std::hypot for Pythagorean distance It will be available in 24.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
HakimOttey committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/9dad7c0f1095e85ad40ad874215f1051137b0347 tdf#147906 implement hypot function for s1 x s1 + s2 x s2 statements It will be available in 24.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
HakimOttey committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/c0adf5a90a51f500d633aad9786015f187531d31 Related: tdf#147906 Rename fQuadDist to pointDistance It will be available in 25.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Sakura286 committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/060d2fe39f27ffbb0e843de5031f6806c9abfce8 tdf#147906: Use hypot in place of sqrt to avoid overflow It will be available in 25.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.