Exemplo n.º 1
0
def test_dot():
    for dtype in DTYPES:
        x = np.arange(cram.N, dtype=dtype)
        mat = cram.ones(dtype=dtype) + 9 * sp.eye(cram.N, format="csr", dtype=dtype)
        exp = mat.dot(x)
        obs = cram.dot(mat, x)
        yield assert_true, np.allclose(exp, obs)
Exemplo n.º 2
0
def test_diag_add():
    for dtype in DTYPES:
        mat = cram.ones(dtype=dtype)
        res = mat + 9 * sp.eye(cram.N, format="csr", dtype=dtype)
        exp = cram.flatten_sparse_matrix(res)
        obs = cram.diag_add(mat, 9.0)
        yield assert_true, np.allclose(exp, obs)
Exemplo n.º 3
0
def test_solve_ones_range():
    for dtype in DTYPES:
        b = np.arange(cram.N, dtype=dtype)
        mat = cram.ones(dtype=dtype) + 9 * sp.eye(cram.N, format="csr", dtype=dtype)
        obs = cram.solve(mat, b)
        exp = spla.spsolve(mat, b)
        yield assert_true, np.allclose(exp, obs)
Exemplo n.º 4
0
def test_solve_range_range():
    for dtype in DTYPES:
        b = np.arange(cram.N, dtype=dtype)
        mat = cram.ones(dtype=dtype) + sp.diags(
            [b], offsets=[0], shape=(cram.N, cram.N), format="csr", dtype=dtype
        )
        obs = cram.solve(mat, b)
        exp = spla.spsolve(mat, b)
        yield assert_true, np.allclose(exp, obs)