[
https://issues.apache.org/jira/browse/MATH-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gunel Jahangirova updated MATH-1414:
------------------------------------
Description:
In class Complex method reciprocal() returns INF only if the real and imaginary
parts are exactly equal to 0.0. In case of real and imaginary parts are double
numbers very close to 0.0, it does not hold. For example, if we run this code
Complex complex0 = new Complex((-2.44242319E-315));
Complex complex1 = complex0.reciprocal();
the value of complex1.getReal() will be -Infinity and the value of
complex1.getImaginary() will be NaN, instead of complex1 being equal to INF.
I think the code in the method
if (real == 0.0 && imaginary == 0.0) {
return INF;
}
should be replaced by the equality check with some tolerance (0.01 in this
case):
if (equals(this, ZERO, 0.01)) {
return INF;
}
was:
In class Complex the method reciprocal() returns INF only if the real and
imaginary parts are equal exactly to 0.0. In case of real and imaginary parts,
being double numbers very close to 0.0, it does not hold. For example, if we
run this code
Complex complex0 = new Complex((-2.44242319E-315));
Complex complex1 = complex0.reciprocal();
the value of complex1.getReal() will be -Infinity and the value of
complex1.getImaginary() will be NaN, instead of complex1 being equal to INF.
I think the code in the method
if (real == 0.0 && imaginary == 0.0) {
return INF;
}
should be replaced by the equality check with some tolerance (0.01 in this
case):
if (equals(this, ZERO, 0.01)) {
return INF;
}
> Method reciprocal() in Complex for complex numbers with parts very close to
> 0.0
> -------------------------------------------------------------------------------
>
> Key: MATH-1414
> URL: https://issues.apache.org/jira/browse/MATH-1414
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Gunel Jahangirova
> Priority: Minor
>
> In class Complex method reciprocal() returns INF only if the real and
> imaginary parts are exactly equal to 0.0. In case of real and imaginary parts
> are double numbers very close to 0.0, it does not hold. For example, if we
> run this code
> Complex complex0 = new Complex((-2.44242319E-315));
> Complex complex1 = complex0.reciprocal();
> the value of complex1.getReal() will be -Infinity and the value of
> complex1.getImaginary() will be NaN, instead of complex1 being equal to INF.
> I think the code in the method
> if (real == 0.0 && imaginary == 0.0) {
> return INF;
> }
> should be replaced by the equality check with some tolerance (0.01 in this
> case):
> if (equals(this, ZERO, 0.01)) {
> return INF;
> }
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)