資源簡介
該程序能實現(31,21,5)BCH編譯碼,并能自動糾錯

代碼片段和文件信息
/*?
?*?File:????bch3121.c??
?*?Author:??Robert?Morelos-Zaragoza?
?*?
?*?%%%%%%%%%%%?Encoder/Decoder?for?a?(31215)?binary?BCH?code?%%%%%%%%%%%%%?
?*?
?*??This?code?is?used?in?the?POCSAG?protocol?specification?for?pagers.?
?*?
?*??In?this?specific?case?there?is?no?need?to?use?the?Berlekamp-Massey?
?*??algorithm?BM算法?since?the?error?locator?polynomial?定位誤差多項式?is?of?at?most?degree?2.?
?*??Instead?we?simply?solve?by?hand?two?simultaneous?equations?聯立方程?to?give?
?*??the?coefficients?of?the?error?locator?polynomial?in?the?case?of?two??
?*??errors.?In?the?case?of?one?error?the?location?is?given?by?the?first?
?*??syndrome.?
?*?m?=?order?of?the?field?GF(2**5)?=?5?
?*?n?=?2**5?-?1?=?31?=?length??
?*?t?=?2?=?error?correcting?capability??
?*?d?=?2*t?+?1?=?5?=?designed?minimum?distance??
?*?k?=?n?-?deg(g(x))?=?21?=?dimension??多項式的次數
?*?p[]?=?coefficients?of?primitive?polynomial本原多項式?used?to?generate?GF(2**5)?
?*?g[]?=?coefficients?of?generator?polynomial生成多項式?g(x)?
?*?alpha_to?[]?=?log?table?對數表of?GF(2**5)??
?*?index_of[]?=?antilog?table?反對數表?of?GF(2**5)?
?*?data[]?=?coefficients?系數?of?data?polynomial?i(x)?
?*?bb[]?=?coefficients?of?redundancy?polynomial?冗余多項式?(?x**(10)?i(x)?)?modulo?模g(x)?
?*?numerr?=?number?of?errors??
?*?errpos[]?=?error?positions??
?*?recd[]?=?coefficients?of?received?polynomial??
?*?decerror?=?number?of?decoding?errors?(in?MESSAGE?positions)??
?*?
?*/??
??
#include???
#include???
#include?
int?????????????m?=?5?n?=?31?k?=?21?t?=?2?d?=?5;??
int?????????????length?=?31;??
int?????????????p[6];???????/*?irreducible?polynomial不可約多項式?*/??
int?????????????alpha_to[32]?index_of[32]?g[11];??
int?????????????recd[31]?data[21]?bb[11];??
int?????????????numerr?errpos[32]?decerror?=?0;??
int?????????????seed;??
??
??
void???read_p()??
/*?Primitive?polynomial?of?degree?5?*/??
{??
????/*register?int????i;??*/
????p[0]?=?p[2]?=?p[5]?=?1;?p[1]?=?p[3]?=?p[4]?=0;??
}??
??
??
void??generate_gf()??
/*?
?*?generate?GF(2**m)?from?the?irreducible?polynomial?p(X)?in?p[0]..p[m]?
?*?lookup?tables查找表:??index->polynomial?form???alpha_to[]?contains?j=alpha**i;?
?*?polynomial?form?->?index?form??index_of[j=alpha**i]?=?i?alpha=2?is?the?
?*?primitive?element?of?GF(2**m)??
?*/??
{??
????register?int????i?mask;??
????mask?=?1;??
????alpha_to[m]?=?0;??
????for?(i?=?0;?i?????????alpha_to[i]?=?mask;??
????????index_of[alpha_to[i]]?=?i;??
????????if?(p[i]?!=?0)??
????????????alpha_to[m]?^=?mask;??
????????mask?<<=?1;??
????}??
????index_of[alpha_to[m]]?=?m;??
????mask?>>=?1;??
????for?(i?=?m?+?1;?i?????????if?(alpha_to[i?-?1]?>=?mask)??
??????????alpha_to[i]?=?alpha_to[m]?^?((alpha_to[i?-?1]?^?mask)?<1);??
????????else??
??????????alpha_to[i]?=?alpha_to[i?-?1]?<1;??
????????index_of[alpha_to[i]]?=?i;??
????}??
????index_of[0]?=?-1;??
}??
??
??
void???gen_poly()??
/*???Compute?generator?polynomial?of?BCH?code?of?lengt
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-05-30?22:11??BCH2\
?????文件????????4260??2015-05-18?17:13??BCH2\BCH2.dsp
?????文件?????????516??2015-05-18?17:12??BCH2\BCH2.dsw
?????文件???????33792??2015-05-18?17:13??BCH2\BCH2.ncb
?????文件???????48640??2015-05-18?17:13??BCH2\BCH2.opt
?????文件?????2183168??2015-05-30?21:45??BCH2\BCH2.sdf
?????文件?????????874??2015-05-30?20:42??BCH2\BCH2.sln
?????文件???????10752??2015-05-30?21:45??BCH2\BCH2.suo
?????文件????????6135??2015-05-30?20:42??BCH2\BCH2.vcxproj
?????文件?????????900??2015-05-30?20:41??BCH2\BCH2.vcxproj.filters
?????文件?????????143??2015-05-27?13:13??BCH2\BCH2.vcxproj.user
?????目錄???????????0??2015-05-30?22:11??BCH2\Debug\
?????文件??????459264??2015-05-30?21:05??BCH2\Debug\BCH2.exe
?????文件???????????2??2015-05-27?13:19??BCH2\Debug\BCH2.exe.em
?????文件??????????68??2015-05-27?13:19??BCH2\Debug\BCH2.exe.em
?????文件?????????381??2015-05-30?21:05??BCH2\Debug\BCH2.exe.intermediate.manifest
?????文件?????????406??2015-05-27?13:20??BCH2\Debug\BCH2.exe.manifest
?????文件?????1023472??2015-05-30?21:05??BCH2\Debug\BCH2.ilk
?????文件??????????46??2015-05-30?21:05??BCH2\Debug\BCH2.lastbuildstate
?????文件????????1488??2015-05-30?21:05??BCH2\Debug\BCH2.log
?????文件?????2124800??2015-05-30?21:05??BCH2\Debug\BCH2.pdb
?????文件?????????707??2015-05-27?13:14??BCH2\Debug\BCH2.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2015-05-27?13:14??BCH2\Debug\BCH2.write.1.tlog
?????文件?????????204??2015-05-27?13:19??BCH2\Debug\BCH2_manifest.rc
?????文件????????1820??2015-05-30?21:05??BCH2\Debug\CL.read.1.tlog
?????文件?????????204??2015-05-30?21:05??BCH2\Debug\CL.write.1.tlog
?????文件???????21269??2015-05-30?21:05??BCH2\Debug\bch2.obj
?????文件?????????600??2015-05-30?21:05??BCH2\Debug\cl.command.1.tlog
?????文件???????????2??2015-05-30?21:05??BCH2\Debug\li
?????文件???????????2??2015-05-30?21:05??BCH2\Debug\li
?????文件????????1078??2015-05-30?21:05??BCH2\Debug\li
............此處省略20個文件信息
- 上一篇:鼠標拖動的實現
- 下一篇:圖像標準測試灰度圖片
評論
共有 條評論