The preaccumulation of a code section corresponds to the process of replacing the recorded tape entries with the Jacobian matrix of that section. If the code part is defined by the function , then the Jacobian is computed by the Preaccumulation helper and stored on the tape.
The preaccumulation of a code part is beneficial if it is complicated to compute but has only a few inputs and outputs. If the computation requires 200 statements with a total of 600 arguments, the storage for this would be 7400 byte on a Jacobian tape. If the function has only two input arguments and two output arguments, the storage for the Jacobian matrix of this function would require 50 byte.
The procedure for the preaccumulation of a code section is as follows.
The preaccumulation helper can be used multiple times, the start routine resets the state such that multiple evaluations are possible. This improves the performance of the helper since stack allocations are only performed once.
Template Parameters
T_Type
The CoDiPack type on which the evaluations take place.
Finish the preaccumulation region and perform the preaccumulation. See addOutput() for outputs. Not compatible with simultaneous thread-local preaccumulations with shared inputs. In this case, see finishLocalMappedAdjoints, finishLocalAdjointsPreprocessTape, and finishLocalAdjoints.
Finish the preaccumulation region and perform the preaccumulation. Uses local adjoints instead of adjoints from the tape. Behaves either like finishLocalMappedAdjoints or like finishLocalAdjointsPreprocessTape, depending on which is more efficient given the numbers of inputs and outputs. See addOutput() for outputs.
Finish the preaccumulation region and perform the preaccumulation. Create a local adjoint vector instead of using adjoints from the tape. Edits the tape, remapping the identifiers to a contiguous range. More efficient than finishLocalMappedAdjoints if both the numbers of inputs and outputs are > 1. Behaves like finishLocalMappedAdjoints if the underlying tape does not support editing.
Finish the preaccumulation region and perform the preaccumulation. Creates a local map of adjoints instead of using adjoints from the tape. See addOutput() for outputs.