Hsiao-Code Check Matrices and Recursively Balanced Matrices
The key step of generating the well-known Hsiao code is to construct a {0,1}-check-matrix in which each column contains the same odd-number of 1's and each row contains the same number of 1's or differs at most by one for the number of 1's. We also r…
Authors: Li Chen
Hsiao-Co de Chec k Matri ces and Recursiv ely Bala nced Matrices Li Chen Departmen t o f Computer Scienc e and Information T ec hnology Univ ersit y of the District of Colum bia W ashington, DC 20008 lc hen@udc.edu F ebruary 13, 2013 Abstract The key step of ge nerating the well-known Hsiao c o de is to construct a { 0 , 1 } -chec k-matrix in which each column contains the same o dd-num ber of 1’s a nd each row con tains the same num b er of 1’s or differs at mos t by one for the num ber of 1’s. W e also r equire that no tw o columns are iden tical in th e matrix. The author solv ed th is problem in 1986 b y introducing a type of recursively bala nced matrices. How ever, since th e pap er was published in Chinese, the solution for such an importa nt problem w as not known by international res earchers in co ding theory . In this note, we fo cus on ho w to pra ctically generate the chec k matrix of Hsiao co des. W e ha ve mo dified the origina l algorithm to b e more efficient and effective. W e hav e also cor rected an error in alg orithm analysis prese nted in the ear lier pap er. The result s hows that the algorithm attained optim um in a v erage cases if a divide-and-conquer technique m ust be inv olved in the algorithm. 1 In tro duction Error-detections and corrections are required for compu ter main memory and secondary storages. I n recen t y ears, trusted computing and compu ting r eliabilit y hav e b ecome more and more imp ortant in theory and practice. Data reco v ery is at the cent er of concerns. Error-corrections co des, esp ecially Hamming co des and Hsiao co des are still essentia l to this t yp e of tec hnology [10 ][9] . The we ll-kno wn Hsiao co d e is the most energy saving Hamming Co des [7][9][4][5][6]. It has b een widely used in memory fault tolerance for more than thirt y decades. As a t yp e of SEC- DED co d es, i.e. single error correct ion and d ouble-error detection co des, Hsiao co des attained the optimal in min im um o dd -w eigh t of columns. Ev en though there w as an observ ation indicating that cellular automata-based co d es migh t b e b etter than Hsiao codes in terms of c h ec k bits for cellular automata –a future computing device [4][2] . Ho wev er, Hsiao co d e is still the most efficien t cod e used in in d ustry [9][6]. 1 After a co d e is d esigned, the most imp ortan t task is to find its c hec k m atrix. The author in tro d uced an algorithm that recursiv ely constru cted the c hec k-matrix to Hsiao cod es in 1986 [1]. Unfortunately , the pu blished p ap er was written in Chin ese and the t itle of the pap er d id not men tion the SEC -DED co d e. This algorithm was not kno wn b y in ternational researc hers in co ding theory . In this pap er, we first explain the algorithm describ ed in [1] where it wa s add ressed in an abstract and in a brief m anner. Th en, we mo dified some steps to s h o w a more detailed algorithm. Finally , we corrected an error in the algorithm analysis of [1] and p ro vided a more p recise time analysis for general cases. Th eoretically , b oth original algo rithm and the mo dified algorithm are v ery efficien t and fast in terms of complexit y theory . W e h a ve prov ed that th e mo dified algorithm is optimal in a ve rage cases. Ho w ev er, in p ractice, we ma y find an ev en more efficien t algorithm. 2 Ma jor Steps of Generating Chec k M atrix H for Hsiao Co de The defin ition of Hsiao cod e is a type of SEC-DED co des wh ose c hec k matrix H defin ed on GF (2) satisfies: (1) Ev ery column con tains an o dd num b er of 1’s. (2) The total n u m b er of 1’s r eac hes the min im um. (3) The difference of the num b er of 1’s in any t w o ro ws is n ot great er than 1. (4) No tw o co lumns are the same. Therefore, Hsiao called this cod e an optimal minim u m o dd -w eigh t-column SEC-DED co de. No w , we will discuss h o w to generate H . Assume that we wa n t to generate the S EC-DED Co d e with k information (data ) bits, first according to the general r equirement of Hsiao co des [7], R ≥ 1 + log 2 ( k + R ) (1) F rom this, we can determine R . After R is determined, w e define ∆( R , J, m ) a { 0 , 1 } -t yp e R × m matrix with column w eight J , 0 ≤ J ≤ R . No t w o columns are the same in ∆( R , J, m ). ∆( R, 2 · i + 1 , C 2 · i +1 R ) , i = 0 , 1 , ..., I − 1 . (2) Where, C 2 · i +1 R = R 2 · i + 1 ! is the combinat orial num b er. Assum e, 2 Σ I − 1 i =0 C 2 · i +1 R ≤ ( k + R ) ≤ Σ I i =0 C 2 · i +1 R . (3) Let m = ( k + R ) − Σ I − 1 i =0 C 2 · i +1 R . W e can see that the most imp ortan t task is to generate ∆( R, 2 · I + 1 , m ) b ecause the other cases are the sp ecial cases of it. Th us, H = [ ⊕ I − 1 i =0 ∆( R, 2 · i + 1 , C 2 · i +1 R )] ⊕ ∆( R , 2 · I + 1 , m ) , (4) where ⊕ is to union these arrays toget her, horizon tally . 3 The A lgorithm of G enerating ∆( R , J, m ) According to Section 2, it is not difficult to see that obtaining the matrix ∆( R, J, m ) is the key to the c hec k matrix H , esp ecially when m 6 = C 2 · i +1 R . Let’s first d efine some notations: (a) ∆( R, J, m ) : a { 0 , 1 } -t yp e R × m matrix w ith column weigh t J , 0 ≤ J ≤ R . (b) < t > ( m ) : a { 0 , 1 } -t yp e 1 × m matrix in whic h ev ery comp onen t is t . F or example, < 1 > (2) = (1 , 1). (c) ◦ : the matrix u p-do wn union op erator, i.e. N ◦ M = " a b # (d) ⊕ : the matrix left-righ t u nion op erator, i.e. N ⊕ M = [ N M ] (e) ⊕ : N ⊕ M is to place the matrix M ups id e down, do “ ⊕ ,” and then mo v e th e rows that con tain more 1’s to the top of the matrix. (f ) L − condition : ∆( R , J, m ) is said to satisfy the condition if 0 ≤ J ≤ R & 0 ≤ m ≤ C J R . (g) Matrices with equal-w eigh t-columns/ro ws: Matrices h a ve equal-w eigh t columns and quasi-equal-w eigh t ro w s. In other w ords, in these matrices, eac h column has the same num b er of 1’s and eac h ro w has almost the same num b er of 1’s. (Th e difference of the num b ers of 1’s is less than 1.) W e will also call su ch a m atrix a (w eigh ted) Balanced matrix. W e also defin e the follo wing sp ecial ∆( R , J, m ) that will ke ep the rows with more 1’s at the top of the array: 3 (1) If m = 0, ∆( R , J, m ) = ∅ . (2) If J = 0, ∆( R , J, m ) = (0 , ..., 0) T . (3) If J = R , ∆( R , J, m ) = (1 , ..., 1) T . (4) If m = 1, ∆( R , J, m ) = (1 , ..., 1 , 0 , ..., 0) T , where the n u m b er of 1’s is J . (5) If J = 1, ∆( R , J, m ) = 1 0 ... 0 ... ... ... 0 ... 0 1 0 ... 0 ... ... ... 0 ... 0 , there are m 1’s in the matrix. (6) If J = R − 1, ∆( R, J, m ) = 1 1 ... 1 ... ... ... 1 ... 1 1 0 1 ... 1 1 0 ... 1 ... ... ... 1 1 ... 0 , there are m 1’s in the matrix. The ab ov e m atrices are called the en d ing-states. So w e can assume that 2 ≤ J ≤ R − 2 for later discussion. Let ∆( R, J, m ) satisfy the L -condition. W e can represen t ∆ ( R , J, m ) in the follo wing form. ∆( R, J, m ) = " 1 ......... ...... 1 0 ......... ...... 0 ∆ 1 ( R − 1 , J − 1 , m 1 ) ∆ 2 ( R − 1 , J, m − m 1 ) # (5) Theorem 1 [1] Assume ∆( R, J, m ) satisfy th e L -c ondition. Let m 1 = [ m · J R + R − 1 R ], then ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆ 2 ( R − 1 , J, m − m 1 ) also satisfy L -conditio n. Theorem 2 [1] S upp ose that ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆ 2 ( R − 1 , J, m − m 1 ) are Matrices with equal-w eight -columns/ro w s, where m 1 = [ m · J R + R − 1 R ]. Th en, ∆ ′ ( R, J, m ) = [ < 1 > ( m 1 ) ⊕ < 0 > ( m − m 1 )] ◦ [∆ 1 ( R − 1 , J − 1 , m 1 ) ⊕ ∆ 2 ( R − 1 , J, m − m 1 )] (6) is a matrix with equal-wei gh t-co lumns/ro ws. The ab o v e t w o theorems indicate a recursiv e p ro cess of generating a matrix with equal-w eigh t columns and quasi-equal-w eigh t ro ws: The Theorem 2 p r o vides the u nion p ro cess that guaran tees that eac h ro w after the un ion h as ab out the same weigh t. ⊕ , to p lace the matrix on the right side of the op erator up side do wn, is to av oid one r ow con taining more than one 1’s after the merge. It is the simplest mathematical w ay of solving the problem. The r ecursiv e matrice in (5) is also call ed a recursivel y balanced matrix. 4 Ho wev er, b y “placing a matrix ups ide do wn” and then mo vin g ro ws with more 1’s to th e top of the matrix after merging tak es more computational time. In [1], the author made a mistak e by simply stating that this pro cess is optim um O ( R · m ). This is b ecause some of the parts in the arra y ma y need to b e “placed upside do w n ” man y times (sa y min { R, m } ). So , in the worst case, the complexit y of the pro cedure giv en in Th eorem 2 is O ( R · m · min { R, m } ). This is still a v ery fast algorithm for generating su c h a m atrix. Other generating algorithms for these c hec k matrice s w ere discussed in [11][5][6]. Ho w ev er, these algorithms are not in p olynomial time. It is ob vious that if m · J is divisible b y R , the pro cedure of ”placing a matrix up side do wn” can b e ignored. S o, Corollary 1 Let m · J b e divisible by R . Supp ose that ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆ 2 ( R − 1 , J, m − m 1 ) are matrices with equal-w eigh t-columns and equal-w eigh t-rows, where m 1 = [ m · J R + R − 1 R ]. Th en, ∆ ′ ( R, J, m ) = [ < 1 > ( m 1 ) ⊕ < 0 > ( m − m 1 )] ◦ [∆ 1 ( R − 1 , J − 1 , m 1 ) ⊕ ∆ 2 ( R − 1 , J, m − m 1 )] . (7) is a matrix with equal-wei gh t-co lumns and equal-w eigh t-ro ws. Corollary 2 There is O ( m · R ) algorithm for generating ∆( R , J, m = C J R ) Based on the ab o ve discussion, we can obtain t w o algorithms b elo w : Algorithm A: the none-recursiv e algorithm Step 1 Chec k if ∆( R, J, m ) satisfies the L -condition. Step 2 Decompose ∆( R, J, m ) into ∆( R 1 , J 1 , m 1 ), ∆( R 2 , J 2 , m 2 ), ..., ∆( R n , J n , m n ), where eac h ∆( R i , J i , m i ),(i=1,2, ...,n) is a endin g-state. Step 3 Merge ∆( R i , J i , m i ),( i = 1 , 2 , ..., n ) using ⊕ op erator. Note: ”decomp osition” and ”merge” use the same ob jects. Algorithm A’: the recursiv e algorithm Step 1 Chec k if ∆( R, J, m ) satisfies L -condition. Step 2 Decompose ∆( R, J, m ) into ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆( R − 1 , J, m − m 1 ). Step 3 Merge ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆( R − 1 , J, m − m 1 ) based on (6) . 4 A Better Algorithm for Genera ting ∆( R, J, m ) Ev en though T heorem 2 did not giv e an O ( R · m ) algorithm, it pro vides a great hint to design a (virtually) optim u m algorithm. The k ey is to keep more 1’s ro ws at the top of the matrix an d to 5 a void pu tting m ore as it n eeded. The follo wing simple calculatio ns can b e used to improv e the pro cess. W e wo uld b e able to kno w ho w many rows h a v e the extra 1’s in eac h of ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆ 2 ( R − 1 , J, m − m 1 ) b efore the merge. After the merge, the arra y will n ot change. Supp ose that ∆ 1 ( R − 1 , J − 1 , m 1 ) and ∆ 2 ( R − 1 , J, m − m 1 ) are Matric es with equal-w eigh t- columns/ro ws, where m 1 = [ m · J R + R − 1 R ]. First, calculate r 1 = ( J − 1) · ( m 1 ) (mo d R − 1) , 0 ≤ r 1 < ( R − 1) , (8) r 2 = J · ( m − m 1 ) (mo d R − 1) , 0 ≤ r 2 < ( R − 1) . (9) If ( r 1 + r 2 > ( R − 1)), let r ′ = r 1 + r 2 − ( R − 1). Because r 1 < ( R − 1) and r 2 < ( R − 1), r 1 > r ′ and r 2 > r ′ . Shift r 2 − r ′ ro ws in ∆ 2 to the b ottom to obtain a ∆ ′ 2 . If ( r 1 + r 2 ≤ ( R − 1)), then mo v e the fir st r 2 ro ws to r 1 + 1 to r 1 + r 2 , so ∆ ′ ( R, J, m ) = [ < 1 > ( m 1 ) ⊕ < 0 > ( m − m 1 )] ◦ [∆ 1 ( R − 1 , J − 1 , m 1 ) ⊕ ∆ ′ 2 ( R − 1 , J , m − m 1 )] (10) is a matrix with equal-wei gh t-co lumns/ro ws. The time complexit y of th e ab ov e pro cess is T ( m ) = T ( m 1 ) + T ( m − m 1 ) + O ( m · R ) . (11) Using the same tec hnique to analyze the a v erage case of Quic k -S ort [3], we ha v e T ( m ) = R · m log ( m · R ) = T ( m ) = R · m log ( m ) . (1 2) F or the detail analysis, w e could view T ( m ) as the a verag e time r equired b y the randomized m 1 . That means m 1 could b e an y n um b er b etw een 1 to m − 1. So T ( m ) = ( T (1) + T ( m − 1) + T (2) + T ( m − 2) + ... + T ( m − 1) + T (1) + O ( R · m · m )) / ( m − 1) , (13) T ( m ) = 2 m − 1 Σ m − 1 k =1 T ( k ) + O ( R · m ) . (14) Using the metho d of the mathematical induction, we can pro v e that T ( m ) ≤ R · m · log ( R · m ) [3]. W e know that R ≤ m is held in most of case s. Therefore, we h a v e: Theorem 3 The time complexit y of generating ∆( R, J, m ) is O ( R · m (log R + log m )) for av erage cases, or O ( R · m · log m ) for most cases. 6 5 More Efficien t Algorithms for Generating ∆ ( R, J, m ) ? T o av oid using extra time to bu ild ∆( R, J, m ), we h a ve to kno w exactly wh ere to pu t the extra 1’s if r = J · m (mo d R ) is not zero. Except in th e case of m = C J R , even though r = J · m (mo d R ), we ma y ha v e an unbalanced n um b er of 1’s at the n ext lev el. F or example, let R = 6, J = 3, and m = 10. m 1 = [( J · m ) /R + ( R − 1) /R ] = 6 and ( m − m 1 ) = 6. r = ( J − 1) · m 1 ) (mo d ( R − 1)) = 12 (mo d 5) = 2. Therefore, it seems imp ossible to design an O ( R · m ) algorithm for generating ∆( R , J, m ). In other w ords, it is reasonable to sa y th at the b est algorithm sh ould use the divide-and-conquer to reac h the time complexit y O ( R · m log m ). Moreo ve r, to set up a dividing p oint in the middle of the length of the array migh t break the L -condition, it seems hard to d esign an algo rithm that mak es a matrix based on t wo equal sized arra ys without the L -condition. W e ha v e provi ded an analysis of a verag e cases in Section 4. W e h a ve the reason to b eliev e that the algorithms discussed in this note attain the optimal in th eory . Ho wev er, practicall y one can still dev elop more efficien t alg orithms for ge nerating s uc h a matrix. 6 Conclusion This note translates the ma jor steps of the author’s earlier pap er wr itten in Chinese for optimal Hsiao co des. An algorithm analysis err or wa s found and corrected. The original algorithm has b een mo dified and improv ed. A brief analysis sh ows that th e algorithm reac hed optim um in a v erage cases if a divide-and-conquer tec hniqu e w as inv olv ed in the algorithm. A cknow le dgements The author would lik e to presen t thanks to Dr. W. Stallings and Dr. Nur T ouba for their interest s in his researc h that m otiv ated the author to wr ite this n ote. References [1] L. Chen, An optimal generati ng algo rithm for a matrix of equal-w eigh t columns and quasi- equal-w eight ro ws. Jour nal of Nanjing Inst. T ec h n ol. 16, No.2, 33-39 (1986). [ISSN 0254-4 180] [2] D. R. Chowdh ury , S. Basu, I. S. Gupta, and P . Pal Ch au d h uri. Design of CAEC C: Cellular Automata based Error Correcting Co de. I E EE T rans. on Computers, 43(6):75 9-764, June 1994. [3] T. H. Cormem etal , Introd u ction to Algorithms, MIT PRE S S, 1993. [4] Nilo y Ganguly ,et al, A Survey on Cellular Au tomata, Man uscript, T ec h nical rep ort, Cen tre for High Performance Computing, Dresden Universit y of T ec hnology , Decem b er 2003. [5] S . Ghosh, S. Basu, N.A. T oub a, Reducing P o wer Consumption in Memory ECC Chec k ers, Pro ceedings of IE E E Inte rnational T est Conference, 2004. pp 1322-1331 [6] S . Ghosh, S. Basu, N.A. T ouba, Selecting Error Correcting Co des to Minimize Po we r in Mem- ory Ch ec ker Circuits , J. Lo w Po wer Electronics 1, pp.63-72( 2005) 7 [7] M.Y. Hsiao. A Class of Optimal Minim u m Odd-w eigh t-column SEC -DED Co d es. IBM J. of Res. and Deve lop., vol. 14, n o. 4, pp. 395-40 1 (197 0) [8] Jien-Chung L o, Y u-Lu n W an, E iji F ujiwa ra, ”T rans ient Beha vior of the Enco d ing/Decoding Circuits of Error Correcting Co des,” , pp. 120-1 30, 20th IEEE Inte rnational Symp osium on Defect and F ault T olerance in VLSI Systems (DFT’05), 2005. [9] Parag Lala, Self-Chec king and F ault-T oleran t Digita l Desig n,Morgan K aufmann, 2000. [10] W. Stallings, Computer Organization and Arc hitecture, 7ed, Pren tice Hall, Upp er Saddle Riv er, NJ, 2006. [11] H.G . Zhang, A ge nerating algorithm for optimal minim u m o d d-we igh t-column cod es, Journ al of W uhan Un iv ersit y (Natural Science), No 4, 1980. App endix ————— ————— — Zbl 0629.65046 Chen, Li An optimal generating algorithm for a ma trix of equal-weigh t columns a nd quasi- equal-w eigh t ro ws. (C hinese. English sum mary) [J] J. Nanjing Inst. T ec hnol. 16, No.2, 33-39 (1986). [ISSN 0254-4180 ] According to a rec ursiv e mat rix whic h is in t ro duced in this pap er, an algorithm for a matrix of equal-weigh t columns which are inequal eac h other and quasi-equal-w eigh t ro ws is giv en. The algorithm is optimal in time and space, and it can b e applied to generate c hec k matrices of optimal minim um o dd-weigh t-column SEC-DED codes. Finally , this algorithm is extended to a set of n elemen ts. MSC 2000: *65F30 Other matrix algorithms Keyw ords: recursiv e mat rix; equal- w eigh t columns; quasi-equal-weigh t ro ws; optimal minim um o dd-w eigh t -column SEC-DED codes ————— ————— —– 8
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment