e precoding matrices, we further define a user grouping and power allocation algorithm for NOMA. 2.4 Precoding and User Grouping Algorithm In this section, we first construct a beamforming vector Wn for each beam that can effec- tively reduce or eliminate some interferences. Based on the selected precoding scheme, we further solve the user grouping and power allocation problem, in order to maximize the total system throughput. 2 5G Wireless Networks with Underlaid D2D Communications 2.4.1 Zero-Forcing Beamforming Normally the number of transmit antennas NT should be larger than or equal to the number of receiver antennas NR, i.e. NT NR, SO that the transmitter side will have enough degree of freedom to generate a precoding matrix that can effectively eliminate the inter-user inter- ference. In this chapter, each MBS has N transmit antennas and can generate N beams. Within each beam, K(K > 2) users can be supported by using NOMA. Thus, the total num- ber of receive antennas in this case is N X K, which is larger than N. Existing literatures have observed and addressed this issue. In [167], a coordinated transmit-receive block diag- onalization algorithm is put forward. However, the receive antenna set employs a joint precoding matrix, which requires information exchange among different users and con- sequently adds extra complexity. Here, we consider two zero-forcing precoding methods. The first one aims to minimize the inter-beam interference for CUs, while the second one aims to eliminate the interference from MBS to DUs. 2.4.1.1 First ZF Precoding In this scheme, we first select one user from each beam and then generate the beamform- ing matrix based on N selected users. Specifically, users with the largest channel gain in each beam are selected. The channel gain vector for these N selected CUs is denoted as H = [hu(1,K),hu(2,K) hu(N,K)]- The zero-forcing beamforming vector is calculated based on: (2.15) Thus, I m should lie in the null space of Hn [167]. Here, Hn is defined as (2.16) which consists of downlink