From 6ed93668db260590dab33e0286a07d8777738464 Mon Sep 17 00:00:00 2001
From: Michael Sarahan <msarahan@gmail.com>
Date: Tue, 12 Jun 2018 09:11:09 -0500
Subject: [PATCH 13/15] Remove np.invsqrt

---
 numpy/core/code_generators/generate_umath.py   |  9 ---------
 numpy/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 ++----------
 numpy/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 94b2a13..ea52f3c 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -782,15 +782,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 39b8827..ece0b9c 100644
--- a/numpy/core/code_generators/ufunc_docstrings.py
+++ b/numpy/core/code_generators/ufunc_docstrings.py
@@ -3443,34 +3443,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 91ea82e..dd4876d 100644
--- a/numpy/core/include/numpy/npy_math.h
+++ b/numpy/core/include/numpy/npy_math.h
@@ -132,7 +132,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);
@@ -239,7 +238,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);
@@ -284,7 +282,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);
@@ -442,7 +439,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);
@@ -472,7 +468,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);
@@ -503,7 +498,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 9f93b00..7cb9680 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -107,7 +107,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"]
diff --git a/numpy/core/src/npymath/npy_math_complex.c.src b/numpy/core/src/npymath/npy_math_complex.c.src
index e1de1e1..d2fae29 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.
@@ -1807,9 +1798,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 6f919f1..127d3df 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#
  */
 
@@ -473,19 +473,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 45d80ce..af2dca1 100644
--- a/numpy/core/src/umath/funcs.inc.src
+++ b/numpy/core/src/umath/funcs.inc.src
@@ -271,13 +271,6 @@ nc_sqrt@c@(@ctype@ *x, @ctype@ *r)
 }
 
 static void
-nc_invsqrt@c@(@ctype@ *x, @ctype@ *r)
-{
-    *r = npy_cinvsqrt@c@(*x);
-    return;
-}
-
-static void
 nc_rint@c@(@ctype@ *x, @ctype@ *r)
 {
     r->real = npy_rint@c@(x->real);
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 0cc2823..7839675 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1743,34 +1743,6 @@ NPY_NO_EXPORT void
  * 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#
- *  #TYPE = FLOAT, DOUBLE#
  *  #A = F, #
  *  #c = s, d#
  *  #scalarf = npy_expf, npy_exp#
diff --git a/numpy/core/src/umath/loops.h.src b/numpy/core/src/umath/loops.h.src
index ecc2076..fe81360 100644
--- a/numpy/core/src/umath/loops.h.src
+++ b/numpy/core/src/umath/loops.h.src
@@ -161,7 +161,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.7.4

