| 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 { | 
|---|
| 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 |  | 
|---|
| 33 | /** Namespace for some internal helper functions. | 
|---|
| 34 | * | 
|---|
| 35 | */ | 
|---|
| 36 | namespace _detail { | 
|---|
| 37 | /** Gather all distances from a given set of positions. | 
|---|
| 38 | * | 
|---|
| 39 | * \param positins vector of positions | 
|---|
| 40 | * \param globalid index to associated in argument_t with | 
|---|
| 41 | * \return vector of argument_ , each with a distance | 
|---|
| 42 | */ | 
|---|
| 43 | FunctionModel::arguments_t | 
|---|
| 44 | gatherAllDistanceArguments( | 
|---|
| 45 | const Fragment::positions_t &positions, | 
|---|
| 46 | const size_t globalid); | 
|---|
| 47 |  | 
|---|
| 48 | /** Gather all positions from the same aligned vector of charges. | 
|---|
| 49 | * | 
|---|
| 50 | * Basically, we filter the positions indicated by the targets but | 
|---|
| 51 | * from a different vector that has the same layout. | 
|---|
| 52 | * | 
|---|
| 53 | * \param positions positions to search | 
|---|
| 54 | * \param charges charges to match with \targets | 
|---|
| 55 | * \param targets iterators on charges | 
|---|
| 56 | * \return filtered positions | 
|---|
| 57 | */ | 
|---|
| 58 | Fragment::positions_t gatherPositionsFromCharges( | 
|---|
| 59 | const Fragment::positions_t &positions, | 
|---|
| 60 | const Fragment::charges_t &charges, | 
|---|
| 61 | const chargeiters_t targets | 
|---|
| 62 | ); | 
|---|
| 63 |  | 
|---|
| 64 | /** Counts all same elements in the vector and places into map of elements. | 
|---|
| 65 | * | 
|---|
| 66 | * \param elements vector of elements | 
|---|
| 67 | * \return count of same element in vector | 
|---|
| 68 | */ | 
|---|
| 69 | elementcounts_t getElementCounts( | 
|---|
| 70 | const Fragment::charges_t elements | 
|---|
| 71 | ); | 
|---|
| 72 |  | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | /** Simple extractor of all unique pair distances of a given \a fragment. | 
|---|
| 76 | * | 
|---|
| 77 | * \param fragment fragment with all nuclei positions | 
|---|
| 78 | * \param index index refers to the index within the global set of configurations | 
|---|
| 79 | * \return vector of of argument_t containing all found distances | 
|---|
| 80 | */ | 
|---|
| 81 | inline FunctionModel::arguments_t gatherAllDistances( | 
|---|
| 82 | const Fragment& fragment, | 
|---|
| 83 | const size_t index | 
|---|
| 84 | ) { | 
|---|
| 85 | // get distance out of Fragment | 
|---|
| 86 | return _detail::gatherAllDistanceArguments(fragment.getPositions(), index); | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | /** Gather all positions associated to the matching \a elements. | 
|---|
| 90 | * | 
|---|
| 91 | * \param fragment fragment with all nuclei positions | 
|---|
| 92 | * \param elements tuple of desired elements | 
|---|
| 93 | * \return vector of positions_t containing | 
|---|
| 94 | */ | 
|---|
| 95 | Fragment::positions_t gatherDistanceOfTuples( | 
|---|
| 96 | const Fragment& fragment, | 
|---|
| 97 | const Fragment::charges_t elements | 
|---|
| 98 | ); | 
|---|
| 99 |  | 
|---|
| 100 | /** Reorder arguments by increasing distance. | 
|---|
| 101 | * | 
|---|
| 102 | * \param args arguments to reorder | 
|---|
| 103 | * \return reordered args | 
|---|
| 104 | */ | 
|---|
| 105 | FunctionModel::arguments_t reorderArgumentsByIncreasingDistance( | 
|---|
| 106 | const FunctionModel::arguments_t &args | 
|---|
| 107 | ); | 
|---|
| 108 |  | 
|---|
| 109 | }; /* namespace Extractors */ | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 | #endif /* TRAININGDATA_EXTRACTORS_HPP_ */ | 
|---|