| [66cfc7] | 1 | /*
|
|---|
| 2 | * FunctionArgument.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: 02.10.2012
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef FUNCTIONARGUMENT_HPP_
|
|---|
| 9 | #define FUNCTIONARGUMENT_HPP_
|
|---|
| 10 |
|
|---|
| 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | #include <utility>
|
|---|
| [9e903b] | 17 | #include <iosfwd>
|
|---|
| [66cfc7] | 18 |
|
|---|
| [4266eb] | 19 | #include "FunctionApproximation/Subgraph/SubgraphEdge.hpp"
|
|---|
| 20 |
|
|---|
| [66cfc7] | 21 | /** This class encapsulates all information with respect to a single argument
|
|---|
| 22 | * for a high-dimensional model function.
|
|---|
| 23 | *
|
|---|
| 24 | * We restrict ourselves here to a function that dependent on a set of
|
|---|
| 25 | * three-dimensional vectors, i.e. a set of positions in space. And for
|
|---|
| 26 | * the moment to distances in between these sets.
|
|---|
| 27 | *
|
|---|
| 28 | */
|
|---|
| [4266eb] | 29 | struct argument_t : public SubgraphEdge
|
|---|
| [66cfc7] | 30 | {
|
|---|
| [9e903b] | 31 | //!> grant operator access to private parts
|
|---|
| 32 | friend std::ostream& operator<<(std::ostream &ost, const argument_t &arg);
|
|---|
| 33 |
|
|---|
| [5b5724] | 34 | /** Default constructor for class argument_t.
|
|---|
| 35 | *
|
|---|
| 36 | */
|
|---|
| 37 | argument_t() :
|
|---|
| [eb1efe] | 38 | distance(0.),
|
|---|
| 39 | globalid(-1)
|
|---|
| [5b5724] | 40 | {}
|
|---|
| 41 |
|
|---|
| 42 | /** Constructor for class argument_t.
|
|---|
| 43 | *
|
|---|
| 44 | * This constructors uses the index pair (0,1) as default.
|
|---|
| 45 | *
|
|---|
| 46 | * \param _distance distance argument
|
|---|
| 47 | */
|
|---|
| 48 | argument_t(const double &_distance) :
|
|---|
| [4266eb] | 49 | SubgraphEdge(
|
|---|
| 50 | indices_t( std::make_pair(0,1) ),
|
|---|
| 51 | types_t( std::make_pair(0,0) )),
|
|---|
| [eb1efe] | 52 | distance(_distance),
|
|---|
| 53 | globalid(-1)
|
|---|
| [5b5724] | 54 | {}
|
|---|
| 55 |
|
|---|
| 56 | /** Constructor for class argument_t.
|
|---|
| 57 | *
|
|---|
| 58 | * \param _indices pair of indices associated with the \a _distance
|
|---|
| 59 | * \param _distance distance argument
|
|---|
| 60 | */
|
|---|
| 61 | argument_t(const indices_t &_indices, const double &_distance) :
|
|---|
| [4266eb] | 62 | SubgraphEdge(
|
|---|
| 63 | indices,
|
|---|
| 64 | types_t( std::make_pair(0,0) )),
|
|---|
| [691be4] | 65 | distance(_distance),
|
|---|
| 66 | globalid(-1)
|
|---|
| 67 | {}
|
|---|
| 68 |
|
|---|
| 69 | /** Constructor for class argument_t.
|
|---|
| 70 | *
|
|---|
| 71 | * \param _indices pair of indices associated with the \a _distance
|
|---|
| 72 | * \param _types pair of particle type
|
|---|
| 73 | * \param _distance distance argument
|
|---|
| 74 | */
|
|---|
| 75 | argument_t(const indices_t &_indices, const types_t &_types, const double &_distance) :
|
|---|
| [4266eb] | 76 | SubgraphEdge(_indices, _types),
|
|---|
| [eb1efe] | 77 | distance(_distance),
|
|---|
| 78 | globalid(-1)
|
|---|
| [5b5724] | 79 | {}
|
|---|
| 80 |
|
|---|
| [355af8] | 81 | /** Comparator with respect to the distance.
|
|---|
| 82 | *
|
|---|
| 83 | * \note We'll have this as static function to allow usage in e.g. STL's sort.
|
|---|
| 84 | *
|
|---|
| 85 | * \param one first argument
|
|---|
| 86 | * \param other other argument to compare to \a one to
|
|---|
| 87 | * \return true - first distance is less
|
|---|
| 88 | */
|
|---|
| 89 | static bool DistanceComparator(const argument_t &one, const argument_t &other)
|
|---|
| 90 | {
|
|---|
| 91 | return one.distance < other.distance;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| [64bdfd] | 94 | /** Comparator with respect to the pair of types.
|
|---|
| 95 | *
|
|---|
| 96 | * \note We'll have this as static function to allow usage in e.g. STL's sort.
|
|---|
| 97 | *
|
|---|
| 98 | * \param one first argument
|
|---|
| 99 | * \param other other argument to compare to \a one to
|
|---|
| 100 | * \return true - first type is less or if equal, second type is less, else
|
|---|
| 101 | */
|
|---|
| [355af8] | 102 | bool static IndexComparator(const argument_t &one, const argument_t &other)
|
|---|
| 103 | {
|
|---|
| [4266eb] | 104 | return (static_cast<const SubgraphEdge &>(one) < static_cast<const SubgraphEdge &>(other));
|
|---|
| [64bdfd] | 105 | }
|
|---|
| 106 |
|
|---|
| [66cfc7] | 107 | //!> distance
|
|---|
| 108 | double distance;
|
|---|
| [eb1efe] | 109 | //!> global id refers to some global index, e.g. the configuration id in training set
|
|---|
| 110 | size_t globalid;
|
|---|
| [66cfc7] | 111 | };
|
|---|
| 112 |
|
|---|
| [9e903b] | 113 | /** Print given \a arg to stream \a ost.
|
|---|
| 114 | *
|
|---|
| 115 | * \param ost output stream to print to
|
|---|
| 116 | * \param arg argument to print
|
|---|
| 117 | * \return output stream for concatenation
|
|---|
| 118 | */
|
|---|
| 119 | std::ostream& operator<<(std::ostream &ost, const argument_t &arg);
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| [66cfc7] | 122 | #endif /* FUNCTIONARGUMENT_HPP_ */
|
|---|