Diffusion in porous media A geometrical confinement considerably affects the diffusive motion of the nuclei and the consequent signal attenuation under inhomogeneous magnetic fields. In the tutorial lecture, we focus on theoretical and numerical aspects of resticted diffusion in NMR. Starting from the classical Bloch-Torrey equation, we obtain the free induction decay (FID) and the spin-echo or gradient-echo signal in a compact matrix form. Each attenuation mechanism (restricted diffusion, gradient dephasing, surface or bulk relaxation) is represented by a matrix which is constructed from the Laplace operator eigenbasis and thus depending only on the geometry of the confinement. In turn, the physical parameters (free diffusion coefficient, gradient intensity, surface or bulk relaxivity) characterize the "strengths" of the underlying attenuation mechanisms and naturally appear as coefficients in front of these matrices. Once the Laplacian eigenfunctions for a given confinement are found (analytically or numerically), further computation of the macroscopic signal is more accurate and much faster than by using conventional simulation methods. The matrix technique is actually a simple numerical tool to deal with arbitrary gradient waveforms, including simple or stimulated, single or multiple spin echoes. We illustrate its efficiency by considering restricted diffusion in simple domains: a slab, a cylinder, and a sphere. Classical and recent theoretical advances achieved by using Laplacian eigenfunctions are overviewed.