ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
absnormalform.h
Go to the documentation of this file.
1#ifndef ADOLC_ABSNORMALFORM_H
2#define ADOLC_ABSNORMALFORM_H
3
4#include <adolc/adolcexport.h>
7#include <cmath>
8#include <cstddef>
9#include <vector>
10
11namespace ADOLC {
12
22 size_t m{};
23 size_t n{};
24 size_t s{};
25
26 constexpr DenseShape() = default;
27 constexpr DenseShape(size_t m, size_t n, size_t s) : m(m), n(n), s(s) {}
28};
29
31
41
44
46 std::vector<double *> Y;
48 std::vector<double *> J;
50 std::vector<double *> Z;
52 std::vector<double *> L;
53
55 std::vector<double> Y_storage;
57 std::vector<double> J_storage;
59 std::vector<double> Z_storage;
61 std::vector<double> L_storage;
62
64 std::vector<double> cz;
66 std::vector<double> cy;
68 std::vector<double> y;
70 std::vector<double> z;
71
72 ~AbsNormalForm() = default;
73 AbsNormalForm() = default;
74
82
85
86 AbsNormalForm(const AbsNormalForm &) = delete;
88
95 static AbsNormalForm fromTape(short tapeId) {
96 return AbsNormalForm(getShapeFromTape(tapeId));
97 }
98
102 bool empty() const { return shape.m == 0 && shape.n == 0 && shape.s == 0; }
103
110 void clear();
111
113 Shape dims() const { return shape; }
114
116 void updateCy() {
117 cy = y;
118 for (size_t depRow = 0; depRow < dims().m; ++depRow) {
119 for (size_t col = 0; col < dims().s; ++col) {
120 cy[depRow] -= J[depRow][col] * std::fabs(z[col]);
121 }
122 }
123 }
124
126 void updateCz() {
127 cz = z;
128 for (size_t switchRow = 0; switchRow < dims().s; ++switchRow) {
129 for (size_t col = 0; col < dims().s; ++col) {
130 cz[switchRow] -= L[switchRow][col] * std::fabs(z[col]);
131 }
132 }
133 }
134
143};
144
145} // namespace ADOLC
146
147#endif // ADOLC_ABSNORMALFORM_H
Definition adtl_indo.h:46
DenseShape getShapeFromTape(short tapeId)
Base tag for abs-normal form shapes.
Definition absnormalformconcept.h:10
Dense abs-normal form container backed by contiguous storage.
Definition absnormalform.h:39
std::vector< double * > Y
Row-pointer view of the m x n block Y.
Definition absnormalform.h:46
std::vector< double > y
Dependent values at the evaluation point.
Definition absnormalform.h:68
void updateCz()
Compute cz = z - L|z| from the current data.
Definition absnormalform.h:126
std::vector< double > z
Switching-variable values at the evaluation point.
Definition absnormalform.h:70
void updateCy()
Compute cy = y - J|z| from the current data.
Definition absnormalform.h:116
std::vector< double > Z_storage
Owning contiguous storage for Z.
Definition absnormalform.h:59
AbsNormalForm(const AbsNormalForm &)=delete
AbsNormalForm & operator=(const AbsNormalForm &)=delete
std::vector< double * > L
Row-pointer view of the s x s block L.
Definition absnormalform.h:52
std::vector< double > J_storage
Owning contiguous storage for J.
Definition absnormalform.h:57
AbsNormalForm & operator=(AbsNormalForm &&)=default
AbsNormalForm(Shape dims)
Construct a dense abs-normal form with the requested principal dimensions.
Definition absnormalform.h:81
static AbsNormalForm fromTape(short tapeId)
Allocate an abs-normal form using the dimensions of a recorded tape.
Definition absnormalform.h:95
Shape shape
Principal dimensions of the represented abs-normal form.
Definition absnormalform.h:43
bool empty() const
Report whether all principal dimensions are zero.
Definition absnormalform.h:102
~AbsNormalForm()=default
std::vector< double > cz
Constant term of the switching equations.
Definition absnormalform.h:64
std::vector< double > cy
Constant term of the dependent equations.
Definition absnormalform.h:66
std::vector< double > Y_storage
Owning contiguous storage for Y.
Definition absnormalform.h:55
void resize(Shape dims)
Resize the abs-normal form to the given principal dimensions.
void clear()
Clear all stored data and reset the principal dimensions to {0, 0, 0}.
AbsNormalForm(AbsNormalForm &&)=default
std::vector< double * > Z
Row-pointer view of the s x n block Z.
Definition absnormalform.h:50
Shape dims() const
Return the principal abs-normal form dimensions.
Definition absnormalform.h:113
std::vector< double > L_storage
Owning contiguous storage for L.
Definition absnormalform.h:61
std::vector< double * > J
Row-pointer view of the m x s block J.
Definition absnormalform.h:48
Stores the principal dimensions of a dense abs-normal form.
Definition absnormalform.h:21
constexpr DenseShape()=default
size_t n
Definition absnormalform.h:23
constexpr DenseShape(size_t m, size_t n, size_t s)
Definition absnormalform.h:27
size_t m
Definition absnormalform.h:22
size_t s
Definition absnormalform.h:24