Tensor/matrix operations
Transpose
Transpose is an important operation defined for matrices or tensors. For a matrix, the transpose is defined as follows:
![Transpose](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_22.jpg)
Here, AT denotes the transpose of A.
An example of the transpose operation can be illustrated as follows:
![Transpose](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_23.jpg)
After the transpose operation:
![Transpose](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_24.jpg)
For a tensor, transpose can be seen as permuting the dimensions order. For example, let's define a tensor S, as shown here:
![Transpose](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_25.jpg)
Now a transpose operation (out of many) can be defined as follows:
![Transpose](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_26.jpg)
Multiplication
Matrix multiplication is another important operation that appears quite frequently in linear algebra.
Given the matrices and
, the multiplication of A and B is defined as follows:
![Multiplication](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_29.jpg)
Here, .
Consider this example:
![Multiplication](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_31.jpg)
![Multiplication](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_32.jpg)
This gives
![Multiplication](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_33.jpg)
, and the value of C is as follows:
![Multiplication](https://static.packt-cdn.com/products/9781788478311/graphics/graphics/B08681_12_34.jpg)
Element-wise multiplication
Element-wise matrix multiplication (or the Hadamard product) is computed for two matrices that have the same shape. Given the matrices and
, the element-wise multiplication of A and B is defined as follows...