Dealing with CP2K's real space matrices in k-point calculations can be quite challenging. In principle, it follows equations (10) and (11) of
https://arxiv.org/pdf/2508.15559. Elements i of the qs_env%ks_env%matrix_s_kp array contains real space overlap matrix elements between AOs in the main cell, and AOs in periodic image with index i. The indexing of periodic images is that imposed by the neighbor lists.
For historical reasons, the KP overlap and KS matrices are stored as DBCSR
symmetric types, even though they are not symmetric. That's where it gets complicated. Both the S and KS matrices are Hermitian, and they have the following symmetry: S_ij^
b = S_ji^-
b, where
b denotes the translation from the main cell to a given periodic image.
If you have access to the upper diagonal of a real space matrix with one AO in a periodic cell shifted by b, and that of a real space matrix with an AO shifted by -b, then you can reconstruct the full, asymmetric, real space matrix at b.
I hope that helps.