time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

evalpoly.js.txt (504B)


      1 'use strict';
      2 
      3 // MAIN //
      4 
      5 /**
      6 * Evaluates a polynomial.
      7 *
      8 * ## Notes
      9 *
     10 * -   The implementation uses [Horner's rule][horners-method] for efficient computation.
     11 *
     12 * [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
     13 *
     14 *
     15 * @private
     16 * @param {number} x - value at which to evaluate the polynomial
     17 * @returns {number} evaluated polynomial
     18 */
     19 function evalpoly( x ) {
     20 	if ( x === 0.0 ) {
     21 		return {{coefficient}};
     22 	}
     23 	return {{horner}};{{eslint}}
     24 }
     25 
     26 
     27 // EXPORTS //
     28 
     29 module.exports = evalpoly;