acado/acado — pull request #33 by roryyorke (2013-07-13 12:53:11+00:00)
Title: Float warnings

The second of three branches aimed at reducing warnings when compiling with gcc.

This is aimed the at -Wfloat-equals warnings. The only comparisons are to -1, 0, and 1; I have pulled these out into three inline functions (isExactlyMinusOne(), etc.) which are inside a pragma block disabling the warning. The functions are in hpp/ipp files, modelled on existing ACADO code.

One non-pragma solution is something like abs(1-a) < DBL_EPSILON (or equivalent using std::numeric_limits), but that seems silly.

Alternatively -Wfloat-equal could be disabled specifically for these files.

Incidentally, I first thought branching on -1, 1, 0 etc. was a pointless micro-optimization, but some benchmarking with big enough datasets showed something like a 20% speedup.