Precompute the Q15 damping decay factor for a power-of-two exponent. The damping update is `f_new = f * (1 - 1/2^damp)`, equivalent to the arithmetic-shift form `f -= f >> damp` (modulo 1-LSB rounding). Caching it as Q15 here lets the kernel use a single Q15 multiply per cell and opens the door to non-power-of-two damping if the public API ever needs it (today it's still int-only). damp <= 0 means
| 47 | // opens the door to non-power-of-two damping if the public API ever |
| 48 | // needs it (today it's still int-only). damp <= 0 means no decay. |
| 49 | i16 compute_damp_decay_q15(int damp) FL_NOEXCEPT { |
| 50 | if (damp <= 0) return INT16_POS; // ~1.0 — no decay |
| 51 | const float decay = 1.0f - 1.0f / static_cast<float>(1 << damp); |
| 52 | return float_to_fixed(decay); |
| 53 | } |
| 54 | } // namespace wave_detail |
| 55 | |
| 56 | WaveSimulation1D_Real::WaveSimulation1D_Real(u32 len, float courantSq, |
no test coverage detected