[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: use of math.h / libmath discouraged?

**From**: |
Paul Smith |

**Subject**: |
Re: use of math.h / libmath discouraged? |

**Date**: |
Wed, 25 Jul 2018 09:06:05 -0400 |

On Tue, 2018-07-24 at 16:04 -0600, Brian Vandenberg wrote:
>* In a plugin I wrote I created a function with the following form /*
>* function:*
>* *
>* $ cat makefile*
>* ASDF := something*
>* $(timeit 100, ${ASDF})*
>* $ make*
>* makefile:2 Time taken: mean: 232, stdev: 81.719765*
>* *
>* make: *** No targets. Stop.*
>* *
>* ... where "timeit" is implemented using the online mean/variance*
>* estimate from Knuth's TAoCP. It evaluates the 2nd argument a number*
>* of times equal to what the 1st argument evaluates to then spits out a*
>* mean / std deviation across those runs.*
>* *
>* I want to contribute this function back to the make project, however*
>* there's a problem if it gets accepted: calculating the standard*
>* deviation requires calling sqrt from math.h / libmath.*
>* *
>* Am I safe to assume that adding a dependence on math.h / libmath*
>* isn't an option?*
IIRC, math.h / sqrt() is defined in the ISO C90 standard and so it
should be portable.
However, I'm not sure that this function is sufficiently generic to be
added as a built-in function. Can you provide use-cases for it?
Cheers!