## 3 Beamformer Design
### IRS Phase Adjustment  
In this subsection, we consider the optimization of the diagonal matrix \(\mathbf{\Phi}\) at the IRS with the AP pre-coder \(\mathbf{w}\) fixed. We provide two methods, where one is based on the LS method as in the previous subsection and the other one relies on an intuitive approach derived from the optimal phase alignment of [16]. The latter method associates each IRS reflection element with a user so that the elements are separated into few groups. A similaridea is applied in [19], where the multiuser channel with an IRS support is considered. With the definition \(\mathbf{h}_{0}=\mathbf{H}_{0}\mathbf{w}\) and \(g_{k}=\mathbf{g}_{k}^{T}\mathbf{w}\) for \(k=1,\ldots,K\), we can modify the problem (3) as  
\[(\mathbf{\Phi})=\max\min_{k\in\{1,\ldots,K\}}\ |g_{k}+\mathbf{h}_{k}^{T}\mathbf{ \Phi}\mathbf{h}_{0}|,|\phi_{i}|=1,\ i=1,\ldots,N. \tag{7}\]  
For \(K=1\), the authors in [16] show that phase alignment among the different channel paths passing through the IRS so that they are all aligned to the phase of \(g_{1}\) achieves the optimal beamforming for \(\mathbf{\Phi}\). In other words, \(\angle(g_{1})=\angle(\mathbf{h}_{1}(i)\phi_{i}\mathbf{h}_{0}(i))\) or \(\angle(\phi_{i})=(\angle(g_{1})-\angle(\mathbf{h}_{1}(i)\mathbf{h}_{0}(i)))\) is the necessary condition required for \(\phi_{i}\), \(i=1,\ldots,N\). Since this rule is difficult to apply for all user channels at the same time where \(K\geq 2\), a modification of the method is required to reflect the minimum operation in (7), and thus the rule is to be compromised and shared among different user channels. Note that the phase alignment of [16] is equivalent to the equal gain combining (EGC) of diversity combining. First, we apply the LS method as we did in Section 3.1 to find the matrix \(\mathbf{\Phi}\), although it is constrained to be a diagonal matrix with unit magnitude elements. With the definitions of the phase vector from the diagonal elements of \(\mathbf{\Phi}\) as \(\mathbf{GE}\doteq\mathrm{diag}[\mathbf{\Phi}]\) and \(\tilde{\mathbf{h}}_{k}\doteq\mathrm{diag}[\mathbf{h}_{k}]\mathbf{h}_{0}\), the right-most term in (7) can be re-written as \(g_{k}+\mathbf{h}_{k}^{T}\mathbf{\Phi}\mathbf{h}_{0}=g_{k}+\tilde{\mathbf{h}} _{k}^{T}\mathbf{GE}\). Then, we can form the following LS estimation problem of \(\mathbf{GE}\). \[ \begin{array}{c}(\mathbf{GE})=\min\|\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}( \mathbf{g}+\mathbf{H}\mathbf{GE})\|^{2},\\ \|\mathbf{GE}\|\leq N.\end{array}  \tag{8}\]  
Here, the matrix \(\mathbf{H}\doteq[\tilde{\mathbf{h}}_{1},\ldots,\tilde{\mathbf{h}}_{K}]^{T}\) is composed of \(\tilde{\mathbf{h}}_{k}^{T}\)'s on its rows. Note that the elements of \(\mathbf{GE}\) are not yet constrained to be unit magnitude to apply the LS method in (8), and the constraint will be applied at the final stage. Again, we can define  
\[\mathbf{S}_{H}\doteq(\mathbf{H}^{H}\mathbf{H})^{\dagger}\mathbf{H}^{H}/\sqrt {P}.\]  
For a positive \(\gamma\) (\(\sqrt{\gamma}\leq\lambda_{max}(\mathbf{H})\sqrt{P}\)), the LS estimate of \(\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}\mathbf{g}\) with the magnitude constraint is given as  
\[\mathbf{CE}= \begin{cases}\frac{N\mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}- \sqrt{P}\mathbf{g}]}{\|\mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P} \mathbf{g}]\|},&\text{if }\|\mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P} \mathbf{g}]\|\geq N,\\ \mathbf{S}_{H}[\sqrt{\gamma}\mathbf{1}_{K}-\sqrt{P}\mathbf{g}],&\text{o.w.} \end{cases}  \tag{9}\]  
Again, the decision \(\mathbf{CE}\) is dependent on \(\gamma\) and we now turn to the optimization of \(\gamma\).