You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dieter Roth (JIRA)" <ji...@apache.org> on 2008/08/29 15:33:44 UTC
[jira] Created: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Result of multiplying and equals for complex numbers is wrong
-------------------------------------------------------------
Key: MATH-221
URL: https://issues.apache.org/jira/browse/MATH-221
Project: Commons Math
Issue Type: Bug
Affects Versions: 1.2
Environment: OS: Debian lenny
IDE: Version: 3.4.0; Build id: I20080617-2000
java.runtime.version=1.6.0_04-b12
java.vendor.url=http://java.sun.com/
Reporter: Dieter Roth
Priority: Minor
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
Mathematoc background: (0,i) * (-1,0i) = (0,-i).
Little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
>
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
>
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
Mathematoc background: (0,i) * (-1,0i) = (0,-i).
Little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
>
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Luc Maisonobe resolved MATH-221.
--------------------------------
Resolution: Fixed
According to IEEE-754 (the standard that specifies double number representation), 0 is a signed value, so there are two different representations: +0 and -0, and there is a specific rule that say these two representations should always compare as equal.
The fact the multiplication returns a real part as -0 is therefore correct behavior. The fact it is not equal to another value where +0 appears was an error in out implementation of the equal method.
The problem has been fixed in the subversion repository (in branch 2.0) as of r690308.
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Eclipse; Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> {code}
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> {code}
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the "equals" should return "true".
> The problem could either be the "multiply" method that gives (-0,-1i) instead of (0,-1i),
> or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
{code}
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
{code}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the "equals" should return "true".
The problem could either be the "multiply" method that gives (-0,-1i) instead of (0,-1i),
or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
{code}
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
{code}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> {code}
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> {code}
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the "equals" should return "true".
> The problem could either be the "multiply" method that gives (-0,-1i) instead of (0,-1i),
> or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
{code}
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
{code}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> {code}
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> {code}
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
>
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
>
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Description:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
was:
Hi.
The bug relates on complex numbers.
The methods "multiply" and "equals" of the class Complex are involved.
mathematic background: (0,i) * (-1,0i) = (0,-i).
little java program + output that shows the bug:
-----------------------------------------------------------------------
import org.apache.commons.math.complex.*;
public class TestProg {
public static void main(String[] args) {
ComplexFormat f = new ComplexFormat();
Complex c1 = new Complex(0,1);
Complex c2 = new Complex(-1,0);
Complex res = c1.multiply(c2);
Complex comp = new Complex(0,-1);
System.out.println("res: "+f.format(res));
System.out.println("comp: "+f.format(comp));
System.out.println("res=comp: "+res.equals(comp));
}
}
-----------------------------------------------------------------------
res: -0 - 1i
comp: 0 - 1i
res=comp: false
-----------------------------------------------------------------------
I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
Or if you think thats right, the equals method has to be modified.
Good Luck
Dieter
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
>
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
>
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
>
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
>
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the problem could be "multiply" method that gives (-0,-1i) instead of (0,-1i).
> Or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (MATH-221) Result of multiplying and equals for
complex numbers is wrong
Posted by "Dieter Roth (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dieter Roth updated MATH-221:
-----------------------------
Environment:
OS: Debian lenny
IDE: Eclipse; Version: 3.4.0; Build id: I20080617-2000
java.runtime.version=1.6.0_04-b12
java.vendor.url=http://java.sun.com/
was:
OS: Debian lenny
IDE: Version: 3.4.0; Build id: I20080617-2000
java.runtime.version=1.6.0_04-b12
java.vendor.url=http://java.sun.com/
> Result of multiplying and equals for complex numbers is wrong
> -------------------------------------------------------------
>
> Key: MATH-221
> URL: https://issues.apache.org/jira/browse/MATH-221
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: OS: Debian lenny
> IDE: Eclipse; Version: 3.4.0; Build id: I20080617-2000
> java.runtime.version=1.6.0_04-b12
> java.vendor.url=http://java.sun.com/
> Reporter: Dieter Roth
> Priority: Minor
>
> Hi.
> The bug relates on complex numbers.
> The methods "multiply" and "equals" of the class Complex are involved.
> mathematic background: (0,i) * (-1,0i) = (0,-i).
> little java program + output that shows the bug:
> -----------------------------------------------------------------------
> {code}
> import org.apache.commons.math.complex.*;
> public class TestProg {
> public static void main(String[] args) {
> ComplexFormat f = new ComplexFormat();
> Complex c1 = new Complex(0,1);
> Complex c2 = new Complex(-1,0);
> Complex res = c1.multiply(c2);
> Complex comp = new Complex(0,-1);
> System.out.println("res: "+f.format(res));
> System.out.println("comp: "+f.format(comp));
> System.out.println("res=comp: "+res.equals(comp));
> }
> }
> {code}
> -----------------------------------------------------------------------
> res: -0 - 1i
> comp: 0 - 1i
> res=comp: false
> -----------------------------------------------------------------------
> I think the "equals" should return "true".
> The problem could either be the "multiply" method that gives (-0,-1i) instead of (0,-1i),
> or if you think thats right, the equals method has to be modified.
> Good Luck
> Dieter
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.