2
$\begingroup$

I have a batch of vectors $X$ that have row vectors of size $n$, and batch size of $k$, so $$\begin{bmatrix} v_{11} & ... & v_{1n} \\ v_{21} & ... & v_{2n} \\ &\;\;\vdots \notag \\ v_{k1} & v_{k2} & v_{kn} \end{bmatrix}$$

The $k$ is always bigger than $n$ ($k>n$), so the matrix is non-square. What I would like is to calculate in a vectorized manner, if all of the vectors are orthogonal. I tried fallowing $$XX^T$$ and check if it equals $I$ (identity matrix). But I have doubts, if it works for non-square matrix.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

It works. Let $i$-th row be $x_i^T$: $$\begin{align}XX^T&=\begin{bmatrix}x_1^T\\x_2^T\\\vdots \\x_k^T\end{bmatrix}\begin{bmatrix}x_1 & x_2 & \dots & x_k\end{bmatrix}\\&=\begin{bmatrix}x_1^Tx_1&x_1^Tx_2&\dots&x_1^Tx_k\\x_2^Tx_1&x_2^Tx_2&\dots&x_2^Tx_k\\\vdots&\ddots&&\vdots\\x_k^Tx_1&x_k^Tx_2&\dots&x_k^Tx_k\end{bmatrix}_{k\times k}\end{align}$$ And, the off-diagonal entries will be $0$ if all vectors are orthogonal. Note that, for this being equal to $I$, they should be orthonormal.

However, since $k>n$, you won't be able to get $k$ orthonormal or orthogonal vectors of size $n$, because the dimensionality of the space spanned by these vectors is $n$ at maximum.

$\endgroup$
4
  • $\begingroup$ Thanks for your answer @gunes. So in general I'd search for such vectors, that are: $XX^T = \lambda I$ ? Or the normalization constant can be different for every vector and would be a matrix, e.g. $XX^T = N^{-1/2}IN^{-1/2}$ (assuming $N$ is a normalization matrix) ? $\endgroup$ Jun 17, 2021 at 5:42
  • $\begingroup$ Or to check if they're orthogonal $||XX^T - diag(XX^T)||^2_2 = 0$ would be enough ? $\endgroup$ Jun 17, 2021 at 5:54
  • 1
    $\begingroup$ checking off diagonals as in your second message is enough. But you wont have orthogonals for $k>n$ because of the dimensionality constraint. $\endgroup$
    – gunes
    Jun 17, 2021 at 6:59
  • $\begingroup$ Thanks for answer. In general those vectors come from the same transformation, i.e. $T(y_k) = x_k$, but I want to make it in a batch manner to avoid for loop. So I think $n$ is enough. $\endgroup$ Jun 17, 2021 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.