Generated by Cython 3.0.11

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

Raw output: fast_lazy_gaussian.c

    +001: # cython: language_level=3

      __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_7) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

     002: # cython: profile=True

     003:

     004: import cython

    +005: import numpy as np

      __pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_7) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

     006: from libc.math cimport frexp, floor

     007: cimport numpy as np

     008: cimport scipy.special.cython_special

    +009: np.import_array()

      __pyx_t_9 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 9, __pyx_L1_error)

    +010: ctypedef unsigned long long int uint64

    typedef unsigned PY_LONG_LONG __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64;

     011: ctypedef unsigned int uint

     012:

     013: @cython.boundscheck(False)

    +014: cpdef hash_int_c(uint64[:] vals):

    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    static PyObject *__pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(__Pyx_memviewslice __pyx_v_vals, CYTHON_UNUSED int __pyx_skip_dispatch) {
      Py_ssize_t __pyx_v_N;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint __pyx_v_shift1;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint __pyx_v_shift2;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint __pyx_v_shift3;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_mult1;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_mult2;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_add1;
      int __pyx_v_i;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_r;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__11)
      __Pyx_TraceCall("hash_int_c", __pyx_f[0], 14, 0, __PYX_ERR(0, 14, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.hash_int_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    PyDoc_STRVAR(__pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c, "Use simple hashing for generating random numbers from indices\n    deterministically. See\n    https://stackoverflow.com/questions/664014/what-integer-hash-function-are-good-that-accepts-an-integer-hash-key\n    ");
    static PyMethodDef __pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c = {"hash_int_c", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c};
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ) {
      __Pyx_memviewslice __pyx_v_vals = { 0, 0, { 0 }, { 0 }, { 0 } };
      #if !CYTHON_METH_FASTCALL
      CYTHON_UNUSED Py_ssize_t __pyx_nargs;
      #endif
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("hash_int_c (wrapper)", 0);
      #if !CYTHON_METH_FASTCALL
      #if CYTHON_ASSUME_SAFE_MACROS
      __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      #else
      __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
      #endif
      #endif
      __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
      {
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_vals,0};
      PyObject* values[1] = {0};
        if (__pyx_kwds) {
          Py_ssize_t kw_args;
          switch (__pyx_nargs) {
            case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
          switch (__pyx_nargs) {
            case  0:
            if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_vals)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
            else goto __pyx_L5_argtuple_error;
          }
          if (unlikely(kw_args > 0)) {
            const Py_ssize_t kwd_pos_args = __pyx_nargs;
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "hash_int_c") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
          }
        } else if (unlikely(__pyx_nargs != 1)) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
        }
        __pyx_v_vals = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_vals.memview)) __PYX_ERR(0, 14, __pyx_L3_error)
      }
      goto __pyx_L6_skip;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("hash_int_c", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 14, __pyx_L3_error)
      __pyx_L6_skip:;
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L3_error:;
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_vals, 1);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.hash_int_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(__pyx_self, __pyx_v_vals);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_vals, 1);
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_vals) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__11)
      __Pyx_TraceCall("hash_int_c (wrapper)", __pyx_f[0], 14, 0, __PYX_ERR(0, 14, __pyx_L1_error));
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(!__pyx_v_vals.memview)) { __Pyx_RaiseUnboundLocalError("vals"); __PYX_ERR(0, 14, __pyx_L1_error) }
      __pyx_t_1 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(__pyx_v_vals, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.hash_int_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_s_vals); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__26);
      __Pyx_GIVEREF(__pyx_tuple__26);
    /* … */
      __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_1hash_int_c, 0, __pyx_n_s_hash_int_c, NULL, __pyx_n_s_tt_sketch_drm_fast_lazy_gaussian_2, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_hash_int_c, __pyx_t_7) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_tt_sketch_drm_fast_lazy_gaussian, __pyx_n_s_hash_int_c, 14, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 14, __pyx_L1_error)

     015:     """Use simple hashing for generating random numbers from indices

     016:     deterministically. See

     017:     https://stackoverflow.com/questions/664014/what-integer-hash-function-are-good-that-accepts-an-integer-hash-key

     018:     """

    +019:     cdef Py_ssize_t N = vals.shape[0]

      __pyx_v_N = (__pyx_v_vals.shape[0]);

    +020:     cdef uint shift1 = 30

      __pyx_v_shift1 = 30;

    +021:     cdef uint shift2 = 27

      __pyx_v_shift2 = 27;

    +022:     cdef uint shift3 = 31

      __pyx_v_shift3 = 31;

    +023:     cdef uint64 mult1 = 0xBF58476D1CE4E5B9

      __pyx_v_mult1 = 0xBF58476D1CE4E5B9;

    +024:     cdef uint64 mult2 = 0x94D049BB133111EB

      __pyx_v_mult2 = 0x94D049BB133111EB;

    +025:     cdef uint64 add1 = 0X4BE98134A5976FD3

      __pyx_v_add1 = 0X4BE98134A5976FD3;

     026:

     027:     cdef int i

     028:     cdef uint64 r

    +029:     for i in range(N):

      __pyx_t_1 = __pyx_v_N;
      __pyx_t_2 = __pyx_t_1;
      for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
        __pyx_v_i = __pyx_t_3;

    +030:         r = vals[i]

        __pyx_t_4 = __pyx_v_i;
        if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_v_vals.shape[0];
        __pyx_v_r = (*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_vals.data + __pyx_t_4 * __pyx_v_vals.strides[0]) )));

    +031:         r = r + add1

        __pyx_v_r = (__pyx_v_r + __pyx_v_add1);

    +032:         r ^= r >> shift1

        __pyx_v_r = (__pyx_v_r ^ (__pyx_v_r >> __pyx_v_shift1));

    +033:         r *= mult1

        __pyx_v_r = (__pyx_v_r * __pyx_v_mult1);

    +034:         r ^= r >> shift2

        __pyx_v_r = (__pyx_v_r ^ (__pyx_v_r >> __pyx_v_shift2));

    +035:         r *= mult2

        __pyx_v_r = (__pyx_v_r * __pyx_v_mult2);

    +036:         r ^= r >> shift3

        __pyx_v_r = (__pyx_v_r ^ (__pyx_v_r >> __pyx_v_shift3));

    +037:         vals[i] = r

        __pyx_t_4 = __pyx_v_i;
        if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_v_vals.shape[0];
        *((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_vals.data + __pyx_t_4 * __pyx_v_vals.strides[0]) )) = __pyx_v_r;
      }

     038:

     039: @cython.boundscheck(False)

    +040: cdef uint_to_normal(double[:] nums):

    static PyObject *__pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_uint_to_normal(__Pyx_memviewslice __pyx_v_nums) {
      Py_ssize_t __pyx_v_N;
      Py_ssize_t __pyx_v_i;
      int __pyx_v_e;
      double __pyx_v_x;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceCall("uint_to_normal", __pyx_f[0], 40, 0, __PYX_ERR(0, 40, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.uint_to_normal", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     041:     """Turn hashed indices into normally distributed numbers"""

     042:     # cdef double[:] nums = <double[:]>inds

    +043:     cdef Py_ssize_t N = nums.shape[0]

      __pyx_v_N = (__pyx_v_nums.shape[0]);

     044:     cdef Py_ssize_t i

     045:     cdef int e

     046:     cdef double x

    +047:     for i in range(N): #prange here messes stuff up when parallelizing

      __pyx_t_1 = __pyx_v_N;
      __pyx_t_2 = __pyx_t_1;
      for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
        __pyx_v_i = __pyx_t_3;

    +048:         x = frexp(nums[i], &e) * 2 - 1

        __pyx_t_4 = __pyx_v_i;
        if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_v_nums.shape[0];
        __pyx_v_x = ((frexp((*((double *) ( /* dim=0 */ (__pyx_v_nums.data + __pyx_t_4 * __pyx_v_nums.strides[0]) ))), (&__pyx_v_e)) * 2.0) - 1.0);

    +049:         x = scipy.special.cython_special.ndtri(x)

        __pyx_v_x = __pyx_f_5scipy_7special_14cython_special_ndtri(__pyx_v_x, 0);

    +050:         nums[i] = x

        __pyx_t_4 = __pyx_v_i;
        if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_v_nums.shape[0];
        *((double *) ( /* dim=0 */ (__pyx_v_nums.data + __pyx_t_4 * __pyx_v_nums.strides[0]) )) = __pyx_v_x;
      }

     051:

     052: @cython.boundscheck(False)

    +053: cpdef double[:] _inds_to_rand_double(

    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    static __Pyx_memviewslice __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_rand_double(__Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_shape, int __pyx_v_rank_min, int __pyx_v_rank_max, __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_seed, CYTHON_UNUSED int __pyx_skip_dispatch) {
      __Pyx_memviewslice __pyx_v_indices_flat = { 0, 0, { 0 }, { 0 }, { 0 } };
      int __pyx_v_N;
      int __pyx_v_n_dim;
      int __pyx_v_rank;
      int __pyx_v_prod;
      int __pyx_v_i;
      int __pyx_v_j;
      __Pyx_memviewslice __pyx_v_size_salt = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_indices_flat_large = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_hashes = { 0, 0, { 0 }, { 0 }, { 0 } };
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_SETBIT3;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_SETBITS12;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_h;
      __Pyx_memviewslice __pyx_v_nums = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__12)
      __Pyx_TraceCall("_inds_to_rand_double", __pyx_f[0], 53, 0, __PYX_ERR(0, 53, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_4, 1);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_17);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_18, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_20, 1);
      __pyx_r.data = NULL;
      __pyx_r.memview = NULL;
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian._inds_to_rand_double", __pyx_clineno, __pyx_lineno, __pyx_filename);
      goto __pyx_L2;
      __pyx_L0:;
      if (unlikely(!__pyx_r.memview)) {
        PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
      }
      __pyx_L2:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_indices_flat, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_size_salt, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_indices_flat_large, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_hashes, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_nums, 1);
      __Pyx_TraceReturn(Py_None, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    static PyMethodDef __pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double = {"_inds_to_rand_double", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ) {
      __Pyx_memviewslice __pyx_v_indices = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_shape = { 0, 0, { 0 }, { 0 }, { 0 } };
      int __pyx_v_rank_min;
      int __pyx_v_rank_max;
      __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_seed;
      #if !CYTHON_METH_FASTCALL
      CYTHON_UNUSED Py_ssize_t __pyx_nargs;
      #endif
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_inds_to_rand_double (wrapper)", 0);
      #if !CYTHON_METH_FASTCALL
      #if CYTHON_ASSUME_SAFE_MACROS
      __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      #else
      __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
      #endif
      #endif
      __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
      {
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indices,&__pyx_n_s_shape,&__pyx_n_s_rank_min,&__pyx_n_s_rank_max,&__pyx_n_s_seed,0};
      PyObject* values[5] = {0,0,0,0,0};
        if (__pyx_kwds) {
          Py_ssize_t kw_args;
          switch (__pyx_nargs) {
            case  5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
          switch (__pyx_nargs) {
            case  0:
            if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_indices)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shape)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("_inds_to_rand_double", 1, 5, 5, 1); __PYX_ERR(0, 53, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_min)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("_inds_to_rand_double", 1, 5, 5, 2); __PYX_ERR(0, 53, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_max)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("_inds_to_rand_double", 1, 5, 5, 3); __PYX_ERR(0, 53, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[4]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("_inds_to_rand_double", 1, 5, 5, 4); __PYX_ERR(0, 53, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            const Py_ssize_t kwd_pos_args = __pyx_nargs;
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_inds_to_rand_double") < 0)) __PYX_ERR(0, 53, __pyx_L3_error)
          }
        } else if (unlikely(__pyx_nargs != 5)) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
          values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
          values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
          values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
          values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
        }
        __pyx_v_indices = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_indices.memview)) __PYX_ERR(0, 54, __pyx_L3_error)
        __pyx_v_shape = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_shape.memview)) __PYX_ERR(0, 55, __pyx_L3_error)
        __pyx_v_rank_min = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_rank_min == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L3_error)
        __pyx_v_rank_max = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_rank_max == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L3_error)
        __pyx_v_seed = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(values[4]); if (unlikely((__pyx_v_seed == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 58, __pyx_L3_error)
      }
      goto __pyx_L6_skip;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_inds_to_rand_double", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 53, __pyx_L3_error)
      __pyx_L6_skip:;
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L3_error:;
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_indices, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_shape, 1);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian._inds_to_rand_double", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_2_inds_to_rand_double(__pyx_self, __pyx_v_indices, __pyx_v_shape, __pyx_v_rank_min, __pyx_v_rank_max, __pyx_v_seed);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_indices, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_shape, 1);
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_2_inds_to_rand_double(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_shape, int __pyx_v_rank_min, int __pyx_v_rank_max, __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_seed) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__12)
      __Pyx_TraceCall("_inds_to_rand_double (wrapper)", __pyx_f[0], 53, 0, __PYX_ERR(0, 53, __pyx_L1_error));
      __Pyx_XDECREF(__pyx_r);
      if (unlikely(!__pyx_v_indices.memview)) { __Pyx_RaiseUnboundLocalError("indices"); __PYX_ERR(0, 53, __pyx_L1_error) }
      if (unlikely(!__pyx_v_shape.memview)) { __Pyx_RaiseUnboundLocalError("shape"); __PYX_ERR(0, 53, __pyx_L1_error) }
      __pyx_t_1 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_rand_double(__pyx_v_indices, __pyx_v_shape, __pyx_v_rank_min, __pyx_v_rank_max, __pyx_v_seed, 0); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 53, __pyx_L1_error)
      __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_1, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1);
      __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian._inds_to_rand_double", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__27 = PyTuple_Pack(5, __pyx_n_s_indices, __pyx_n_s_shape, __pyx_n_s_rank_min, __pyx_n_s_rank_max, __pyx_n_s_seed); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__27);
      __Pyx_GIVEREF(__pyx_tuple__27);
    /* … */
      __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_3_inds_to_rand_double, 0, __pyx_n_s_inds_to_rand_double, NULL, __pyx_n_s_tt_sketch_drm_fast_lazy_gaussian_2, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_inds_to_rand_double, __pyx_t_7) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_tt_sketch_drm_fast_lazy_gaussian, __pyx_n_s_inds_to_rand_double, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 53, __pyx_L1_error)

     054:     uint64[:,:] indices,

     055:     uint64[:] shape,

     056:     int rank_min,

     057:     int rank_max,

     058:     uint64 seed,

     059: ):

    +060:     cdef uint64[:] indices_flat = np.copy(indices[0])

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4.data = __pyx_v_indices.data;
      __pyx_t_4.memview = __pyx_v_indices.memview;
      __PYX_INC_MEMVIEW(&__pyx_t_4, 1);
      {
        Py_ssize_t __pyx_tmp_idx = 0;
            Py_ssize_t __pyx_tmp_shape = __pyx_v_indices.shape[0];
        Py_ssize_t __pyx_tmp_stride = __pyx_v_indices.strides[0];
            if (__pyx_tmp_idx < 0)
                __pyx_tmp_idx += __pyx_tmp_shape;
            __pyx_t_4.data += __pyx_tmp_idx * __pyx_tmp_stride;
    }

    __pyx_t_4.shape[0] = __pyx_v_indices.shape[1];
    __pyx_t_4.strides[0] = __pyx_v_indices.strides[1];
        __pyx_t_4.suboffsets[0] = -1;

    __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_4, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_4, 1);
      __pyx_t_4.memview = NULL; __pyx_t_4.data = NULL;
      __pyx_t_5 = NULL;
      __pyx_t_6 = 0;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_6 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_2};
        __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 60, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_indices_flat = __pyx_t_4;
      __pyx_t_4.memview = NULL;
      __pyx_t_4.data = NULL;

    +061:     cdef int N = indices.shape[1]

      __pyx_v_N = (__pyx_v_indices.shape[1]);

    +062:     cdef int n_dim = len(shape)

      __pyx_t_7 = __Pyx_MemoryView_Len(__pyx_v_shape);
      __pyx_v_n_dim = __pyx_t_7;

    +063:     cdef int rank = rank_max - rank_min

      __pyx_v_rank = (__pyx_v_rank_max - __pyx_v_rank_min);

     064:

    +065:     cdef int prod = shape[0]

      __pyx_t_8 = 0;
      if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_v_shape.shape[0];
      __pyx_v_prod = (*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_shape.data + __pyx_t_8 * __pyx_v_shape.strides[0]) )));

     066:     cdef int i

     067:     cdef int j

    +068:     for i in range(1,n_dim):

      __pyx_t_9 = __pyx_v_n_dim;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

    +069:         for j in range(N):

        __pyx_t_12 = __pyx_v_N;
        __pyx_t_13 = __pyx_t_12;
        for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
          __pyx_v_j = __pyx_t_14;

    +070:             indices_flat[j] += indices[i,j] * prod

          __pyx_t_8 = __pyx_v_i;
          __pyx_t_15 = __pyx_v_j;
          if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_v_indices.shape[0];
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_indices.shape[1];
          __pyx_t_16 = __pyx_v_j;
          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_v_indices_flat.shape[0];
          *((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_indices_flat.data + __pyx_t_16 * __pyx_v_indices_flat.strides[0]) )) += ((*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_8 * __pyx_v_indices.strides[0]) ) + __pyx_t_15 * __pyx_v_indices.strides[1]) ))) * __pyx_v_prod);
        }

    +071:         prod *= shape[i]

        __pyx_t_15 = __pyx_v_i;
        if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_shape.shape[0];
        __pyx_v_prod = (__pyx_v_prod * (*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_shape.data + __pyx_t_15 * __pyx_v_shape.strides[0]) ))));
      }

     072:

    +073:     cdef uint64[:] size_salt = np.arange(rank_min, rank_max, dtype=np.uint64)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rank_min); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rank_max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error);
      __Pyx_GIVEREF(__pyx_t_2);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_17) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_t_17, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_v_size_salt = __pyx_t_4;
      __pyx_t_4.memview = NULL;
      __pyx_t_4.data = NULL;

    +074:     hash_int_c(size_salt)

      __pyx_t_17 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(__pyx_v_size_salt, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 74, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

     075:     # print(np.array(size_salt)) (if we increase rank then first r size salts

     076:     # are still the same)

     077:

    +078:     for i in range(rank):

      __pyx_t_9 = __pyx_v_rank;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

    +079:         size_salt[i] += seed

        __pyx_t_15 = __pyx_v_i;
        if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_size_salt.shape[0];
        *((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_size_salt.data + __pyx_t_15 * __pyx_v_size_salt.strides[0]) )) += __pyx_v_seed;
      }

     080:

    +081:     cdef uint64[:,:] indices_flat_large = np.empty(

      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    /* … */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 81, __pyx_L1_error);
      __pyx_t_3 = 0;
    /* … */
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_indices_flat_large = __pyx_t_18;
      __pyx_t_18.memview = NULL;
      __pyx_t_18.data = NULL;

    +082:         (N, rank), dtype=np.uint64

      __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_rank); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_17);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_17)) __PYX_ERR(0, 82, __pyx_L1_error);
      __Pyx_GIVEREF(__pyx_t_5);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error);
      __pyx_t_17 = 0;
      __pyx_t_5 = 0;
    /* … */
      __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_uint64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     083:     )

     084:

    +085:     for i in range(N):

      __pyx_t_9 = __pyx_v_N;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

    +086:         for j in range(rank):

        __pyx_t_12 = __pyx_v_rank;
        __pyx_t_13 = __pyx_t_12;
        for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
          __pyx_v_j = __pyx_t_14;

    +087:             indices_flat_large[i,j] = indices_flat[i] + size_salt[j]

          __pyx_t_15 = __pyx_v_i;
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_indices_flat.shape[0];
          __pyx_t_8 = __pyx_v_j;
          if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_v_size_salt.shape[0];
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_19 = __pyx_v_j;
          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_v_indices_flat_large.shape[0];
          if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_v_indices_flat_large.shape[1];
          *((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_indices_flat_large.data + __pyx_t_16 * __pyx_v_indices_flat_large.strides[0]) ) + __pyx_t_19 * __pyx_v_indices_flat_large.strides[1]) )) = ((*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_indices_flat.data + __pyx_t_15 * __pyx_v_indices_flat.strides[0]) ))) + (*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_size_salt.data + __pyx_t_8 * __pyx_v_size_salt.strides[0]) ))));
        }
      }

     088:

    +089:     cdef uint64[:] hashes =  np.reshape(indices_flat_large, -1)

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reshape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_indices_flat_large, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = NULL;
      __pyx_t_6 = 0;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_6 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_3, __pyx_int_neg_1};
        __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_hashes = __pyx_t_4;
      __pyx_t_4.memview = NULL;
      __pyx_t_4.data = NULL;

     090:

    +091:     cdef uint64 SETBIT3 = 0x2000000000000000

      __pyx_v_SETBIT3 = 0x2000000000000000;

    +092:     cdef uint64 SETBITS12 = 0x3FFFFFFFFFFFFFFF

      __pyx_v_SETBITS12 = 0x3FFFFFFFFFFFFFFF;

     093:     cdef uint64 h

    +094:     hash_int_c(hashes)

      __pyx_t_1 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_hash_int_c(__pyx_v_hashes, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +095:     for i in range(N*rank):

      __pyx_t_9 = (__pyx_v_N * __pyx_v_rank);
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

     096:         # Set first three bits to 001

     097:         # Avoids NaN values and zero values for float exp

     098:         # Assures mantissa is between 0.5 and 1.0

    +099:         h = hashes[i]

        __pyx_t_8 = __pyx_v_i;
        if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_v_hashes.shape[0];
        __pyx_v_h = (*((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_hashes.data + __pyx_t_8 * __pyx_v_hashes.strides[0]) )));

    +100:         h = (h | SETBIT3) & SETBITS12

        __pyx_v_h = ((__pyx_v_h | __pyx_v_SETBIT3) & __pyx_v_SETBITS12);

    +101:         hashes[i] = h

        __pyx_t_8 = __pyx_v_i;
        if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_v_hashes.shape[0];
        *((__pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 *) ( /* dim=0 */ (__pyx_v_hashes.data + __pyx_t_8 * __pyx_v_hashes.strides[0]) )) = __pyx_v_h;
      }

    +102:     cdef double[:] nums = np.frombuffer(hashes, dtype=np.float64)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_hashes, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_17) < 0) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_17, PyBUF_WRITABLE); if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_v_nums = __pyx_t_20;
      __pyx_t_20.memview = NULL;
      __pyx_t_20.data = NULL;

     103:

     104:

    +105:     return nums

      __PYX_INC_MEMVIEW(&__pyx_v_nums, 1);
      __pyx_r = __pyx_v_nums;
      goto __pyx_L0;

     106:

     107:

    +108: cdef double[:] _inds_to_normal(

    static __Pyx_memviewslice __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_normal(__Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_shape, int __pyx_v_rank_min, int __pyx_v_rank_max, __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_seed) {
      __Pyx_memviewslice __pyx_v_nums = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_TraceDeclarations
      __Pyx_TraceCall("_inds_to_normal", __pyx_f[0], 108, 0, __PYX_ERR(0, 108, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1);
      __Pyx_XDECREF(__pyx_t_2);
      __pyx_r.data = NULL;
      __pyx_r.memview = NULL;
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian._inds_to_normal", __pyx_clineno, __pyx_lineno, __pyx_filename);
      goto __pyx_L2;
      __pyx_L0:;
      if (unlikely(!__pyx_r.memview)) {
        PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
      }
      __pyx_L2:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_nums, 1);
      __Pyx_TraceReturn(Py_None, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     109:     uint64[:,:] indices,

     110:     uint64[:] shape,

     111:     int rank_min,

     112:     int rank_max,

     113:     uint64 seed,

     114: ):

    +115:     cdef double[:] nums = _inds_to_rand_double(

      __pyx_t_1 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_rand_double(__pyx_v_indices, __pyx_v_shape, __pyx_v_rank_min, __pyx_v_rank_max, __pyx_v_seed, 0); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 115, __pyx_L1_error)
      __pyx_v_nums = __pyx_t_1;
      __pyx_t_1.memview = NULL;
      __pyx_t_1.data = NULL;

     116:         indices, shape, rank_min, rank_max, seed

     117:     )

    +118:     uint_to_normal(nums)

      __pyx_t_2 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian_uint_to_normal(__pyx_v_nums); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    +119:     return nums

      __PYX_INC_MEMVIEW(&__pyx_v_nums, 1);
      __pyx_r = __pyx_v_nums;
      goto __pyx_L0;

     120:

     121: @cython.boundscheck(False)

    +122: cdef short[:] _inds_to_sparse_sign(

    static __Pyx_memviewslice __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_sparse_sign(__Pyx_memviewslice __pyx_v_indices, __Pyx_memviewslice __pyx_v_shape, int __pyx_v_rank, int __pyx_v_nnz, __pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64 __pyx_v_seed) {
      Py_ssize_t __pyx_v_N;
      __Pyx_memviewslice __pyx_v_uniform_nums = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_sparse_sign = { 0, 0, { 0 }, { 0 }, { 0 } };
      int __pyx_v_i;
      int __pyx_v_j;
      int __pyx_v_e;
      short __pyx_v_temp;
      int __pyx_v_rand_num;
      __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_TraceDeclarations
      __Pyx_TraceCall("_inds_to_sparse_sign", __pyx_f[0], 122, 0, __PYX_ERR(0, 122, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
      __pyx_r.data = NULL;
      __pyx_r.memview = NULL;
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian._inds_to_sparse_sign", __pyx_clineno, __pyx_lineno, __pyx_filename);
      goto __pyx_L2;
      __pyx_L0:;
      if (unlikely(!__pyx_r.memview)) {
        PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized");
      }
      __pyx_L2:;
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_uniform_nums, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_sparse_sign, 1);
      __Pyx_TraceReturn(Py_None, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     123:     uint64[:,:] indices,

     124:     uint64[:] shape,

     125:     int rank,

     126:     int nnz,

     127:     uint64 seed,

     128: ):

    +129:     cdef Py_ssize_t N = indices.shape[1]

      __pyx_v_N = (__pyx_v_indices.shape[1]);

    +130:     cdef double[:] uniform_nums = _inds_to_rand_double(

      __pyx_t_1 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_rand_double(__pyx_v_indices, __pyx_v_shape, 0, __pyx_v_nnz, __pyx_v_seed, 0); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 130, __pyx_L1_error)
      __pyx_v_uniform_nums = __pyx_t_1;
      __pyx_t_1.memview = NULL;
      __pyx_t_1.data = NULL;

     131:         indices, shape, 0, nnz, seed

     132:     )

    +133:     cdef short[:] sparse_sign = torch.zeros((N*rank), dtype=np.int16)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_N * __pyx_v_rank)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int16); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_short(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 133, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_sparse_sign = __pyx_t_7;
      __pyx_t_7.memview = NULL;
      __pyx_t_7.data = NULL;

     134:     cdef int i

     135:     cdef int j

     136:     cdef int e

     137:     cdef short temp

     138:     cdef int rand_num

     139:

    +140:     for i in range(N):

      __pyx_t_8 = __pyx_v_N;
      __pyx_t_9 = __pyx_t_8;
      for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
        __pyx_v_i = __pyx_t_10;

     141:         # populate matrix with rand signs

    +142:         for j in range(nnz):

        __pyx_t_11 = __pyx_v_nnz;
        __pyx_t_12 = __pyx_t_11;
        for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
          __pyx_v_j = __pyx_t_13;

     143:             # Replace uniform num with mantissa, store exponent in &e

    +144:             uniform_nums[i*nnz+j] = frexp(uniform_nums[i*nnz+j], &e) * 2 - 1

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_nnz) + __pyx_v_j);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_uniform_nums.shape[0];
          __pyx_t_15 = ((__pyx_v_i * __pyx_v_nnz) + __pyx_v_j);
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_uniform_nums.shape[0];
          *((double *) ( /* dim=0 */ (__pyx_v_uniform_nums.data + __pyx_t_15 * __pyx_v_uniform_nums.strides[0]) )) = ((frexp((*((double *) ( /* dim=0 */ (__pyx_v_uniform_nums.data + __pyx_t_14 * __pyx_v_uniform_nums.strides[0]) ))), (&__pyx_v_e)) * 2.0) - 1.0);

    +145:             sparse_sign[i*rank+j] = (e % 2) * 2 - 1  # random sign

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_rank) + __pyx_v_j);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_sparse_sign.shape[0];
          *((short *) ( /* dim=0 */ (__pyx_v_sparse_sign.data + __pyx_t_14 * __pyx_v_sparse_sign.strides[0]) )) = ((__Pyx_mod_long(__pyx_v_e, 2) * 2) - 1);
        }

     146:

     147:         # randomly permute

    +148:         for j in range(nnz):

        __pyx_t_11 = __pyx_v_nnz;
        __pyx_t_12 = __pyx_t_11;
        for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
          __pyx_v_j = __pyx_t_13;

     149:             # random int in [j,rank)

    +150:             rand_num = <int>(uniform_nums[i*nnz+j]*(rank-j) + j)

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_nnz) + __pyx_v_j);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_uniform_nums.shape[0];
          __pyx_v_rand_num = ((int)(((*((double *) ( /* dim=0 */ (__pyx_v_uniform_nums.data + __pyx_t_14 * __pyx_v_uniform_nums.strides[0]) ))) * (__pyx_v_rank - __pyx_v_j)) + __pyx_v_j));

    +151:             temp = sparse_sign[i*rank+j]

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_rank) + __pyx_v_j);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_sparse_sign.shape[0];
          __pyx_v_temp = (*((short *) ( /* dim=0 */ (__pyx_v_sparse_sign.data + __pyx_t_14 * __pyx_v_sparse_sign.strides[0]) )));

    +152:             sparse_sign[i*rank+j] = sparse_sign[i*rank+rand_num]

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_rank) + __pyx_v_rand_num);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_sparse_sign.shape[0];
          __pyx_t_15 = ((__pyx_v_i * __pyx_v_rank) + __pyx_v_j);
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_v_sparse_sign.shape[0];
          *((short *) ( /* dim=0 */ (__pyx_v_sparse_sign.data + __pyx_t_15 * __pyx_v_sparse_sign.strides[0]) )) = (*((short *) ( /* dim=0 */ (__pyx_v_sparse_sign.data + __pyx_t_14 * __pyx_v_sparse_sign.strides[0]) )));

    +153:             sparse_sign[i*rank+rand_num]=temp

          __pyx_t_14 = ((__pyx_v_i * __pyx_v_rank) + __pyx_v_rand_num);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_v_sparse_sign.shape[0];
          *((short *) ( /* dim=0 */ (__pyx_v_sparse_sign.data + __pyx_t_14 * __pyx_v_sparse_sign.strides[0]) )) = __pyx_v_temp;
        }
      }

    +154:     return sparse_sign

      __PYX_INC_MEMVIEW(&__pyx_v_sparse_sign, 1);
      __pyx_r = __pyx_v_sparse_sign;
      goto __pyx_L0;

     155:

    +156: def inds_to_sparse_sign(

    /* Python wrapper */
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_5inds_to_sparse_sign(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    PyDoc_STRVAR(__pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_4inds_to_sparse_sign, "\n    Converts a list of indices into the non-zero entries of a sparse sign matrix\n    ");
    static PyMethodDef __pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_5inds_to_sparse_sign = {"inds_to_sparse_sign", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_5inds_to_sparse_sign, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_4inds_to_sparse_sign};
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_5inds_to_sparse_sign(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ) {
      PyObject *__pyx_v_indices = 0;
      PyObject *__pyx_v_shape = 0;
      PyObject *__pyx_v_rank = 0;
      PyObject *__pyx_v_rank_min = 0;
      PyObject *__pyx_v_rank_max = 0;
      PyObject *__pyx_v_non_zero_per_row = 0;
      PyObject *__pyx_v_seed = 0;
      #if !CYTHON_METH_FASTCALL
      CYTHON_UNUSED Py_ssize_t __pyx_nargs;
      #endif
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("inds_to_sparse_sign (wrapper)", 0);
      #if !CYTHON_METH_FASTCALL
      #if CYTHON_ASSUME_SAFE_MACROS
      __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      #else
      __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
      #endif
      #endif
      __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
      {
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indices,&__pyx_n_s_shape,&__pyx_n_s_rank,&__pyx_n_s_rank_min,&__pyx_n_s_rank_max,&__pyx_n_s_non_zero_per_row,&__pyx_n_s_seed,0};
      PyObject* values[7] = {0,0,0,0,0,0,0};
        if (__pyx_kwds) {
          Py_ssize_t kw_args;
          switch (__pyx_nargs) {
            case  7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6);
            CYTHON_FALLTHROUGH;
            case  6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
            CYTHON_FALLTHROUGH;
            case  5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
          switch (__pyx_nargs) {
            case  0:
            if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_indices)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shape)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 1); __PYX_ERR(0, 156, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 2); __PYX_ERR(0, 156, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_min)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 3); __PYX_ERR(0, 156, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_max)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[4]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 4); __PYX_ERR(0, 156, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  5:
            if (likely((values[5] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_non_zero_per_row)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[5]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 5); __PYX_ERR(0, 156, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  6:
            if (likely((values[6] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[6]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, 6); __PYX_ERR(0, 156, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            const Py_ssize_t kwd_pos_args = __pyx_nargs;
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "inds_to_sparse_sign") < 0)) __PYX_ERR(0, 156, __pyx_L3_error)
          }
        } else if (unlikely(__pyx_nargs != 7)) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
          values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
          values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
          values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
          values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
          values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
          values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6);
        }
        __pyx_v_indices = values[0];
        __pyx_v_shape = values[1];
        __pyx_v_rank = values[2];
        __pyx_v_rank_min = values[3];
        __pyx_v_rank_max = values[4];
        __pyx_v_non_zero_per_row = values[5];
        __pyx_v_seed = values[6];
      }
      goto __pyx_L6_skip;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("inds_to_sparse_sign", 1, 7, 7, __pyx_nargs); __PYX_ERR(0, 156, __pyx_L3_error)
      __pyx_L6_skip:;
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L3_error:;
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.inds_to_sparse_sign", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_4inds_to_sparse_sign(__pyx_self, __pyx_v_indices, __pyx_v_shape, __pyx_v_rank, __pyx_v_rank_min, __pyx_v_rank_max, __pyx_v_non_zero_per_row, __pyx_v_seed);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_4inds_to_sparse_sign(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_shape, PyObject *__pyx_v_rank, PyObject *__pyx_v_rank_min, PyObject *__pyx_v_rank_max, PyObject *__pyx_v_non_zero_per_row, PyObject *__pyx_v_seed) {
      PyObject *__pyx_v_N = NULL;
      __Pyx_memviewslice __pyx_v_nums_view = { 0, 0, { 0 }, { 0 }, { 0 } };
      PyObject *__pyx_v_nums = NULL;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__13)
      __Pyx_TraceCall("inds_to_sparse_sign", __pyx_f[0], 156, 0, __PYX_ERR(0, 156, __pyx_L1_error));
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_INCREF(__pyx_v_shape);
      __Pyx_INCREF(__pyx_v_rank_min);
      __Pyx_INCREF(__pyx_v_rank_max);
      __Pyx_INCREF(__pyx_v_non_zero_per_row);
      __Pyx_INCREF(__pyx_v_seed);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_12, 1);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.inds_to_sparse_sign", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_N);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_nums_view, 1);
      __Pyx_XDECREF(__pyx_v_nums);
      __Pyx_XDECREF(__pyx_v_indices);
      __Pyx_XDECREF(__pyx_v_shape);
      __Pyx_XDECREF(__pyx_v_rank_min);
      __Pyx_XDECREF(__pyx_v_rank_max);
      __Pyx_XDECREF(__pyx_v_non_zero_per_row);
      __Pyx_XDECREF(__pyx_v_seed);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__28 = PyTuple_Pack(10, __pyx_n_s_indices, __pyx_n_s_shape, __pyx_n_s_rank, __pyx_n_s_rank_min, __pyx_n_s_rank_max, __pyx_n_s_non_zero_per_row, __pyx_n_s_seed, __pyx_n_s_N, __pyx_n_s_nums_view, __pyx_n_s_nums); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__28);
      __Pyx_GIVEREF(__pyx_tuple__28);
    /* … */
      __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_5inds_to_sparse_sign, 0, __pyx_n_s_inds_to_sparse_sign, NULL, __pyx_n_s_tt_sketch_drm_fast_lazy_gaussian_2, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_inds_to_sparse_sign, __pyx_t_7) < 0) __PYX_ERR(0, 156, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(7, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__28, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_tt_sketch_drm_fast_lazy_gaussian, __pyx_n_s_inds_to_sparse_sign, 156, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 156, __pyx_L1_error)

     157:     indices,

     158:     shape,

     159:     rank,

     160:     rank_min,

     161:     rank_max,

     162:     non_zero_per_row,

     163:     seed

     164: ):

     165:     """

     166:     Converts a list of indices into the non-zero entries of a sparse sign matrix

     167:     """

    +168:     indices = indices.astype(np.uint64)

      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
        __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_1);
      __pyx_t_1 = 0;

    +169:     N = indices.shape[1]

      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_N = __pyx_t_2;
      __pyx_t_2 = 0;

    +170:     shape = np.array(shape,dtype=np.uint64)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_shape);
      __Pyx_GIVEREF(__pyx_v_shape);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape)) __PYX_ERR(0, 170, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 170, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_6);
      __pyx_t_6 = 0;

    +171:     rank_min = int(rank_min)

      __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_rank_min); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 171, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_rank_min, __pyx_t_6);
      __pyx_t_6 = 0;

    +172:     rank_max = int(rank_max)

      __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_rank_max); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_rank_max, __pyx_t_6);
      __pyx_t_6 = 0;

    +173:     non_zero_per_row = int(non_zero_per_row)

      __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_non_zero_per_row); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_non_zero_per_row, __pyx_t_6);
      __pyx_t_6 = 0;

    +174:     seed = np.mod(seed,2**63,dtype=np.uint64)

      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_mod); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_seed);
      __Pyx_GIVEREF(__pyx_v_seed);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_seed)) __PYX_ERR(0, 174, __pyx_L1_error);
      __Pyx_INCREF(__pyx_int_0x8000000000000000);
      __Pyx_GIVEREF(__pyx_int_0x8000000000000000);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0x8000000000000000)) __PYX_ERR(0, 174, __pyx_L1_error);
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_seed, __pyx_t_3);
      __pyx_t_3 = 0;

    +175:     nums_view = _inds_to_sparse_sign(

      __pyx_t_12 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_sparse_sign(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(0, 175, __pyx_L1_error)
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
      __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
      __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
      __pyx_v_nums_view = __pyx_t_12;
      __pyx_t_12.memview = NULL;
      __pyx_t_12.data = NULL;

    +176:         indices, shape, rank, non_zero_per_row, seed

      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_v_indices, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 176, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_v_shape, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 176, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_rank); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L1_error)
      __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_non_zero_per_row); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L1_error)
      __pyx_t_11 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_v_seed); if (unlikely((__pyx_t_11 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 176, __pyx_L1_error)

     177:     )

    +178:     nums = np.array(nums_view).reshape(N,rank)

      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_nums_view, 1, (PyObject *(*)(char *)) __pyx_memview_get_short, (int (*)(char *, PyObject *)) __pyx_memview_set_short, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_6};
        __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_N, __pyx_v_rank};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_v_nums = __pyx_t_3;
      __pyx_t_3 = 0;

    +179:     nums = nums[:, rank_min:rank_max]

      __pyx_t_3 = PySlice_New(__pyx_v_rank_min, __pyx_v_rank_max, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_slice__5);
      __Pyx_GIVEREF(__pyx_slice__5);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__5)) __PYX_ERR(0, 179, __pyx_L1_error);
      __Pyx_GIVEREF(__pyx_t_3);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_nums, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_nums, __pyx_t_3);
      __pyx_t_3 = 0;

    +180:     return nums

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_nums);
      __pyx_r = __pyx_v_nums;
      goto __pyx_L0;

     181:

     182:

    +183: def inds_to_normal(

    /* Python wrapper */
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_7inds_to_normal(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    PyDoc_STRVAR(__pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_6inds_to_normal, "\n    Converts a list of indices into the associated entries of gaussian matrix\n    ");
    static PyMethodDef __pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_7inds_to_normal = {"inds_to_normal", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_7inds_to_normal, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9tt_sketch_3drm_18fast_lazy_gaussian_6inds_to_normal};
    static PyObject *__pyx_pw_9tt_sketch_3drm_18fast_lazy_gaussian_7inds_to_normal(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ) {
      PyObject *__pyx_v_indices = 0;
      PyObject *__pyx_v_shape = 0;
      PyObject *__pyx_v_rank_min = 0;
      PyObject *__pyx_v_rank_max = 0;
      PyObject *__pyx_v_seed = 0;
      #if !CYTHON_METH_FASTCALL
      CYTHON_UNUSED Py_ssize_t __pyx_nargs;
      #endif
      CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("inds_to_normal (wrapper)", 0);
      #if !CYTHON_METH_FASTCALL
      #if CYTHON_ASSUME_SAFE_MACROS
      __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
      #else
      __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
      #endif
      #endif
      __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
      {
        PyObject **__pyx_pyargnames[] = {&__pyx_n_s_indices,&__pyx_n_s_shape,&__pyx_n_s_rank_min,&__pyx_n_s_rank_max,&__pyx_n_s_seed,0};
      PyObject* values[5] = {0,0,0,0,0};
        if (__pyx_kwds) {
          Py_ssize_t kw_args;
          switch (__pyx_nargs) {
            case  5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
          switch (__pyx_nargs) {
            case  0:
            if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_indices)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shape)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_normal", 1, 5, 5, 1); __PYX_ERR(0, 183, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_min)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_normal", 1, 5, 5, 2); __PYX_ERR(0, 183, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rank_max)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_normal", 1, 5, 5, 3); __PYX_ERR(0, 183, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed)) != 0)) {
              (void)__Pyx_Arg_NewRef_FASTCALL(values[4]);
              kw_args--;
            }
            else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
            else {
              __Pyx_RaiseArgtupleInvalid("inds_to_normal", 1, 5, 5, 4); __PYX_ERR(0, 183, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            const Py_ssize_t kwd_pos_args = __pyx_nargs;
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "inds_to_normal") < 0)) __PYX_ERR(0, 183, __pyx_L3_error)
          }
        } else if (unlikely(__pyx_nargs != 5)) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
          values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
          values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
          values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
          values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
        }
        __pyx_v_indices = values[0];
        __pyx_v_shape = values[1];
        __pyx_v_rank_min = values[2];
        __pyx_v_rank_max = values[3];
        __pyx_v_seed = values[4];
      }
      goto __pyx_L6_skip;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("inds_to_normal", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 183, __pyx_L3_error)
      __pyx_L6_skip:;
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L3_error:;
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.inds_to_normal", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_6inds_to_normal(__pyx_self, __pyx_v_indices, __pyx_v_shape, __pyx_v_rank_min, __pyx_v_rank_max, __pyx_v_seed);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      {
        Py_ssize_t __pyx_temp;
        for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
          __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
        }
      }
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_9tt_sketch_3drm_18fast_lazy_gaussian_6inds_to_normal(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_indices, PyObject *__pyx_v_shape, PyObject *__pyx_v_rank_min, PyObject *__pyx_v_rank_max, PyObject *__pyx_v_seed) {
      PyObject *__pyx_v_N = NULL;
      PyObject *__pyx_v_rank = NULL;
      __Pyx_memviewslice __pyx_v_nums_view = { 0, 0, { 0 }, { 0 }, { 0 } };
      PyObject *__pyx_v_nums = NULL;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarations
      __Pyx_TraceFrameInit(__pyx_codeobj__14)
      __Pyx_TraceCall("inds_to_normal", __pyx_f[0], 183, 0, __PYX_ERR(0, 183, __pyx_L1_error));
      __Pyx_INCREF(__pyx_v_indices);
      __Pyx_INCREF(__pyx_v_shape);
      __Pyx_INCREF(__pyx_v_rank_min);
      __Pyx_INCREF(__pyx_v_rank_max);
      __Pyx_INCREF(__pyx_v_seed);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_6);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_12, 1);
      __Pyx_AddTraceback("tt_sketch.drm.fast_lazy_gaussian.inds_to_normal", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_N);
      __Pyx_XDECREF(__pyx_v_rank);
      __PYX_XCLEAR_MEMVIEW(&__pyx_v_nums_view, 1);
      __Pyx_XDECREF(__pyx_v_nums);
      __Pyx_XDECREF(__pyx_v_indices);
      __Pyx_XDECREF(__pyx_v_shape);
      __Pyx_XDECREF(__pyx_v_rank_min);
      __Pyx_XDECREF(__pyx_v_rank_max);
      __Pyx_XDECREF(__pyx_v_seed);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_TraceReturn(__pyx_r, 0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__29 = PyTuple_Pack(9, __pyx_n_s_indices, __pyx_n_s_shape, __pyx_n_s_rank_min, __pyx_n_s_rank_max, __pyx_n_s_seed, __pyx_n_s_N, __pyx_n_s_rank, __pyx_n_s_nums_view, __pyx_n_s_nums); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__29);
      __Pyx_GIVEREF(__pyx_tuple__29);
    /* … */
      __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_9tt_sketch_3drm_18fast_lazy_gaussian_7inds_to_normal, 0, __pyx_n_s_inds_to_normal, NULL, __pyx_n_s_tt_sketch_drm_fast_lazy_gaussian_2, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_inds_to_normal, __pyx_t_7) < 0) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

     184:     indices,

     185:     shape,

     186:     rank_min,

     187:     rank_max,

     188:     seed

     189: ):

     190:     """

     191:     Converts a list of indices into the associated entries of gaussian matrix

     192:     """

    +193:     indices = indices.astype(np.uint64)

      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
        __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __Pyx_DECREF_SET(__pyx_v_indices, __pyx_t_1);
      __pyx_t_1 = 0;

    +194:     N = indices.shape[1]

      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_indices, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_N = __pyx_t_2;
      __pyx_t_2 = 0;

    +195:     shape = np.array(shape,dtype=np.uint64)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_shape);
      __Pyx_GIVEREF(__pyx_v_shape);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape)) __PYX_ERR(0, 195, __pyx_L1_error);
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF_SET(__pyx_v_shape, __pyx_t_6);
      __pyx_t_6 = 0;

    +196:     rank_min = int(rank_min)

      __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_rank_min); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 196, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_rank_min, __pyx_t_6);
      __pyx_t_6 = 0;

    +197:     rank_max = int(rank_max)

      __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_v_rank_max); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF_SET(__pyx_v_rank_max, __pyx_t_6);
      __pyx_t_6 = 0;

    +198:     rank = rank_max - rank_min

      __pyx_t_6 = PyNumber_Subtract(__pyx_v_rank_max, __pyx_v_rank_min); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_rank = __pyx_t_6;
      __pyx_t_6 = 0;

    +199:     seed = np.mod(seed,2**63,dtype=np.uint64)

      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_mod); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_seed);
      __Pyx_GIVEREF(__pyx_v_seed);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_seed)) __PYX_ERR(0, 199, __pyx_L1_error);
      __Pyx_INCREF(__pyx_int_0x8000000000000000);
      __Pyx_GIVEREF(__pyx_int_0x8000000000000000);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0x8000000000000000)) __PYX_ERR(0, 199, __pyx_L1_error);
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uint64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_seed, __pyx_t_3);
      __pyx_t_3 = 0;

    +200:     nums_view = _inds_to_normal(indices, shape, rank_min, rank_max, seed)

      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_v_indices, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_9tt_sketch_3drm_18fast_lazy_gaussian_uint64(__pyx_v_shape, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_rank_min); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_rank_max); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_11 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_v_seed); if (unlikely((__pyx_t_11 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error)
      __pyx_t_12 = __pyx_f_9tt_sketch_3drm_18fast_lazy_gaussian__inds_to_normal(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(0, 200, __pyx_L1_error)
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_7, 1);
      __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
      __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1);
      __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
      __pyx_v_nums_view = __pyx_t_12;
      __pyx_t_12.memview = NULL;
      __pyx_t_12.data = NULL;

    +201:     nums = np.array(nums_view)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 201, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_nums_view, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_2};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __pyx_v_nums = __pyx_t_3;
      __pyx_t_3 = 0;

    +202:     return nums.reshape(N,rank)

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_nums, __pyx_n_s_reshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = NULL;
      __pyx_t_5 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
          __pyx_t_5 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_N, __pyx_v_rank};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;