Quantcast
Channel: User Rodrigo de Azevedo - MathOverflow
Viewing all articles
Browse latest Browse all 198

Answer by Rodrigo de Azevedo for How to calculate $y^T \mbox{diag}(A^T B A) \,y$ efficiently?

$
0
0

$$\mathrm y^\top \mbox{diag}(\mathrm A^\top \mathrm B \,\mathrm A) \,\mathrm y = \sum_{k=1}^n \mathrm e_k^\top\mathrm A^\top \mathrm B \,\mathrm A \,\mathrm e_k \, y_k^2 = \sum_{k=1}^n \mathrm a_k^\top \mathrm B \, \mathrm a_k \, y_k^2$$

where $\mathrm a_k \in \mathbb R^m$ is the $k$-th column of $\rm A$. Since each $\mathrm a_k^\top \mathrm B \, \mathrm a_k$ costs $\mathcal O (m^2)$ operations, the total computational cost is $\mathcal O (m^2 n)$ operations.

However, if $\rm B$ is a diagonal matrix, then each $\mathrm a_k^\top \mathrm B \, \mathrm a_k$ only costs $\mathcal O (m)$ operations, and the total computational cost is $\mathcal O (m n)$ operations.


Viewing all articles
Browse latest Browse all 198

Trending Articles