This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Correcting matrix products over the ring of integers

Yu-Lun Wu 60947037s@ntnu.edu.tw Hung-Lung Wang hlwang@ntnu.edu.tw Department of Computer Science and Information Engineering,
National Taiwan Normal University,
No.88, Sec. 4, Tingzhou Rd., Wenshan Dist., Taipei City 116, Taiwan
Abstract

Let AA, BB, and CC be three n×nn\times n matrices. We investigate the problem of verifying whether AB=CAB=C over the ring of integers and finding the correct product ABAB. Given that CC is different from ABAB by at most kk entries, we propose an algorithm that uses O(kn2+k2n)O(\sqrt{k}n^{2}+k^{2}n) operations. Let α\alpha be the largest absolute value of an entry in AA, BB, and CC. The integers involved in the computation are of O(n3α2)O(n^{3}\alpha^{2}).

keywords:
matrix multiplication, certifying algorithm, correction

1 Introduction

Designing efficient algorithms to multiply two matrices is an ongoing research topic, due to its wide applications. The research originates from Strassen [9] in 1969, and the known fastest algorithm was proposed by Duan, Wu, and Zhou [2] in 2023, with time complexity O(n2.37188)O(n^{2.37188}), where nn is the row- and column-dimensions of the matrices. Although the best known algorithm for matrix multiplication is still super-quadratic, verifying whether the product of two matrices is equal to a given matrix can be done more efficiently. Freivalds [3] proposed a randomized algorithm that verifies with high probability whether AB=CAB=C, for given matrices AA, BB, and CC. In Freivalds’ algorithm, a vector 𝐯\mathbf{v} is chosen at random, and the result of whether A(B𝐯)=C𝐯A(B\mathbf{v})=C\mathbf{v} is reported. Clearly, Freivalds’ algorithm has one-sided error; namely the answer may be false-positive. Nevertheless, there are only O(n2)O(n^{2}) operations needed.

It is still unknown whether Freivalds’ algorithm can be efficiently derandomized [4]. An immediate attempt for derandomizing Freivalds’ algorithm is to choose a vector 𝐱\mathbf{x} of the form (1,x,x2,,xn)(1,x,x^{2},\dots,x^{n}). Then AB𝐱C𝐱AB\mathbf{x}-C\mathbf{x} consists of nn polynomials in xx. The problem reduces to determining whether the nonzero polynomials are all zero at x{x}. If xx is chosen as a non-root to all nonzero polynomials, then the modified algorithm verifies whether AB=CAB=C deterministically. However, even though such an xx can be found, for example, by applying Cauchy’s bound, one needs to manipulate numbers which are exponentially large. This makes the algorithm impractical. Related discussion can be found in [4, 5].

Recently, Gąsieniec et al. [4] showed that, if the matrix CC has at most kk erroneous entries, then these entries can be identified and also corrected in deterministic O~(kn2)\tilde{O}(kn^{2}) time, where O~()\tilde{O}(\cdot) suppresses polylogarithmic terms in nn and kk. Their approach resembles methods from combinatorial group testing [1]. Based on the same concept, randomized algorithms were also developed for kk equal to the number of erroneous entries. When the number of erroneous entries is not known, they applied the technique of compressed matrix multiplication [8], and developed a randomized algorithm which runs in O~(n2+kn)\tilde{O}(n^{2}+kn) time. Note that the algorithms of Gąsieniec et al. applies for matrix multiplications over any ring. For matrix multiplications over the ring of integers, Kutzkov [7] developed a deterministic algorithm running in O(n2+k2nlog5n)O(n^{2}+k^{2}n\log^{5}n) time; Künnemann [6] proposed an O(kn2log2+o(1)n+k2log3+o(1)n){O}(\sqrt{k}n^{2}\log^{2+o(1)}n+k^{2}\log^{3+o(1)}n)-time deterministic algorithm, given that the absolute values of the input integers are upper bounded by ncn^{c} for some constant cc.

