15#ifndef ADOLC_SPARSE_DRIVERS_H
16#define ADOLC_SPARSE_DRIVERS_H
36#define PQ_STRIPMINE_MAX 30
43static constexpr int BITS_PER_WORD = 8 *
sizeof(
bitword_t);
45 << (BITS_PER_WORD - 1);
60template <BitPatternPropagationDirection BPPD>
struct BvpData {
68 std::vector<unsigned char>
74 std::vector<bitword_t *>
102 int numWordsFullSeed = 0;
105 indep_ / BITS_PER_WORD + ((
indep_ % BITS_PER_WORD) != 0);
107 numWordsFullSeed = depen / BITS_PER_WORD + ((depen % BITS_PER_WORD) != 0);
120 for (
auto &s :
seed_)
131 for (
auto &s :
seed_)
150template <ControlFlowMode CFM>
160inline void resetInput(std::span<uint *> &compressedRowStorage) {
161 for (
auto &row : compressedRowStorage) {
174template <BitPatternPropagationDirection BPPD>
176 for (
auto &s : data.
seed_)
177 for (
size_t j = 0; j < dim2; ++j)
188template <BitPatternPropagationDirection BPPD>
208template <BitPatternPropagationDirection BPPD>
211 data.
seed_[idx][(idx - currentStripWordIdx) / BITS_PER_WORD] =
212 MOST_SIGNIFICANT_BIT >> ((idx - currentStripWordIdx) % BITS_PER_WORD);
215 data.
seed_[(idx - currentStripWordIdx) / BITS_PER_WORD][idx] =
216 MOST_SIGNIFICANT_BIT >> ((idx - currentStripWordIdx) % BITS_PER_WORD);
228template <BitPatternPropagationDirection BPPD>
231 size_t nextStripWordIdx = (stripIdx + 1) * data.
bitsPerStrip_;
232 if (nextStripWordIdx > end)
233 nextStripWordIdx = end;
235 for (
size_t idx = currentStripWordIdx; idx < nextStripWordIdx; idx++)
236 setSeed(data, idx, currentStripWordIdx);
262void extract(
size_t wordIdx,
size_t stripIdx,
size_t currentStripWordIdx,
264 std::span<uint *> &compressedRowStorage);
288 std::span<uint *> &compressedRowStorage);
299template <BitPatternPropagationDirection BPPD>
301 std::span<uint *> &compressedRowStorage,
306 for (
int wordIdx = 0; wordIdx < data.
depen_; wordIdx++) {
308 bitword_t currentBit = MOST_SIGNIFICANT_BIT;
310 if (currentBit == 0) {
311 currentBit = MOST_SIGNIFICANT_BIT;
317 currentBit = currentBit >> 1;
319 extract(wordIdx, stripIdx, currentStripWordIdx, data,
320 compressedRowStorage);
323 if (nextStripWordIdx > data.
depen_)
324 nextStripWordIdx = data.
depen_;
326 bitword_t currentBit = MOST_SIGNIFICANT_BIT;
327 for (
int wordIdx = currentStripWordIdx; wordIdx < nextStripWordIdx;
329 if (currentBit == 0) {
330 currentBit = MOST_SIGNIFICANT_BIT;
333 for (
int i = 0; i < data.
indep_; i++) {
338 currentBit = currentBit >> 1;
339 extract(wordIdx, stripIdx, data, compressedRowStorage);
354template <BitPatternPropagationDirection BPPD, ControlFlowMode CFM>
374template <BitPatternPropagationDirection BPPD, ControlFlowMode CFM>
415template <ControlFlowMode CFM, BitPatternPropagationDirection BPPD>
417 const double *basepoint,
418 std::span<uint *> &compressedRowStorage) {
419 using namespace detail;
420 checkBVPInput<CFM>(basepoint);
422 prepareADCalls<BPPD, CFM>(tapeId, basepoint, data);
423 for (
int stripIdx = 0; stripIdx < data.numStripmineBatches_; stripIdx++) {
425 ADCalls<BPPD, CFM>(tapeId, basepoint, data);
480 const double *basepoint,
481 std::span<uint *> &compressedRowStorage) {
482 using namespace detail;
485 if (depen >= indep / 2)
486 return bitVectorPropagation<CFM, BitPatternPropagationDirection::Forward>(
487 tapeId, depen, indep, basepoint, compressedRowStorage);
490 return bitVectorPropagation<CFM, BitPatternPropagationDirection::Reverse>(
491 tapeId, depen, indep, basepoint, compressedRowStorage);
493 return bitVectorPropagation<CFM, BPPD>(tapeId, depen, indep, basepoint,
494 compressedRowStorage);
538 std::span<uint *> &compressedRowStorage) {
543 compressedRowStorage.data());
547 compressedRowStorage.data());
549 return bit_vector_propagation<CFM, BPPD>(tag, depen, indep, basepoint,
550 compressedRowStorage);
575template <PiecewiseLinear>
577 const double *basepoint,
578 std::span<uint *> &compressedRowStorage) {
581 compressedRowStorage.data());
609template <CompressionMode CM>
611 double ***Seed,
int *p) {
612 generateSeedJac<CM>(m, n, JP, Seed, p);
665 const double *basepoint) {
668 tape.sJInfos().setJP(std::vector<uint *>(depen));
669 std::span<uint *> JPSpan = tape.sJInfos().getJP();
670 int ret_val = jac_pat<SM, CFM, BPPD>(tag, depen, indep, basepoint, JPSpan);
673 printf(
" ADOL-C error in sparse_jac() \n");
677 tape.sJInfos().depen_ = depen;
678 tape.sJInfos().nnzIn_ = 0;
679 for (
int i = 0; i < depen; i++) {
680 for (
uint j = 1; j <= tape.sJInfos().JP_[i][0]; j++)
681 tape.sJInfos().nnzIn_++;
684 tape.sJInfos().initColoring(depen, indep);
687 tape.sJInfos().generateSeedJac(
"ROW_PARTIAL_DISTANCE_TWO");
688 tape.sJInfos().seedClms_ = indep;
689 ret_val = tape.sJInfos().seedRows_;
691 tape.sJInfos().generateSeedJac(
"COLUMN_PARTIAL_DISTANCE_TWO");
692 tape.sJInfos().seedRows_ = depen;
693 ret_val = tape.sJInfos().seedClms_;
708template <PiecewiseLinear>
710 const double *basepoint) {
712 tape.sJInfos().setJP(std::vector<uint *>(depen + numSwitches));
713 std::span<uint *> JPSpan{tape.sJInfos().getJP()};
718 printf(
" ADOL-C error in sparse_jac() \n");
722 tape.sJInfos().depen_ = depen + numSwitches;
723 tape.sJInfos().nnzIn_ = 0;
724 for (
int i = 0; i < depen + numSwitches; i++) {
725 for (
uint j = 1; j <= tape.sJInfos().getJP()[i][0]; j++) {
726 tape.sJInfos().nnzIn_++;
729 tape.sJInfos().initColoring(depen + numSwitches, indep + numSwitches);
731 tape.sJInfos().generateSeedJac(
"ROW_PARTIAL_DISTANCE_TWO");
732 tape.sJInfos().seedClms_ = indep + numSwitches;
733 ret_val = tape.sJInfos().seedRows_;
738inline int ensureSparseJacCacheInitialized(
const ValueTape &tape) {
739 if (tape.sJInfos().Seed_ ==
nullptr || tape.sJInfos().seedRows_ == 0 ||
740 tape.sJInfos().seedClms_ == 0) {
741 printf(
" ADOL-C error in sparse_jac():"
742 " First call with repeat = 0 \n");
748inline int validateManualStorage(
const ValueTape &tape,
749 const SparseMatrix &sparseJac) {
750 if (sparseJac.size() != to_size_t(tape.sJInfos().nnzIn_)) {
751 printf(
" ADOL-C error in sparse_jac():"
752 " SparseMatrix size mismatch for MemoryHandler::Manual,"
753 " expected %d entries but got %zu \n",
754 tape.sJInfos().nnzIn_, sparseJac.size());
760inline SparseShape countSparseANFEntries(
const SparseJacInfos &sJInfos,
761 int depen,
int indep) {
762 using Coordinates = CoordinateFormatTripled::Coordinates;
767 for (coordinate_type rowIndex = 0; rowIndex < sJInfos.JP_.size();
769 const auto numOfNonZeros = sJInfos.JP_[rowIndex][0];
770 for (
unsigned int j = 1; j <= numOfNonZeros; ++j) {
771 const Coordinates coords{rowIndex, sJInfos.JP_[rowIndex][j]};
791inline int validateManualStorage(
const ValueTape &tape,
792 const SparseANF &sparseANF,
int depen,
794 const auto counts = countSparseANFEntries(tape.sJInfos(), depen, indep);
795 if (sparseANF.dims().y != counts.y || sparseANF.dims().j != counts.j ||
796 sparseANF.dims().z != counts.z || sparseANF.dims().l != counts.l) {
797 printf(
" ADOL-C error in sparse_jac():"
798 " SparseANF block sizes mismatch for MemoryHandler::Manual"
799 " (expected Y=%zu J=%zu Z=%zu L=%zu,"
800 " got Y=%zu J=%zu Z=%zu L=%zu) \n",
801 counts.y, counts.j, counts.z, counts.l, sparseANF.dims().y,
802 sparseANF.dims().j, sparseANF.dims().z, sparseANF.dims().l);
809template <CompressionMode CM, MemoryHandler MH>
812 assert(sparseJac.
size() == to_size_t(tape.sJInfos().nnzIn_) &&
813 "Mismatch in allocated size and required size!");
815 tape.sJInfos().recoverRowFormatUserMem(sparseJac);
817 tape.sJInfos().recoverColFormatUserMem(sparseJac);
821 tape.sJInfos().recoverRowFormat(sparseJac);
823 tape.sJInfos().recoverColFormat(sparseJac);
829template <MemoryHandler MH>
831 const int numInds =
static_cast<int>(tape.
numInds());
832 const int numSwitches =
static_cast<int>(tape.
numSwitches());
834 tape.sJInfos().recoverANFUserMem(sparseANF, numInds, numSwitches);
836 tape.sJInfos().recoverANF(sparseANF, numInds, numSwitches);
887template <CompressionMode CM, MemoryHandler MH>
895 myalloc2(tape.sJInfos().seedRows_, tape.sJInfos().seedClms_);
896 tape.sJInfos().y_ =
myalloc1(depen);
899 ret_val =
zos_forward(tag, depen, indep, 1, basepoint, tape.sJInfos().y_);
903 tape.sJInfos().Seed_, tape.sJInfos().B_));
906 fov_forward(tag, depen, indep, tape.sJInfos().seedClms_, basepoint,
907 tape.sJInfos().Seed_, tape.sJInfos().y_, tape.sJInfos().B_);
908 recover<CM, MH>(tape, sparseJac);
921template <MemoryHandler MH>
923 const double *basepoint,
SparseANF &sparseANF) {
925 assert(tape.sJInfos().seedClms_ == indep + numSwitches &&
926 "Row Compression must have a seed with column number equal to indep + "
931 myalloc2(tape.sJInfos().seedRows_, tape.sJInfos().seedClms_);
933 std::vector<double *> results(tape.sJInfos().seedRows_);
934 std::vector<double *> resultsSwitch(tape.sJInfos().seedRows_);
936 std::vector<double *> seedResults(tape.sJInfos().seedRows_);
937 std::vector<double *> seedSwitches(tape.sJInfos().seedRows_);
939 for (
int i = 0; i < tape.sJInfos().seedRows_; i++) {
940 results[i] = tape.sJInfos().B_[i];
941 resultsSwitch[i] = tape.sJInfos().B_[i] + indep;
942 seedResults[i] = tape.sJInfos().Seed_[i];
943 seedSwitches[i] = tape.sJInfos().Seed_[i] + depen;
946 sparseANF.
y.resize(depen);
947 sparseANF.
z.resize(numSwitches);
948 ret_val =
zos_pl_forward(tag, depen, indep, 1, basepoint, sparseANF.
y.data(),
953 tape.sJInfos().seedRows_, seedResults.data(),
954 seedSwitches.data(), results.data(),
955 resultsSwitch.data()));
957 recover<MH>(tape, sparseANF);
1010 using namespace detail;
1014 buildJacPatternAndSeed<SM, CM, CFM, BPPD>(tag, depen, indep, basepoint);
1016 ret_val = ensureSparseJacCacheInitialized(
findTape(tag));
1018 printf(
" ADOL-C error in sparse_jac() \n");
1023 ret_val = validateManualStorage(
findTape(tag), sparseJac);
1027 return computeSparseJac<CM, MH>(tag, depen, indep, basepoint, sparseJac);
1060template <PiecewiseLinear PL = PiecewiseLinear{},
1063 int repeat,
const double *basepoint,
1066 using namespace detail;
1070 buildJacPatternAndSeed<PL>(tag, depen, indep, numSwitches, basepoint);
1072 ret_val = ensureSparseJacCacheInitialized(
findTape(tag));
1074 printf(
" ADOL-C error in sparse_jac() \n");
1078 ret_val = validateManualStorage(
findTape(tag), sparseANF, depen, indep);
1082 return computeSparseJac<MH>(tag, depen, indep, numSwitches, basepoint,
1122template <ControlFlowMode CFM>
1124 std::span<uint *> &compressedRowStorage) {
1128 compressedRowStorage.data());
1131 compressedRowStorage.data());
1134 compressedRowStorage.data());
1137 compressedRowStorage.data());
1160template <RecoveryMethod RCM>
1206template <ControlFlowMode CFM, RecoveryMethod RCM>
1212 tape.sHInfos().setHP(indep, std::vector<uint *>(indep));
1213 std::span<uint *> HPSpan = tape.sHInfos().HP_;
1215 ret_val = hess_pat<CFM>(tag, indep, basepoint, HPSpan);
1218 printf(
" ADOL-C error in sparse_hess() \n");
1222 tape.sHInfos().indep_ = indep;
1223 tape.sHInfos().nnzIn_ = 0;
1225 for (
uint i = 0; i < static_cast<uint>(indep); i++) {
1226 for (
uint j = 1; j <= tape.sHInfos().HP_[i][0]; j++)
1227 if (tape.sHInfos().HP_[i][j] >= i)
1228 tape.sHInfos().nnzIn_++;
1231 *nnz = tape.sHInfos().nnzIn_;
1236 double **Seed =
nullptr;
1237 tape.sHInfos().initColoring(indep);
1239 tape.sHInfos().generateSeedHess(&Seed,
"ACYCLIC_FOR_INDIRECT_RECOVERY");
1241 tape.sHInfos().generateSeedHess(&Seed,
"STAR");
1244 myfree2(tape.sHInfos().Hcomp_);
1245 myfree3(tape.sHInfos().Xppp_);
1246 myfree3(tape.sHInfos().Yppp_);
1247 myfree3(tape.sHInfos().Zppp_);
1250 tape.sHInfos().Hcomp_ =
myalloc2(indep, tape.sHInfos().p_);
1251 tape.sHInfos().Xppp_ =
myalloc3(indep, tape.sHInfos().p_, 1);
1253 for (
int i = 0; i < indep; i++)
1254 for (
int l = 0; l < tape.sHInfos().p_; l++)
1255 tape.sHInfos().Xppp_[i][l][0] = Seed[i][l];
1257 tape.sHInfos().Yppp_ =
myalloc3(1, tape.sHInfos().p_, 1);
1258 tape.sHInfos().Zppp_ =
myalloc3(tape.sHInfos().p_, indep, 2);
1259 tape.sHInfos().Upp_ =
myalloc2(1, 2);
1260 tape.sHInfos().Upp_[0][0] = 1;
1261 tape.sHInfos().Upp_[0][1] = 0;
1300template <RecoveryMethod RCM>
1302 unsigned int **rind,
unsigned int **cind,
1305 if (tape.sHInfos().Upp_ ==
nullptr) {
1306 printf(
" ADOL-C error in sparse_hess():"
1307 " First call with repeat = 0 \n");
1311 if (tape.sHInfos().nnzIn_ != *nnz) {
1312 printf(
" ADOL-C error in sparse_hess():"
1313 " Number of nonzeros not consistent,"
1314 " new call with repeat = 0 \n");
1322 hov_wk_forward(tag, 1, indep, 1, 2, tape.sHInfos().p_, basepoint,
1323 tape.sHInfos().Xppp_, &y, tape.sHInfos().Yppp_);
1325 tape.sHInfos().Upp_, tape.sHInfos().Zppp_));
1327 for (
int i = 0; i < tape.sHInfos().p_; ++i)
1328 for (
int l = 0; l < indep; ++l)
1329 tape.sHInfos().Hcomp_[l][i] = tape.sHInfos().Zppp_[i][l][1];
1331 if (*values !=
nullptr && *rind !=
nullptr && *cind !=
nullptr) {
1335 tape.sHInfos().indirectRecoverUserMem(rind, cind, values);
1337 tape.sHInfos().directRecoverUserMem(rind, cind, values);
1341 if (*values !=
nullptr) {
1345 if (*rind !=
nullptr) {
1349 if (*cind !=
nullptr) {
1354 tape.sHInfos().indirectRecover(rind, cind, values);
1356 tape.sHInfos().directRecover(rind, cind, values);
1396template <ControlFlowMode CFM, RecoveryMethod RCM>
1398sparse_hess(
short tag,
int indep,
int repeat,
const double *basepoint,
int *nnz,
1399 unsigned int **rind,
unsigned int **cind,
double **values) {
1400 using namespace detail;
1403 ret_val = buildHessPatternAndSeed<CFM, RCM>(tag, indep, basepoint, nnz);
1405 printf(
" ADOL-C error in sparse_hess() \n");
1408 return computeSparseHess<RCM>(tag, indep, basepoint, nnz, rind, cind, values);
ADOLC_API double *** myalloc3(size_t, size_t, size_t)
ADOLC_API void myfree2(double **)
ADOLC_API double * myalloc1(size_t)
ADOLC_API void myfree1(double *)
ADOLC_API void myfree3(double ***)
ADOLC_API double ** myalloc2(size_t, size_t)
#define ADOLC_API
Definition adolcexport.h:16
Owning sparse matrix container in coordinate-format.
Definition sparsematrix.h:81
size_t size() const
Get the number of stored nonzeros.
Definition sparsematrix.h:137
Owns one recorded function and the state required to evaluate it.
Definition valuetape.h:79
size_t numInds() const
Definition valuetape.h:366
void numSwitches(size_t num)
Definition valuetape.h:377
#define MINDEC(a, b)
Definition common.h:137
unsigned int uint
Definition common.h:39
uint32_t bitword_t
Definition common.h:37
ADOLC_API int int_forward_tight(short, int, int, int, const double *, const bitword_t *const *, double *, bitword_t **)
ADOLC_API int int_reverse_safe(short, int, int, int, const bitword_t *const *, bitword_t **)
ADOLC_API int hos_ov_reverse(short, int, int, int, int, const double *const *, double ***)
ADOLC_API int nonl_ind_forward_tight(short, int, int, const double *, uint **)
ADOLC_API int indopro_forward_absnormal(short, int, int, int, const double *, uint **)
ADOLC_API int nonl_ind_old_forward_tight(short, int, int, const double *, uint **)
ADOLC_API int indopro_forward_tight(short, int, int, const double *, uint **)
ADOLC_API int int_reverse_tight(short, int, int, int, const bitword_t *const *, bitword_t **)
ADOLC_API int fov_forward(short, int, int, int, const double *, const double *const *, double *, double **)
ADOLC_API int nonl_ind_forward_safe(short, int, int, const double *, uint **)
ADOLC_API int nonl_ind_old_forward_safe(short, int, int, const double *, uint **)
ADOLC_API int fov_reverse(short, int, int, int, const double *const *, double **)
ADOLC_API int zos_pl_forward(short, int, int, int, const double *, double *, double *)
ADOLC_API int int_forward_safe(short, int, int, int, const bitword_t *const *, bitword_t **)
BEGIN_C_DECLS ADOLC_API int zos_forward(short, int, int, int, const double *, double *)
ADOLC_API int hov_wk_forward(short, int, int, int, int, int, const double *, const double *const *const *, double *, double ***)
ADOLC_API int indopro_forward_safe(short, int, int, const double *, uint **)
ADOLC_API int fov_pl_reverse(short tag, int m, int n, int s, int nrow, const double *const *lagrange, const double *const *lagrangeSwitch, double **results, double **resultsSwitch)
Computes several vector-Jacobian product of the extended Jacobian of the abs-linearization.
void resetInput(std::span< uint * > &compressedRowStorage)
Resets all entries in the compressed row storage pointer array to nullptr.
Definition sparsedrivers.h:160
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.
Definition sparsedrivers.h:1301
void prepareADCalls(short tapeId, const double *basepoint, BvpData< BPPD > &data)
Prepares reverse call using zos_forward.
Definition sparsedrivers.h:355
int bitVectorPropagation(short tapeId, int depen, int indep, const double *basepoint, std::span< uint * > &compressedRowStorage)
Main internal implementation for bit-vector propagation.
Definition sparsedrivers.h:416
void checkBVPInput(const double *basepoint)
Verifies input data consistency for bit-vector propagation.
Definition sparsedrivers.h:151
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.
Definition sparsedrivers.h:229
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.
Definition sparsedrivers.h:209
void extractCompressedRowStorage(int stripIdx, std::span< uint * > &compressedRowStorage, BvpData< BPPD > &data)
Converts Jacobian bit patterns to compressed row storage (CRS) format for one strip.
Definition sparsedrivers.h:300
void ADCalls(short tapeId, const double *basepoint, BvpData< BPPD > &data)
Executes the ADOL-C internal bit-vector propagation calls (forward or reverse).
Definition sparsedrivers.h:375
int computeSparseJac(short tag, int depen, int indep, const double *basepoint, SparseMatrix &sparseJac)
Compute sparse Jacobian using precomputed seed matrix and recovery information.
Definition sparsedrivers.h:888
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.
Definition sparsedrivers.h:664
void resetOldSeed(BvpData< BPPD > &data, size_t dim2)
Sets all seed matrix entries to zero for reuse in the next strip-mined batch.
Definition sparsedrivers.h:175
int buildHessPatternAndSeed(short tag, int indep, const double *basepoint, int *nnz)
Build Hessian sparsity pattern and generate ColPack seed for recovery.
Definition sparsedrivers.h:1207
SparseANFBlock classifySparseANFBlock(CoordinateFormatTripled::Coordinates coords, int depen, int indep)
Definition sparsematrix.h:196
void recover(const ValueTape &tape, SparseMatrix &sparseJac)
Passes args to jacobian-recover method based on the template-args.
Definition sparsedrivers.h:810
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 prepareSeedMatrix(size_t stripIdx, BvpData< BPPD > &data)
Builds a strip-mined partition of the seed matrix for a given batch.
Definition sparsedrivers.h:189
Definition adtl_indo.h:46
MemoryHandler
Selects how sparse coordinate buffers are provided.
Definition sparse_options.h:184
ADOLC_API void generate_seed_jac(int m, int n, const std::span< uint * > JP, double ***Seed, int *p)
Generate a seed matrix (coloring) for compressed Jacobian recovery.
Definition sparsedrivers.h:610
SparseMethod
Method used to determine the sparsity pattern.
Definition sparse_options.h:12
@ BitPattern
Bit-pattern propagation.
@ IndexDomains
Index-domain propagation.
ADOLC_API int sparse_jac(short tag, int depen, int indep, int repeat, const double *basepoint, SparseMatrix &sparseJac)
High-level API to compute a sparse Jacobian (single call or repeat).
Definition sparsedrivers.h:1008
ADOLC_API int sparse_hess(short tag, int indep, int repeat, const double *basepoint, int *nnz, unsigned int **rind, unsigned int **cind, double **values)
High-level API to compute a sparse Hessian.
Definition sparsedrivers.h:1398
ControlFlowMode
Control-flow handling mode for sparsity and dependence analysis.
Definition sparse_options.h:37
@ Tight
Tight (basepoint-dependent) control-flow handling.
@ OldSafe
Legacy safe control-flow handling.
@ OldTight
Legacy tight control-flow handling.
@ Safe
Safe (conservative) control-flow handling.
@ Indirect
Indirect (acyclic) recovery.
@ Direct
Direct (star) recovery.
BitPatternPropagationDirection
Direction used for bit-pattern propagation.
Definition sparse_options.h:86
@ Auto
Automatic selection of propagation direction.
@ Forward
Forward-mode bit-pattern propagation.
@ Reverse
Reverse-mode bit-pattern propagation.
ADOLC_API int jac_pat(short tag, int depen, int indep, const double *basepoint, std::span< uint * > &compressedRowStorage)
Compute Jacobian sparsity pattern using the selected sparse method.
Definition sparsedrivers.h:537
ADOLC_API int hess_pat(short tag, int indep, const double *basepoint, std::span< uint * > &compressedRowStorage)
Compute Hessian sparsity pattern (dispatch by control-flow mode).
Definition sparsedrivers.h:1123
void generateSeedHess(int dimIn, const std::span< uint * > HP, double ***Seed, int *p, const std::string &coloringVariant)
Generate a Hessian seed matrix using ColPack.
ADOLC_API void generate_seed_hess(int n, std::span< uint * > HP, double ***Seed, int *p)
Generate a seed matrix for compressed Hessian recovery.
Definition sparsedrivers.h:1161
CompressionMode
Compression orientation for sparse Jacobian recovery.
Definition sparse_options.h:120
@ Column
Column compression.
ADOLC_API int bit_vector_propagation(short tapeId, int depen, int indep, const double *basepoint, std::span< uint * > &compressedRowStorage)
Computes the sparsity pattern of a Jacobian using bit-vector propagation.
Definition sparsedrivers.h:479
#define PQ_STRIPMINE_MAX
Definition sparsedrivers.h:36
Tag type selecting sparse drivers for piecewise-linear abs-normal forms.
Definition sparse_options.h:172
Stores the abs-normal form in sparse format.
Definition sparsematrix.h:247
std::vector< double > z
Switching-variable values at the evaluation point.
Definition sparsematrix.h:268
void updateCz()
Compute cz = z - L|z| from the current data.
Definition sparsematrix.h:308
std::vector< double > y
Dependent values at the evaluation point.
Definition sparsematrix.h:266
void updateCy()
Compute cy = y - J|z| from the current data.
Definition sparsematrix.h:300
Internal data structure managing buffers and parameters for bit-vector propagation.
Definition sparsedrivers.h:60
BvpData & operator=(const BvpData &)=delete
std::vector< bitword_t * > seed_
Seed matrix partitions.
Definition sparsedrivers.h:73
int depen_
Number of dependent (output) variables.
Definition sparsedrivers.h:62
~BvpData()
Destructor — frees dynamically allocated memory for bit patterns.
Definition sparsedrivers.h:85
std::vector< bitword_t * > jacobianBitPattern_
Jacobian bit pattern partitions.
Definition sparsedrivers.h:75
int numStripmineBatches_
Number of batches needed to cover all variables.
Definition sparsedrivers.h:66
BvpData & operator=(BvpData &&)=delete
std::vector< unsigned char > indepWordHasNonzero_
Definition sparsedrivers.h:69
int rc_
Return code from ADOL-C drivers.
Definition sparsedrivers.h:61
BvpData(BvpData &&)=delete
std::vector< double > valuepoint_
Definition sparsedrivers.h:71
int bitsPerStrip_
Number of bits represented by one batch.
Definition sparsedrivers.h:65
int wordsPerBatch_
Number of bit words per batch.
Definition sparsedrivers.h:64
BvpData(const BvpData &)=delete
BvpData(int depen, int indep)
Constructs a bit-vector propagation data container.
Definition sparsedrivers.h:101
int indep_
Number of independent (input) variables.
Definition sparsedrivers.h:63
ADOLC_API ValueTape & findTape(short tapeId)
Returns a reference to a ValueTape by tapeId, or throws an error if not found.