# Check orthogonality of batched vectors, of non square matrix

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.

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.
• 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) ? Jun 17, 2021 at 5:42
• Or to check if they're orthogonal $||XX^T - diag(XX^T)||^2_2 = 0$ would be enough ? Jun 17, 2021 at 5:54
• checking off diagonals as in your second message is enough. But you wont have orthogonals for $k>n$ because of the dimensionality constraint. Jun 17, 2021 at 6:59
• 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. Jun 17, 2021 at 7:07