本文整理汇总了Python中numpy.core.numeric.zeros方法的典型用法代码示例。如果您正苦于以下问题:Python numeric.zeros方法的具体用法?Python numeric.zeros怎么用?Python numeric.zeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.core.numeric
的用法示例。
在下文中一共展示了numeric.zeros方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setitem__
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
raise ValueError("Does not support negative powers.")
if key > self.order:
zr = NX.zeros(key-self.order, self.coeffs.dtype)
self._coeffs = NX.concatenate((zr, self.coeffs))
ind = 0
self._coeffs[ind] = val
return
示例2: __init__
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
示例3: __setitem__
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def __setitem__(self, key, val):
ind = self.order - key
if key < 0:
raise ValueError("Does not support negative powers.")
if key > self.order:
zr = NX.zeros(key-self.order, self.coeffs.dtype)
self.__dict__['coeffs'] = NX.concatenate((zr, self.coeffs))
self.__dict__['order'] = key
ind = 0
self.__dict__['coeffs'][ind] = val
return
示例4: __init__
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape, strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
示例5: make_mask_none
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def make_mask_none (s):
"Return a mask of all zeros of shape s."
result = numeric.zeros(s, dtype=MaskType)
result.shape = s
return result
示例6: zeros
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def zeros (shape, dtype=float):
"""zeros(n, dtype=float) =
an array of all zeros of the given length or shape."""
return array(numeric.zeros(shape, dtype))
示例7: inner
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def inner(a, b):
"""inner(a,b) returns the dot product of two arrays, which has
shape a.shape[:-1] + b.shape[:-1] with elements computed by summing the
product of the elements from the last dimensions of a and b.
Masked elements are replace by zeros.
"""
fa = filled(a, 0)
fb = filled(b, 0)
if len(fa.shape) == 0: fa.shape = (1,)
if len(fb.shape) == 0: fb.shape = (1,)
return masked_array(numeric.inner(fa, fb))
示例8: dot
# 需要导入模块: from numpy.core import numeric [as 别名]
# 或者: from numpy.core.numeric import zeros [as 别名]
def dot(a, b):
"""dot(a,b) returns matrix-multiplication between a and b. The product-sum
is over the last dimension of a and the second-to-last dimension of b.
Masked values are replaced by zeros. See also innerproduct.
"""
return innerproduct(filled(a, 0), numeric.swapaxes(filled(b, 0), -1, -2))