## 7 Solution of The Digital Beamforming Matrix and The Analog Beamforming Matrix
### Solution of The Digital Beamforming Matrix  
Based on the analog beamforming matrix \(\mathbf{F}_{RF}\) obtained in the previous section, the solution problem of the digital beamforming matrix \(\mathbf{F}_{BB}\) can be modeled as follows:  
\[P_{6}:\min_{\mathbf{F}_{BB}}\left\|\mathbf{F}-\mathbf{F}_{RF}^{(n)}\mathbf{F}_{BB}\right\|_{F}^{2}, \tag{97}\]  
\[s.t.\,\left\|\mathbf{F}_{RF}^{(n)}\mathbf{F}_{BB}\right\|_{F}^{2}=P_{T}, \tag{98}\]  
where \(\mathbf{F}_{RF}^{(n)}\) represents the estimated value of the analog beamforming matrix \(\mathbf{F}_{RF}\) at the \(n\)th iteration. Due to the quadratic form and the convex equality constraint in the problem \(P_{6}\), the problem \(P_{6}\) is a nonconvex QCQP form problem.  
One of the ways to solve the problem \(P_{6}\) is to relax the equality constraint into the inequality constraint, and then convert the problem \(P_{6}\) into a convex minimization problem, which can be solved with the CVX toolbox, but the complexity of this method is high. To this end, based on the fact that the hybrid beamforming matrix \(\mathbf{F}\) satisfies the power constraint, i.e., \(\|\mathbf{F}\|_{F}^{2}=P_{T}\), the following closed form solution can be obtained for the problem \(P_{6}\), which is reflected in line two of the **main algorithm** in Algorithm 3:  
\[\mathbf{F}_{BB}=\left(\mathbf{F}_{RF}^{(n)H}\mathbf{F}_{RF}^{(n)}\right)^{-1}\mathbf{F}_{RF}^ {(n)H}\mathbf{F}, \tag{99}\]  
In conclusion, the MM-AltOpt algorithm for solving \(\mathbf{F}_{BB}\) and \(\mathbf{F}_{RF}\) can be described as the main algorithm and the inner algorithm, as follows:  
```
Main algorithm: MM-AltOpt algorithm. Input: Hybrid beamforming matrix \(\mathbf{F}_{i}\) initial: \(\mathbf{F}_{RF}^{(n=0)}\in\mathbb{F}\), iteration index \(n=0\), threshold \(\varepsilon_{3}=10^{-3}\), the solution of the objective function of the problem \(P_{1}\) in the \(n\)th iteration is \(\delta^{(n)}\). 1. while \(\left|\delta^{(n)}-\delta^{(n-1)}\right|\geq\varepsilon_{3}\)
2. Based on \(\mathbf{F}_{RF}^{(n)}\), calculate \(\mathbf{F}_{BB}^{(n+1)}\) according to \(\mathbf{F}_{BB}=\left(\mathbf{F}_{RF}^{(n)H}\mathbf{F}_{RF}^{(n)}\right)^{-1}\mathbf{F}_{RF}^ {(n)H}\mathbf{F}\).
3. Based on \(\mathbf{F}_{BB}^{(n+1)}\), calculate \(\mathbf{F}_{RF}^{(n+1)}\) according to the **inner algorithm**.
4. Set \(n=n+1\).
5. end Output:\(\mathbf{F}_{RF}\mathbf{F}_{BB}\), normalize \(\mathbf{F}_{BB}=\frac{\sqrt{\mathbf{F}_{RF}}}{\left\|\mathbf{F}_{RF}\mathbf{F}_{BB}\right\|_{ F}}\mathbf{F}_{BB}\). Inner algorithm: Algorithm for solving the analog beamforming matrix. Input: Hybrid beamforming matrix \(\mathbf{F}\), \(\mathbf{F}_{BB}^{(n)}\), \(\mathbf{F}_{RF}^{(n=0)}\in\mathbb{F}\), iteration index \(q=0\), threshold \(\varepsilon_{4}=10^{-3}\), the solution of the objective function of the problem \(P_{5}\) in the \(q\)th iteration is \(\delta_{1}^{(q)}\). 1. while \(\left|\delta^{(n)}-\delta^{(n-1)}\right|\geq\varepsilon_{4}\)
2. Calculate \(\mathbf{C}^{(q)}=\mathbf{F}_{BB}^{(n)}\mathbf{F}^{H}-\left(\mathbf{F}_{BB}^{(n)}\mathbf{F}_{BB}^{( n)H}-\lambda_{\max}\left(\mathbf{F}_{BB}^{(n)}\mathbf{F}_{BB}^{(n)H}\right)\mathbf{I} \right)\mathbf{F}_{RF}^{(q)H}\).
3. Calculate \(\mathbf{F}_{RF}=e^{-\text{arg}\left(\mathbf{C}^{(q)T}\right)}\).
4. Set \(q=q+1\).
5. end Output:\(\mathbf{F}_{RF}^{(n)}\).
```  
**Algorithm 3**Design algorithm of the digital beamforming matrix and the analog beamforming matrix.