User blog comment:Kyodaisuu/Update of Bashicu Matrix Calculator/@comment-11227630-20170430092347/@comment-24061664-20170430123417

It is written in the source code of Bashicu matrix calculator.

(1) Initialization

/*** Initialize C matrix ***/ for (m = 0; m<=row; m++) { C[m + nr] = 1; }

It initializes all the elements of the leftmost C matrix to 1. Please note that nr is numbers of row, and row = nr-1. C matrix is stored in one dimensional array like this.


 * $$\begin{pmatrix}

C(0 + nr) & C(0 + 2nr) & \cdots \\ C(1 + nr) & C(1 + 2nr) & \cdots \\ \vdots & \vdots & \cdots \\ C(row + nr) & C(row + 2nr) & \cdots \\ \end{pmatrix}$$

(2) Calculation

/* Calculate C matrix */ for (k=1; k<=bad; k++) { /* Find the largest l which satisfies S_(n-bad+l)[0] < S_(n-bad+k)[0] */ for (l=k; l>=0; l--) { if (S[(n-bad+l)*nr] < S[(n-bad+k)*nr]) { for (m=0; m<=row; m++) { C[m+(k+1)*nr] = ( S[m+(n-bad)*nr] < S[m+(n-bad+k)*nr] && C[m+(l+1)*nr] == 1 )? 1: 0;                }                 l=0; }          }        }

Bashicu matrix is stored in one dimensional array of S like this.


 * $$\begin{pmatrix}

S(0) & S(0 + nr) & S(0 + 2nr) & \cdots & S(0 + n \cdot nr) \\ S(1) & S(1 + nr) & S(1 + 2nr) & \cdots & S(1 + n \cdot nr) \\ \vdots & \vdots & \vdots & \cdots & \vdots \\ S(row) & S(row + nr) & S(row + 2nr) & \cdots & S(row + n \cdot nr) \\ \end{pmatrix}$$

is stored in S. For example, in calculating (0,0,0)(1,1,1)(2,0,0)(1,1,0)(2,1,0)(3,1,0),

n = 5 (Length of the sequence + 1) bad = 5 (length of bad sequence)

Now you can read the program and translate it into English if you want.