You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2019/10/03 14:54:00 UTC

[jira] [Created] (NUMBERS-137) Supicious special case in "log"

Gilles Sadowski created NUMBERS-137:
---------------------------------------

             Summary: Supicious special case in "log"
                 Key: NUMBERS-137
                 URL: https://issues.apache.org/jira/browse/NUMBERS-137
             Project: Commons Numbers
          Issue Type: Bug
          Components: complex
            Reporter: Gilles Sadowski
             Fix For: 1.0


In the implementation (copied below), two special cases return the same value.
If intended, the two conditions should be grouped.

{code}
    public Complex log() {
        if (real == Double.POSITIVE_INFINITY &&
            imaginary == Double.POSITIVE_INFINITY) {
            return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
        } else if (real == Double.POSITIVE_INFINITY &&
                   Double.isNaN(imaginary)) {
            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
        } else if (Double.isNaN(real) &&
                   imaginary == Double.POSITIVE_INFINITY) {
            return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
        }
        return new Complex(Math.log(abs()),
                           Math.atan2(imaginary, real));
    }
{code}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)