3 ms·
I just wish I could replace my floating point numbers by an arbitrarily more precise version of them (no matter what the cost in terms of performance), in order
by amelius 12y ago
I just wish I could replace my floating point numbers by an arbitrarily more precise version of them (no matter what the cost in terms of performance), in order to simply test the hypothesis that rounding errors are causing, for example, convergence problems.
- ableal 12y agoThat's an interesting idea. It would allow unit tests to check what breaks under different precision settings. It could probably be emulated in C++ with user defined types and overloaded operators. In C one could go the other way - '#define double float' and see if it breaks sooner ...
- amelius 12y agoUnfortunately, in reality it is a lot more complicated than replacing a define or typedef, especially when using external libraries, where some of them are written in e.g. Fortran.
- anon4 12y agoUse GMP (well, mpfr really)? Or I guess you could combine that with interval arithmetic.
- simonbyrne 12y agoI actually do this quite regularly in Julia: it provides a BigFloat type which wraps the MPFR library. Since it has generic methods, you can simply do something like foo(big(x)), and all the internal computations will be done in extended precision, and the result can be compared to foo(x).
- amelius 12y agoDoes this also work with matrix type of operations? For example solving a linear system?
- simonbyrne 12y agoYes, you can define an Array of BigFloats, and most of the linear algebra operations have general purpose fallbacks that work as expected.