当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_longlong方法代码示例

本文整理汇总了Python中ctypes.c_longlong方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_longlong方法的具体用法?Python ctypes.c_longlong怎么用?Python ctypes.c_longlong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_longlong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getintp_ctype

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _getintp_ctype():
    val = _getintp_ctype.cache
    if val is not None:
        return val
    if ctypes is None:
        import numpy as np
        val = dummy_ctype(np.intp)
    else:
        char = dtype('p').char
        if (char == 'i'):
            val = ctypes.c_int
        elif char == 'l':
            val = ctypes.c_long
        elif char == 'q':
            val = ctypes.c_longlong
        else:
            val = ctypes.c_long
    _getintp_ctype.cache = val
    return val 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:_internal.py

示例2: _getintp_ctype

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _getintp_ctype():
    from .multiarray import dtype
    val = _getintp_ctype.cache
    if val is not None:
        return val
    char = dtype('p').char
    import ctypes
    if (char == 'i'):
        val = ctypes.c_int
    elif char == 'l':
        val = ctypes.c_long
    elif char == 'q':
        val = ctypes.c_longlong
    else:
        val = ctypes.c_long
    _getintp_ctype.cache = val
    return val 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:_internal.py

示例3: inplace_setitem

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def inplace_setitem(self, key, val):
    try:
        n_dims = self.numdims()
        if (arrayfire.util._is_number(val)):
            tdims = arrayfire.array._get_assign_dims(key, self.dims())
            other_arr = arrayfire.array.constant_array(val, tdims[0], tdims[1], tdims[2], tdims[3], self.type())
            del_other = True
        else:
            other_arr = val.arr
            del_other = False

        inds  = arrayfire.array._get_indices(key)

        # In place assignment. Notice passing a pointer to self.arr as output
        arrayfire.util.safe_call(arrayfire.backend.get().af_assign_gen(ctypes.pointer(self.arr),
                                                                            self.arr, ctypes.c_longlong(n_dims),
                                                                            inds.pointer,
                                                                            other_arr))
        if del_other:
            arrayfire.safe_call(arrayfire.backend.get().af_release_array(other_arr))
    except RuntimeError as e:
        raise IndexError(str(e)) 
开发者ID:FilipeMaia,项目名称:afnumpy,代码行数:24,代码来源:__init__.py

示例4: _read_by_block

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _read_by_block(archive_res):
    buffer_ = ctypes.c_char_p()
    num = ctypes.c_size_t()
    offset = ctypes.c_longlong()

    while 1:
        r = libarchive.calls.archive_read.c_archive_read_data_block(
                archive_res,
                ctypes.cast(ctypes.byref(buffer_),
                            ctypes.POINTER(ctypes.c_void_p)),
                ctypes.byref(num),
                ctypes.byref(offset))

        if r == libarchive.constants.archive.ARCHIVE_OK:
            block = ctypes.string_at(buffer_, num.value)
            assert len(block) == num.value

            yield block

        elif r == libarchive.constants.archive.ARCHIVE_EOF:
            break

        else:
            raise ValueError("Read failed (archive_read_data_block): (%d)" %
                             (r,)) 
开发者ID:dsoprea,项目名称:PyEasyArchive,代码行数:27,代码来源:archive_read.py

示例5: elbow

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def elbow(sample, kmin, kmax, initializer, random_state):
    random_state = random_state or -1
    pointer_data = package_builder(sample, c_double).create()

    ccore = ccore_library.get()
    if initializer == elbow_center_initializer.KMEANS_PLUS_PLUS:
        ccore.elbow_method_ikpp.restype = POINTER(pyclustering_package)
        package = ccore.elbow_method_ikpp(pointer_data, c_size_t(kmin), c_size_t(kmax), c_longlong(random_state))
    elif initializer == elbow_center_initializer.RANDOM:
        ccore.elbow_method_irnd.restype = POINTER(pyclustering_package)
        package = ccore.elbow_method_irnd(pointer_data, c_size_t(kmin), c_size_t(kmax), c_longlong(random_state))
    else:
        raise ValueError("Not supported type of center initializer '" + str(initializer) + "'.")

    results = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)

    return (results[elbow_package_indexer.ELBOW_PACKAGE_INDEX_AMOUNT][0],
            results[elbow_package_indexer.ELBOW_PACKAGE_INDEX_WCE]) 
