﻿ compute gains
```/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                             C
C  COMPUTE GAINS (due to effectively setting M(3), M(4) or M(5) to 0 in the   C
C		  sum of sgn(M(x/i))i)					      C
C  12/21/14 (dkc)							      C
C                                                                             C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/
#include <stdio.h>
#include <math.h>
unsigned int maxn=10250;
unsigned int flag=0;  // 0 for s(x), 1 for t(x), 2 for u(x), 3 for v(x)
// t(x) is the effective increase due to setting M(3) to 0
// u(x) is the effective increase due to setting M(4) to 0
// v(x) is the effective increase due to setting M(5) to 0
void main() {
int s[6]={1,0,1,1,1,1};
int t[12]={1,0,0,1,1,0,1,1,1,1,1,1};
int u[20]={1,0,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,1};
int v[30]={1,0,0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1};
int k;
unsigned int i,j,w,size;
FILE *Outfp;
Outfp = fopen("out20.dat","w");
size=(flag+2)*(flag+3);
for (i=0; i<flag; i++) {
printf(" %d\n",0);
fprintf(Outfp," %d\n",0);
}
k=1; // "normalization" variable (for comparisons with sum of n(x/i)-m(x/i), etc.)
j=0; // wrap-around variable (for input arrays)
w=0; // wrap-around variable (for normalization variable)
for (i=(flag+1); i<maxn; i++) {
if (flag==0) {
printf(" %d\n",s[j]);
fprintf(Outfp," %d\n",k-s[j]);       // "normalized value"
s[j]=s[j]+1;
}
else {
if (flag==1) {
printf(" %d\n",t[j]);
fprintf(Outfp," %d\n",k-t[j]);    // "normalized value"
t[j]=t[j]+1;
}
else {
if (flag==2) {
printf(" %d\n",u[j]);
fprintf(Outfp," %d\n",k-u[j]);  // "normalized value"
u[j]=u[j]+1;
}
else {
printf(" %d\n",v[j]);
fprintf(Outfp," %d\n",k-v[j]); // "normalized value"
v[j]=v[j]+1;
}
}
}
j=j+1;
if (j==size)
j=0;
w=w+1;
if (w==(flag+3)) {
k=k+1;
w=0;
}
}
fclose(Outfp);
return;
}
```