/* * FunctionArgument.hpp * * Created on: 02.10.2012 * Author: heber */ #ifndef FUNCTIONARGUMENT_HPP_ #define FUNCTIONARGUMENT_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include /** This class encapsulates all information with respect to a single argument * for a high-dimensional model function. * * We restrict ourselves here to a function that dependent on a set of * three-dimensional vectors, i.e. a set of positions in space. And for * the moment to distances in between these sets. * */ struct argument_t { //!> grant operator access to private parts friend std::ostream& operator<<(std::ostream &ost, const argument_t &arg); //!> typedef for the two indices of the argument typedef std::pair indices_t; /** Default constructor for class argument_t. * */ argument_t() : indices( std::make_pair(0,1) ), distance(0.), globalid(-1) {} /** Constructor for class argument_t. * * This constructors uses the index pair (0,1) as default. * * \param _distance distance argument */ argument_t(const double &_distance) : indices( std::make_pair(0,1) ), distance(_distance), globalid(-1) {} /** Constructor for class argument_t. * * \param _indices pair of indices associated with the \a _distance * \param _distance distance argument */ argument_t(const indices_t &_indices, const double &_distance) : indices( _indices ), distance(_distance), globalid(-1) {} /** Comparator with respect to the distance. * * \note We'll have this as static function to allow usage in e.g. STL's sort. * * \param one first argument * \param other other argument to compare to \a one to * \return true - first distance is less */ static bool DistanceComparator(const argument_t &one, const argument_t &other) { return one.distance < other.distance; } /** Comparator with respect to the pair of indices. * * \note We'll have this as static function to allow usage in e.g. STL's sort. * * \param one first argument * \param other other argument to compare to \a one to * \return true - first index is less or if equal, second index is less, else */ bool static IndexComparator(const argument_t &one, const argument_t &other) { if (one.indices.first < other.indices.first) return true; else if (one.indices.first > other.indices.first) return false; else return one.indices.second < other.indices.second; } //!> indices between which the distance is given indices_t indices; //!> distance double distance; //!> global id refers to some global index, e.g. the configuration id in training set size_t globalid; }; /** Print given \a arg to stream \a ost. * * \param ost output stream to print to * \param arg argument to print * \return output stream for concatenation */ std::ostream& operator<<(std::ostream &ost, const argument_t &arg); #endif /* FUNCTIONARGUMENT_HPP_ */