Efficient modal-expansion discrete-dipole approximation: Application to the simulation of optical extinction and electron energy-loss spectroscopies