(bs, dtype, mat_random, mat_gather)
| 85 | ], |
| 86 | ) |
| 87 | def test_matvec_transpose(bs, dtype, mat_random, mat_gather): |
| 88 | # Create a random square MatrixCSR |
| 89 | A = mat_random(0, 0, 54321, dtype, bs) |
| 90 | |
| 91 | Ascipy = mat_gather(A) |
| 92 | imap = A.index_map(0) |
| 93 | lr0, lr1 = imap.local_range |
| 94 | nr = imap.size_local |
| 95 | # Check gathered matrix |
| 96 | assert np.allclose(A.to_dense()[: nr * bs[0], :], Ascipy.todense()[lr0 * bs[0] : lr1 * bs[0]]) |
| 97 | |
| 98 | b = la.vector(imap, dtype=dtype, bs=bs[0]) |
| 99 | u = la.vector(imap, dtype=dtype, bs=bs[1]) |
| 100 | u.array[:] = 0.0 |
| 101 | b.array[:] = np.arange(len(b.array)) |
| 102 | |
| 103 | A.mult(b, u, True) |
| 104 | bscipy = np.concatenate(imap.comm.allgather(b.array[: nr * bs[0]])) |
| 105 | us = Ascipy.T @ bscipy |
| 106 | assert np.allclose(u.array[: nr * bs[1]], us[lr0 * bs[1] : lr1 * bs[1]]) |
| 107 | |
| 108 | |
| 109 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected