I am reading through code for optimization routines (Nelder Mead, SQP…). Languages are C++, Python. I observe that often conversion from double to float is performed, or methods are duplicated with double resp. float arguments. Why is it profitable in optimization routines code, and is it significant? In my own code in C++, should I be careful for types double and float and why?
Kind regards.
Often the choice between
doubleandfloatis made more on space demands than speed. Modern processors are capable of operating ondoublequite fast.Floats may be faster than doubles when using SIMD instructions (such as SSE) which can operate on multiple values at a time. Also if the operations are faster than the memory pipeline, the smaller memory requirements of
floatwill speed things overall.