(bs, dtype, mat_random, mat_gather)
| 55 | ], |
| 56 | ) |
| 57 | def test_matvec(bs, dtype, mat_random, mat_gather): |
| 58 | A = mat_random(0, 0, 12345, dtype, bs) |
| 59 | Ascipy = mat_gather(A) |
| 60 | imap = A.index_map(0) |
| 61 | lr0, lr1 = imap.local_range |
| 62 | nr = imap.size_local |
| 63 | # Check gathered matrix |
| 64 | assert np.allclose(A.to_dense()[: nr * bs[0], :], Ascipy.todense()[lr0 * bs[0] : lr1 * bs[0]]) |
| 65 | |
| 66 | b = la.vector(imap, bs=bs[1], dtype=dtype) |
| 67 | u = la.vector(imap, bs=bs[0], dtype=dtype) |
| 68 | u.array[:] = 0.0 |
| 69 | b.array[:] = np.arange(len(b.array)) |
| 70 | |
| 71 | A.mult(b, u) |
| 72 | bscipy = np.concatenate(imap.comm.allgather(b.array[: nr * bs[1]])) |
| 73 | us = Ascipy @ bscipy |
| 74 | assert np.allclose(u.array[: nr * bs[0]], us[lr0 * bs[0] : lr1 * bs[0]]) |
| 75 | |
| 76 | |
| 77 | @pytest.mark.parametrize("bs", [[1, 1], [2, 2], [1, 2], [2, 1], [2, 3], [3, 3]]) |
nothing calls this directly
no test coverage detected