In this paper, we are also concerned with the problem of correcting CC to be the product of AA and BB, where AA, BB, and CC are three n×nn\times n matrices with CC different from ABAB by at most kk entries. The matrix multiplication is restricted to be over the ring of integers. We develop a deterministic algorithm, which runs in O(kn2+k2n)O(\sqrt{k}n^{2}+k^{2}n) time. Our algorithm is purely combinatorial; i.e. it does not rely on fast matrix multiplications or other well-developed subroutines. The idea is inherited from Gąsieniec et al. [4], based on combinatorial group testing. This can also be viewed as an extension of Freivalds’ algorithm; a number of vectors 𝐱1,𝐱2,,𝐱m\mathbf{x}_{1},\mathbf{x}_{2},\dots,\mathbf{x}_{m} are chosen, and the erroneous entries are identified and corrected based on the result of (ABC)(𝐱1𝐱2𝐱m)(AB-C)(\mathbf{x}_{1}\mid\mathbf{x}_{2}\mid\dots\mid\mathbf{x}_{m}).

We note here that the values manipulated by the algorithm are of O(α2n3)O(\alpha^{2}n^{3}), where α\alpha is the largest absolute value of an entry in the input matrices. All values to manipulate are in a reasonable range, namely polynomial in both nn and the input values. In the remainder of this paper, we summarize necessary tools in Section 2, and then give the algorithm in Section 3.

2 Preliminaries

For a matrix AA, we use AijA_{ij} to denote the entry at the intersection of the iith row and the jjth column. We use [n][n] to denote the set {x: 1xn}\{x\in\mathbb{N}\colon\,1\leq x\leq n\}. Let x1,x2,,xnx_{1},x_{2},\dots,x_{n} be nn integers. The n×nn\times n Vandermonde matrix of x1,x2,,xnx_{1},x_{2},\dots,x_{n} is defined to be the matrix VV with Vij=xij1V_{ij}=x_{i}^{j-1}; i.e.

V=(1x1x12x1n11x2x22x2n11xnxn2xnn1)V=\left(\begin{array}[]{ccccc}1&x_{1}&x_{1}^{2}&\dots&x_{1}^{n-1}\\ 1&x_{2}&x_{2}^{2}&\dots&x_{2}^{n-1}\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 1&x_{n}&x_{n}^{2}&\dots&x_{n}^{n-1}\\ \end{array}\right)

The determinant of the n×nn\times n Vandermonde matrix is

1i<jn(xjxi).\prod_{1\leq i<j\leq n}(x_{j}-x_{i}). (1)

Let pp be a prime greater than nn, and let x1,x2,,xnx_{1},x_{2},\dots,x_{n} be nn distinct integers less than pp. Consider the matrix XX, with 0Xij<p0\leq X_{ij}<p and

Xijxij1(modp).X_{ij}\equiv x_{i}^{j-1}\pmod{p}.

By (1)

det(X)1i<jn(xjxi)(modp).\det(X)\equiv\prod_{1\leq i<j\leq n}(x_{j}-x_{i})\pmod{p}.

Since pp is prime, det(X)0\det(X)\neq 0. Thus, XX is invertible over \mathbb{R}. The following lemma is an immediate consequence of the discussion above.

Lemma 1

Let pp be a prime, and let x1,x2,,xnx_{1},x_{2},\dots,x_{n} be nn distinct integers less than pp. For the n×nn\times n matrix XX, with 0Xij<p0\leq X_{ij}<p and Xijxij1(modp)X_{ij}\equiv x_{i}^{j-1}\pmod{p}, and a column vector 𝐲n\mathbf{y}\in\mathbb{R}^{n},

X𝐲=𝟎𝐲=𝟎.X\mathbf{y}=\mathbf{0}\iff\mathbf{y}=\mathbf{0}.

3 Correcting the product

In the following, we use nn to denote the row- and column-dimensions of the input matrices, and we let pp be a prime number greater than nn.

3.1 The certificate

Let mm be a positive integer, and let VV be an n×mn\times m matrix with entries in [p][p] such that

Vijij1(modp).V_{ij}\equiv i^{j-1}\pmod{p}.

We call VV an mm-certificate. Given the mm-certificate VV, a nonzero row 𝐮\mathbf{u} of ABCAB-C is VV-detectable if 𝐮V𝟎\mathbf{u}V\neq\mathbf{0}. Similarly, a nonzero column 𝐮\mathbf{u} of ABCAB-C is VV-detectable if 𝐮TV𝟎\mathbf{u}^{T}V\neq\mathbf{0}.

Lemma 2

Let VV be an mm-certificate. Then every nonzero row or column of ABCAB-C containing at most mm nonzeros is VV-detectable.

Proof 1

