/*-----------------------------------------------------------------------------+
| File : errorcode.cpp |
| purpose: |
| The program used to find the optimum code for error correction code. User |
| require to input the codeword size and the minimum Hamming distance. |
| According this input data, program will derive the optimum code. The |
| optimum code can dervied, becuase it use the matching table. The program |
| is not use the exhaustive search teachnique. This program use the table |
| matching method. That previously, the table store the info that useful |
| for optimum code generation very quickly. |
| |
| Output : Optimum code with maximum code size |
| |
| Dillian 24/7/04 |
|_____________________________________________________________________________*/
#include
#include "Math.h"
int minDistance; //minimum hamming distance
int codewordSize; //codeword size
int candidate[65536]; //codeword in 10-base digit form
int memberCount[65536]; //candidate[?] as the first round member
//how many member of that code
bool isPass[65536]; //indidate this candidate is pass or not
bool bits_cand[65536][16]; //candidate in 8-bits form
int infoTable[16][16]; //infoTable[codeword size][min Distance]
//contain the info that can generate the optimum code quickly
void init_infoTable(void)
{
int i,j;
//clear all info
for(i=0;i<16;i++)
for(j=0;j<16;j++)
infoTable[i][j]=0;
//add extra info
infoTable[8][3]=31;
infoTable[9][4]=63;
infoTable[9][5]=256;
infoTable[10][5]=256;
infoTable[10][6]=512;
infoTable[11][5]=1079;
infoTable[11][6]=512;
infoTable[12][5]=415;
infoTable[12][6]=512;
infoTable[13][5]=372;
infoTable[13][6]=831;
infoTable[14][5]=2086;
infoTable[14][6]=744;
}
//participate candidate have a new chance
void reset(void)
{
int i;
for(i=0;i=0;i--)
{
l=a%2; //modules
a=a/2;
if(l)
bits_cand[j][i]=true;
else
bits_cand[j][i]=false;
}
}
//init info Table for quick generate the optimum code
init_infoTable();
}
//print the date to screen
void print2Screen(void)
{
int i,j;
for(j=0;j>codewordSize;
if(codewordSize>16 || codewordSize<3)
{
cout<<"Error input!. Press any key to close the program";
return 0;
}
cout << "Minimum Hamming distance ? : ";
cin >> minDistance;
if(minDistance <=0 || minDistance>codewordSize)
{
cout<<"Error input!. Press any key to close the program";
cin>>input;
return 0;
}
// m=0;
// while(m<1000)
// {
init();
maxMemberCount=0;
//start calculation
// m=infoTable[codewordSize][minDistance];
cout<<"\n m : ? ";
cin>>m;
playGameWithAssignedWinnerNo1 (m);
//count the number of member of one code
for(i=0;i>input;
// }
return 0;
}
               (
geocities.com/hk)