discretize.tests.assert_isadjoint#
- discretize.tests.assert_isadjoint(forward, adjoint, shape_u, shape_v, complex_u=False, complex_v=False, clinear=True, rtol=1e-06, atol=0.0, assert_error=True, random_seed=None)[source]#
Do a dot product test for the forward operator and its adjoint operator.
Dot product test to verify the correctness of the adjoint operator \(F^H\) of the forward operator \(F\).
\[\mathbf{v}^H ( \mathbf{F} \mathbf{u} ) = ( \mathbf{F}^H \mathbf{v} )^H \mathbf{u}\]- Parameters:
- forward
callable() Forward operator.
- adjoint
callable() Adjoint operator.
- shape_u
int,tupleofint Shape of vector
upassed in toforward; it is accordingly the expected shape of the vector returned from theadjoint.- shape_v
int,tupleofint Shape of vector
vpassed in toadjoint; it is accordingly the expected shape of the vector returned from theforward.- complex_ubool, default:
False If True, vector
upassed toforwardis a complex vector; accordingly theadjointis expected to return a complex vector.- complex_vbool, default:
False If True, vector
vpassed toadjointis a complex vector; accordingly theforwardis expected to return a complex vector.- clinearbool, default:
True If operator is complex-linear (True) or real-linear (False).
- rtol
float, default: 1e-6 Relative tolerance.
- atol
float, default: 0.0 Absolute tolerance.
- assert_errorbool, default:
True By default this test is an assertion (silent if passed, raising an assertion error if failed). If set to False, the result of the test is returned as boolean and a message is printed.
- random_seed
numpy.random.Generator,int,optional The random number generator to use for the adjoint test. If an integer or None it is used to seed a new numpy.random.default_rng.
- forward
- Returns:
- passedbool,
optional Result of the dot product test; only returned if
assert_erroris False.
- passedbool,
- Raises:
AssertionErrorIf the dot product test fails (only if assert_error=True).