# Path: retina/vrf/utils/parray.py
# def _splay_backend(n, M):
# def splay(n, M):
# def _get_common_dtype(obj1, obj2):
# def _get_inplace_dtype(obj1, obj2):
# def _get_common_dtype_with_scalar(scalar, obj1):
# def _get_inplace_dtype_with_scalar(scalar, obj1):
# def _pd(shape):
# def _assignshape(shape, axis, value):
# def PitchTrans(shape, dst, dst_ld, src, src_ld, dtype, aligned=False, _async = False, stream = None):
#     def __init__(self, shape, dtype, gpudata=None, pitch = None, base = None):
#     def set(self, ary):
#     def set_async(self, ary, stream=None):
#     def get(self, ary = None, pagelocked = False):
#     def get_async(self, stream = None, ary = None):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def _new_like_me(self, dtype = None):
#     def __add__(self, other):
#     def __sub__(self, other):
#     def __rsub__(self, other):
#     def __mul__(self, other):
#     def __div__(self, other):
#     def __rdiv__(self, other):
#     def __neg__(self):
#     def __iadd__(self, other):
#     def __isub__(self, other):
#     def __imul__(self, other):
#     def __idiv__(self, other):
#     def __pow__(self, other):
#     def __ipow__(self, other):
#     def add(self, other):
#     def sub(self, other):
#     def rsub(self, other):
#     def mul(self, other):
#     def div(self, other):
#     def rdiv(self, other):
#     def neg(self):
#     def fill(self, value, stream=None):
#     def copy(self, result=None):
#     def real(self):
#     def imag(self):
#     def abs(self):
#     def conj(self, inplace = True):
#     def reshape(self, shape, inplace = True):
#     def astype(self, dtype):
#     def T(self):
#     def H(self):
#     def copy_rows(self, start, stop, step = 1):
#     def view(self, dtype = None):
#     def __getitem__(self, idx):
# def to_gpu(ary):
# def to_gpu_async(ary, stream = None):
# def empty_like(other_ary):
# def zeros(shape, dtype):
# def zeros_like(other_ary):
# def ones(shape, dtype):
# def ones_like(other_ary):
# def make_pitcharray(dptr, shape, dtype, linear = False, pitch=None):
# def arrayg2p(other_gpuarray):
# def arrayp2g(pary):
# def conj(pary):
# def reshape(pary, shape):
# def iscomplexobj(pary):
# def isrealobj(pary):
# def issingle(dtype):
# def floattocomplex(dtype):
# def complextofloat(dtype):
# def make_complex(real, imag):
# def angle(array):
# def complex_from_amp_phase(amp, phase):
# class PitchArray(object):
# 
# Path: retina/vrf/utils/linalg.py
# class cublashandle(object):
#     def __init__(self):
#     def create(self):
#     def destroy(self):
#     def __del__(self):
# def dot(A, B, opa = 'n', opb = 'n',
#         C = None, Cstart = None,
#         scale = 1.0, Cscale = 0.0, handle = None):
# def norm(A, handle = None):
#         C = parray.empty((m,l), dtype)


from abc import ABCMeta, abstractmethod, abstractproperty
from pycuda.tools import dtype_to_ctype, context_dependent_memoize
from pycuda.compiler import SourceModule
from .utils import parray as parray
from .utils import linalg as la
import numpy as np
import pycuda.driver as cuda
    import pycuda.autoinit
    import numpy.random as random
        for i in np.arange(0, self.num_neurons, self.ONE_TIME_FILTERS):
            Nfilters = min(self.ONE_TIME_FILTERS, self.num_neurons - i)
            self.generate_filters(startbias=i, N_filters=Nfilters)
            la.dot(self.filters, d_image, opb='t',
                   C=d_output[i: i+Nfilters],
                   handle=handle)
        del self.filters
        return d_output.T()

    def filter_image_use(self, image_input):
        """
        Performs RF filtering on input video
        for all the rfs
        """
        # video dimensions should match screen dimensions
        # numpy resize operation doesn,t make any checks
        if len(image_input.shape) == 2:
            # if input has 2 dimensions
            assert image_input.shape[1] == self.size
        else:
            # if input has 3 dimensions
            assert (image_input.shape[1]*image_input.shape[2] ==
                    self.size)

        # rasterizing inputs
        image_input.resize((1, self.size))

        d_image = parray.to_gpu(image_input)
        handle = la.cublashandle()


