-
Notifications
You must be signed in to change notification settings - Fork 5
/
poly.pro
52 lines (49 loc) · 958 Bytes
/
poly.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; $Id: poly.pro,v 1.8 2002/02/06 21:45:51 scottm Exp $
;
; Copyright (c) 1983-2002, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
FUNCTION POLY,X,C
;+
; NAME:
; POLY
;
; PURPOSE:
; Evaluate a polynomial function of a variable.
;
; CATEGORY:
; C1 - Operations on polynomials.
;
; CALLING SEQUENCE:
; Result = POLY(X,C)
;
; INPUTS:
; X: The variable. This value can be a scalar, vector or array.
;
; C: The vector of polynomial coefficients. The degree of
; of the polynomial is N_ELEMENTS(C) - 1.
;
; OUTPUTS:
; POLY returns a result equal to:
; C[0] + c[1] * X + c[2]*x^2 + ...
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None.
;
; RESTRICTIONS:
; None.
;
; PROCEDURE:
; Straightforward.
;
; MODIFICATION HISTORY:
; DMS, Written, January, 1983.
;-
on_error,2 ;Return to caller if an error occurs
N = N_ELEMENTS(C)-1 ;Find degree of polynomial
Y = c[n]
for i=n-1,0,-1 do y = y * x + c[i]
return,y
end