2 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * long double x, y, coef[N+1], polevl[];
29 * y = polevll( x, coef, N );
35 * Evaluates polynomial of degree N:
38 * y = C + C x + C x +...+ C x
41 * Coefficients are stored in reverse order:
43 * coef[0] = C , ..., coef[N] = C .
46 * The function p1evll() assumes that coef[N] = 1.0 and is
47 * omitted from the array. Its calling arguments are
48 * otherwise the same as polevll().
53 * In the interest of speed, there are no checks for out
54 * of bounds arithmetic. This routine is used by most of
55 * the functions in the library. Depending on available
56 * equipment features, the user may wish to rewrite the
57 * program in microcode or assembly language.
61 #include <sys/cdefs.h>
62 __FBSDID("$FreeBSD$");
66 #include "math_private.h"
69 * Polynomial evaluator:
70 * P[0] x^n + P[1] x^(n-1) + ... + P[n]
73 __polevll(long double x, void *PP, int n)
78 P = (long double *)PP;
88 * Polynomial evaluator:
89 * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n]
92 __p1evll(long double x, void *PP, int n)
97 P = (long double *)PP;