  We consider a multiple-input multiple-output (MIMO) channel in the presence
of a reconfigurable intelligent surface (RIS). Specifically, our focus is on
analyzing the spatial multiplexing gains in line-of-sight and low-scattering
MIMO channels in the near field. We prove that the channel capacity is achieved
by diagonalizing the end-to-end transmitter-RIS-receiver channel, and applying
the water-filling power allocation to the ordered product of the singular
values of the transmitter-RIS and RIS-receiver channels. The obtained
capacity-achieving solution requires an RIS with a non-diagonal matrix of
reflection coefficients. Under the assumption of nearly-passive RIS, i.e., no
power amplification is needed at the RIS, the water-filling power allocation is
necessary only at the transmitter. We refer to this design of RIS as a linear,
nearly-passive, reconfigurable electromagnetic object (EMO). In addition, we
introduce a closed-form and low-complexity design for RIS, whose matrix of
reflection coefficients is diagonal with unit-modulus entries. The reflection
coefficients are given by the product of two focusing functions: one steering
the RIS-aided signal towards the mid-point of the MIMO transmitter and one
steering the RIS-aided signal towards the mid-point of the MIMO receiver. We
prove that this solution is exact in line-of-sight channels under the paraxial
setup. With the aid of extensive numerical simulations in line-of-sight
(free-space) channels, we show that the proposed approach offers performance
(rate and degrees of freedom) close to that obtained by numerically solving
non-convex optimization problems at a high computational complexity. Also, we
show that it provides performance close to that achieved by the EMO
(non-diagonal RIS) in most of the considered case studies.
