def ones(shape, typecode='l', savespace=0, dtype=None): """ones(shape, dtype=int) returns an array of the given dimensions which is initialized to all ones. """ dtype = convtypecode(typecode,dtype) a = mu.empty(shape, dtype) a.fill(1) return a
def ones(shape, typecode='l', savespace=0, dtype=None): """ones(shape, dtype=int) returns an array of the given dimensions which is initialized to all ones. """ dtype = convtypecode(typecode, dtype) a = mu.empty(shape, dtype) a.fill(1) return a
def tri(N, M=None, k=0, typecode=None, dtype=None): """ returns a N-by-M array where all the diagonals starting from lower left corner up to the k-th are all ones. """ dtype = convtypecode(typecode, dtype) if M is None: M = N m = np.greater_equal(np.subtract.outer(np.arange(N), np.arange(M)), -k) if m.dtype != dtype: return m.astype(dtype)
def tri(N, M=None, k=0, typecode=None, dtype=None): """ returns a N-by-M array where all the diagonals starting from lower left corner up to the k-th are all ones. """ dtype = convtypecode(typecode, dtype) if M is None: M = N m = np.greater_equal(np.subtract.outer(np.arange(N), np.arange(M)),-k) if m.dtype != dtype: return m.astype(dtype)
def eye(N, M=None, k=0, typecode=None, dtype=None): """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones, and everything else is zeros. """ dtype = convtypecode(typecode, dtype) if M is None: M = N m = np.equal(np.subtract.outer(np.arange(N), np.arange(M)), -k) if m.dtype != dtype: return m.astype(dtype)
def eye(N, M=None, k=0, typecode=None, dtype=None): """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones, and everything else is zeros. """ dtype = convtypecode(typecode, dtype) if M is None: M = N m = np.equal(np.subtract.outer(np.arange(N), np.arange(M)),-k) if m.dtype != dtype: return m.astype(dtype)
def _LoadArray(fp): import typeconv ln = fp.readline().split() if ln[0][0] == 'A': ln[0] = ln[0][1:] typecode = ln[0][0] endian = ln[0][1] itemsize = int(ln[0][2:]) shape = [int(x) for x in ln[1:]] sz = itemsize for val in shape: sz *= val dstr = fp.read(sz) m = mu.fromstring(dstr, typeconv.convtypecode(typecode)) m.shape = shape if (LittleEndian and endian == 'B') or (not LittleEndian and endian == 'L'): return m.byteswap(True) else: return m
def empty(shape, typecode='l', dtype=None): dtype = convtypecode(typecode, dtype) return mu.empty(shape, dtype)
def zeros(shape, typecode='l', savespace=0, dtype=None): """zeros(shape, dtype=int) returns an array of the given dimensions which is initialized to all zeros """ dtype = convtypecode(typecode, dtype) return mu.zeros(shape, dtype)
def identity(n, typecode='l', dtype=None): """identity(n) returns the identity 2-d array of shape n x n. """ dtype = convtypecode(typecode, dtype) return nn.identity(n, dtype)
def indices(dimensions, typecode=None, dtype=None): dtype = convtypecode(typecode, dtype) return N.indices(dimensions, dtype)
def indices(dimensions, typecode=None, dtype=None): dtype = convtypecode(typecode, dtype) return np.indices(dimensions, dtype)
def fromstring(string, typecode='l', count=-1, dtype=None): dtype = convtypecode(typecode, dtype) return mu.fromstring(string, dtype, count=count)
def zeros(shape, typecode='l', savespace=0, dtype=None): """zeros(shape, dtype=int) returns an array of the given dimensions which is initialized to all zeros """ dtype = convtypecode(typecode,dtype) return mu.zeros(shape, dtype)
def identity(n,typecode='l', dtype=None): """identity(n) returns the identity 2-d array of shape n x n. """ dtype = convtypecode(typecode, dtype) return nn.identity(n, dtype)