Is it possible to multiply A[m,n,k] by B[p,q,r]? Does the regular matrix product have generalized form?

I would appreciate it if you could help me to find out some tutorials online or mathematical ‘word’ which means N-dimensional matrix product.

Upd.

I’m writing a program that can perform matrix calculations. I created a class called matrix

and made it independent from the storage using object oriented features of C++. But when I started to write this program I thought that it was some general operation to multiply for all kinds of arrays(matrices). And my plan was to implement this multiplication (and other operators) and get generalized class of objects. Since this site is not concerned with programming I didn’t post too much technical details earlier. Now I’m not quite sure if that one general procedure exists. Thanks for all comments.

**Answer**

The general procedure is called tensor contraction. Concretely it’s given by summing over various indices. For example, just as ordinary matrix multiplication $C = AB$ is given by

$$c_{ij} = \sum_k a_{ik} b_{kj}$$

we can contract by summing across any index. For example, we can write

$$c_{ijlm} = \sum_k a_{ijk} b_{klm}$$

which gives a $4$-tensor (“$4$-dimensional matrix”) rather than a $3$-tensor. One can also contract twice, for example

$$c_{il} = \sum_{j,k} a_{ijk} b_{kjl}$$

which gives a $2$-tensor.

The abstract details shouldn’t matter terribly unless you explicitly want to implement mixed variance, which as far as I know nobody who writes algorithms for manipulating matrices does.

**Attribution***Source : Link , Question Author : danny_23 , Answer Author : Qiaochu Yuan*