We consider diffusion within pores with general shapes in the presence of spatially linear magnetic field profiles. The evolution of local magnetization of the spin bearing particles can be described by the Bloch-Torrey equation. We study the diffusive process in the eigenbasis of the non-Hermitian Bloch-Torrey operator. It is possible to find expressions for some special temporal gradient waveforms employed to sensitize the nuclear magnetic resonance (NMR) signal to diffusion. For more general gradient waveforms, we derive an efficient numerical solution by introducing a novel matrix formalism. Compared to previous methods, this new approach requires a fewer number of eigenfunctions to achieve the same accuracy. This shows that these basis functions are better suited to the problem studied. The new framework could provide new important insights into the fundamentals of diffusion sensitization, which could further the development of the field of NMR.