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
,tuple
of
int
Shape of vector
u
passed in toforward
; it is accordingly the expected shape of the vector returned from theadjoint
.- shape_v
int
,tuple
of
int
Shape of vector
v
passed in toadjoint
; it is accordingly the expected shape of the vector returned from theforward
.- complex_ubool, default:
False
If True, vector
u
passed toforward
is a complex vector; accordingly theadjoint
is expected to return a complex vector.- complex_vbool, default:
False
If True, vector
v
passed toadjoint
is a complex vector; accordingly theforward
is 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_error
is False.
- passedbool,
- Raises:
AssertionError
If the dot product test fails (only if assert_error=True).