PROGRAMMING:Matrix multiplication and its gradient
Matrix multiplication is no stranger to everyone. Given two matrices $$a $$and $$B $$whose dimensions are $$m / times n $$and $$n / times p $$, the product can be expressed as $$C = A / times B $$, the dimension of $$C $$is $$m / times p $$, and the elements can be expressed as $$C_{ i,j}= \sum_{ k=0}^{n-1}A_{ i,k}B_{ k,j}$$。
If we regard matrix $$a $$as an independent variable, matrix multiplication can be regarded as a function of $$mathbb {r} ^ {m times n} mapsto {mathbb {r} ^ {m times P} $_{ i. J} $$, which only takes part in the operation of forming line $$I $$in matrix $$C $$, we can write it in detail, that is:
$$C_{ i,0}=\sum_{ k=0}^{n-1} A_{ i,k}B_{ k,0}$$,$$C_{ i,1}=\sum_{ k=0}^{n-1} A_{ i,k}B_{ k,1}$$……
Let the function $$f $$have a gradient on the matrix $$C $$g = - nabla_{ C} F $$, that is, it is a matrix with the same dimension as $$C $, each element of which is $$G_{ i,j}=\frac {\partial f}{\partial C_{ i,j}} $$。 According to the chain derivation rule, $$\ frac {partial f} {partial a}_{ i, j}} = \sum_{ k=0}^{n-1} \frac {\partial f }{\partial C_{ i, k}} \frac {\partial C_{ i, k}}{\partial A_{ i,j}} = \sum_{ k=0}^{n-1} G_{ i,j} B_{ k. J} $$, i.e. $$nabla_{ A} f=GB^T$$。
Similarly, for the matrix $$B $, you can also find the gradient of it_ Bf$$。
Now, we give the matrix $$a $, $$B $$and the gradient of function $$f $$to $$C $$$$g $$. We need to output the product $$AB $$, the gradient of function $$f $$to $$a $$, and the gradient of function $$f $$to $$B $$.
###Input format:
The first line gives three integers, $$M $$, $$n $$, and $$p $$, which are not greater than $$10 ^ 2 $$. Then followed by a blank line.
Then, the elements in the matrix $$a $$are given in the main order of the $$M $$row, with each row of $$n $$elements separated by spaces. Then followed by a blank line.
Then, the elements in the matrix $$B $$are given in the main order of the $$n $$row, with each row of $$p $$elements separated by spaces. Then followed by a blank line.
Finally, $$M $$line gives the gradient of $$f $$to the matrix $$C $$in the main order of lines, that is, the elements in the matrix $$g $$, each line has $$p $$elements, and the elements are separated by spaces.
###Output format:
First, output product matrix $$C $$, a total of $$M $$lines, each line $$p $$elements, each element is followed by a space, each line ends with a new line. Finally, an extra blank line is output.
Then output matrix $$\ nabla_{ A} F $$, a total of $$M $$lines, each line has $$n $$elements, each element is followed by a space, and each line ends with a new line. Finally, an extra blank line is output.
Finally, output matrix $$\ nabla_{ B} F $$, a total of $$n $$lines, each line $$p $$elements, each element is followed by a space, each line ends with a new line.
The output elements are reserved for 2 decimal places.
###Input example:
```in
2 2 3
1 2
3 4
1 2 3
4 5 6
1 1 1
1 1 1
```
###Output example:
```out
9.00 12.00 15.00
19.00 26.00 33.00
6.00 15.00
6.00 15.00
4.00 4.00 4.00
6.00 6.00 6.00
```
answer:If there is no answer, please comment
If we regard matrix $$a $$as an independent variable, matrix multiplication can be regarded as a function of $$mathbb {r} ^ {m times n} mapsto {mathbb {r} ^ {m times P} $_{ i. J} $$, which only takes part in the operation of forming line $$I $$in matrix $$C $$, we can write it in detail, that is:
$$C_{ i,0}=\sum_{ k=0}^{n-1} A_{ i,k}B_{ k,0}$$,$$C_{ i,1}=\sum_{ k=0}^{n-1} A_{ i,k}B_{ k,1}$$……
Let the function $$f $$have a gradient on the matrix $$C $$g = - nabla_{ C} F $$, that is, it is a matrix with the same dimension as $$C $, each element of which is $$G_{ i,j}=\frac {\partial f}{\partial C_{ i,j}} $$。 According to the chain derivation rule, $$\ frac {partial f} {partial a}_{ i, j}} = \sum_{ k=0}^{n-1} \frac {\partial f }{\partial C_{ i, k}} \frac {\partial C_{ i, k}}{\partial A_{ i,j}} = \sum_{ k=0}^{n-1} G_{ i,j} B_{ k. J} $$, i.e. $$nabla_{ A} f=GB^T$$。
Similarly, for the matrix $$B $, you can also find the gradient of it_ Bf$$。
Now, we give the matrix $$a $, $$B $$and the gradient of function $$f $$to $$C $$$$g $$. We need to output the product $$AB $$, the gradient of function $$f $$to $$a $$, and the gradient of function $$f $$to $$B $$.
###Input format:
The first line gives three integers, $$M $$, $$n $$, and $$p $$, which are not greater than $$10 ^ 2 $$. Then followed by a blank line.
Then, the elements in the matrix $$a $$are given in the main order of the $$M $$row, with each row of $$n $$elements separated by spaces. Then followed by a blank line.
Then, the elements in the matrix $$B $$are given in the main order of the $$n $$row, with each row of $$p $$elements separated by spaces. Then followed by a blank line.
Finally, $$M $$line gives the gradient of $$f $$to the matrix $$C $$in the main order of lines, that is, the elements in the matrix $$g $$, each line has $$p $$elements, and the elements are separated by spaces.
###Output format:
First, output product matrix $$C $$, a total of $$M $$lines, each line $$p $$elements, each element is followed by a space, each line ends with a new line. Finally, an extra blank line is output.
Then output matrix $$\ nabla_{ A} F $$, a total of $$M $$lines, each line has $$n $$elements, each element is followed by a space, and each line ends with a new line. Finally, an extra blank line is output.
Finally, output matrix $$\ nabla_{ B} F $$, a total of $$n $$lines, each line $$p $$elements, each element is followed by a space, each line ends with a new line.
The output elements are reserved for 2 decimal places.
###Input example:
```in
2 2 3
1 2
3 4
1 2 3
4 5 6
1 1 1
1 1 1
```
###Output example:
```out
9.00 12.00 15.00
19.00 26.00 33.00
6.00 15.00
6.00 15.00
4.00 4.00 4.00
6.00 6.00 6.00
```
answer:If there is no answer, please comment