Banded emulated double precision#
Compute
1/3withaether::banded::BandedRealand compare it to the nativedoubleresult.
Time: ~2 min · Runs on: CPU · You need: Banded/emulated real arithmetic
running on: cpu
aether::banded::BandedReal emulates double precision using float
maths – see Banded/emulated real arithmetic
for how. Useful on a GPU with slow or missing FP64 hardware:
print(run_cpp(r"""
using aether::banded::BandedReal;
BandedReal a = BandedReal::fromDouble(1.0);
BandedReal b = BandedReal::fromDouble(3.0);
BandedReal q = a / b;
double banded_result = q.toDouble();
double native_result = 1.0 / 3.0;
std::printf("banded 1/3 = %.17g\n", banded_result);
std::printf("native 1/3 = %.17g\n", native_result);
std::printf("difference = %.3e\n", banded_result - native_result);
""", includes=("<aether/banded/banded.h>",)))
banded 1/3 = 0.33333333333333331
native 1/3 = 0.33333333333333331
difference = 0.000e+00
BandedReal never implicitly converts to double – fromDouble/toDouble are the only crossing points, by design.