# What is the correct way to write this matrix equation?

Given an $n \times m$ matrix $X$ and $m \times m$ matrix $A$, I would like to define the vector $y$ as

$$y_i = X_{i,*} A (X_{i,*})^T$$

where $X_{i,*}$ is the $i$th row of $X$. Is there a simpler way to write this without using the row index?

Edit: $y$ should indeed be a vector of length $n$ and not an $n \times m$ matrix as another answer has pointed out. I also made my matrix row notation less ambiguous.

Edit 2: Rephrased question to better reflect what I was looking for.

• For $A_{i,*}^T$, it's unclear whether you take the row and then transpose it into a column, or whether you take the transpose of the matrix and then take the row. – GFauxPas Jul 2 '15 at 21:20
• Thanks, just realized this. $A_{i,*}^T$ was meant to be $(A_{i,*})^T$ – JaredL Jul 2 '15 at 21:56

For $A^Ti,∗$, it's unclear whether you take the row and then transpose it into a column, or whether you take the transpose of the matrix and then take the row.

It can only be the first. If it were the second there would be a dimension mismatch if $n \neq m$

And $Y$ also cannot be a matrix if you are really doing what you are writing. If you multiply a vector by a matrix by a vector you can only have a scalar at the end. $Y$ can only be a vector of size $n$, and it is the diagonal of $XAX^T$

• This is better off as a comment. My point was the notation was ambiguous, whether or not the context helps clarify. Note that the equation stated does not define $Y$ but rather $Y_{i,*}$. – GFauxPas Jul 2 '15 at 21:38
• I would have commented if I had enough rep to do it. The equation is noting $Y_{i,*}$ as if it were a row of matrix $Y$ which it cannot be, the right side is a scalar – gsmafra Jul 2 '15 at 21:49
• Thanks @gsmafra, you are correct about Y needing to be a vector. I was actually doing this with many different $m \times m$ matrices $A_{1 \dotsc k}$ and combining by columns to make a final $n \times k$ vector. I ended up confusing myself here. I have edited my post to correct this. – JaredL Jul 2 '15 at 22:02
• Well then, I don't think you will get anything more simple than $\operatorname{diag}(XAX^T)$ – gsmafra Jul 2 '15 at 22:22
• I agree, I think this best answers my question. Thank you! – JaredL Jul 2 '15 at 22:37

If $e_i$ is the $i$th standard basis vector (all zero but one at the $i$th position), then $e_i^\top X$ is the $i$th row of $X$.

• Thanks. This is indeed a much nicer way of writing it, but it looks like I pretty much mangled this post. What I was actually looking for was a way to express this without using row indices at all. I have rephrased the question. – JaredL Jul 2 '15 at 22:08