def ndtri(self,y0): out = cp.zeros(y0.shape) cond1 = y0 == 0.0 cond2 = y0 == 1.0 if cp.any(cond1) == True: y0[cond1] = -cp.inf if cp.any(cond2) == True: y0[cond2] = cp.inf code = cp.ones(y0.shape, dtype=bool) cond3 = y0 > (1.0 - 0.13533528323661269189) if cp.any(cond3) == True: y0[cond3] = 1.0 - y0[cond3] code[cond3] = 0 cond4 = y0 > 0.13533528323661269189 cond5 = y0 <= 0.13533528323661269189 x = cp.sqrt(-2.0 * cp.log(y0)) cond6 = (x < 8.0) & cond5 cond7 = (x >= 8.0) & cond5 x0 = x - cp.log(x) / x z = 1.0 / x if cp.any(cond6) == True: x1 = x0[cond6] - z[cond6] * cp.polyval(P1,z[cond6]) / cp.polyval(Q1, z[cond6]) out[cond6] = x1 if cp.any(cond7) == True: x2 = x0[cond7] - z[cond7] * cp.polyval(P2, z[cond7]) / cp.polyval(Q2, z[cond7]) out[cond7] = x2 out[code] = -out[code] if cp.any(cond4) == True: y = y0[cond4] y = y - 0.5 y2 = y * y x = y + y * (y2 * cp.polyval(P0,y2) / cp.polyval(Q0, y2)) x = x * s2pi out[cond4] = x return out
def test_polyval_poly1d_values(self, dtype): a = testing.shaped_arange((5, ), cupy, dtype) b = testing.shaped_arange((3, ), cupy, dtype) b = cupy.poly1d(b) with pytest.raises(NotImplementedError): cupy.polyval(a, b)
def test_polyval_ndim_values(self, dtype): a = testing.shaped_arange((2, ), cupy, dtype) b = testing.shaped_arange((2, 4), cupy, dtype) with pytest.raises(NotImplementedError): cupy.polyval(a, b)
def test_polyval_poly1d_values(self, dtype): a = testing.shaped_arange((5, ), cupy, dtype) b = testing.shaped_arange((3, ), cupy, dtype) b = cupy.poly1d(b) return cupy.polyval(a, b)
def test_polyval_ndim_values(self, dtype): a = testing.shaped_arange((10, ), cupy, dtype) b = testing.shaped_arange((2, 4), cupy, dtype) return cupy.polyval(a, b)