Let 𝐮=(u1,,un)\mathbf{u}=(u_{1},\dots,u_{n}) be a nonzero row of ABCAB-C, and let S={i[n]:ui0}S=\{i\in[n]\colon\,u_{i}\neq 0\}. The submatrix VSV_{S} of VV consisting of the rows indexed by SS is an m×mm\times m Vandermonde matrix of mm distinct elements over /p\mathbb{Z}/p\mathbb{Z}. By Lemma 1, 𝐮𝟎\mathbf{u}\neq\mathbf{0} iff 𝐮SVS𝟎\mathbf{u}_{S}V_{S}\neq\mathbf{0}, where 𝐮S\mathbf{u}_{S} is the subvector consisting of entries indexed by SS. \qed

In the following, we assume that k\sqrt{k} is an integer to ease the presentation, and mm is fixed to be k\sqrt{k}. For succinctness a k\sqrt{k}-certificate VV is simply called a certificate, and a row or a column that is VV-detectable is simply said to be detectable. For a certificate VV, the matrices IC=(ABC)TV\mbox{IC}=(AB-C)^{T}V and IR=(ABC)V\mbox{IR}=(AB-C)V are called the column-indicator and row-indicator of ABCAB-C, respectively.

Lemma 3

Given three n×nn\times n matrices AA, BB and CC, let VV be a certificate, and let IC and IR be the column-indicator and row-indicator of ABCAB-C, respectively. If IC=𝟎\mbox{IC}={\bf 0} and IR=𝟎\mbox{IR}={\bf 0}, then AB=CAB=C.

Proof 2

Since IC=𝟎\mbox{IC}={\bf 0} and IR=𝟎\mbox{IR}={\bf 0}, by Lemma 2, every column or row of ABCAB-C that contains a nonzero has more than k\sqrt{k} nonzeros. The existence of a nonzero column implies that ABCAB-C contains more than kk nonzeros. \qed

Observe that for a row of ABCAB-C containing more than k\sqrt{k} nonzeros, one of these nonzero entries must be in a column containing less than k\sqrt{k} nonzeros, given that ABCAB-C contains at most kk nonzeros. As an immediate consequence, we note the following.

Remark 1

Every non-detectable row (respectively, column) contains a nonzero entry residing in a detectable column (respectively, row).

We end this section by giving the pseudocode for computing the indicators. Note that the sets, SS and TT, of indices of nonzero rows of IR and nonzero columns of IC are essential for our algorithm. In the following, we denote the indicators by (IR,S)(\mbox{IR},S) and (IC,T)(\mbox{IC},T).

1:function RowIndicator(AA, BB, CC, VV)
2:     IRA(BV)CV\mbox{IR}\leftarrow A(BV)-CV
3:     S{i[n]:row i of IR is nonzero}S\leftarrow\{i\in[n]\colon\,\mbox{row $i$ of \mbox{IR} is nonzero}\}
4:     return (IR,S)(\mbox{IR},S)
5:end function
6:function ColIndicator(AA, BB, CC, VV)
7:     IC(VTA)BVTC\mbox{IC}\leftarrow(V^{T}A)B-V^{T}C
8:     T{j[n]:column j of IC is nonzero}T\leftarrow\{j\in[n]\colon\,\mbox{column $j$ of \mbox{IC} is nonzero}\}
9:     return (IC,T)(\mbox{IC},T)
10:end function

3.2 The algorithm

1:ABCAB-C contains no more than kk nonzeros, VV is the certificate
2:C=ABC=AB
3:(IR,S)(\mbox{IR},S)\leftarrowRowIndicator(A,B,C,V)(A,B,C,V)
4:(IC,T)(\mbox{IC},T)\leftarrow ColIndicator(A,B,C,V)(A,B,C,V)
5:for (i,j)(S×[n])([n]×T)(i,j)\in(S\times[n])\cup([n]\times T) do
6:     Cij(AB)ijC_{ij}\leftarrow(AB)_{ij}
7:end for
Algorithm 1: An O(kn2)O(kn^{2})-time algorithm for correcting the matrix product with no more than kk errors.

