

// TypeScript Version: 2.0

/**
* Evaluates a polynomial.
*
* @param x - value at which to evaluate a polynomial
* @returns evaluated polynomial
*/
type EvaluationFunction = ( x: number ) => number;

/**
* Interface for evaluating polynomials.
*/
interface EvalPoly {
	/**
	* Evaluates a polynomial.
	*
	* ## Notes
	*
	* -   The implementation uses [Horner's rule][horners-method] for efficient computation.
	*
	* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
	*
	*
	* @param c - polynomial coefficients sorted in ascending degree
	* @param x - value at which to evaluate the polynomial
	* @returns evaluated polynomial
	*
	* @example
	* var v = evalpoly( [3.0,2.0,1.0], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
	* // returns 123.0
	*/
	( c: Array<number>, x: number ): number;

	/**
	* Generates a function for evaluating a polynomial.
	*
	* ## Notes
	*
	* -   The compiled function uses [Horner's rule][horners-method] for efficient computation.
	*
	* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
	*
	*
	* @param c - polynomial coefficients sorted in ascending degree
	* @returns function for evaluating a polynomial
	*
	* @example
	* var polyval = evalpoly.factory( [3.0,2.0,1.0] );
	*
	* var v = polyval( 10.0 ); // => 3*10^0 + 2*10^1 + 1*10^2
	* // returns 123.0
	*
	* v = polyval( 5.0 ); // => 3*5^0 + 2*5^1 + 1*5^2
	* // returns 38.0
	*/
	factory( c: Array<number> ): EvaluationFunction;
}

/**
* Evaluates a polynomial.
*
* ## Notes
*
* -   The implementation uses [Horner's rule][horners-method] for efficient computation.
*
* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
*
*
* @param c - polynomial coefficients sorted in ascending degree
* @param x - value at which to evaluate the polynomial
* @returns evaluated polynomial
*
* @example
* var v = evalpoly( [3.0,2.0,1.0], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
* // returns 123.0
*
* @example
* var polyval = evalpoly.factory( [3.0,2.0,1.0] );
*
* var v = polyval( 10.0 ); // => 3*10^0 + 2*10^1 + 1*10^2
* // returns 123.0
*
* v = polyval( 5.0 ); // => 3*5^0 + 2*5^1 + 1*5^2
* // returns 38.0
*/
declare var evalpoly: EvalPoly;


// EXPORTS //

export = evalpoly;
