# Arithmetic Matrix Operations

 Home Matrix Home Arithmetic Matrix Routines Home Matrix Addition / Subtraction Matrix Diagonal Add / Subract Scalar Matrix Multiply / Divide by Scalar Matrix Multiplication ATB, ABT, ATA, AAT [A,B] and {A, B} Row / Column Transform Row Sum / Column Sum / Trace Zero Matrix / Identity Matrix Direct Sum Bilinear Function / Kronecker Product / Tensor Product

## Bilinear Functions / Kronecker Product / Tensor Product.

Given vector spaces V and W, a bilinear function is a function f : V×WR which is linear in each variable when the other variable is held fixed, i.e. f(av1 + bv2,w) = af(v1,w) + bf(v2,w) and f(v,aw1 + bw2) = af(v,w1) + bf(v,w2).

The Kronecker product of the n×m matrix A and the n'×m' matrix B is the (nn')×(mm') matrix C where C in block matrix form is given by
C =
 ⌈ a00B a01B ··· a0,m-1B ⌉ | a10B a11B ··· a1,m-1B | | ··· ··· ··· ··· | ⌊ an-1,0B an-1,1B ··· an-1,m-1B ⌋

Given vector spaces V and W, the tensor product of V and W is the vector space V W and bilinear map i: V×WV Wi(v,w)=v w (unique up to isomorphism) such that given a third vector space U and a bilinear map h:V×W→U there exists a unique linear map k: (V W) → U such that h = k i. Given bases {e1i} of V1, {e2i} of V2, {f1i} of W1 and {f2i} of W2, then if (aij) is the matrix of A:V1W1 with respect to the bases {e1i} and {f1i}, and (bij) is the matrix of B:V2W2 with respect to the bases {e2i} and {f2i}, then the Kronecker product of the matrices (aij) and (bij), is the matrix of the linear map (A B) defined by
(A B)( v1 v2) = (A v1) (B v2) with respect to the basis vectors {e1i e2j} and {f1i f2j} ordered lexicographically, i.e.
<e10 e20e10 e21,  ... , e10 e2m'-1e11 e20,  ... , e1m-1 e2m'-1>
and
<f10 f20f10 f21,  ... ,f10 f2n'-1f11 f20,  ... , f1n-1 f2n'-1>.

### Function List

• double Bilinear_Function( double u[ ], double *A, double v[ ], int nrows, int ncols )

This routine evaluates the product uTAv, where A is an nrows×ncols matrix, uT is an nrows row vector and v is an ncols column vector.

• void Kronecker_Product( double *C, double *A, int nrows, int ncols, double *B, int mrows, int mcols)

This routine initializes the (nrowsmrows)×(ncolsmcols) matrix C as the Kronecker product of the nrows×ncols matrix A and the mrows×mcols matrix B. The matrix C should be declared as double [nrows·mrows][ncols·mcols] in the calling routine.

• void Kronecker_CProduct( double complex *C, double complex *A, int nrows, int ncols, double complex *B, int mrows, int mcols)

This routine initializes the (nrowsmrows)×(ncolsmcols) complex matrix C as the Kronecker product of the nrows×ncols complex matrix A and the mrows×mcols complex matrix B. The complex matrix C should be declared as double complex [nrows·mrows][ncols·mcols] in the calling routine.

#### C Test Code, Test Results, and Build Shell Script

• The file, testkroneckerproduct.c, contains a test program of Kronecker_Product( ) in the file kronecker_product.c. This test program requires the file kronecker_product.c listed above.

• The file, KroneckerProductTests.txt, contains the results of the test program testkroneckerproduct.c.

• The file, testkroneckerproduct.sh, contains the shell script used to compile, link, and execute the test program testkroneckerproduct.c.

• The file, testkroneckercproduct.c, contains a test program of Kronecker_CProduct( ) in the file kronecker_cproduct.c. This test program requires the file kronecker_cproduct.c listed above.

• The file, KroneckerCProductTests.txt, contains the results of the test program testkroneckercproduct.c.

• The file, testkroneckercproduct.sh, contains the shell script used to compile, link, and execute the test program testkroneckercproduct.c.