Once we have the row- and column-indicators (IR,S)(\mbox{IR},S) and (IC,T)(\mbox{IC},T), all erroneous entries in CC can be corrected using O(kn2)O(kn^{2}) operations (see Algorithm 1 below). If IC=𝟎\mbox{IC}=\mathbf{0} and IR=𝟎\mbox{IR}=\mathbf{0}, then AB=CAB=C (Lemma 3). Otherwise, we identify nonzero rows and columns, and then recompute all these rows and columns one by one. As mentioned in Remark 1, the index ii of a nonzero row is either in SS or there exists jTj\in T such that Mij0M_{ij}\neq 0. Therefore, all nonzero rows can be identified either via SS, or via computing the columns indexed by TT; a symmetric procedure can be applied to identify all the nonzero columns. Since there are no more than kk nonzero entries in MM, at most kk rows and columns of ABAB are identified and to be computed. A straightforward computation using O(n2)O(n^{2}) operations per row/column leads to an algorithm of O(kn2)O(kn^{2}) operations.

Remark 2

The upper bound of kn2kn^{2} is tight for the algorithm described above. For instance, if each of the iith row and the jjth column of ABCAB-C contains about k/2k/2 nonzeros, then each nonzero entry at row ii or column jj is located using Θ(n2)\Theta(n^{2}) operations.

(00a1j000a2j0ai1ai2aijain00anj0)\left(\begin{array}[]{cccccc}0&0&\dots&a_{1j}&\dots&0\\ 0&0&\dots&a_{2j}&\dots&0\\ \vdots&\vdots&&\vdots&&\vdots\\ a_{i1}&a_{i2}&\dots&a_{ij}&\dots&a_{in}\\ \vdots&\vdots&&\vdots&&\vdots\\ 0&0&\dots&a_{nj}&\dots&0\\ \end{array}\right)

Below, we modify Algorithm 1 to obtain an O(k2n+kn2)O(k^{2}n+\sqrt{k}n^{2})-time algorithm. The algorithm works in two phases. For clarity, let (IR0,S0)(\mbox{IR}_{0},S_{0}) and (IC0,T0)(\mbox{IC}_{0},T_{0}) be the indicators in the very beginning, and let M0=ABCM_{0}=AB-C be the matrix before the correction on CC starts. In the first phase, entries residing in both a detectable row and a detectable column are corrected. Note that right after this phase, nonzero entries are in a row belonging to [n]S0[n]\setminus S_{0} or a column belonging to [n]T0[n]\setminus T_{0}, which means that each of these rows and columns contains more than k\sqrt{k} nonzeros in M0M_{0}. Then, in the second phase the remaining nonzero rows and columns are identified and corrected as in Algorithm 1, except that the indicators are kept up-to-date by the procedure Update. An illustration is given in Figure 1, and the pseudocode of the modified algorithm is given in Algorithm 2.

