1 #ifndef CPPAD_CG_PLANE_2D_INDEX_PATTERN_INCLUDED 2 #define CPPAD_CG_PLANE_2D_INDEX_PATTERN_INCLUDED 41 CPPADCG_ASSERT_UNKNOWN(pattern1_ !=
nullptr || pattern2_ !=
nullptr);
54 inline IndexPatternType getType()
const override {
55 return IndexPatternType::Plane2D;
58 inline void getSubIndexes(std::set<IndexPattern*>& indexes)
const override {
59 if (pattern1_ !=
nullptr) {
60 indexes.insert(pattern1_);
61 pattern1_->getSubIndexes(indexes);
63 if (pattern2_ !=
nullptr) {
64 indexes.insert(pattern2_);
65 pattern2_->getSubIndexes(indexes);
84 if (x2y2z.size() == 1) {
86 const std::map<size_t, size_t>& y2z = x2y2z.begin()->second;
91 size_t y = x2y2z.begin()->second.begin()->first;
92 std::map<size_t, size_t> x2z;
93 std::map<size_t, std::map<size_t, size_t> >::const_iterator itx2y2z;
94 for (itx2y2z = x2y2z.begin(); itx2y2z != x2y2z.end(); ++itx2y2z) {
95 size_t x = itx2y2z->first;
96 const std::map<size_t, size_t>& y2z = itx2y2z->second;
98 if (y2z.size() != 1 ||
99 y != y2z.begin()->first) {
104 size_t z = y2z.begin()->second;
116 std::map<size_t, size_t> x2zStart;
117 std::map<size_t, size_t> y2zOffset;
119 for (itx2y2z = x2y2z.begin(); itx2y2z != x2y2z.end(); ++itx2y2z) {
120 size_t x = itx2y2z->first;
121 const std::map<size_t, size_t>& y2z = itx2y2z->second;
123 size_t zFirst = y2z.begin()->second;
124 x2zStart[x] = zFirst;
126 std::map<size_t, size_t>::const_iterator ity2z;
128 for (ity2z = y2z.begin(); ity2z != y2z.end(); ++ity2z) {
129 size_t y = ity2z->first;
130 size_t offset = ity2z->second - zFirst;
131 std::map<size_t, size_t>::const_iterator itY2zOffset = y2zOffset.find(y);
132 if (itY2zOffset == y2zOffset.end()) {
133 y2zOffset[y] = offset;
134 }
else if (itY2zOffset->second != offset) {
143 std::unique_ptr<IndexPattern> fx;
145 std::map<size_t, IndexPattern*> startSections = SectionedIndexPattern::detectLinearSections(x2zStart, 2);
146 if (startSections.empty()) {
151 if (startSections.size() == 1) {
152 fx = std::unique_ptr<IndexPattern> (startSections.begin()->second);
161 std::map<size_t, IndexPattern*> sections = SectionedIndexPattern::detectLinearSections(y2zOffset, 2);
162 if (sections.empty()) {
167 std::unique_ptr<IndexPattern> fy;
168 if (sections.size() == 1) {
169 fy = std::unique_ptr<IndexPattern> (sections.begin()->second);
175 if (fx->getType() == IndexPatternType::Linear && fy->getType() == IndexPatternType::Linear) {
179 if (ipx->getLinearSlopeDy() == 0 && ipy->getLinearSlopeDy() == 0) {
183 ipx->setLinearConstantTerm(ipx->getLinearConstantTerm() + ipy->getLinearConstantTerm());
static Plane2DIndexPattern * detectPlane2D(const std::map< size_t, std::map< size_t, size_t > > &x2y2z)
static IndexPattern * detect(const VectorSizeT &x2y)