Beispiel #1
0
def rand(dp, D=None, bc=None, seed=None, dtype=np.float64, fix_D=False):
    if dtype != np.float64:
        raise NotImplementedError

    if seed is not None:
        np.random.seed(seed)

    def fn(a, dtype):
        return np.array(np.random.random(a), dtype=dtype)

    return gMPX.create(dp, D, bc, fn=fn, dtype=dtype, fix_D=fix_D)
Beispiel #2
0
def rand(dp, D = None, bc = None, seed = None, density = 0.8, dtype=np.float64, fix_D = False):
    # random float, upcast to dtype
    if seed is not None:
        np.random.seed(seed)
    def fn(shape, dtype):
        return sp.random(shape, density=density)

    if dtype != np.float64:
        raise NotImplementedError
    
    return MPX.create(dp, D, bc, fn=fn, dtype=None, fix_D = fix_D)
Beispiel #3
0
def empty(dp, D=None, bc=None, dtype=np.float64, fix_D=False):
    return gMPX.create(dp, D, bc, fn=np.empty, dtype=dtype, fix_D=fix_D)
Beispiel #4
0
def zeros(dp, D=None, bc=None, dtype=np.float64, fix_D=False):
    return gMPX.create(dp, D, bc, fn=np.zeros, dtype=dtype, fix_D=fix_D)
Beispiel #5
0
def zeros(dp, D = None, bc = None, dtype = np.float64, fix_D = False):
    def _from_np_zeros(shape, dtype):
        return sp.COO.from_numpy(np.zeros(shape, dtype))
    return MPX.create(dp, D, bc, fn=_from_np_zeros, fix_D = fix_D)