Skip to content

Commit

Permalink
Bugfix in complex division - to allow increment of denominator to pre…
Browse files Browse the repository at this point in the history
…vent division by zero!
  • Loading branch information
hkbinaurics committed Mar 7, 2024
1 parent d36ee36 commit ffd37dd
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ jvxDataCplx JVX_STATIC_INLINE jvx_complex_sub_i(jvxDataCplx in1, jvxDataCplx in2
}

// https://mathworld.wolfram.com/ComplexDivision.html
jvxDataCplx JVX_STATIC_INLINE jvx_complex_div_i(jvxDataCplx in1, jvxDataCplx in2)
jvxDataCplx JVX_STATIC_INLINE jvx_complex_div_i(jvxDataCplx in1, jvxDataCplx in2, jvxData epsAdd)
{
jvxDataCplx out;
jvxData den = in2.re * in2.re + in2.im * in2.im;
jvxData den = in2.re * in2.re + in2.im * in2.im + epsAdd;
out.re = (in1.re * in2.re + in1.im * in2.im) / den;
out.im = (in1.im * in2.re - in1.re * in2.im) / den;
return out;
Expand Down

0 comments on commit ffd37dd

Please sign in to comment.