(00000000000000000000000)S0S={1,3,4,5,6}(000[]00000000000000000000)S0S={1,3,4,5,6}(000𝟎00𝟎000𝟎0000𝟎0000𝟎0000000)S0S={3,4,5,6}\underset{\begin{array}[]{c}\\ S_{0}\cap S=\{1,3,4,5,6\}\\ \end{array}}{\left(\begin{array}[]{cccccc}0&0&0&\ast&0&0\\ \ast&\ast&\ast&\ast&\ast&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&0&0&0\\ \end{array}\right)}\implies\underset{\begin{array}[]{c}\\ S_{0}\cap S=\{1,3,4,5,6\}\\ \end{array}}{\left(\begin{array}[]{cccccc}0&0&0&[\ast]&0&0\\ \ast&\ast&\ast&\ast&\ast&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&\ast&0&0\\ 0&\ast&0&0&0&0\\ \end{array}\right)}\implies\underset{\begin{array}[]{c}\\ S_{0}\cap S=\{3,4,5,6\}\\ \end{array}}{\left(\begin{array}[]{cccccc}0&0&0&\mathbf{0}&0&0\\ \ast&\ast&\ast&\mathbf{0}&\ast&0\\ 0&\ast&0&\mathbf{0}&0&0\\ 0&\ast&0&\mathbf{0}&0&0\\ 0&\ast&0&\mathbf{0}&0&0\\ 0&\ast&0&0&0&0\\ \end{array}\right)}
(000000000[]0000000000000000000)S0S={3,4,5,6}(000000𝟎000𝟎00000𝟎00000𝟎00000𝟎0000)S0S=\implies\underset{\begin{array}[]{c}\\ S_{0}\cap S=\{3,4,5,6\}\\ \end{array}}{\left(\begin{array}[]{cccccc}0&0&0&{0}&0&0\\ \ast&\ast&\ast&{0}&\ast&0\\ 0&[\ast]&0&{0}&0&0\\ 0&\ast&0&{0}&0&0\\ 0&\ast&0&{0}&0&0\\ 0&\ast&0&0&0&0\\ \end{array}\right)}\implies\underset{\begin{array}[]{c}\\ S_{0}\cap S=\emptyset\\ \end{array}}{\left(\begin{array}[]{cccccc}0&0&0&{0}&0&0\\ \ast&\mathbf{0}&\ast&{0}&\ast&0\\ 0&\mathbf{0}&0&{0}&0&0\\ 0&\mathbf{0}&0&{0}&0&0\\ 0&\mathbf{0}&0&{0}&0&0\\ 0&\mathbf{0}&0&0&0&0\\ \end{array}\right)}
Figure 1: An illustration for the first half of Phase 2 (lines 8 to 15) of Algorithm 2, assuming k=4\sqrt{k}=4. We use the matrix CABC-AB to illustrate the process of correction. First, an element ii of S0SS_{0}\cap S is chosen (line 9), say i=1i=1. Then, row 11 is recomputed to identify the nonzero columns, and in this example only column 44 is identified (line 10). All nonzero entries in column 44 are corrected, and S0SS_{0}\cap S is updated accordingly (lines 11 to 14). Notice that S={2,3,4,5,6}S=\{2,3,4,5,6\} at the moment. The for loop stops after the second round. The remaining nonzero entries will be corrected later in lines 16 to 23.
1:function Update(i,j,A,B,C,V,(IR,S),(IC,T)i,j,A,B,C,V,(\mbox{IR},S),(\mbox{IC},T))
2:     x(AB)ijCijx\leftarrow(AB)_{ij}-C_{ij}
3:     for l[k]l\in\left[\sqrt{k}\;\right] do
4:         IRilIRil+xVjl\mbox{IR}_{il}\leftarrow\mbox{IR}_{il}+x\cdot V_{jl}
5:         ICljIClj+xVil\mbox{IC}_{lj}\leftarrow\mbox{IC}_{lj}+x\cdot V_{il}
6:     end for
7:     Update SS and TT accordingly
8:     return (IR,S),(IC,T)(\mbox{IR},S),(\mbox{IC},T)
9:end function
Algorithm 2: An O(k2n+kn2)O(k^{2}n+\sqrt{k}n^{2})-time algorithm for correcting the matrix product with no more than kk errors.
1:ABCAB-C contains no more than kk nonzeros, VV is the certificate
2:C=ABC=AB
3:(IR0,S0)(\mbox{IR}_{0},S_{0})\leftarrowRowIndicator(A,B,C,V)(A,B,C,V)
4:(IC0,T0)(\mbox{IC}_{0},T_{0})\leftarrow ColIndicator(A,B,C,V)(A,B,C,V)
5:for (i,j)S0×T0(i,j)\in S_{0}\times T_{0} do
6:     Cij(AB)ijC_{ij}\leftarrow(AB)_{ij}
7:end for
8:(IR,S)(\mbox{IR},S)\leftarrow RowIndicator(A,B,C,V)(A,B,C,V)
9:(IC,T)(\mbox{IC},T)\leftarrow ColIndicator(A,B,C,V)(A,B,C,V)
10:while S0SS_{0}\cap S\neq\emptyset do
11:     ian element of S0Si\leftarrow\mbox{an element of $S_{0}\cap S$}
12:     T{j[n]:(AB)ijCij}T^{\prime}\leftarrow\{j^{\prime}\in[n]\colon\,(AB)_{ij^{\prime}}\neq C_{ij^{\prime}}\} \triangleright Identify the nonzero columns
13:     for (i,j)[n]×T(i^{\prime},j^{\prime})\in[n]\times T^{\prime} do
14:         (IR,S),(IC,T)(\mbox{IR},S),(\mbox{IC},T)\leftarrowUpdate(i,j,A,B,C,V,(IR,S),(IC,T))(i^{\prime},j^{\prime},A,B,C,V,(\mbox{IR},S),(\mbox{IC},T))
15:         Cij(AB)ijC_{i^{\prime}j^{\prime}}\leftarrow(AB)_{i^{\prime}j^{\prime}}
16:     end for
17:end while
18:while T0TT_{0}\cap T\neq\emptyset do
19:     jan element of T0Tj\leftarrow\mbox{an element of $T_{0}\cap T$}
20:     S{i[n]:(AB)ijCij}S^{\prime}\leftarrow\{i^{\prime}\in[n]\colon\,(AB)_{i^{\prime}j}\neq C_{i^{\prime}j}\} \triangleright Identify the nonzero rows
21:     for (i,j)S×[n](i^{\prime},j^{\prime})\in S^{\prime}\times[n] do
22:         (IR,S),(IC,T)(\mbox{IR},S),(\mbox{IC},T)\leftarrowUpdate(i,j,A,B,C,V,(IR,S),(IC,T))(i^{\prime},j^{\prime},A,B,C,V,(\mbox{IR},S),(\mbox{IC},T))
23:         Cij(AB)ijC_{i^{\prime}j^{\prime}}\leftarrow(AB)_{i^{\prime}j^{\prime}}
24:     end for
25:end while

