def test_compute_M_04(self): gld = 0.00000000000000E+00 + 0.00000000000000E+00j k = 16.0 p_on_element = True pyx = iops_pyx.m_2d(k, self.p_on, self.a, self.b, p_on_element) self.assertAlmostEqual(pyx, gld) cpp = iops_cpp.m_2d(k, self.p_on, self.a, self.b, p_on_element) self.assertAlmostEqual(cpp, gld) sci = iops_sci.m_2d(k, self.p_on, self.a, self.b, p_on_element) self.assertAlmostEqual(sci, gld, 5)
def test_compute_M_02(self): k = 10.0 p = np.array([0.5, 0.75], dtype=np.float32) a = np.array([0.0, 0.00], dtype=np.float32) b = np.array([0.0, 0.10], dtype=np.float32) pOnElement = False zP = iops_pyx.m_2d(k, p, a, b, pOnElement) zC = iops_cpp.m_2d(k, p, a, b, pOnElement) self.assertAlmostEqual(zP, zC) zS = iops_sci.m_2d(k, p, a, b, pOnElement) self.assertAlmostEqual(zP, zS)
def test_compute_M_04(self): k = 10.0 p = np.array([0.0, 0.05], dtype=np.float32) a = np.array([0.0, 0.00], dtype=np.float32) b = np.array([0.0, 0.10], dtype=np.float32) pOnElement = True zP = iops_pyx.m_2d(k, p, a, b, pOnElement) zC = iops_cpp.m_2d(k, p, a, b, pOnElement) self.assertAlmostEqual(zP, zC) zS = iops_sci.m_2d(k, p, a, b, pOnElement) # The following agree (despite same implementation) # because expected result is 0. self.assertAlmostEqual(zP, zS)
def test_compute_M_02(self): gld = -0.29596284015305E+00 - 0.65862830497453E-01j k = 16.0 p_on_element = False pyx = iops_pyx.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(pyx, gld, 6) cpp = iops_cpp.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(cpp, gld, 6) sci = iops_sci.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(cpp, gld, 6) sci = iops_sci.m_2d_off(k, self.p_off, self.a, self.b) self.assertAlmostEqual(sci, gld, 6) sci = iops_sci.m_2d_off(k, self.p_off, self.a, self.b) self.assertAlmostEqual(sci, gld, 6)
def test_compute_M_01(self): gld = -.43635102946856E-01 + 0.00000000000000E+00j k = 0.0 p_on_element = False pyx = iops_pyx.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(pyx, gld) cpp = iops_cpp.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(cpp, gld) cpp = iops_cpp.m_2d_off_k0(self.p_off, self.a, self.b) self.assertAlmostEqual(cpp, gld) sci = iops_sci.m_2d(k, self.p_off, self.a, self.b, p_on_element) self.assertAlmostEqual(sci, gld) sci = iops_sci.m_2d_off_k0(self.p_off, self.a, self.b) self.assertAlmostEqual(sci, gld)
def test_compute_M_01(self): k = 0.0 p = np.array([0.5, 0.75], dtype=np.float32) a = np.array([0.0, 0.00], dtype=np.float32) b = np.array([0.0, 0.10], dtype=np.float32) pOnElement = False zP = iops_pyx.m_2d(k, p, a, b, pOnElement) zC = iops_cpp.m_2d(k, p, a, b, pOnElement) self.assertAlmostEqual(zP, zC) zS = iops_sci.m_2d(k, p, a, b, pOnElement) # Todo: Currently produces zP == -zS. Need to determine, # if the sci implementation or the old python implementation # is right. In terms of code the sci implementation is # a more straight forward translation of the formulae in # the thesis. self.assertAlmostEqual(zP, zS)