Generic linear optics simulator