N1 = 80;
beita = 0.3;
// s3[N1][N1]
for(i = 0; i < N1; i++)
for(j = i; j < N1; j++)
s3[i][j] = s3[j][i] = exp(-beita * (i * i + j * j));
NN = 40;
nb3 = 0;
nb4 = NN - 1;
for(i = 0; i < N1; i++)
{
if(i > NN)
nb3++;
if(nb4 < N1)
nb4++;
nb1 = 0;
nb2 = NN - 1;
for(j = 0; j < N1; j++)
{
if(j > NN)
nb1++;
if(nb2 < N1)
nb2++;
aa = 0;
for(i1 = nb3; i1 < nb4; i1++)
{
for (j1 = nb1; j1 < nb2; j1++)
{
j2 = i > i1 ? i - i1 : i1 - i;
j3 = j > j1 ? j - j1 : j1 - j;
bb = s3[j2][j3] * s1[i1][j1];
if(aa < bb)
aa = bb;
}
}
s2[i][j] = aa;
}
}
beita = 0.3;
// s3[N1][N1]
for(i = 0; i < N1; i++)
for(j = i; j < N1; j++)
s3[i][j] = s3[j][i] = exp(-beita * (i * i + j * j));
NN = 40;
nb3 = 0;
nb4 = NN - 1;
for(i = 0; i < N1; i++)
{
if(i > NN)
nb3++;
if(nb4 < N1)
nb4++;
nb1 = 0;
nb2 = NN - 1;
for(j = 0; j < N1; j++)
{
if(j > NN)
nb1++;
if(nb2 < N1)
nb2++;
aa = 0;
for(i1 = nb3; i1 < nb4; i1++)
{
for (j1 = nb1; j1 < nb2; j1++)
{
j2 = i > i1 ? i - i1 : i1 - i;
j3 = j > j1 ? j - j1 : j1 - j;
bb = s3[j2][j3] * s1[i1][j1];
if(aa < bb)
aa = bb;
}
}
s2[i][j] = aa;
}
}