From 83e2b25ecad70d8a24b85f4935ce2b86aa59ca2d Mon Sep 17 00:00:00 2001
From: Stuart Archibald <redacted>
Date: Fri, 22 Feb 2019 11:19:29 +0000
Subject: [PATCH 17/21] Remove np.invsqrt

---
 numpy/core/code_generators/generate_umath.py  |  9 ------
 .../core/code_generators/ufunc_docstrings.py  | 28 -------------------
 numpy/core/include/numpy/npy_math.h           |  6 ----
 numpy/core/setup_common.py                    |  2 +-
 numpy/core/src/npymath/npy_math_complex.c.src | 13 ++-------
 .../core/src/npymath/npy_math_internal.h.src  | 17 ++---------
 numpy/core/src/umath/funcs.inc.src            |  7 -----
 numpy/core/src/umath/loops.c.src              | 28 -------------------
 numpy/core/src/umath/loops.h.src              |  2 +-
 9 files changed, 6 insertions(+), 106 deletions(-)

diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index 82550ffb8..1af1b3320 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -803,15 +803,6 @@ defdict = {
           TD(inexact, f='sqrt', astype={'e':'f'}),
           TD(P, f='sqrt'),
           ),
-'invsqrt':
-    Ufunc(1, 1, None,
-          docstrings.get('numpy.core.umath.invsqrt'),
-          None,
-          TD('e', f='invsqrt', astype={'e':'f'}),
-          TD(inexactvec),
-          TD(inexact, f='invsqrt', astype={'e':'f'}),
-          TD(P, f='invsqrt'),
-          ),
 'cbrt':
     Ufunc(1, 1, None,
           docstrings.get('numpy.core.umath.cbrt'),
diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py
index 19605a069..f6ab39848 100644
--- a/numpy/core/code_generators/ufunc_docstrings.py
+++ b/numpy/core/code_generators/ufunc_docstrings.py
@@ -3612,34 +3612,6 @@ add_newdoc('numpy.core.umath', 'sqrt',
 
     """)
 
-add_newdoc('numpy.core.umath', 'invsqrt',
-    """
-    Return the positive 1/square-root of an array, element-wise.
-
-    Parameters
-    ----------
-    x : array_like
-        The values whose 1/square-roots are required.
-    $PARAMS
-
-    Returns
-    -------
-    y : ndarray
-        An array of the same shape as `x`, containing the positive
-        1/square-root of each element in `x`.  If any element in `x` is
-        complex, a complex array is returned (and the 1/square-roots of
-        negative reals are calculated).  If all of the elements in `x`
-        are real, so is `y`, with negative elements returning ``nan``.
-        If `out` was provided, `y` is a reference to it.
-        $OUT_SCALAR_1
-
-    Examples
-    --------
-    >>> np.invsqrt([1,4,9])
-    array([ 1.,  0.5,  0.33333])
-
-    """)
-
 add_newdoc('numpy.core.umath', 'cbrt',
     """
     Return the cube-root of an array, element-wise.
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h
index 69693cfa9..31d647f55 100644
--- a/numpy/core/include/numpy/npy_math.h
+++ b/numpy/core/include/numpy/npy_math.h
@@ -181,7 +181,6 @@ NPY_INPLACE double npy_log10(double x);
 NPY_INPLACE double npy_erf(double x);
 NPY_INPLACE double npy_exp(double x);
 NPY_INPLACE double npy_sqrt(double x);
-NPY_INPLACE double npy_invsqrt(double x);
 NPY_INPLACE double npy_cbrt(double x);
 
 NPY_INPLACE double npy_fabs(double x);
@@ -290,7 +289,6 @@ NPY_INPLACE float npy_ceilf(float x);
 NPY_INPLACE float npy_rintf(float x);
 NPY_INPLACE float npy_truncf(float x);
 NPY_INPLACE float npy_sqrtf(float x);
-NPY_INPLACE float npy_invsqrtf(float x);
 NPY_INPLACE float npy_cbrtf(float x);
 NPY_INPLACE float npy_log10f(float x);
 NPY_INPLACE float npy_logf(float x);
@@ -335,7 +333,6 @@ NPY_INPLACE npy_longdouble npy_ceill(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_rintl(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_truncl(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_sqrtl(npy_longdouble x);
-NPY_INPLACE npy_longdouble npy_invsqrtl(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_cbrtl(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_log10l(npy_longdouble x);
 NPY_INPLACE npy_longdouble npy_logl(npy_longdouble x);
@@ -493,7 +490,6 @@ npy_cdouble npy_clog(npy_cdouble z);
 npy_cdouble npy_cpow(npy_cdouble x, npy_cdouble y);
 
 npy_cdouble npy_csqrt(npy_cdouble z);
-npy_cdouble npy_cinvsqrt(npy_cdouble z);
 
 npy_cdouble npy_ccos(npy_cdouble z);
 npy_cdouble npy_csin(npy_cdouble z);
@@ -523,7 +519,6 @@ npy_cfloat npy_clogf(npy_cfloat z);
 npy_cfloat npy_cpowf(npy_cfloat x, npy_cfloat y);
 
 npy_cfloat npy_csqrtf(npy_cfloat z);
-npy_cfloat npy_cinvsqrtf(npy_cfloat z);
 
 npy_cfloat npy_ccosf(npy_cfloat z);
 npy_cfloat npy_csinf(npy_cfloat z);
@@ -554,7 +549,6 @@ npy_clongdouble npy_clogl(npy_clongdouble z);
 npy_clongdouble npy_cpowl(npy_clongdouble x, npy_clongdouble y);
 
 npy_clongdouble npy_csqrtl(npy_clongdouble z);
-npy_clongdouble npy_cinvsqrtl(npy_clongdouble z);
 
 npy_clongdouble npy_ccosl(npy_clongdouble z);
 npy_clongdouble npy_csinl(npy_clongdouble z);
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index f7f509765..7c18a2be5 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -108,7 +108,7 @@ MANDATORY_FUNCS = ["sin", "cos", "tan", "sinh", "cosh", "tanh", "fabs",
 # Standard functions which may not be available and for which we have a
 # replacement implementation. Note that some of these are C99 functions.
 OPTIONAL_STDFUNCS = ["expm1", "log1p", "acosh", "asinh", "atanh",
-        "rint", "trunc", "exp2", "log2", "invsqrt", "hypot", "atan2", "pow",
+        "rint", "trunc", "exp2", "log2", "hypot", "atan2", "pow",
         "copysign", "nextafter", "ftello", "fseeko",
         "strtoll", "strtoull", "cbrt", "strtold_l", "fallocate",
         "backtrace", "madvise"]
diff --git a/numpy/core/src/npymath/npy_math_complex.c.src b/numpy/core/src/npymath/npy_math_complex.c.src
index da0d4af17..208d001e4 100644
--- a/numpy/core/src/npymath/npy_math_complex.c.src
+++ b/numpy/core/src/npymath/npy_math_complex.c.src
@@ -455,15 +455,6 @@ npy_csqrt@c@(@ctype@ z)
 #undef THRESH
 #endif
 
-#ifndef HAVE_CINVSQRT@C@
-
-@ctype@
-npy_cinvsqrt@c@(@ctype@ z)
-{
-    return z;
-}
-#endif
-
 /*
  * Always use this function because of the multiplication for small
  * integer powers, but in the body use cpow if it is available.
@@ -1822,9 +1813,9 @@ npy_@kind@@c@(@ctype@ z)
 /**end repeat1**/
 
 /**begin repeat1
- * #kind = cerf,cexp,clog,csqrt,cinvsqrt,ccos,csin,ctan,ccosh,csinh,ctanh,
+ * #kind = cerf,cexp,clog,csqrt,ccos,csin,ctan,ccosh,csinh,ctanh,
  *         cacos,casin,catan,cacosh,casinh,catanh#
- * #KIND = CERF,CEXP,CLOG,CSQRT,CINVSQRT,CCOS,CSIN,CTAN,CCOSH,CSINH,CTANH,
+ * #KIND = CERF,CEXP,CLOG,CSQRT,CCOS,CSIN,CTAN,CCOSH,CSINH,CTANH,
  *         CACOS,CASIN,CATAN,CACOSH,CASINH,CATANH#
  */
 #ifdef HAVE_@KIND@@C@
diff --git a/numpy/core/src/npymath/npy_math_internal.h.src b/numpy/core/src/npymath/npy_math_internal.h.src
index 2ced6a7d1..737758388 100644
--- a/numpy/core/src/npymath/npy_math_internal.h.src
+++ b/numpy/core/src/npymath/npy_math_internal.h.src
@@ -379,9 +379,9 @@ NPY_INPLACE double npy_log2(double x)
  */
 
 /**begin repeat1
- * #kind = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,invsqrt,log10,
+ * #kind = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,log10,
  *         log,erf,exp,expm1,asin,acos,atan,asinh,acosh,atanh,log1p,exp2,log2#
- * #KIND = SIN,COS,TAN,SINH,COSH,TANH,FABS,FLOOR,CEIL,RINT,TRUNC,SQRT,INVSQRT,LOG10,
+ * #KIND = SIN,COS,TAN,SINH,COSH,TANH,FABS,FLOOR,CEIL,RINT,TRUNC,SQRT,LOG10,
  *         LOG,ERF,EXP,EXPM1,ASIN,ACOS,ATAN,ASINH,ACOSH,ATANH,LOG1P,EXP2,LOG2#
  */
 
@@ -472,19 +472,6 @@ NPY_INPLACE @type@ npy_@kind@@c@(@type@ x)
 
 /**end repeat1**/
 
-/**begin repeat1
- * #kind = invsqrt#
- * #KIND = INVSQRT#
- */
-#ifdef HAVE_@KIND@@C@
-NPY_INLINE @type@ npy_@kind@@c@(@type@ x)
-{
-    return 1/sqrt@c@(x);
-}
-#endif
-
-/**end repeat1**/
-
 /**begin repeat1
  * #kind = atan2,hypot,pow,fmod,copysign#
  * #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src
index b04c63e47..d5eeaedfb 100644
--- a/numpy/core/src/umath/funcs.inc.src
+++ b/numpy/core/src/umath/funcs.inc.src
@@ -314,13 +314,6 @@ nc_sqrt@c@(@ctype@ *x, @ctype@ *r)
     return;
 }
 
-static void
-nc_invsqrt@c@(@ctype@ *x, @ctype@ *r)
-{
-    *r = npy_cinvsqrt@c@(*x);
-    return;
-}
-
 static void
 nc_rint@c@(@ctype@ *x, @ctype@ *r)
 {
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 348033526..4fccd71ab 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1667,34 +1667,6 @@ NPY_NO_EXPORT void
 
 /**end repeat**/
 
-/**begin repeat
- * Float types
- *  #type = npy_float, npy_double#
- *  #TYPE = FLOAT, DOUBLE#
- *  #c = s, d#
- *  #scalarf = npy_invsqrtf, npy_invsqrt#
- */
-
-NPY_NO_EXPORT void
-@TYPE@_invsqrt(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
-{
-    if(IS_UNARY_CONT(@type@, @type@) &&
-           dimensions[0] > VML_TRANSCEDENTAL_THRESHOLD &&
-           DISJOINT_OR_SAME(args[0], args[1], dimensions[0], sizeof(@type@)) ) {
-        CHUNKED_VML_CALL2(v@c@InvSqrt, dimensions[0], @type@, args[0], args[1]);
-        /* v@c@InvSqrt(dimensions[0], (@type@*) args[0], (@type@*) args[1]); */
-    } else {
-        UNARY_LOOP_DISPATCH(
-            DISJOINT_OR_SAME(args[0], args[1], dimensions[0], sizeof(@type@))
-            ,
-            const @type@ in1 = *(@type@ *)ip1;
-            *(@type@ *)op1 = @scalarf@(in1);
-	)
-    }
-}
-
-/**end repeat**/
-
 /**begin repeat
  * Float types
  *  #type = npy_float, npy_double#
diff --git a/numpy/core/src/umath/loops.h.src b/numpy/core/src/umath/loops.h.src
index 8079512b3..3f8b6c729 100644
--- a/numpy/core/src/umath/loops.h.src
+++ b/numpy/core/src/umath/loops.h.src
@@ -175,7 +175,7 @@ NPY_NO_EXPORT void
  */
 
 /**begin repeat1
- * #func = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,invsqrt,log10,log,erf,
+ * #func = sin,cos,tan,sinh,cosh,tanh,fabs,floor,ceil,rint,trunc,sqrt,log10,log,erf,
  *         exp,expm1,arcsin,arccos,arctan,arcsinh,arccosh,arctanh,log1p,exp2,log2,cbrt#
  */
 NPY_NO_EXPORT void
-- 
2.20.1

