print.c
1.45 KB
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
64
#include "tabledesign.h"
int
print_entry(FILE *op, double *entry, int order)
{
int i, j, k, r;
double **cmat, e;
int overflow = 0;
cmat = (double **) malloc(VECTORSIZE*sizeof(double *));
for (i=0; i<VECTORSIZE; i++)
cmat[i] = (double *) malloc(order*sizeof(double));
/*
* Initialize matrix
*/
for (i=0; i<order; i++){
for (j=0; j<i; j++)
cmat[i][j] = 0.0;
for (j=i; j<order; j++)
cmat[i][j] = -entry[order-(j-i)];
}
for (i=order; i<VECTORSIZE; i++)
for (j=0; j<order; j++)
cmat[i][j] = 0.0;
/*
* Now recursively compute the VECTORSIZE rows
*/
for (i=1; i<VECTORSIZE; i++)
for (j=1; j<=order; j++)
if (i-j >= 0)
for (k=0; k<order; k++)
cmat[i][k] -= entry[j]*cmat[i-j][k];
/*
* Now print them out in columns
*/
for (i=0; i<order; i++){
for (j=0; j<VECTORSIZE; j++){
e = VSCALE*cmat[j][i];
if (e<0){
r = (int) (e-0.5);
if (r<MINCOEF)
overflow++;
}
else {
r = (int) (e+0.5);
if (r>MAXCOEF)
overflow++;
}
fprintf(op, "%5d ", r);
}
fprintf(op,"\n");
}
for (i=0; i<VECTORSIZE; i++)
free(cmat[i]);
free(cmat);
return overflow;
}