# Path: retina/vrf/utils/parray.py
# def _splay_backend(n, M):
# def splay(n, M):
# def _get_common_dtype(obj1, obj2):
# def _get_inplace_dtype(obj1, obj2):
# def _get_common_dtype_with_scalar(scalar, obj1):
# def _get_inplace_dtype_with_scalar(scalar, obj1):
# def _pd(shape):
# def _assignshape(shape, axis, value):
# def PitchTrans(shape, dst, dst_ld, src, src_ld, dtype, aligned=False, _async = False, stream = None):
#     def __init__(self, shape, dtype, gpudata=None, pitch = None, base = None):
#     def set(self, ary):
#     def set_async(self, ary, stream=None):
#     def get(self, ary = None, pagelocked = False):
#     def get_async(self, stream = None, ary = None):
#     def __str__(self):
#     def __repr__(self):
#     def __hash__(self):
#     def _new_like_me(self, dtype = None):
#     def __add__(self, other):
#     def __sub__(self, other):
#     def __rsub__(self, other):
#     def __mul__(self, other):
#     def __div__(self, other):
#     def __rdiv__(self, other):
#     def __neg__(self):
#     def __iadd__(self, other):
#     def __isub__(self, other):
#     def __imul__(self, other):
#     def __idiv__(self, other):
#     def __pow__(self, other):
#     def __ipow__(self, other):
#     def add(self, other):
#     def sub(self, other):
#     def rsub(self, other):
#     def mul(self, other):
#     def div(self, other):
#     def rdiv(self, other):
#     def neg(self):
#     def fill(self, value, stream=None):
#     def copy(self, result=None):
#     def real(self):
#     def imag(self):
#     def abs(self):
#     def conj(self, inplace = True):
#     def reshape(self, shape, inplace = True):
#     def astype(self, dtype):
#     def T(self):
#     def H(self):
#     def copy_rows(self, start, stop, step = 1):
#     def view(self, dtype = None):
#     def __getitem__(self, idx):
# def to_gpu(ary):
# def to_gpu_async(ary, stream = None):
# def empty_like(other_ary):
# def zeros(shape, dtype):
# def zeros_like(other_ary):
# def ones(shape, dtype):
# def ones_like(other_ary):
# def make_pitcharray(dptr, shape, dtype, linear = False, pitch=None):
# def arrayg2p(other_gpuarray):
# def arrayp2g(pary):
# def conj(pary):
# def reshape(pary, shape):
# def iscomplexobj(pary):
# def isrealobj(pary):
# def issingle(dtype):
# def floattocomplex(dtype):
# def complextofloat(dtype):
# def make_complex(real, imag):
# def angle(array):
# def complex_from_amp_phase(amp, phase):
# class PitchArray(object):
# 
# Path: retina/vrf/utils/linalg.py
# class cublashandle(object):
#     def __init__(self):
#     def create(self):
#     def destroy(self):
#     def __del__(self):
# def dot(A, B, opa = 'n', opb = 'n',
#         C = None, Cstart = None,
#         scale = 1.0, Cscale = 0.0, handle = None):
# def norm(A, handle = None):
#         C = parray.empty((m,l), dtype)


# Path: retina/vrf/vrf.py
from abc import ABCMeta, abstractmethod, abstractproperty
from pycuda.tools import dtype_to_ctype, context_dependent_memoize
from pycuda.compiler import SourceModule
from .utils import parray as parray
from .utils import linalg as la
import numpy as np
import pycuda.driver as cuda
    import pycuda.autoinit
    import numpy.random as random

        for i in np.arange(0, self.num_neurons, self.ONE_TIME_FILTERS):
            Nfilters = min(self.ONE_TIME_FILTERS, self.num_neurons - i)
            self.generate_filters(startbias=i, N_filters=Nfilters)
            la.dot(self.filters, d_image, opb='t',
                   C=d_output[i: i+Nfilters],
                   handle=handle)
        del self.filters
        return d_output.T()

    def filter_image_use(self, image_input):
        """
        Performs RF filtering on input video
        for all the rfs
        """
        # video dimensions should match screen dimensions
        # numpy resize operation doesn,t make any checks
        if len(image_input.shape) == 2:
            # if input has 2 dimensions
            assert image_input.shape[1] == self.size
        else:
            # if input has 3 dimensions
            assert (image_input.shape[1]*image_input.shape[2] ==
                    self.size)

        # rasterizing inputs
        image_input.resize((1, self.size))

        d_image = parray.to_gpu(image_input)
        handle = la.cublashandle()


        return la.dot(self.filters, d_image, opb='t', handle=handle).T()