def _findIndices(ArrSize, FilterSize): N = FilterSize.shape[0] n = int(FilterSize.prod()) CumSizeArr = numpy.ones([N], dtype=numpy.int32) CumSizeArr[1:N] = ArrSize[0:N - 1].cumprod() CumSize = numpy.ones([N], dtype=numpy.int32) CumSize[1:N] = FilterSize[0:N - 1].cumprod() vals = numpy.empty((n, N), dtype=numpy.int32) for i in range(N): vals[:, i] = numpy.linspace(0, n - 1, n) vals = vals // CumSize vals = vals % FilterSize CurrPos = summations.sum(vals * CumSizeArr, axis=1) return CurrPos.astype(numpy.int32)
def ones(shape, dtype=float, bohrium=True): """ Matrix of ones. Return a matrix of given shape and type, filled with ones. Parameters ---------- shape : {sequence of ints, int} Shape of the matrix dtype : data-type, optional The desired data-type for the matrix, default is np.float64. bohrium : boolean, optional Determines whether it is a Bohrium-enabled array or a regular NumPy array Returns ------- out : matrix Matrix of ones of given shape, dtype, and order. See Also -------- ones : Array of ones. matlib.zeros : Zero matrix. Notes ----- The order of the data in memory is always row-major (C-style). If `shape` has length one i.e. ``(N,)``, or is a scalar ``N``, `out` becomes a single row matrix of shape ``(1,N)``. Examples -------- >>> np.matlib.ones((2,3)) matrix([[ 1., 1., 1.], [ 1., 1., 1.]]) >>> np.matlib.ones(2) matrix([[ 1., 1.]]) """ if bohrium and not dtype_support(dtype): _warn_dtype(dtype, 3) return numpy.ones(shape, dtype=dtype) A = empty(shape, dtype=dtype, bohrium=bohrium) A[...] = A.dtype.type(1) return A