Sync validation logic of full Complex division with division by double
authorAndrii Kurdiumov <kant2002@gmail.com>
Sat, 21 Jul 2018 08:40:38 +0000 (11:40 +0300)
committerTanner Gooding <tagoo@outlook.com>
Tue, 11 Sep 2018 14:27:21 +0000 (07:27 -0700)
For validation purposes Complex / double translated to Complex / Complex
to pass tests with existing test data

Commit migrated from https://github.com/dotnet/corefx/commit/7c486d62915bb84ad0e5c7f5a89e927cb5c5ae9c

src/libraries/System.Runtime.Numerics/tests/ComplexTests.cs

index f0a69a9..6063a9b 100644 (file)
@@ -782,8 +782,18 @@ namespace System.Numerics.Tests
             var dividend = new Complex(realLeft, imaginaryLeft);
             var divisor = realRight;
 
-            double expectedReal = dividend.Real / divisor;
-            double expectedImaginary = dividend.Imaginary / divisor;
+            Complex expected = dividend * Complex.Conjugate(new Complex(realRight, 0.0));
+            double expectedReal = expected.Real;
+            double expectedImaginary = expected.Imaginary;
+
+            if (!double.IsInfinity(expectedReal))
+            {
+                expectedReal = expectedReal / (divisor.Magnitude * divisor.Magnitude);
+            }
+            if (!double.IsInfinity(expectedImaginary))
+            {
+                expectedImaginary = expectedImaginary / (divisor.Magnitude * divisor.Magnitude);
+            }
 
             // Operator
             Complex result = dividend / divisor;