Treating arrays as functions, although very powerful, completely neglects the linear algebra structures we are familiar with, that is, matrix-vector and matrix-matrix operations. Fortunately, these linear algebra operations may all be written in a similar unified form:
The vector-vector operation:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/5d4531ef-e516-4ea5-907d-0de7b6edc077.png)
The matrix-vector operation:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/6b07789a-b088-40b2-aa11-da31e046119c.png)
The matrix-matrix operation:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/d1e4e002-ee95-448c-91bd-4c9ecfa7120d.png)
The vector-matrix operation:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/91a09614-743b-4b57-8b5c-2b98fd13232b.png)
The essential mathematical concept is that of reduction. For a matrix-vector operation, the reduction is given by:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/aec07b60-4dd3-4aa2-a52c-c21caae0c27d.png)
In general, a reduction operation defined between two tensors,  and
, of respective number of dimensions
 and
 may be defined as:
![](https://static.packt-cdn.com/products/9781838822323/graphics/assets/6d735bf5-14bf-40c0-b43b-3347aab64854.png)
Clearly, the shapes of the tensors must be compatible with that operation to make
any sense. This requirement is familiar for matrix-matrix multiplication. The multiplication Â
of matrices and
only makes sense if the number of columns ofÂ
 equals the number of...