dlib icon indicating copy to clipboard operation
dlib copied to clipboard

Replaces hypotenuses length calculation by hypot() call

Open denizzzka opened this issue 1 month ago • 2 comments

Hypotenuse calculation is used in many places in the code and can be sped up (but not right now, see: https://github.com/dlang/phobos/issues/10906)

I made it into separate commits to make it easier to check and roll back if I screwed up somewhere

denizzzka avatar Nov 29 '25 22:11 denizzzka

Tested this with some Dagon demos, and at least basic logics in the engine didn't break. Right now I'm not sure yet how justified such a change is. Performance-wise, it needs proper benchmarking, ideally against different implementations of hypot and sqrt, including LDC intrinsics. llvm_sqrt is already almost free, for instance. I'm working on a faster math library for dcore, which will be the basis for dlib 2.0, and I think it's better to postpone this until dlib.math is ported to dcore.math.

gecko0307 avatar Nov 30 '25 15:11 gecko0307

llvm_sqrt is already almost free

Someone on internet write that the SIMD version of hypot() works 2-8 times faster than naive implementation, especially for three-argument

denizzzka avatar Dec 02 '25 11:12 denizzzka