| OLD | NEW |
| 1 /* origin: OpenBSD /usr/src/lib/libm/src/polevll.c */ | 1 /* origin: OpenBSD /usr/src/lib/libm/src/polevll.c */ |
| 2 /* | 2 /* |
| 3 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> | 3 * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net> |
| 4 * | 4 * |
| 5 * Permission to use, copy, modify, and distribute this software for any | 5 * Permission to use, copy, modify, and distribute this software for any |
| 6 * purpose with or without fee is hereby granted, provided that the above | 6 * purpose with or without fee is hereby granted, provided that the above |
| 7 * copyright notice and this permission notice appear in all copies. | 7 * copyright notice and this permission notice appear in all copies. |
| 8 * | 8 * |
| 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 */ | 55 */ |
| 56 | 56 |
| 57 #include "libm.h" | 57 #include "libm.h" |
| 58 | 58 |
| 59 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 | 59 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 |
| 60 #else | 60 #else |
| 61 /* | 61 /* |
| 62 * Polynomial evaluator: | 62 * Polynomial evaluator: |
| 63 * P[0] x^n + P[1] x^(n-1) + ... + P[n] | 63 * P[0] x^n + P[1] x^(n-1) + ... + P[n] |
| 64 */ | 64 */ |
| 65 long double __polevll(long double x, const long double *P, int n) | 65 long double __polevll(long double x, const long double* P, int n) { |
| 66 { | 66 long double y; |
| 67 » long double y; | |
| 68 | 67 |
| 69 » y = *P++; | 68 y = *P++; |
| 70 » do { | 69 do { |
| 71 » » y = y * x + *P++; | 70 y = y * x + *P++; |
| 72 » } while (--n); | 71 } while (--n); |
| 73 | 72 |
| 74 » return y; | 73 return y; |
| 75 } | 74 } |
| 76 | 75 |
| 77 /* | 76 /* |
| 78 * Polynomial evaluator: | 77 * Polynomial evaluator: |
| 79 * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] | 78 * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] |
| 80 */ | 79 */ |
| 81 long double __p1evll(long double x, const long double *P, int n) | 80 long double __p1evll(long double x, const long double* P, int n) { |
| 82 { | 81 long double y; |
| 83 » long double y; | |
| 84 | 82 |
| 85 » n -= 1; | 83 n -= 1; |
| 86 » y = x + *P++; | 84 y = x + *P++; |
| 87 » do { | 85 do { |
| 88 » » y = y * x + *P++; | 86 y = y * x + *P++; |
| 89 » } while (--n); | 87 } while (--n); |
| 90 | 88 |
| 91 » return y; | 89 return y; |
| 92 } | 90 } |
| 93 #endif | 91 #endif |
| OLD | NEW |