本文整理汇总了Python中Numeric.zeros方法的典型用法代码示例。如果您正苦于以下问题:Python Numeric.zeros方法的具体用法?Python Numeric.zeros怎么用?Python Numeric.zeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Numeric
的用法示例。
在下文中一共展示了Numeric.zeros方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def __init__ (self):
# // Initalize all our member varibles.
self.m_MaxPitchRate = 0.0;
self.m_MaxHeadingRate = 0.0;
self.m_HeadingDegrees = 0.0;
self.m_PitchDegrees = 0.0;
self.m_MaxForwardVelocity = 0.0;
self.m_ForwardVelocity = 0.0;
self.m_GlowTexture = None;
# bleair: NOTE that glCamera.cpp has a bug. m_BigGlowTexture isn't initialized.
# Very minor bug because only in the case where we fail to get an earlier
# texture will the class potentially read from the uninited memory. Most of
# the time the field is assigned to straight away in InitGL ().
self.m_BigGlowTexture = None;
self.m_HaloTexture = None;
self.m_StreakTexture = None;
self.m_MaxPointSize = 0.0;
self.m_Frustum = Numeric.zeros ( (6,4), 'f')
self.m_LightSourcePos = glPoint ()
self.m_Position = glPoint ()
self.m_DirectionVector = glVector ()
self.m_ptIntersect = glPoint ()
示例2: Reset
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def Reset ():
""" // Reset The Maze, Colors, Start Point, Etc """
global tex_data, r, g, b, mx, my
# ZeroMemory(tex_data, width * height *3); // Clear Out The Texture Memory With 0's
# This creates or array of unsigned bytes for our texture data. All values initialized to 0
# tex_data = numarray.zeros ((width * height * 3), type="u1")
tex_data = Numeric.zeros ((width * height * 3), "b")
# This Will seed the random num stream with current system time.
random.seed ()
for loop in xrange (4): # // Loop So We Can Assign 4 Random Colors
r[loop]=128 + random.randint (0,127) # // Pick A Random Red Color (Bright)
g[loop]=128 + random.randint (0,127) # // Pick A Random Green Color (Bright)
b[loop]=128 + random.randint (0,127) # // Pick A Random Blue Color (Bright)
mx = random.randint (0, (width/2) - 1) * 2 # // Pick A New Random X Position
my = random.randint (0, (width/2) - 1) * 2 # // Pick A New Random Y Position
return
# // Any GL Init Code & User Initialiazation Goes Here
示例3: grid_coarse
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def grid_coarse(in_grid, in_ny, in_nx, out_ny, out_nx, factor):
"""Replace a grid with one that is more coarse
Inputs:
in_ny -- number of input grid rows
in_nx -- number of input grid columns
out_ny -- number of output grid rows
out_nx -- number of output grid columns
factor -- input grid box length divided by output grid box length
"""
out_grid = Numeric.zeros((out_ny, out_nx), in_grid.typecode())
for j in xrange(0, out_ny):
xjfine = float(j) * factor
jfine = int (float(j) * factor)
dj = xjfine - float(jfine)
jp1 = min(in_ny-1, jfine+1)
jm1 = max(0, jfine-1)
for i in xrange(0, out_nx):
xifine = float(i) * factor
ifine = int (float(i) * factor)
di = xifine - float(ifine)
ip1 = min(in_nx-1, ifine+1)
xval = (1.-di) * (1.-dj) * in_grid[jfine, ifine] + (1.-di) * dj * in_grid[jp1, ifine] + di * (1.-dj) * in_grid[jfine, ip1] + di * dj * in_grid[jp1, ip1]
out_grid[j, i] = xval
return out_grid
示例4: __init__
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def __init__(self, in_ny, in_nx, out_ny, out_nx, factor):
"""Constructor
Inputs:
in_ny -- number of input grid rows
in_nx -- number of input grid columns
out_ny -- number of output grid rows
out_nx -- number of output grid columns
factor -- input grid box length divided by output grid box length
"""
self.in_ny = in_ny
self.in_nx = in_nx
self.out_ny = out_ny
self.out_nx = out_nx
self.factor = factor
self.jfine = Numeric.zeros(out_ny)
self.dj = Numeric.zeros(out_ny, Numeric.Float64)
self.jp1 = Numeric.zeros(out_ny)
self.ifine = Numeric.zeros(out_nx)
self.di = Numeric.zeros(out_nx, Numeric.Float64)
self.ip1 = Numeric.zeros(out_nx)
for j in xrange(0, out_ny):
xjfine = float(j) * self.factor
self.jfine[j] = int(float(j) * self.factor)
self.dj[j] = xjfine - float(self.jfine[j])
self.jp1[j] = min(self.in_ny-1, self.jfine[j]+1)
for i in xrange(0, out_nx):
xifine = float(i) * self.factor
self.ifine[i] = int(float(i) * self.factor)
self.di[i] = xifine - float(self.ifine[i])
self.ip1[i] = min (self.in_nx-1, self.ifine[i]+1)
self.d1 = Numeric.outerproduct(1.0 - self.dj, 1.0 - self.di)
self.d2 = Numeric.outerproduct(self.dj, 1.0 - self.di)
self.d3 = Numeric.outerproduct(1.0 - self.dj, self.di)
self.d4 = Numeric.outerproduct(self.dj, self.di)
示例5: Quat4fT
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def Quat4fT ():
return Numeric.zeros (4, 'f')
示例6: Vector3fT
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def Vector3fT ():
return Numeric.zeros (3, 'f')
示例7: Point2fT
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def Point2fT (x = 0.0, y = 0.0):
pt = Numeric.zeros (2, 'f')
pt [0] = x
pt [1] = y
return pt
示例8: Vector3fCross
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def Vector3fCross(u, v):
# Cross product of two 3f vectors
X = 0
Y = 1
Z = 2
cross = Numeric.zeros (3, 'f')
cross [X] = (u[Y] * v[Z]) - (u[Z] * v[Y])
cross [Y] = (u[Z] * v[X]) - (u[X] * v[Z])
cross [Z] = (u[X] * v[Y]) - (u[Y] * v[X])
return cross
示例9: newcolumn
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def newcolumn(self,str):
ncol = len(self.snaps[0].atoms[0])
self.map(ncol+1,str)
for snap in self.snaps:
atoms = snap.atoms
if oldnumeric: newatoms = np.zeros((snap.natoms,ncol+1),np.Float)
else: newatoms = np.zeros((snap.natoms,ncol+1),np.float)
newatoms[:,0:ncol] = snap.atoms
snap.atoms = newatoms
# --------------------------------------------------------------------
# sort snapshots on time stamp
示例10: read_snapshot
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def read_snapshot(self,f):
try:
snap = Snap()
item = f.readline()
snap.time = int(f.readline().split()[0]) # just grab 1st field
item = f.readline()
snap.natoms = int(f.readline())
item = f.readline()
f.readline() # read past BOX BOUNDS
f.readline()
f.readline()
f.readline()
if snap.natoms:
words = f.readline().split()
ncol = len(words)
for i in xrange(1,snap.natoms):
words += f.readline().split()
floats = map(float,words)
if oldnumeric: atoms = np.zeros((snap.natoms,ncol),np.Float)
else: atoms = np.zeros((snap.natoms,ncol),np.float)
start = 0
stop = ncol
for i in xrange(snap.natoms):
atoms[i] = floats[start:stop]
start = stop
stop += ncol
else: atoms = None
snap.atoms = atoms
return snap
except:
return 0
# --------------------------------------------------------------------
# map atom column names
示例11: read_snapshot
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def read_snapshot(self,f):
try:
snap = Snap()
item = f.readline()
snap.time = int(f.readline().split()[0]) # just grab 1st field
item = f.readline()
snap.natoms = int(f.readline())
item = f.readline()
words = f.readline().split()
snap.xlo,snap.xhi = float(words[0]),float(words[1])
words = f.readline().split()
snap.ylo,snap.yhi = float(words[0]),float(words[1])
words = f.readline().split()
snap.zlo,snap.zhi = float(words[0]),float(words[1])
item = f.readline()
if snap.natoms:
words = f.readline().split()
ncol = len(words)
for i in xrange(1,snap.natoms):
words += f.readline().split()
floats = map(float,words)
if oldnumeric: atoms = np.zeros((snap.natoms,ncol),np.Float)
else: atoms = np.zeros((snap.natoms,ncol),np.float)
start = 0
stop = ncol
for i in xrange(snap.natoms):
atoms[i] = floats[start:stop]
start = stop
stop += ncol
else: atoms = None
snap.atoms = atoms
return snap
except:
return 0
# --------------------------------------------------------------------
# map atom column names
示例12: make_echo
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def make_echo(sound, samples_per_second, mydebug = True):
""" returns a sound which is echoed of the last one.
"""
echo_length = 3.5
a1 = sndarray.array(sound)
if mydebug:
print ('SHAPE1: %s' % (a1.shape,))
length = a1.shape[0]
#myarr = zeros(length+12000)
myarr = zeros(a1.shape, int32)
if len(a1.shape) > 1:
mult = a1.shape[1]
size = (a1.shape[0] + int(echo_length * a1.shape[0]), a1.shape[1])
#size = (a1.shape[0] + int(a1.shape[0] + (echo_length * 3000)), a1.shape[1])
else:
mult = 1
size = (a1.shape[0] + int(echo_length * a1.shape[0]),)
#size = (a1.shape[0] + int(a1.shape[0] + (echo_length * 3000)),)
if mydebug:
print (int(echo_length * a1.shape[0]))
myarr = zeros(size, int32)
if mydebug:
print ("size %s" % (size,))
print (myarr.shape)
myarr[:length] = a1
#print (myarr[3000:length+3000])
#print (a1 >> 1)
#print ("a1.shape %s" % (a1.shape,))
#c = myarr[3000:length+(3000*mult)]
#print ("c.shape %s" % (c.shape,))
incr = int(samples_per_second / echo_length)
gap = length
myarr[incr:gap+incr] += a1>>1
myarr[incr*2:gap+(incr*2)] += a1>>2
myarr[incr*3:gap+(incr*3)] += a1>>3
myarr[incr*4:gap+(incr*4)] += a1>>4
if mydebug:
print ('SHAPE2: %s' % (myarr.shape,))
sound2 = sndarray.make_sound(myarr.astype(int16))
return sound2
示例13: read_snapshot
# 需要导入模块: import Numeric [as 别名]
# 或者: from Numeric import zeros [as 别名]
def read_snapshot(self,f):
try:
snap = Snap()
item = f.readline()
snap.time = int(f.readline())
snap.nflag = snap.eflag = snap.nvalueflag = snap.evalueflag = 0
str = f.readline()
if "NUMBER OF NODES" in str: snap.nflag = 1
elif "NUMBER OF TRIANGLES" in str: snap.eflag = 1
elif "NUMBER OF TETS" in str: snap.eflag = 2
elif "NUMBER OF SQUARES" in str: snap.eflag = 3
elif "NUMBER OF CUBES" in str: snap.eflag = 4
elif "NUMBER OF NODE VALUES" in str: snap.nvalueflag = 1
elif "NUMBER OF ELEMENT VALUES" in str: snap.evalueflag = 1
else: raise StandardError,"unrecognized snapshot in dump file"
n = int(f.readline())
if snap.eflag: snap.eselect = np.zeros(n)
if snap.nflag:
item = f.readline()
words = f.readline().split()
snap.xlo,snap.xhi = float(words[0]),float(words[1])
words = f.readline().split()
snap.ylo,snap.yhi = float(words[0]),float(words[1])
words = f.readline().split()
snap.zlo,snap.zhi = float(words[0]),float(words[1])
item = f.readline()
if n:
words = f.readline().split()
ncol = len(words)
for i in xrange(1,n):
words += f.readline().split()
floats = map(float,words)
if oldnumeric: values = np.zeros((n,ncol),np.Float)
else: values = np.zeros((n,ncol),np.float)
start = 0
stop = ncol
for i in xrange(n):
values[i] = floats[start:stop]
start = stop
stop += ncol
else: values = None
if snap.nflag:
snap.nodes = values; snap.nnodes = n
elif snap.eflag:
snap.elements = values; snap.nelements = n
elif snap.nvalueflag:
snap.nvalues = values; snap.nnvalues = n
elif snap.evalueflag:
snap.evalues = values; snap.nevalues = n
return snap
except:
return 0
# --------------------------------------------------------------------
# map atom column names