| 712 | |
| 713 | @pytest.mark.parametrize(("shape", "chunk"), [(20, 10), (50, 10)]) |
| 714 | def test_solve(shape, chunk): |
| 715 | rng = np.random.default_rng(1) |
| 716 | |
| 717 | A = rng.integers(1, 10, (shape, shape)) |
| 718 | dA = da.from_array(A, (chunk, chunk)) |
| 719 | |
| 720 | # vector |
| 721 | b = rng.integers(1, 10, shape) |
| 722 | db = da.from_array(b, chunk) |
| 723 | |
| 724 | res = da.linalg.solve(dA, db) |
| 725 | assert_eq(res, scipy.linalg.solve(A, b), check_graph=False) |
| 726 | assert_eq(dA.dot(res), b.astype(float), check_graph=False) |
| 727 | |
| 728 | # tall-and-skinny matrix |
| 729 | b = rng.integers(1, 10, (shape, 5)) |
| 730 | db = da.from_array(b, (chunk, 5)) |
| 731 | |
| 732 | res = da.linalg.solve(dA, db) |
| 733 | assert_eq(res, scipy.linalg.solve(A, b), check_graph=False) |
| 734 | assert_eq(dA.dot(res), b.astype(float), check_graph=False) |
| 735 | |
| 736 | # matrix |
| 737 | b = rng.integers(1, 10, (shape, shape)) |
| 738 | db = da.from_array(b, (chunk, chunk)) |
| 739 | |
| 740 | res = da.linalg.solve(dA, db) |
| 741 | assert_eq(res, scipy.linalg.solve(A, b), check_graph=False) |
| 742 | assert_eq(dA.dot(res), b.astype(float), check_graph=False) |
| 743 | |
| 744 | |
| 745 | @pytest.mark.parametrize(("shape", "chunk"), [(20, 10), (50, 10)]) |