CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
random_1d_index_pattern.hpp
1 #ifndef CPPAD_CG_RANDOM_1D_INDEX_PATTERN_INCLUDED
2 #define CPPAD_CG_RANDOM_1D_INDEX_PATTERN_INCLUDED
3 /* --------------------------------------------------------------------------
4  * CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5  * Copyright (C) 2013 Ciengis
6  * Copyright (C) 2018 Joao Leal
7  *
8  * CppADCodeGen is distributed under multiple licenses:
9  *
10  * - Eclipse Public License Version 1.0 (EPL1), and
11  * - GNU General Public License Version 3 (GPL3).
12  *
13  * EPL1 terms and conditions can be found in the file "epl-v10.txt", while
14  * terms and conditions for the GPL3 can be found in the file "gpl3.txt".
15  * ----------------------------------------------------------------------------
16  * Author: Joao Leal
17  */
18 
19 namespace CppAD {
20 namespace cg {
21 
26 protected:
27  std::map<size_t, size_t> indexes_;
28  std::string name_;
29 public:
30 
31  template<class VectorSizeT>
32  inline Random1DIndexPattern(const VectorSizeT& x2y) {
33  CPPADCG_ASSERT_UNKNOWN(x2y.size() > 0);
34  for (size_t x = 0; x < x2y.size(); x++)
35  indexes_[x] = x2y[x];
36  }
37 
38  inline virtual ~Random1DIndexPattern() = default;
39 
40  inline Random1DIndexPattern(const std::map<size_t, size_t>& x2y) :
41  indexes_(x2y) {
42  CPPADCG_ASSERT_UNKNOWN(!indexes_.empty());
43  }
44 
45  inline IndexPatternType getType() const override {
46  return IndexPatternType::Random1D;
47  }
48 
49  inline const std::map<size_t, size_t>& getValues() const {
50  return indexes_;
51  }
52 
53 };
54 
55 } // END cg namespace
56 } // END CppAD namespace
57 
58 #endif