-
Notifications
You must be signed in to change notification settings - Fork 1
/
IUPEVAL.c,v
63 lines (50 loc) · 1.01 KB
/
IUPEVAL.c,v
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
52
53
54
55
56
57
58
59
60
61
62
63
head 1.1;
access;
symbols;
locks
saclib:1.1; strict;
comment @ * @;
1.1
date 95.08.07.20.53.34; author George; state new;
branches;
next ;
desc
@Integral univariate polynomial evaluation.
@
1.1
log
@Initial revision
@
text
@/*======================================================================
b <- IUPEVAL(A,a)
Integral univariate polynomial evaluation.
Inputs
A : a univariate integral polynomial.
a : an integer
Outputs
b : the integer A(a).
======================================================================*/
#include "saclib.h"
Word IUPEVAL(A,a)
Word A,a;
{
Word a2,Ap,b,e1,e2,i;
Step1: /* A = 0. */
if (A == 0) {
b = 0;
goto Return; }
Step2: /* Apply Horner's method. */
ADV2(A,&e1,&b,&Ap);
while (Ap != NIL) {
ADV2(Ap,&e2,&a2,&Ap);
for (i = 1; i <= e1 - e2; i++)
b = IPROD(a,b);
b = ISUM(b,a2);
e1 = e2; }
for (i = 1; i <= e1; i++)
b = IPROD(a,b);
Return: /* Return b. */
return(b);
}
@