/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss of reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#include <math.h>

/****************************************************************************/
/*					Public API functions									*/
/****************************************************************************/

/** @addtogroup func */
/** @{ */

/**
*	Evaluate a polynom.
*
*	This function evaluates a polynom, that is, it calculates the sum of<br>
*	<tt>SUM( C<sub>i</sub> * x<sup>i</sup> )</tt> <br>where \p i goes from
*	0 to \p n (inclusive), \p x is a variable, <tt>c<sub>i</sub></tt> is
*	the i-th coefficient and \p n is the order of the polynom. <br>
*	The function uses the Horner scheme, performing n multiplications and
*	n additions.
*
*	@param	x	The place where the polynom should be evaluated.
*	@param	c	Pointer to an array containing the coefficients.
*				The array must have <tt>n+1</tt> elements and the array
*				index corresponds to the index of the coefficient.
*	@param	n	The order of the polynom. 0 is a valid value.
*
*	@return		The value of the polynom determined by \p c and \p n,
*				at the point of \p x.
*/

float	polynomf( float x, const float *c, unsigned n )
{
float	r;

	for ( c += n++, r = *c-- ; --n ; r = r * x + *c-- );
	return( r );
}

/** @} */


