MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / test_matvec_transpose

Function test_matvec_transpose

python/test/unit/la/test_matrix_vector.py:87–106  ·  view source on GitHub ↗
(bs, dtype, mat_random, mat_gather)

Source from the content-addressed store, hash-verified

85 ],
86)
87def 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(

Callers

nothing calls this directly

Calls 6

mat_randomFunction · 0.85
mat_gatherFunction · 0.85
vectorMethod · 0.80
index_mapMethod · 0.45
to_denseMethod · 0.45
multMethod · 0.45

Tested by

no test coverage detected