A container class holding arrays of state information. ! * SolutionArray objects provide a convenient interface for representing many * thermodynamic states using the same Solution object. C++ SolutionArray objects are * one-dimensional by design; while shape information for multi-dimensional arrays is * stored, reshaping operations need to be implemented in high-level API's. * * The Solutio
| 30 | * @ingroup solnGroup |
| 31 | */ |
| 32 | class SolutionArray |
| 33 | { |
| 34 | private: |
| 35 | SolutionArray(const shared_ptr<Solution>& sol, |
| 36 | int size, |
| 37 | const AnyMap& meta); |
| 38 | |
| 39 | SolutionArray(const SolutionArray& arr, const vector<int>& indices); |
| 40 | |
| 41 | public: |
| 42 | virtual ~SolutionArray(); |
| 43 | |
| 44 | /** |
| 45 | * Instantiate a new SolutionArray reference. |
| 46 | * |
| 47 | * @param sol Solution object defining phase definitions |
| 48 | * @param size Number of SolutionArray entries |
| 49 | * @param meta AnyMap holding SolutionArray meta data |
| 50 | */ |
| 51 | static shared_ptr<SolutionArray> create(const shared_ptr<Solution>& sol, |
| 52 | int size=0, |
| 53 | const AnyMap& meta={}) |
| 54 | { |
| 55 | return shared_ptr<SolutionArray>(new SolutionArray(sol, size, meta)); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Share locations from an existing SolutionArray and return new reference. |
| 60 | * |
| 61 | * Both SolutionArray object share common data. The method is used for slicing |
| 62 | * of SolutionArrays from high-level API's. Note that meta data are not inherited. |
| 63 | * @param selected List of locations for shared entries |
| 64 | */ |
| 65 | shared_ptr<SolutionArray> share(const vector<int>& selected) |
| 66 | { |
| 67 | return shared_ptr<SolutionArray>(new SolutionArray(*this, selected)); |
| 68 | } |
| 69 | |
| 70 | //! Reset all entries of the SolutionArray to the current Solution state |
| 71 | void reset(); |
| 72 | |
| 73 | //! Size of SolutionArray (number of entries). |
| 74 | int size() const { |
| 75 | return static_cast<int>(m_size); |
| 76 | } |
| 77 | |
| 78 | //! Resize SolutionArray objects with a single dimension (default). |
| 79 | void resize(int size); |
| 80 | |
| 81 | //! SolutionArray shape information used by high-level API's. |
| 82 | vector<long int> apiShape() const { |
| 83 | return m_apiShape; |
| 84 | } |
| 85 | |
| 86 | //! Set SolutionArray shape information used by high-level API's. |
| 87 | //! The size of the SolutionArray is adjusted automatically. |
| 88 | void setApiShape(const vector<long int>& shape); |
| 89 |
no test coverage detected