<ul>
<li><p>You can construct the orthogonal projection matrix onto <span class="math-container">$u$</span> as <span class="math-container">$P= uu^T$</span> if <span class="math-container">$u$</span> is unit length, otherwise it is <span class="math-container">$P_{u,u^{\perp}}=u(u^Tu)^{-1}u^T = \frac{uu^T}{u^Tu}$</span>.</p>
</li>
<li><p>If you have <span class="math-container">$P_{u,v^{\perp}}=u(v^Tu)^{-1}v^T = \frac{uv^T}{v^Tu}$</span> that's an oblique projection onto <span class="math-container">$u$</span> along the perpendicular hyperplane to <span class="math-container">$v$</span>.</p>
</li>
<li><p>If you have a matrix <span class="math-container">$A$</span> and its singular value decomposition <span class="math-container">$A=USV^T$</span> you can write <span class="math-container">$A= \sum_{r=1}^{rank(A)} \sigma_i u_iv_i^T$</span>, ditto for eigendecomposition of a symmetric matrix <span class="math-container">$A=\sum_{i=1}^r \lambda_i v_iv_i^T$</span>. You can &quot;compress&quot; the matrix by dropping terms from the sum with smaller singular values <span class="math-container">$\sigma_i$</span>.</p>
</li>
<li><p><a href="https://en.wikipedia.org/wiki/Structure_tensor#Applications" rel="nofollow noreferrer">The structure tensor</a> in image processing is computed through the outer product of the gradient and a subsequent convolution: <span class="math-container">$K_{\rho} * \nabla u \nabla u^T$</span>.</p>
</li>
<li><p>You can compute the covariance matrix between random vectors <span class="math-container">$U$</span> and <span class="math-container">$V$</span> as <span class="math-container">$\mathbb{E}[(U-\mathbb{E}[U])(V-\mathbb{E}[V])^T] \approx \frac{1}{M} \sum_{i=1}^M (u_i - \mu_u)(v_i-\mu_v)^T$</span>. Here <span class="math-container">$u_i, v_i$</span> are randomly sampled vectors with the same density as <span class="math-container">$U$</span> and <span class="math-container">$V$</span>, and <span class="math-container">$\mu_u, \mu_v$</span> are approximations of the means of those. Typically you perform an eigendecomposition on the covariance matrix for analysis purposes.</p>
</li>
</ul>

CC BY-SA 4.0
2024-11-17T05:27:56.800Z
2024-11-23T15:30:56.343Z
2024-11-23T15:30:56.343Z
lightxbulb
<p>I've been reading through the specification of OpenGL ES 3.20 and found a built-in &quot;outerProduct&quot; function for computing the outer product of two vectors, specifically, outerProduct(a,b) = <span class="math-container">$a\cdot b^T$</span>.</p>
<p>What applications is this intended for? That is, why would someone want to use the outerProduct function in a shader?</p>
<p>I recall seeing this sort of construction in quantum physics, and the Wikipedia page suggests it is also used for signal processing and image compression without going into detail.</p>

<shader><matrix><linear-algebra>
Applications of the outer product in shaders
TomKern
# Applications of the outer product in shaders

(Asked by: username_0 on 2024-11-17)

I've been reading through the specification of OpenGL ES 3.20 and found a built-in "outerProduct" function for computing the outer product of two vectors, specifically, outerProduct(a,b) = $a\cdot b^T$.

What applications is this intended for? That is, why would someone want to use the outerProduct function in a shader?

I recall seeing this sort of construction in quantum physics, and the Wikipedia page suggests it is also used for signal processing and image compression without going into detail.

**Tags:** shader, matrix, linear-algebra


---

## 1 answers

### Answer by username_1 on 2024-11-17. Score: 4

* You can construct the orthogonal projection matrix onto $u$ as $P= uu^T$ if $u$ is unit length, otherwise it is $P\_{u,u^{\perp}}=u(u^Tu)^{-1}u^T = \frac{uu^T}{u^Tu}$.
* If you have $P\_{u,v^{\perp}}=u(v^Tu)^{-1}v^T = \frac{uv^T}{v^Tu}$ that's an oblique projection onto $u$ along the perpendicular hyperplane to $v$.
* If you have a matrix $A$ and its singular value decomposition $A=USV^T$ you can write $A= \sum\_{r=1}^{rank(A)} \sigma\_i u\_iv\_i^T$, ditto for eigendecomposition of a symmetric matrix $A=\sum\_{i=1}^r \lambda\_i v\_iv\_i^T$. You can "compress" the matrix by dropping terms from the sum with smaller singular values $\sigma\_i$.
* [The structure tensor](https://en.wikipedia.org/wiki/Structure_tensor#Applications) in image processing is computed through the outer product of the gradient and a subsequent convolution: $K\_{\rho} \* \nabla u \nabla u^T$.
* You can compute the covariance matrix between random vectors $U$ and $V$ as $\mathbb{E}[(U-\mathbb{E}[U])(V-\mathbb{E}[V])^T] \approx \frac{1}{M} \sum\_{i=1}^M (u\_i - \mu\_u)(v\_i-\mu\_v)^T$. Here $u\_i, v\_i$ are randomly sampled vectors with the same density as $U$ and $V$, and $\mu\_u, \mu\_v$ are approximations of the means of those. Typically you perform an eigendecomposition on the covariance matrix for analysis purposes.


---

