ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since 8eee1d7 was
79492222,
checked in by krzywon, 10 years ago
|
Changed the file and folder names to remove all SANS references.
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[230f479] | 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 | */ |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | double polevl( x, coef, N ) |
---|
| 54 | double x; |
---|
| 55 | double coef[]; |
---|
| 56 | int N; |
---|
| 57 | { |
---|
| 58 | double ans; |
---|
| 59 | int i; |
---|
| 60 | double *p; |
---|
| 61 | |
---|
| 62 | p = coef; |
---|
| 63 | ans = *p++; |
---|
| 64 | i = N; |
---|
| 65 | |
---|
| 66 | do |
---|
| 67 | ans = ans * x + *p++; |
---|
| 68 | while( --i ); |
---|
| 69 | |
---|
| 70 | return( ans ); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /* p1evl() */ |
---|
| 74 | /* N |
---|
| 75 | * Evaluate polynomial when coefficient of x is 1.0. |
---|
| 76 | * Otherwise same as polevl. |
---|
| 77 | */ |
---|
| 78 | |
---|
| 79 | double p1evl( x, coef, N ) |
---|
| 80 | double x; |
---|
| 81 | double coef[]; |
---|
| 82 | int N; |
---|
| 83 | { |
---|
| 84 | double ans; |
---|
| 85 | double *p; |
---|
| 86 | int i; |
---|
| 87 | |
---|
| 88 | p = coef; |
---|
| 89 | ans = x + *p++; |
---|
| 90 | i = N-1; |
---|
| 91 | |
---|
| 92 | do |
---|
| 93 | ans = ans * x + *p++; |
---|
| 94 | while( --i ); |
---|
| 95 | |
---|
| 96 | return( ans ); |
---|
| 97 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.