next up previous contents [pdf] index

Next: Implementation of operators Up: Introduction Previous: Adjoint operators


The dot-product test

The dot-product test is a valuable checkpoint, which can tell us whether the implementation of the adjoint operator is wrong (however it cannot guarantee that it is indeed correct). The concept is the following: Assuming that we have coded an operator $ L$ and its adjoint $ L^*$ . Then for any two vectors or functions $ a$ and $ b$ ,

$\displaystyle \langle a,Lb\rangle = \langle(L^*a)^*,b\rangle$ (1)

where $ \langle , {}\rangle$ denotes the dot product. Remember that the dot product of two functions $ f,g\in \mathbb{L}_2$ is $ \int fg^*\;dt$ while the dot product of two vectors $ \mathbf{x}$ and $ \mathbf{y}$ is $ \mathbf{x}^H\mathbf{y}$ . Notice that for vectors eq. (1) becomes $ \mathbf{x}^H\mathbf{Ly} = (\mathbf{L}^H\mathbf{y})^H\mathbf{y}$ which is obviously true. The lhs of eq. (1) is computed using $ L$ , while the rhs is computed using the adjoint $ L^*$ . For the dot-product test, one just needs to load the vectors x and y with random numbers and perform the two computations. If the two results are not equal (within machine precision), then the computation of either $ L$ or $ L^*$ is erroneous. Note that truncation errors have identical effects on both operators, so the two results should be almost equal. The dot-product test (for real operators only) is implemented by [sec:sf_dot_test]sf_dot_test.


next up previous contents [pdf] index

Next: Implementation of operators Up: Introduction Previous: Adjoint operators

2011-07-02