0
$\begingroup$

I have a matrix $A$:

$$A=\begin{pmatrix} 1 &3 &1\\ 7 &5 &2\\ 4& 3& 7\\ 8& 2& 1\\ 3& 9& 6\\ 4 &5 &2 \end{pmatrix}$$

and a matrix $B$:

$$\begin{pmatrix} 2& 9& 1\\ 4& 3 &8\\ 9& 7& 3\\ 4& 4& 2\\ 6& 5& 7\\ 2 &9& 2 \end{pmatrix}$$

I want to compute $C$:

$$\begin{pmatrix} 1\cdot2+3\cdot9+1\cdot1\\ 7\cdot4+5\cdot3+2\cdot8\\ 4\cdot9+3\cdot7+7\cdot3\\ 8\cdot4+2\cdot4+1\cdot2\\ 3\cdot6+9\cdot5+6\cdot7\\ 4\cdot2+5\cdot9+2\cdot2 \end{pmatrix}$$

How can I express this purely using matrix operations?

  • 0
    Would you tell why are you interested in this? This can be done via $$ C = (A.B)\begin{pmatrix}1\\1\\1\end{pmatrix} $$ where $A.B$ denotes the element-wise product which is not quite a *pure* matrix operation (although it is implemented e.g. in MATLAB)2012-05-18
  • 2
    Also $\operatorname{diag}(AB^T)$ gives the vector. (Horizontal or vertical, depending on how we define the operator $\operatorname{diag}$.)2012-05-18
  • 0
    I am interested in this because I am trying to compute the cost function of a neural network. I have a 5000 x 10 output vector and a 5000 x 10 training vector. I. e. it is classifying a training set of 5000 things into 10 classes.2012-05-18
  • 0
    thank you for your responses; i am trying to understand/verify them.2012-05-18

2 Answers 2