Skip to content

Commit

Permalink
Add a test for 0.0 + 0.0*i in complex_volume_log; now it returns -INF…
Browse files Browse the repository at this point in the history
…INITY + NAN*i.
  • Loading branch information
culler committed Dec 9, 2023
1 parent 8914cf5 commit 79444b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/addl_code/dilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ Complex complex_volume_dilog(Complex z)
Complex complex_volume_log(Complex z)
{
Complex result;
if (z.real == 0.0 && z.imag == 0.0) {
result.real = -INFINITY;
result.imag = NAN;
return result;
}
result.real = 0.5 * log(z.real * z.real + z.imag * z.imag);
// We explicitly make a special case for the negative real axis!
// This is because in the implementation of double, zero is signed,
Expand Down

0 comments on commit 79444b3

Please sign in to comment.