|
ADOL-C: Automatic Differentiation in C/C++ 2.7.3
|
Classes | |
| struct | BvpData |
| Internal data structure managing buffers and parameters for bit-vector propagation. More... | |
Enumerations | |
| enum class | SparseANFBlock { Y , J , Z , L } |
| Represents the different ANF blocks. More... | |
Functions | |
| template<ControlFlowMode CFM> | |
| void | checkBVPInput (const double *basepoint) |
| Verifies input data consistency for bit-vector propagation. | |
| void | resetInput (std::span< uint * > &compressedRowStorage) |
| Resets all entries in the compressed row storage pointer array to nullptr. | |
| template<BitPatternPropagationDirection BPPD> | |
| void | resetOldSeed (BvpData< BPPD > &data, size_t dim2) |
| Sets all seed matrix entries to zero for reuse in the next strip-mined batch. | |
| template<BitPatternPropagationDirection BPPD> | |
| void | prepareSeedMatrix (size_t stripIdx, BvpData< BPPD > &data) |
| Builds a strip-mined partition of the seed matrix for a given batch. | |
| template<BitPatternPropagationDirection BPPD> | |
| void | setSeed (BvpData< BPPD > &data, size_t idx, size_t currentStripWordIdx) |
| Sets a single bit in the seed matrix corresponding to a specific variable index. | |
| template<BitPatternPropagationDirection BPPD> | |
| void | createSeed (BvpData< BPPD > &data, size_t stripIdx, size_t end) |
| Creates a seed matrix segment by invoking setSeed() for each variable in the strip. | |
| void | extract (size_t wordIdx, size_t stripIdx, size_t currentStripWordIdx, BvpData< BitPatternPropagationDirection::Forward > &data, std::span< uint * > &compressedRowStorage) |
| Extracts the sparsity pattern for one dependent variable (row) in forward bit-vector propagation mode. | |
| void | extract (size_t wordIdx, size_t stripIdx, BvpData< BitPatternPropagationDirection::Reverse > &data, std::span< uint * > &compressedRowStorage) |
| Extracts the sparsity pattern for one dependent variable (row) in reverse bit-vector propagation mode. | |
| template<BitPatternPropagationDirection BPPD> | |
| void | extractCompressedRowStorage (int stripIdx, std::span< uint * > &compressedRowStorage, BvpData< BPPD > &data) |
| Converts Jacobian bit patterns to compressed row storage (CRS) format for one strip. | |
| template<BitPatternPropagationDirection BPPD, ControlFlowMode CFM> | |
| void | prepareADCalls (short tapeId, const double *basepoint, BvpData< BPPD > &data) |
| Prepares reverse call using zos_forward. | |
| template<BitPatternPropagationDirection BPPD, ControlFlowMode CFM> | |
| void | ADCalls (short tapeId, const double *basepoint, BvpData< BPPD > &data) |
| Executes the ADOL-C internal bit-vector propagation calls (forward or reverse). | |
| template<ControlFlowMode CFM, BitPatternPropagationDirection BPPD> | |
| int | bitVectorPropagation (short tapeId, int depen, int indep, const double *basepoint, std::span< uint * > &compressedRowStorage) |
| Main internal implementation for bit-vector propagation. | |
| template<SparseMethod SM, CompressionMode CM, ControlFlowMode CFM, BitPatternPropagationDirection BPPD = BitPatternPropagationDirection::Auto> | |
| int | buildJacPatternAndSeed (short tag, int depen, int indep, const double *basepoint) |
| Allocates and computes pattern of jacobian and computes a seed to compute a sparse Jacobian. | |
| template<PiecewiseLinear > | |
| int | buildJacPatternAndSeed (short tag, int depen, int indep, int numSwitches, const double *basepoint) |
| Build pattern and seed data for the piecewise-linear sparse Jacobian. | |
| template<CompressionMode CM, MemoryHandler MH> | |
| void | recover (const ValueTape &tape, SparseMatrix &sparseJac) |
| Passes args to jacobian-recover method based on the template-args. | |
| template<MemoryHandler MH> | |
| void | recover (const ValueTape &tape, SparseANF &sparseANF) |
| Passes args to ANF recovery methods based on the template args. | |
| template<CompressionMode CM, MemoryHandler MH> | |
| int | computeSparseJac (short tag, int depen, int indep, const double *basepoint, SparseMatrix &sparseJac) |
| Compute sparse Jacobian using precomputed seed matrix and recovery information. | |
| template<MemoryHandler MH> | |
| int | computeSparseJac (short tag, int depen, int indep, int numSwitches, const double *basepoint, SparseANF &sparseANF) |
| Recover the piecewise-linear sparse Jacobian into ANF blocks. | |
| template<ControlFlowMode CFM, RecoveryMethod RCM> | |
| int | buildHessPatternAndSeed (short tag, int indep, const double *basepoint, int *nnz) |
| Build Hessian sparsity pattern and generate ColPack seed for recovery. | |
| template<RecoveryMethod RCM> | |
| int | computeSparseHess (short tag, int indep, const double *basepoint, int *nnz, unsigned int **rind, unsigned int **cind, double **values) |
| Compute sparse Hessian using precomputed seed/recovery info. | |
| SparseANFBlock | classifySparseANFBlock (CoordinateFormatTripled::Coordinates coords, int depen, int indep) |
|
strong |
| void ADOLC::Sparse::detail::ADCalls | ( | short | tapeId, |
| const double * | basepoint, | ||
| BvpData< BPPD > & | data | ||
| ) |
Executes the ADOL-C internal bit-vector propagation calls (forward or reverse).
| BPPD | Bit pattern propagation direction. |
| CFM | Control flow mode. |
| tapeId | ADOL-C tape identifier. |
| basepoint | Pointer to independent variable values (required for forward
|
| data | Bit-vector propagation state container. |
| int ADOLC::Sparse::detail::bitVectorPropagation | ( | short | tapeId, |
| int | depen, | ||
| int | indep, | ||
| const double * | basepoint, | ||
| std::span< uint * > & | compressedRowStorage | ||
| ) |
Main internal implementation for bit-vector propagation.
Iteratively builds and propagates seed matrices, performs ADOL-C bit-vector propagation calls, and extracts the sparsity pattern into CRS format.
| CFM | Control flow mode. |
| BPPD | Bit pattern propagation direction. |
| tapeId | ADOL-C tape identifier. |
| depen | Number of dependent variables. |
| indep | Number of independent variables. |
| basepoint | Pointer to basepoint values. |
| compressedRowStorage | Output CRS sparsity pattern. |
| int ADOLC::Sparse::detail::buildHessPatternAndSeed | ( | short | tag, |
| int | indep, | ||
| const double * | basepoint, | ||
| int * | nnz | ||
| ) |
Build Hessian sparsity pattern and generate ColPack seed for recovery.
This routine computes the sparsity pattern of the Hessian and constructs a seed matrix for Hessian recovery using ColPack. It stores pattern and seed/recovery related data inside the tape's sHInfos() structure for reuse by subsequent numerical recovery calls.
| CFM | ControlFlowMode used when computing the Hessian pattern:
|
| RCM | RecoveryMethod selecting Hessian recovery strategy:
|
| tag | ADOL-C tape identifier. | |
| indep | Number of independent variables (dimension of Hessian). | |
| basepoint | Pointer to an array of length indep with the point at which control-flow (if any) should be tested. May be nullptr if not required by the chosen CFM (Safe vs Tight). | |
| [out] | nnz | Pointer to an integer where the number of nonzero Hessian entries will be stored. |
hess_pathess_pat.tape.sHInfos().HP_.tape.sHInfos().Xppp_. The ColPack-owned seed memory will be freed when the ColPack graph object (g_) is destroyed.| int ADOLC::Sparse::detail::buildJacPatternAndSeed | ( | short | tag, |
| int | depen, | ||
| int | indep, | ||
| const double * | basepoint | ||
| ) |
Allocates and computes pattern of jacobian and computes a seed to compute a sparse Jacobian.
This routine computes the Jacobian sparsity pattern (via jac_pat) and then uses ColPack to generate a seed matrix (graph coloring) suitable for compressed Jacobian recovery. It stores results inside the tape's sJInfos() structure so subsequent compute_sparse_jac/repeat calls can reuse the seed and recovery objects.
| SM | Sparsity-detection method used by jac_pat:
|
| CM | Compression orientation for ColPack seed generation:
|
| CFM | Control-flow mode used when computing the sparsity pattern. |
| BPPD | Bit pattern propagation direction when SM == BitPattern. When BitPatternPropagationDirection::Auto a runtime heuristic is used. |
| tag | ADOL-C tape identifier. |
| depen | Number of dependent (output) variables (rows of Jacobian). |
| indep | Number of independent (input) variables (columns of Jacobian). |
| basepoint | Pointer to an array of length indep with the basepoint values. May be nullptr if control-flow mode does not require a basepoint. |
jac_pat or other internal failures.tape.sJInfos().JP_. Ownership of those row buffers is transferred to the tape (they will be freed/managed by the tape lifecycle).tape.sJInfos().g_ and tape.sJInfos().jr1d_ are created and kept in the tape for later use by compute_sparse_jac. | int ADOLC::Sparse::detail::buildJacPatternAndSeed | ( | short | tag, |
| int | depen, | ||
| int | indep, | ||
| int | numSwitches, | ||
| const double * | basepoint | ||
| ) |
Build pattern and seed data for the piecewise-linear sparse Jacobian.
This specializes the generic sparse Jacobian setup for abs-smooth functions. It computes the sparsity pattern of the extended Jacobian via indopro_forward_absnormal(), then generates a row-compression seed for the [y ; z] by [x ; |z|] matrix. This driver currently supports only row-compression because the compressed Jacobian is computed with fov_pl_reverse().
| void ADOLC::Sparse::detail::checkBVPInput | ( | const double * | basepoint | ) |
Verifies input data consistency for bit-vector propagation.
| CFM | Control flow mode (Safe, Tight, etc.). |
| basepoint | Pointer to the independent variable values (may be null in Safe mode). |
|
inline |
| int ADOLC::Sparse::detail::computeSparseHess | ( | short | tag, |
| int | indep, | ||
| const double * | basepoint, | ||
| int * | nnz, | ||
| unsigned int ** | rind, | ||
| unsigned int ** | cind, | ||
| double ** | values | ||
| ) |
Compute sparse Hessian using precomputed seed/recovery info.
Executes compressed forward/reverse evaluations followed by ColPack recovery to produce the Hessian in coordinate (rind, cind, values) form. Supports both indirect and direct recovery methods (template parameter RCM).
| RCM | RecoveryMethod controlling the chosen ColPack recovery routine. |
| tag | ADOL-C tape identifier. | |
| indep | Number of independent variables (dimension of Hessian). | |
| basepoint | Pointer to an array of length indep with evaluation point. | |
| nnz | Expected number of nonzeros (must equal the value computed and stored by buildHessPatternAndSeed). If not, the function returns error -3. | |
| [out] | rind | Pointer-to-pointer that will receive the row indices of the coordinate-format Hessian (allocated or user-provided). |
| [out] | cind | Pointer-to-pointer that will receive the column indices. |
| [out] | values | Pointer-to-pointer that will receive the numerical values. |
buildHessPatternAndSeed<...> must have been called previously to populate tape.sHInfos() (seed, graph g_, hr_, workspace arrays).hov_wk_forward + hos_ov_reverse to compute compressed Hessian blocks and then invokes ColPack's recover routines. Both usermem (if rind/cind/values are non-null) and unmanaged variants are supported.| int ADOLC::Sparse::detail::computeSparseJac | ( | short | tag, |
| int | depen, | ||
| int | indep, | ||
| const double * | basepoint, | ||
| SparseMatrix & | sparseJac | ||
| ) |
Compute sparse Jacobian using precomputed seed matrix and recovery information.
This routine performs the actual compressed Jacobian computation using the seed matrix and graph/recovery structures stored in the tape's sJInfos(). It supports both row- and column-oriented compression strategies and writes the recovered coordinate-format entries into a SparseMatrix.
| CM | Compression orientation (Row or Column) chosen when the seed was generated. |
| MH | Selects whether sparseJac may be resized automatically or must already contain exactly nnzIn_ entry slots. |
| tag | ADOL-C tape identifier. | |
| depen | Number of dependent variables (rows). | |
| indep | Number of independent variables (columns). | |
| basepoint | Pointer to basepoint values (length indep) used for evaluation in tight control-flow or other drivers. | |
| [in,out] | sparseJac | Sparse matrix receiving recovered coordinate-format entries. |
0 on success (or driver-specific non-negative codes),tape.sJInfos().nnzIn_; otherwise the function returns -3.sparseJac contains one entry per recovered Jacobian nonzero.repeat and MemoryHandler are orthogonal: repeat controls whether pattern/seed metadata is rebuilt or reused, while MemoryHandler controls only whether sparseJac is resized automatically.B_ and y_ inside the tape; these are freed with the tape lifecycle or overwritten on subsequent calls.CompressionMode::Row, a forward evaluation zos_forward is used to compute y_ followed by fov_reverse to obtain B_. For CompressionMode::Column, fov_forward is used to obtain B_. | int ADOLC::Sparse::detail::computeSparseJac | ( | short | tag, |
| int | depen, | ||
| int | indep, | ||
| int | numSwitches, | ||
| const double * | basepoint, | ||
| SparseANF & | sparseANF | ||
| ) |
Recover the piecewise-linear sparse Jacobian into ANF blocks.
This variant partitions the recovered extended Jacobian into the four abs-normal blocks Y, J, Z, and L. Entries inside each block use block-local coordinates, while cy and cz are filled with the dense constants derived from the same primal y and z evaluation used for recovery.
| void ADOLC::Sparse::detail::createSeed | ( | BvpData< BPPD > & | data, |
| size_t | stripIdx, | ||
| size_t | end | ||
| ) |
Creates a seed matrix segment by invoking setSeed() for each variable in the strip.
| BPPD | Bit pattern propagation direction. |
| data | Bit-vector propagation data container. |
| stripIdx | Index of the strip-mined batch. |
| end | End index (exclusive) of the variable range for this batch. |
| void ADOLC::Sparse::detail::extract | ( | size_t | wordIdx, |
| size_t | stripIdx, | ||
| BvpData< BitPatternPropagationDirection::Reverse > & | data, | ||
| std::span< uint * > & | compressedRowStorage | ||
| ) |
Extracts the sparsity pattern for one dependent variable (row) in reverse bit-vector propagation mode.
This function builds the corresponding CRS row for each output, using the flags stored in indepWordHasNonzero_.
Each bit set in the propagated Jacobian pattern indicates a dependency of the current dependent variable on an independent variable.
| wordIdx | Index of the dependent variable (row in the Jacobian). | |
| stripIdx | Index of the current strip-mined batch. | |
| data | Bit-vector propagation data container (Reverse mode). | |
| [in,out] | compressedRowStorage | Span of pointers to CRS rows (updated in-place). |
| void ADOLC::Sparse::detail::extract | ( | size_t | wordIdx, |
| size_t | stripIdx, | ||
| size_t | currentStripWordIdx, | ||
| BvpData< BitPatternPropagationDirection::Forward > & | data, | ||
| std::span< uint * > & | compressedRowStorage | ||
| ) |
Extracts the sparsity pattern for one dependent variable (row) in forward bit-vector propagation mode.
This routine constructs or extends a row in compressed row storage format based on the current bit pattern flags in indepWordHasNonzero_.
Each bit set in the propagated Jacobian pattern indicates a dependency of the current dependent variable on an independent variable.
| wordIdx | Index of the dependent variable (row in the Jacobian). | |
| stripIdx | Index of the current strip-mined batch. | |
| currentStripWordIdx | Starting global index of the strip. | |
| data | Bit-vector propagation data container (Forward mode). | |
| [in,out] | compressedRowStorage | Span of pointers to CRS rows (updated in-place). |
| void ADOLC::Sparse::detail::extractCompressedRowStorage | ( | int | stripIdx, |
| std::span< uint * > & | compressedRowStorage, | ||
| BvpData< BPPD > & | data | ||
| ) |
Converts Jacobian bit patterns to compressed row storage (CRS) format for one strip.
| BPPD | Bit pattern propagation direction. |
| stripIdx | Index of the strip-mined batch. |
| compressedRowStorage | Output CRS array (span over row pointers). |
| data | Bit-vector propagation data container. |
| void ADOLC::Sparse::detail::prepareADCalls | ( | short | tapeId, |
| const double * | basepoint, | ||
| BvpData< BPPD > & | data | ||
| ) |
Prepares reverse call using zos_forward.
| BPPD | Bit pattern propagation direction. |
| CFM | Control flow mode. |
| tapeId | ADOL-C tape identifier. |
| basepoint | Pointer to basepoint values (used in tight control-flow mode). |
| data | Bit-vector propagation data container. |
| void ADOLC::Sparse::detail::prepareSeedMatrix | ( | size_t | stripIdx, |
| BvpData< BPPD > & | data | ||
| ) |
Builds a strip-mined partition of the seed matrix for a given batch.
| BPPD | Bit pattern propagation direction. |
| stripIdx | Current strip-mined batch index. |
| data | Bit-vector propagation state data. |
| void ADOLC::Sparse::detail::recover | ( | const ValueTape & | tape, |
| SparseANF & | sparseANF | ||
| ) |
Passes args to ANF recovery methods based on the template args.
| void ADOLC::Sparse::detail::recover | ( | const ValueTape & | tape, |
| SparseMatrix & | sparseJac | ||
| ) |
Passes args to jacobian-recover method based on the template-args.
|
inline |
Resets all entries in the compressed row storage pointer array to nullptr.
| compressedRowStorage | Span over the row storage pointer array to be reset. |
| void ADOLC::Sparse::detail::resetOldSeed | ( | BvpData< BPPD > & | data, |
| size_t | dim2 | ||
| ) |
Sets all seed matrix entries to zero for reuse in the next strip-mined batch.
| BPPD | Bit pattern propagation direction. |
| data | Bit-vector propagation state data. |
| dim2 | Inner dimension to clear (depends on direction). |
| void ADOLC::Sparse::detail::setSeed | ( | BvpData< BPPD > & | data, |
| size_t | idx, | ||
| size_t | currentStripWordIdx | ||
| ) |
Sets a single bit in the seed matrix corresponding to a specific variable index.
| BPPD | Bit pattern propagation direction. |
| data | Bit-vector propagation state data. |
| idx | Global variable index. |
| currentStripWordIdx | Starting index of the current strip. |