I use Mathematica mostly for numerical calculations, and sometimes the performance of numerical calculations can be greatly improved if the high-precision arithmetic can be switched off by
Developer`SetSystemOptions["CatchMachineUnderflow" -> False]
As suggested in this post, when one want to switch off the high-precision arithmetic, one can usually do something like
With[{cmuopt = SystemOptions["CatchMachineUnderflow"]},
Internal`WithLocalSettings[
SetSystemOptions["CatchMachineUnderflow" -> False],
(* put your own code here; for example: *)
SetSystemOptions[cmuopt]
]
]
Consider now I have a package that I want to run at the machine precision. This is fine for one function, but for a package containing many functions, adding those pieces of code to each function would be a pain. So I'm wondering whether there are ways to switch off the high precision at package wise, for all the functions in the package. Or in other words, can we change the "CatchMachineUnderflow" settings by context?
f[x_]:=ignoreUnderflow[Exp[-x]]
whereignoreUnderflow
would be said wrapper. That would be straightforward to implement, easy to read/understand and save you almost completely from any redundancy without making your functions rely on some hidden obscure mechanisms... $\endgroup$ – Albert Retey Jan 10 '15 at 16:57