commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dieter Roth (JIRA)" <>
Subject [jira] Created: (MATH-221) Result of multiplying and equals for complex numbers is wrong
Date Fri, 29 Aug 2008 13:33:44 GMT
Result of multiplying and equals for complex numbers is wrong

                 Key: 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

            Reporter: Dieter Roth
            Priority: Minor


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

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message