core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change
on this file since d7baa51 was
0b05c24,
checked in by wojciech, 8 years ago
|
Arrays moved to original files
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[3936ad3] | 1 | /* polevl.c |
---|
| 2 | * p1evl.c |
---|
| 3 | * |
---|
| 4 | * Evaluate polynomial |
---|
| 5 | * |
---|
| 6 | * |
---|
| 7 | * |
---|
| 8 | * SYNOPSIS: |
---|
| 9 | * |
---|
| 10 | * int N; |
---|
| 11 | * double x, y, coef[N+1], polevl[]; |
---|
| 12 | * |
---|
| 13 | * y = polevl( x, coef, N ); |
---|
| 14 | * |
---|
| 15 | * |
---|
| 16 | * |
---|
| 17 | * DESCRIPTION: |
---|
| 18 | * |
---|
| 19 | * Evaluates polynomial of degree N: |
---|
| 20 | * |
---|
| 21 | * 2 N |
---|
| 22 | * y = C + C x + C x +...+ C x |
---|
| 23 | * 0 1 2 N |
---|
| 24 | * |
---|
| 25 | * Coefficients are stored in reverse order: |
---|
| 26 | * |
---|
| 27 | * coef[0] = C , ..., coef[N] = C . |
---|
| 28 | * N 0 |
---|
| 29 | * |
---|
| 30 | * The function p1evl() assumes that coef[N] = 1.0 and is |
---|
| 31 | * omitted from the array. Its calling arguments are |
---|
| 32 | * otherwise the same as polevl(). |
---|
| 33 | * |
---|
| 34 | * |
---|
| 35 | * SPEED: |
---|
| 36 | * |
---|
| 37 | * In the interest of speed, there are no checks for out |
---|
| 38 | * of bounds arithmetic. This routine is used by most of |
---|
| 39 | * the functions in the library. Depending on available |
---|
| 40 | * equipment features, the user may wish to rewrite the |
---|
| 41 | * program in microcode or assembly language. |
---|
| 42 | * |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | /* |
---|
| 47 | Cephes Math Library Release 2.1: December, 1988 |
---|
| 48 | Copyright 1984, 1987, 1988 by Stephen L. Moshier |
---|
| 49 | Direct inquiries to 30 Frost Street, Cambridge, MA 02140 |
---|
| 50 | */ |
---|
[e2af2a9] | 51 | |
---|
[fad5dc1] | 52 | double polevl( double x, constant double *coef, int N ) { |
---|
[3936ad3] | 53 | |
---|
| 54 | int i = 0; |
---|
| 55 | double ans = coef[i]; |
---|
| 56 | |
---|
| 57 | while (i < N) { |
---|
| 58 | i++; |
---|
| 59 | ans = ans * x + coef[i]; |
---|
| 60 | } |
---|
[a5af4e1] | 61 | |
---|
| 62 | return ans ; |
---|
| 63 | } |
---|
| 64 | |
---|
[3936ad3] | 65 | /* p1evl() */ |
---|
| 66 | /* N |
---|
| 67 | * Evaluate polynomial when coefficient of x is 1.0. |
---|
| 68 | * Otherwise same as polevl. |
---|
| 69 | */ |
---|
| 70 | |
---|
[fad5dc1] | 71 | double p1evl( double x, constant double *coef, int N ) { |
---|
[a5af4e1] | 72 | int i=0; |
---|
| 73 | double ans = x+coef[i]; |
---|
| 74 | |
---|
| 75 | while (i < N-1) { |
---|
| 76 | i++; |
---|
| 77 | ans = ans*x + coef[i]; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | return( ans ); |
---|
[fad5dc1] | 81 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.