[8aa597] | 1 | /*
|
---|
| 2 | * Extractors.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: 15.10.2012
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef TRAININGDATA_EXTRACTORS_HPP_
|
---|
| 9 | #define TRAININGDATA_EXTRACTORS_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "Fragmentation/SetValues/Fragment.hpp"
|
---|
| 17 | #include "FunctionApproximation/FunctionModel.hpp"
|
---|
| 18 |
|
---|
| 19 | class Fragment;
|
---|
| 20 |
|
---|
| 21 | /** Namespace containing all simple extractor functions.
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 | namespace Extractors {
|
---|
[301dbf] | 25 | typedef Fragment::charges_t::const_iterator chargeiter_t;
|
---|
| 26 | typedef std::vector<chargeiter_t> chargeiters_t;
|
---|
| 27 |
|
---|
| 28 | typedef size_t count_t;
|
---|
| 29 | typedef Fragment::charge_t element_t;
|
---|
| 30 | typedef std::map< element_t, count_t> elementcounts_t;
|
---|
| 31 | typedef std::map< element_t, chargeiters_t > elementtargets_t;
|
---|
| 32 |
|
---|
[8aa597] | 33 | /** Namespace for some internal helper functions.
|
---|
| 34 | *
|
---|
| 35 | */
|
---|
| 36 | namespace _detail {
|
---|
[301dbf] | 37 | /** Gather all positions from the same aligned vector of charges.
|
---|
| 38 | *
|
---|
| 39 | * Basically, we filter the positions indicated by the targets but
|
---|
| 40 | * from a different vector that has the same layout.
|
---|
| 41 | *
|
---|
| 42 | * \param positions positions to search
|
---|
| 43 | * \param charges charges to match with \targets
|
---|
| 44 | * \param targets iterators on charges
|
---|
| 45 | * \return filtered positions
|
---|
| 46 | */
|
---|
| 47 | Fragment::positions_t gatherPositionsFromCharges(
|
---|
| 48 | const Fragment::positions_t &positions,
|
---|
| 49 | const Fragment::charges_t &charges,
|
---|
| 50 | const chargeiters_t targets
|
---|
| 51 | );
|
---|
[bc6705] | 52 |
|
---|
| 53 | /** Counts all same elements in the vector and places into map of elements.
|
---|
| 54 | *
|
---|
| 55 | * \param elements vector of elements
|
---|
| 56 | * \return count of same element in vector
|
---|
| 57 | */
|
---|
| 58 | elementcounts_t getElementCounts(
|
---|
| 59 | const Fragment::charges_t elements
|
---|
| 60 | );
|
---|
| 61 |
|
---|
[c211f7] | 62 | /** Gather iterators to the elements related to the desired elementcounts.
|
---|
| 63 | *
|
---|
| 64 | * \param charges charges wherein to search for the elements
|
---|
| 65 | * \param elementcounts number of desired hits per element
|
---|
| 66 | * \return iterators equal to the initial vector of elements
|
---|
| 67 | */
|
---|
| 68 | elementtargets_t convertElementcountsToTargets(
|
---|
| 69 | const Fragment::charges_t &charges,
|
---|
| 70 | const elementcounts_t &elementcounts
|
---|
| 71 | );
|
---|
[63e786] | 72 |
|
---|
| 73 | /** Convert the alignment back to as it was in the original vector.
|
---|
| 74 | *
|
---|
| 75 | * We lost the information by storing it in a map. Hence, we need this
|
---|
| 76 | * final step.
|
---|
| 77 | *
|
---|
| 78 | * \param elementtargets targets as they are in the map \a elementcounts
|
---|
| 79 | * \param elements the original order of the elements
|
---|
| 80 | * \param elementcounts the count per element for debugging checks
|
---|
| 81 | * \return vector of targets in the order as they are in \a element
|
---|
| 82 | */
|
---|
| 83 | chargeiters_t realignElementtargets(
|
---|
| 84 | const elementtargets_t &elementtargets,
|
---|
| 85 | const Fragment::charges_t elements,
|
---|
| 86 | const elementcounts_t &elementcounts
|
---|
| 87 | );
|
---|
[8aa597] | 88 | }
|
---|
| 89 |
|
---|
[49f163] | 90 | /** Gather all distances from a given set of positions.
|
---|
| 91 | *
|
---|
| 92 | * \param positions vector of positions
|
---|
| 93 | * \param globalid index to associated in argument_t with
|
---|
| 94 | * \return vector of argument_ , each with a distance
|
---|
| 95 | */
|
---|
| 96 | FunctionModel::arguments_t
|
---|
| 97 | gatherAllDistanceArguments(
|
---|
| 98 | const Fragment::positions_t &positions,
|
---|
| 99 | const size_t globalid);
|
---|
| 100 |
|
---|
| 101 | /** Gather all distances from a given set of positions.
|
---|
| 102 | *
|
---|
| 103 | * Here, we only return one of the two equal distances.
|
---|
| 104 | *
|
---|
| 105 | * \param positions vector of positions
|
---|
| 106 | * \param globalid index to associated in argument_t with
|
---|
| 107 | * \return vector of argument_ , each with a distance
|
---|
| 108 | */
|
---|
| 109 | FunctionModel::arguments_t
|
---|
| 110 | gatherAllSymmetricDistanceArguments(
|
---|
| 111 | const Fragment::positions_t &positions,
|
---|
| 112 | const size_t globalid);
|
---|
| 113 |
|
---|
[8aa597] | 114 | /** Simple extractor of all unique pair distances of a given \a fragment.
|
---|
| 115 | *
|
---|
| 116 | * \param fragment fragment with all nuclei positions
|
---|
| 117 | * \param index index refers to the index within the global set of configurations
|
---|
| 118 | * \return vector of of argument_t containing all found distances
|
---|
| 119 | */
|
---|
| 120 | inline FunctionModel::arguments_t gatherAllDistances(
|
---|
| 121 | const Fragment& fragment,
|
---|
| 122 | const size_t index
|
---|
| 123 | ) {
|
---|
| 124 | // get distance out of Fragment
|
---|
[49f163] | 125 | return gatherAllDistanceArguments(fragment.getPositions(), index);
|
---|
[8aa597] | 126 | }
|
---|
| 127 |
|
---|
[301dbf] | 128 | /** Gather all positions associated to the matching \a elements.
|
---|
[8aa597] | 129 | *
|
---|
| 130 | * \param fragment fragment with all nuclei positions
|
---|
[301dbf] | 131 | * \param elements tuple of desired elements
|
---|
| 132 | * \return vector of positions_t containing
|
---|
[8aa597] | 133 | */
|
---|
[301dbf] | 134 | Fragment::positions_t gatherDistanceOfTuples(
|
---|
[8aa597] | 135 | const Fragment& fragment,
|
---|
[301dbf] | 136 | const Fragment::charges_t elements
|
---|
| 137 | );
|
---|
| 138 |
|
---|
| 139 | /** Reorder arguments by increasing distance.
|
---|
| 140 | *
|
---|
| 141 | * \param args arguments to reorder
|
---|
| 142 | * \return reordered args
|
---|
| 143 | */
|
---|
| 144 | FunctionModel::arguments_t reorderArgumentsByIncreasingDistance(
|
---|
| 145 | const FunctionModel::arguments_t &args
|
---|
[8aa597] | 146 | );
|
---|
| 147 |
|
---|
| 148 | }; /* namespace Extractors */
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | #endif /* TRAININGDATA_EXTRACTORS_HPP_ */
|
---|