Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace -x with fabs(x) due to odd breaking Linux behavior #7

Merged
merged 1 commit into from
Aug 18, 2021

Conversation

chinandrew
Copy link
Collaborator

Within the erf() function, my code was getting hanging on this statement

    if (x < 0.0) {
	return -erf(-x);
    }

due to -x not being successfully passed into the recursive call (i.e. it was still negative).

Both

    double a;
    if (x < 0.0) {
    a = -1.0*x;
	return -erf(a);
    }

and

    if (x < 0.0) {
	return -erf(fabs(x));
    }

work, as did changing the implementation back to the scipy.special one.

Also noting that the following did not work.

    if (x < 0.0) {
	return -erf(-1.0*x);
    }

This PR implements fabs() approach to fix the issue. It was chosen after discussion with @aki-nishimura for simplicity and to avoid any potential other issues with doing a -1 multiplication.

This problem occurred in the following environments:

  1. Kubuntu 21.04, gcc version Ubuntu 10.3.0-1ubuntu1
  2. Mint 20.1, gcc version Ubuntu 9.3.0-17ubuntu1~20.04 (Mint 20.1 is based on Ubuntu 20.04)

It worked fine for me on windows 10 and all OS's pass on Github Actions, where ubuntu-20.04 is currently the latest supported linux version.

Exact root cause of this issue has not been investigated.

@aki-nishimura aki-nishimura merged commit 710e99c into master Aug 18, 2021
@chinandrew chinandrew deleted the fix-negative-bug branch August 18, 2021 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants