## 3 Proposed CG-LIB Algorithm and User Vehicle Localization
### User Vehicle Localization  
Let RIS to user channel covariance \(\Sigma_{i}=\mathbb{E}[\mathbf{g}_{i}\mathbf{g}_{i}^{H}]\), where \(i=1,\ldots,N_{s}\) and the channel vector \(\mathbf{g}=\text{vec}(\mathbf{G})\) is geometrically generated for the different positions as shown in Section 2.3. Thus, the user vehicle localization problem can be computed as a hypothesis testing problem as follows:  
\[H_{i}:\mathbf{g}\sim\mathcal{CN}(0,\mathbf{\Sigma}_{i}). \tag{34}\]  
Hence, the optimal likelihood (ML)-based localization problem is given by  
\[\hat{i}=\operatorname*{arg\,max}_{1\leq i\leq N_{s}}p_{i}(\mathbf{g}), \tag{35}\]  
where \(p_{i}(\mathbf{g})\) is the probability density function under \(\mathbf{G}\)  
\[p_{i}(\mathbf{g})=\frac{1}{\pi^{N_{u},N_{i}}|\mathbf{\Sigma}_{i}(\mathbf{ \varepsilon})|}e^{-\mathbf{g}^{H}\mathbf{\Sigma}_{i}^{-1}(\mathbf{\varepsilon })\mathbf{g}}. \tag{36}\]  
We can now evaluate the error-probability performance under \(H_{i}\), which is given by  
\[P_{e}=\frac{1}{N_{s}}\sum_{i=1}^{N_{s}}P_{e,i},\ \ P_{e,i}=P(\hat{i}\
eq i|H_{i}). \tag{37}\]  
where \(P_{e,i}\) is the conditional error probability under \(H_{i}\). Due to user mobility and high location errors, (36) contains a high channel state information (CSI) error. To overcome this issue, we analyze the location information generated by GPS. Consider the location of the user vehicle from the GPS represented by  
\[\mathbf{u}=\hat{\mathbf{u}}+\Delta\mathbf{u}, \tag{38}\]where \(\mathbf{u}=[u_{x},u_{y},u_{z}]^{T}\) denotes the actual location vector of the user vehicle, \(\hat{\mathbf{u}}=[a_{x},a_{y},a_{z}]^{T}\) is the ego GPS location vector, and \(\Delta\mathbf{u}=[\Delta u_{x},\Delta u_{y},\Delta u_{z}]^{T}\) is the localization error vector and \(\Delta\mathbf{u}\) satisfy \(||\Delta\mathbf{u}||_{2}\leq\epsilon\). Based on (13) and (38), we obtain the actual channel vector \(\mathbf{g}\) that satisfy  
\[\mathbf{g}(u)=\hat{\mathbf{g}}(u)+\Delta\mathbf{g}(u), \tag{39}\]  
where \(\Delta\mathbf{g}\sim\mathcal{N}(0,\mathbf{\Sigma})\) and \(\mathbf{\Sigma}=[\sigma_{g,x}^{2},\sigma_{g,y}^{2},\sigma_{g,z}^{2}]^{T}\) is approximated as diagonal with \(\sigma_{g,x}^{2},\sigma_{g,y}^{2}\) and \(\sigma_{g,z}^{2}\) being the channel variances along the \(x\), \(y\), and \(z\) directions, respectively. Hence, by using (39), with the location error bound (36), the CSI error minimization problem can be formulated as  
\[ \begin{split}\min_{\Delta\mathbf{g}}f(\mathbf{\Theta},\Delta\mathbf{g })&=||\hat{\mathbf{g}}(u)+\Delta\mathbf{g}(u)||^{2},\quad\text{ s.t. }\ ||\mathbf{\Theta}_{ij}||=1,\forall_{i=1,\ldots,N_{R}},\\ |\mathbf{a}_{R}(\theta_{R}^{l},\
u_{R}^{l})_{i}|&= 1,\forall_{i=1,\ldots,N_{R}},\text{and }\ ||\Delta\mathbf{g}||_{2}\leq\epsilon.\end{split}  \tag{40}\]  
It is noted that (40) still suffers high localization errors. This issue can be addressed using a double-step iteration method. Let the error covariance matrix \(\mathbf{\Sigma}\) possesses and split two different covariance matrices \(\mathbf{\Sigma}=\mathbf{\Sigma}_{1}+\mathbf{\Sigma}_{2}\) in (34), where \(\mathbf{\Sigma}_{1}=\mathbf{F}^{*}\mathbf{\Lambda}_{1}\mathbf{F}\), \(\mathbf{\Sigma}_{2}=\mathbf{F}^{*}\mathbf{\Lambda}_{2}\mathbf{\hat{F}}\), \(\mathbf{\Lambda}_{1}\) and \(\mathbf{\Lambda}_{2}\) are the diagonal matrices holding the eigenvalues of \(\mathbf{\Sigma}_{1}\) and \(\mathbf{\Sigma}_{2}\), respectively. If the matrices \(\mathbf{\Sigma}_{1}\) and \(\mathbf{\Sigma}_{2}\) are positive definite and \(\alpha\) is a positive constant, then the iterative covariance matrix \(\mathbf{\Sigma}(\alpha)\) is given using by [42]  
\[\mathbf{\Sigma}(\alpha)=\mathbf{M}_{2}^{-1}\mathbf{N}_{2}\mathbf{M}_{1}^{-1} \mathbf{N}_{1}, \tag{41}\]  
where \(\alpha\) denotes the positive constant, \(\mathbf{M}_{2}=(\alpha\mathbf{I}+\mathbf{\Sigma}_{2})\), \(\mathbf{N}_{2}=(\alpha\mathbf{I}-\mathbf{\Sigma}_{1})\), \(\mathbf{M}_{1}=(\alpha\mathbf{I}+\mathbf{\Sigma}_{1})\) and \(\mathbf{N}_{1}=(\alpha\mathbf{I}-\mathbf{\Sigma}_{2})\).