开发者ID:annoviko,项目名称:pyclustering,代码行数:21,代码来源:elbow_wrapper.py

示例6: DoWrite

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def DoWrite(StateName, Data):
    StateName = ctypes.c_longlong(int(StateName, 16))
    dataBuffer = ctypes.c_char_p(Data)
    bufferSize = len(Data)
    status = ZwUpdateWnfStateData(ctypes.byref(StateName), dataBuffer, bufferSize, 0, 0, 0, 0)
    status = ctypes.c_ulong(status).value

    if status == 0:
        return True
    else:
        print('[Error] Could not write for this statename: 0x{:x}'.format(status))
        return False

   

#########################################################################################



############### MAIN ############### 
开发者ID:ionescu007,项目名称:wnfun,代码行数:22,代码来源:WnfDump.py

示例7: SetStateName

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def SetStateName(self, WnfName):
        tmpName = 0
        try:
            tmpName = g_WellKnownWnfNames[WnfName.upper()]
        except:
            if len(WnfName)>2 and WnfName[1] == 'x':
                WnfName = WnfName[2:]
            try:
                tmpName = int(WnfName, 16)
            except:
                tmpName = 0
                self.pprint("[Error] Could not validate the provided name")
                return False

        self.StateName = ctypes.c_longlong(tmpName)
        self.internalName.value = ctypes.c_ulonglong(tmpName ^ WNF_STATE_KEY)
        return True 
开发者ID:ionescu007,项目名称:wnfun,代码行数:19,代码来源:wnfcom.py

示例8: fprop_relu

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def fprop_relu(self, layer, x, slope):
        if layer is None:
            layer = layer_mkl.ReluLayerMKL()
        if not hasattr(x, 'shape5D'):
            return self.maximum(x, 0) + slope * self.minimum(0, x)
        if slope != 0:
            self.convert(x)
            x.clean_mkl()
            return self.maximum(x, 0) + slope * self.minimum(0, x)

        if x.shape5D is not None:
            C, D, H, W, N = x.shape5D
        else:
            C, N = x._tensor.shape
            D, H, W = 1, 1, 1
            x.shape5D = C, D, H, W, N
        layer.shape5D = C, D, H, W, N

        primitives = c_longlong(layer.dnnPrimitives.ctypes.data)
        if x.primitive[3] == 0:
            layer.inputMKL = False
        self.mklEngine.Relu_f(x.get_prim(), primitives, layer.initOk_f, N, C, H, W)
        layer.initOk_f = 1
        return x 
开发者ID:NervanaSystems,项目名称:neon,代码行数:26,代码来源:nervanamkl.py

示例9: compound_bprop_bn

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def compound_bprop_bn(self, deltas, grad_gamma, grad_beta,
                          error, inputs, xsum, xvar, gamma,
                          eps, binary=False, layer=None):
        if not layer or not isinstance(layer.in_shape, tuple):
            super(NervanaMKL, self).compound_bprop_bn(deltas, grad_gamma,
                                                      grad_beta, error,
                                                      inputs, xsum, xvar,
                                                      gamma, eps, binary,
                                                      layer)
            return

        primitives = c_longlong(layer.dnnPrimitives.ctypes.data)

        self.mklEngine.BatchNormBackp(inputs.get_prim(), error.get_prim(),
                                      deltas.get_prim(), grad_gamma.get_prim(),
                                      grad_beta.get_prim(), layer.in_shape[0],
                                      primitives, layer.init_b)
        layer.init_b = 1
        deltas.shape5D = layer.shape5D 
开发者ID:NervanaSystems,项目名称:neon,代码行数:21,代码来源:nervanamkl.py

示例10: _set_input

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _set_input(self, name, data):
        """Set the input using the input name with data

        Parameters
        __________
        name : str
            The name of an input.
        data : list of numbers
            The data to be set.
        """
        in_data = np.ascontiguousarray(data, dtype=np.float32)
        shape = np.array(in_data.shape, dtype=np.int64)
        _check_call(_LIB.SetDLRInput(byref(self.handle),
                                     c_char_p(name.encode('utf-8')),
                                     shape.ctypes.data_as(POINTER(c_longlong)),
                                     in_data.ctypes.data_as(POINTER(c_float)),
                                     c_int(in_data.ndim)))
        if self.backend == 'treelite':
            self._lazy_init_output_shape() 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:21,代码来源:api.py

