Skip to main content
added 214 characters in body
Source Link

$$\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.

$$\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.

$$\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.

added 65 characters in body
Source Link

$$\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$$\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.

$$\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$ is the $k$-th column of $\rm A$.

$$\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.

Source Link

$$\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$ is the $k$-th column of $\rm A$.