runtime optimization for grid approach
added switch for single/double precision in TSD approach