Efficient numerical approaches for ab-initio linear and nonlinear optics