ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
sparseinfos.h
Go to the documentation of this file.
1#ifndef ADOLC_SPARSE_INFOS_H
2#define ADOLC_SPARSE_INFOS_H
6#include <cstddef>
7#include <memory>
8#include <span>
9#include <vector>
10
11namespace ADOLC::Sparse {
12template <CompressionMode CM>
13void generateSeedJac(int, int, const std::span<uint *>, double ***, int *) {};
22 struct Impl;
23 std::unique_ptr<Impl> pimpl_;
24 double *y_{nullptr};
25
26 // Seed is memory managed by ColPack and will be deleted
27 double **Seed_{nullptr};
28 double **B_{nullptr};
29
30 // type is dictated by ColPack
31 std::vector<uint *> JP_;
32 int depen_{0};
33 int nnzIn_{0};
34 int seedClms_{0};
35 int seedRows_{0};
36
39 SparseJacInfos(const SparseJacInfos &) = delete;
40 SparseJacInfos(SparseJacInfos &&other) noexcept;
43
51 void setJP(std::vector<uint *> &&JPIn) {
52 // delete JP
53 for (auto &j : JP_)
54 delete[] j;
55 JP_ = std::move(JPIn);
56 depen_ = static_cast<int>(JP_.size());
57 }
59 std::vector<uint *> &getJP() { return JP_; }
61 void initColoring(int dimOut, int dimIn);
63 void generateSeedJac(const std::string &coloringVariant);
73 void recoverRowFormatUserMem(SparseMatrix &sparseJac) const;
77 void recoverRowFormat(SparseMatrix &sparseJac) const;
87 void recoverColFormatUserMem(SparseMatrix &sparseJac) const;
88
92 void recoverColFormat(SparseMatrix &sparseJac) const;
101 void recoverANFUserMem(SparseANF &sparseANF, int indep,
102 int numSwitches) const;
110 void recoverANF(SparseANF &sparseANF, int indep, int numSwitches) const;
111};
112
122void generateSeedHess(int dimIn, const std::span<uint *> HP, double ***Seed,
123 int *p, const std::string &coloringVariant);
124
132 struct Impl;
133 std::unique_ptr<Impl> pimpl_;
134
135 double **Hcomp_{nullptr};
136 double ***Xppp_{nullptr};
137 double ***Yppp_{nullptr};
138 double ***Zppp_{nullptr};
139 double **Upp_{nullptr};
140
141 // type is dictated by ColPack
142 std::vector<uint *> HP_;
143
144 int nnzIn_{0};
145 int indep_{0};
146 int p_{0};
147
148public:
155
156 std::vector<uint *> &getHP() { return HP_; }
157 void setHP(int indep, std::vector<uint *> &&HPIn) {
158 // delete HP_
159 for (auto &h : HP_)
160 delete[] h;
161 indep_ = indep;
162 HP_ = std::move(HPIn);
163 }
164 void initColoring(int dimIn);
165 void generateSeedHess(double ***Seed, const std::string &coloringVariant);
166 void directRecoverUserMem(unsigned int **rind, unsigned int **cind,
167 double **values);
168 void indirectRecoverUserMem(unsigned int **rind, unsigned int **cind,
169 double **values);
170 void directRecover(unsigned int **rind, unsigned int **cind, double **values);
171 void indirectRecover(unsigned int **rind, unsigned int **cind,
172 double **values);
173};
174} // namespace ADOLC::Sparse
175#endif // ADOLC_SPARSE_INFOS_H
#define ADOLC_API
Definition adolcexport.h:16
Owning sparse matrix container in coordinate-format.
Definition sparsematrix.h:81
Definition adtl_indo.h:46
void generateSeedHess(int dimIn, const std::span< uint * > HP, double ***Seed, int *p, const std::string &coloringVariant)
Generate a Hessian seed matrix using ColPack.
void generateSeedJac(int, int, const std::span< uint * >, double ***, int *)
Definition sparseinfos.h:13
Stores the abs-normal form in sparse format.
Definition sparsematrix.h:247
Cached sparse Hessian recovery data stored on a tape.
Definition sparseinfos.h:131
void setHP(int indep, std::vector< uint * > &&HPIn)
Definition sparseinfos.h:157
void indirectRecoverUserMem(unsigned int **rind, unsigned int **cind, double **values)
void directRecover(unsigned int **rind, unsigned int **cind, double **values)
SparseHessInfos & operator=(const SparseHessInfos &)=delete
SparseHessInfos(SparseHessInfos &&other) noexcept
std::unique_ptr< Impl > pimpl_
Definition sparseinfos.h:133
SparseHessInfos & operator=(SparseHessInfos &&other) noexcept
std::vector< uint * > HP_
Definition sparseinfos.h:142
std::vector< uint * > & getHP()
Definition sparseinfos.h:156
void indirectRecover(unsigned int **rind, unsigned int **cind, double **values)
void generateSeedHess(double ***Seed, const std::string &coloringVariant)
SparseHessInfos(const SparseHessInfos &)=delete
void directRecoverUserMem(unsigned int **rind, unsigned int **cind, double **values)
Cached sparse Jacobian recovery data stored on a tape.
Definition sparseinfos.h:21
std::vector< uint * > JP_
Definition sparseinfos.h:31
void setJP(std::vector< uint * > &&JPIn)
Replace the cached sparsity pattern.
Definition sparseinfos.h:51
std::unique_ptr< Impl > pimpl_
Definition sparseinfos.h:23
SparseJacInfos & operator=(SparseJacInfos &&other) noexcept
void recoverRowFormatUserMem(SparseMatrix &sparseJac) const
Recover row-compressed sparse Jacobian entries into SparseMatrix.
void recoverColFormatUserMem(SparseMatrix &sparseJac) const
Recover column-compressed sparse Jacobian entries into SparseMatrix.
void generateSeedJac(const std::string &coloringVariant)
Generate and cache a Jacobian seed matrix.
SparseJacInfos & operator=(const SparseJacInfos &)=delete
void recoverColFormat(SparseMatrix &sparseJac) const
Resize and recover a column-compressed sparse Jacobian.
void initColoring(int dimOut, int dimIn)
Initialize ColPack coloring state for the given matrix shape.
std::vector< uint * > & getJP()
Access the cached CRS Jacobian pattern.
Definition sparseinfos.h:59
void recoverANFUserMem(SparseANF &sparseANF, int indep, int numSwitches) const
Split the recovered extended Jacobian into caller-sized ANF blocks.
SparseJacInfos(SparseJacInfos &&other) noexcept
void recoverANF(SparseANF &sparseANF, int indep, int numSwitches) const
Split the recovered extended Jacobian into abs-normal blocks.
SparseJacInfos(const SparseJacInfos &)=delete
void recoverRowFormat(SparseMatrix &sparseJac) const
Resize and recover a row-compressed sparse Jacobian.