示例11: _get_output_size_dim

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _get_output_size_dim(self, index):
        """Get the size and the dimenson of the index-th output.

        Parameters
        __________
        index : int
            The index of the output.

        Returns
        _______
        size : int
            The size of the index-th output.
        dim : int
            The dimension of the index-th output.
        """
        idx = ctypes.c_int(index)
        size = ctypes.c_longlong()
        dim = ctypes.c_int()
        _check_call(_LIB.GetDLROutputSizeDim(byref(self.handle), idx,
                                                      byref(size), byref(dim)))
        return size.value, dim.value 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:23,代码来源:api.py

示例12: _get_output_shape

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def _get_output_shape(self, index):
        """Get the shape for the index-th output.

        Parameters
        __________
        index : int
            The index of the output.

        Returns
        _______
        shape : list
            The shape of the index-th output.
        """
        size, dim = self._get_output_size_dim(index)
        if not self.output_size_dim:
            self.output_size_dim = [(0, 0)] * self._get_num_outputs()
        self.output_size_dim[index] = (size, dim)
        shape = np.zeros(dim, dtype=np.int64)
        _check_call(_LIB.GetDLROutputShape(byref(self.handle),
                                                    c_int(index),
                    shape.ctypes.data_as(ctypes.POINTER(ctypes.c_longlong))))
        return shape 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:24,代码来源:api.py

示例13: cf_number_to_number

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def cf_number_to_number(value):
        """
        Converts a CFNumber object to a python float or integer

        :param value:
            The CFNumber object

        :return:
            A python number (float or integer)
        """

        type_ = CoreFoundation.CFNumberGetType(_cast_pointer_p(value))
        c_type = {
            1: c_byte,              # kCFNumberSInt8Type
            2: ctypes.c_short,      # kCFNumberSInt16Type
            3: ctypes.c_int32,      # kCFNumberSInt32Type
            4: ctypes.c_int64,      # kCFNumberSInt64Type
            5: ctypes.c_float,      # kCFNumberFloat32Type
            6: ctypes.c_double,     # kCFNumberFloat64Type
            7: c_byte,              # kCFNumberCharType
            8: ctypes.c_short,      # kCFNumberShortType
            9: ctypes.c_int,        # kCFNumberIntType
            10: c_long,             # kCFNumberLongType
            11: ctypes.c_longlong,  # kCFNumberLongLongType
            12: ctypes.c_float,     # kCFNumberFloatType
            13: ctypes.c_double,    # kCFNumberDoubleType
            14: c_long,             # kCFNumberCFIndexType
            15: ctypes.c_int,       # kCFNumberNSIntegerType
            16: ctypes.c_double,    # kCFNumberCGFloatType
        }[type_]
        output = c_type(0)
        CoreFoundation.CFNumberGetValue(_cast_pointer_p(value), type_, byref(output))
        return output.value 
开发者ID:wbond,项目名称:oscrypto,代码行数:35,代码来源:_core_foundation_ctypes.py

示例14: strides_as

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def strides_as(self, obj):
        """
        Return the strides tuple as an array of some other
        c-types type. For example: ``self.strides_as(ctypes.c_longlong)``.
        """
        if self._zerod:
            return None
        return (obj*self._arr.ndim)(*self._arr.strides) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:_internal.py

示例15: shape

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_longlong [as 别名]
def shape(self):
        """
        (c_intp*self.ndim): A ctypes array of length self.ndim where
        the basetype is the C-integer corresponding to ``dtype('p')`` on this
        platform. This base-type could be `ctypes.c_int`, `ctypes.c_long`, or
        `ctypes.c_longlong` depending on the platform.
        The c_intp type is defined accordingly in `numpy.ctypeslib`.
        The ctypes array contains the shape of the underlying array.
        """
        return self.shape_as(_getintp_ctype()) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:_internal.py


注:本文中的ctypes.c_longlong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。