A discrete formalism for the computation of extracellular potentials