For the correctness of Algorithm 2, first we observe that once a row or a column is detected, it remains detectable during the execution of the algorithm until all erroneous entries in the row or the column are corrected. This observation is an immediate consequence of Lemma 4.

Lemma 4

Before the execution of line 8, for iS0Si\in S_{0}\cap S row ii of ABCAB-C contains at most k\sqrt{k} nonzeros in M0M_{0}. Similarly, for jT0Tj\in T_{0}\cap T column jj contains at most k\sqrt{k} nonzeros in M0M_{0}.

Proof 3

If row ii of M0M_{0} contains no more than k\sqrt{k} nonzeros, the lemma holds immediately. Otherwise, since the entries that resides in a column containing at most k\sqrt{k} nonzeros were corrected at line 7, by the pigeonhole principle less than k\sqrt{k} entries remains in row ii. A similar argument applies for jT0Tj\in T_{0}\cap T. \qed

Lemma 5 (Correctness of Algorithm 2)

All erroneous entries of CC are corrected during the execution of Algorithm 2.

Proof 4

Suppose to the contrary that there exist ii and jj such that CijC_{ij} is not corrected during the execution. Clearly, iS0i\notin S_{0} or jT0j\notin T_{0}. If either jT0j\in T_{0} or iS0i\in S_{0}, by Lemma 4 MijM_{ij} remains nonzero until CijC_{ij} is corrected so it would be corrected at line 15 or line 23. Thus we may assume that iS0i\notin S_{0} and jT0j\notin T_{0}. Since jT0j\notin T_{0} and Mij0M_{ij}\neq 0, column jj of M0M_{0} contains more than k\sqrt{k} nonzeros. By Remark 1, there is a nonzero entry MijM_{i^{\prime}j} such that iS0i^{\prime}\in S_{0}. If ii^{\prime} is picked at line 10, then column jj of CC is corrected; otherwise all erroneous entries in row ii^{\prime} of CC have to be corrected before ii^{\prime} is picked during the loop. However, the correction of CijC_{i^{\prime}j} implies that all erroneous entries in column jj of CC are corrected, which leads to a contradiction. \qed

Regarding the number of operations, keeping the row- and column-indicators up-to-date ensures that the process of identification is performed only if there is an erroneous entry, not corrected yet, in the corresponding row or column. We show this in Theorem 1.

Theorem 1

Given three n×nn\times n matrices of integers AA, BB, and CC with CC different from ABAB by no more than kk entries, then all erroneous entries can be corrected by a deterministic algorithm using O(k2n+kn2)O(k^{2}n+\sqrt{k}n^{2}) operations. In addition, the values involved in running the algorithm are of O(α2n3)O(\alpha^{2}n^{3}), where α\alpha is the largest absolute value of an entry in AA, BB, and CC.

Proof 5

We claim that Algorithm 2 is the requested algorithm. The correctness of Algorithm 2 follows from Lemma 5. For the number of operations, phase 1 (lines 3 to 7) takes O(k2n)O(k^{2}n) operations. For the remaining nonzero entries MijM_{ij}, clearly iS0i\notin S_{0} or jT0j\notin T_{0}, and by Lemma 2 each nonzero row or column identified in phase 2 contains at least k\sqrt{k} nonzeros in M0M_{0}. Thus, the number of distinct rows and columns to be corrected in phase 2 is at most k\sqrt{k}. Since a row or a column is corrected right after being identified and the indicators are kept up-to-date, a row or a column would not be identified twice. Along with the fact that Update takes O(n+k)O(n+\sqrt{k}) operations, the total number of operations is of O(kn2)O(\sqrt{k}n^{2}).

