next up previous print clean
Next: The word ``adjoint'' Up: ADJOINT DEFINED: DOT-PRODUCT TEST Previous: Definition of a vector

Dot-product test for validity of an adjoint

There is a huge gap between the conception of an idea and putting it into practice. During development, things fail far more often than not. Often, when something fails, many tests are needed to track down the cause of failure. Maybe the cause cannot even be found. More insidiously, failure may be below the threshold of detection and poor performance suffered for years. The dot-product test enables us to ascertain whether the program for the adjoint of an operator is precisely consistent with the operator itself. It can be, and it should be.

Conceptually, the idea of matrix transposition is simply aij'=aji. In practice, however, we often encounter matrices far too large to fit in the memory of any computer. Sometimes it is also not obvious how to formulate the process at hand as a matrix multiplication. (Examples are differential equations and fast Fourier transforms.) What we find in practice is that an application and its adjoint amounts to two routines. The first routine amounts to the matrix multiplication $ \bold F \bold x$.The adjoint routine computes $\bold F' \bold y$,where $\bold F'$ is the conjugate-transpose matrix. In later chapters we will be solving huge sets of simultaneous equations, in which both routines are required. If the pair of routines are inconsistent, we are doomed from the start. The dot-product test is a simple test for verifying that the two routines are adjoint to each other.

The associative property of linear algebra says that we do not need parentheses in a vector-matrix-vector product like $\bold y' \bold F \bold x $ because we get the same result no matter where we put the parentheses. They serve only to determine the sequence of computation. Thus,
\bold y' ( \bold F \bold x ) &=& ( \bold y' \bold F ) \bold x \\ \bold y' ( \bold F \bold x ) &=& ( \bold F' \bold y )' \bold x\end{eqnarray} (26)
(In general, the matrix is not square.) To perform the dot-product test, load the vectors $\bold x$ and $\bold y$ with random numbers. Using your program for $\bold F$,compute the vector $\tilde \bold y = \bold F\bold x$,and using your program for $\bold F'$,compute $\tilde \bold x = \bold F'\bold y$.Inserting these into equation (28) gives you two scalars that should be equal.  
\bold y' ( \bold F \bold x ) \eq
\bold y' \tilde \bold y \eq \tilde \bold x ' \bold x
\eq ( \bold F' \bold y )' \bold x\end{displaymath} (28)
The left and right sides of this equation will be computationally equal only if the program doing $\bold F'$ is indeed adjoint to the program doing $\bold F$(unless the random numbers do something miraculous). A final word: If an operator uses complex arithmetic then both its input and output are ``in the field of complex numbers.'' The conversion between real and complex numbers is not a linear operator despite its seeming similarity to truncation and zero padding.

The program for applying the dot product test is dot_test [*]. The Fortran way of passing a linear operator as an argument is to specify the function interface. Fortunately, we have already defined the interface for a generic linear operator. To use the dot_test program, you need to initialize an operator with specific arguments (the _init subroutine) and then pass the operator itself (the _lop function) to the test program. You also need to specify the sizes of the model and data vectors so that temporary arrays can be constructed. The program runs the dot product test twice, second time with add = .true. to test if the operator can be used properly for accumulating the result like $\bold y \leftarrow \bold y+\bold B\bold x$.dottestdot-product test

I tested (29) on many operators and was surprised and delighted to find that it is often satisfied to an accuracy near the computing precision. I do not doubt that larger rounding errors could occur, but so far, every time I encountered a relative discrepancy of 10-5 or more, I was later able to uncover a conceptual or programming error. Naturally, when I do dot-product tests, I scale the implied matrix to a small dimension in order to speed things along, and to be sure that boundaries are not overwhelmed by the much larger interior.

Do not be alarmed if the operator you have defined has truncation errors. Such errors in the definition of the original operator should be identically matched by truncation errors in the adjoint operator. adjoint ! truncation errors If your code passes the dot-product test, then you really have coded the adjoint operator. In that case, to obtain inverse operators, you can take advantage of the standard methods of mathematics.

We can speak of a continuous function f(t) or a discrete function ft. For continuous functions we use integration, and for discrete ones we use summation. In formal mathematics, the dot-product test defines the adjoint operator, except that the summation in the dot product may need to be changed to an integral. The input or the output or both can be given either on a continuum or in a discrete domain. So the dot-product test $\bold y' \tilde \bold y = \tilde \bold x ' \bold x$could have an integration on one side of the equal sign and a summation on the other. Linear-operator theory is rich with concepts not developed here.

next up previous print clean
Next: The word ``adjoint'' Up: ADJOINT DEFINED: DOT-PRODUCT TEST Previous: Definition of a vector
Stanford Exploration Project