/
MAPMADD.c,v
63 lines (50 loc) · 1.12 KB
/
MAPMADD.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.11.09.37.42; author Mark; state new;
branches;
next ;
desc
@Modular array polynomial multiply and add.
@
1.1
log
@Initial revision
@
text
@/*===========================================================================
MAPMADD(m,A,b,j,C)
Modular array polynomial multiply and add.
Input
m : a BETA-digit.
A : in Z/(m)[x] in array representation.
b : in Z/(m).
j : an exponent such that j + deg(A) <= deg(C).
C : in Z/(m)[x] in array representation.
Side effect
C is modified such that C <- C + A(x) * b * x^j.
===========================================================================*/
#include "saclib.h"
void MAPMADD(m,A,b,j,C)
Word m,*A,b,j,*C;
{
Word n,i,a,c,k;
Step1: /* A = 0 or b = 0. */
if (MAPZERO(A) || b == 0)
goto Return;
Step2: /* Otherwise. */
n = MAPDEG(A);
for (i = 0; i <= n; i++) {
a = MAPCF(A,i);
k = i + j;
if (a != 0) {
c = MDSUM(m,MDPROD(m,a,b),MAPCF(C,k));
MAPCF(C,k) = c; } }
Return: /* Prepare for return. */
return;
}
@