Last, according to Bertrand’s postulate, there exists a prime pp with n<p<2nn<p<2n. It follows that the value of an entry in the certificate VV is of O(n)O(n). Consequently, the largest absolute value of an entry in (ABC)V(AB-C)V is of O(α2n3)O(\alpha^{2}n^{3}). \qed

As a final remark, in Algorithm 2 we have to retrieve elements from S0SS_{0}\cap S at line 11, which is equivalent to finding an element of S0S_{0} and determining whether it is also an element of the present SS. Since S0S_{0} is static and every element of S0S_{0} is processed exactly once, this can be done efficiently by using an array of integers to represent S0S_{0} and SS. Each integer is a counter, recording the number of nonzeros in the corresponding row of IR0\mbox{IR}_{0}/IR. The same implementation can be applied for T0T_{0} and TT, so the expected complexity can be achieved. In addition, the prime pp can be found in O(n2)O(n^{2}) time, e.g. using the sieve of Eratosthenes, and then the certificate VV can be constructed in O(kn)O(\sqrt{k}n) time.

4 Concluding remarks

In this paper, we investigate the problem of correcting matrix products over the ring of integers. We propose a simple deterministic O(kn2+k2n)O(\sqrt{k}n^{2}+k^{2}n)-time algorithm, where nn is the row- and column-dimensions, and kk is an upper bound on the number of erroneous entries. When k<nk<n, the proposed algorithm is more efficient than the naive Θ(n3)\Theta(n^{3})-time algorithm to multiply two n×nn\times n matrices. For certain kk, it also slightly improves the existing ones, e.g. [4, 6, 7]. In addition, the values involved during the execution are in a reasonable range, namely polynomial in nn and the input values, so the algorithm can be implemented with the requested time complexity on conventional computation models.

Acknowledgement

The authors thank the anonymous reviewers, whose comments help improving the presentation, and also thank Wing-Kai Hon and Meng-Tsung Tsai for the discussion regarding the computation models. This research was supported in part by the Ministry of Science and Technology of Taiwan under contract MOST grant 110-2221-E-003-003-MY3.

References

  • [1] Ding-Zhu Du and Frank K. Hwang. Combinatorial Group Testing and Its Applications. WORLD SCIENTIFIC, 2nd edition, 1999.
  • [2] Ran Duan, Hongxun Wu, and Renfei Zhou. Faster matrix multiplication via asymmetric hashing. In 64th IEEE Annual Symposium on Foundations of Computer Science (FOCS 2023), Santa Cruz, CA, USA, pages 2129–2138, 2023.
  • [3] Rusins Freivalds. Probabilistic machines can use less running time. In Information Processing, Proceedings of the 7th IFIP Congress, pages 839–842. North-Holland, 1977.
  • [4] Leszek Gąsieniec, Christos Levcopoulos, Andrzej Lingas, Rasmus Pagh, and Takeshi Tokuyama. Efficiently correcting matrix products. Algorithmica, 79(2):428–443, 2017.
  • [5] Ivan Korec and Jiří Wiedermann. Deterministic verification of integer matrix multiplication in quadratic time. In 40th International Conference on Current Trends in Theory and Practice of Computer Science (SOFSEM 2014), Nový Smokovec, Slovakia, pages 375–382, 2014.
  • [6] Marvin Künnemann. On nondeterministic derandomization of Freivalds’ algorithm: Consequences, avenues and algorithmic progress. In 26th Annual European Symposium on Algorithms (ESA 2018), Helsinki, Finland, volume 112 of LIPIcs, pages 56:1–56:16, 2018.
  • [7] Konstantin Kutzkov. Deterministic algorithms for skewed matrix products. In 30th International Symposium on Theoretical Aspects of Computer Science (STACS 2013), Dagstuhl, Germany, volume 20 of LIPIcs, pages 466–477, 2013.
  • [8] Rasmus Pagh. Compressed matrix multiplication. ACM Trans. Comput. Theory, 5(3):1–17, 2013.
  • [9] Volker Strassen. Gaussian elimination is not optimal. Numer. Math., 13(4):354–356, 1969.