We present an efficient implementation of the computation of the coupling matrix arising in time-dependent density functional theory. The two important aspects involved, solution of Poisson's equation and the assembly of the coupling matrix, are investigated in detail and proper approximations are used. Poisson's equation is solved in the reciprocal space and bounded support of the wave functions are exploited in the numerical integration. Experiments show the new implementation is more efficient by an order of magnitude when compared with a standard real-space code. The method is tested to compute optical spectra of realistic systems with hundreds of atoms from first principles. Details of the formalism and implementation are provided and comparisons with a standard real-space code are reported.