beacon-biosignals / Onda.jl

A Julia package for high-throughput manipulation of structured signal data across arbitrary domain-specific encodings, file formats and storage layers
Other
67 stars 5 forks source link

Use `muladd` / `fma` in encoding/decoding? #146

Closed ericphanson closed 7 months ago

ericphanson commented 10 months ago

E.g. right now we use

    f = x -> sample_resolution_in_unit * x + sample_offset_in_unit

We could use instead f = x -> fma(sample_resolution_in_unit, x, sample_offset_in_unit) (or likely better, muladd, if we were OK with only using fma when available on the hardware, rather than forcing software emulation in that case.)

This would be faster and more accurate, since it avoids the intermediate rounding. Julia will not perform this optimization automatically (at least without @fastmath or such) since the compiler isn't allowed to change the results.

jrevels commented 9 months ago

Open PR?