source: src/FunctionApproximation/FunctionArgument.hpp@ fc08c7

Fix_FitPotential_needs_atomicnumbers
Last change on this file since fc08c7 was fdd789, checked in by Frederik Heber <heber@…>, 9 years ago

Added bonded flag to argument_t.

  • Property mode set to 100644
File size: 3.8 KB
Line 
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>
17#include <iosfwd>
18
19#include "FunctionApproximation/Subgraph/SubgraphEdge.hpp"
20
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 */
29struct argument_t : public SubgraphEdge
30{
31 //!> grant operator access to private parts
32 friend std::ostream& operator<<(std::ostream &ost, const argument_t &arg);
33
34 /** Default constructor for class argument_t.
35 *
36 */
37 argument_t() :
38 distance(0.),
39 globalid(-1),
40 bonded(false)
41 {}
42
43 /** Constructor for class argument_t.
44 *
45 * This constructors uses the index pair (0,1) as default.
46 *
47 * \param _distance distance argument
48 * \param _bonded is this a distance between bonded (true) or nonbonded (false) atoms
49 */
50 argument_t(const double &_distance, const bool _bonded = false) :
51 SubgraphEdge(
52 indices_t( std::make_pair(0,1) ),
53 types_t( std::make_pair(0,0) )),
54 distance(_distance),
55 globalid(-1),
56 bonded(_bonded)
57 {}
58
59 /** Constructor for class argument_t.
60 *
61 * \param _indices pair of indices associated with the \a _distance
62 * \param _distance distance argument
63 * \param _bonded is this a distance between bonded (true) or nonbonded (false) atoms
64 */
65 argument_t(const indices_t &_indices, const double &_distance, const bool _bonded = false) :
66 SubgraphEdge(
67 indices,
68 types_t( std::make_pair(0,0) )),
69 distance(_distance),
70 globalid(-1),
71 bonded(_bonded)
72 {}
73
74 /** Constructor for class argument_t.
75 *
76 * \param _indices pair of indices associated with the \a _distance
77 * \param _types pair of particle type
78 * \param _distance distance argument
79 * \param _bonded is this a distance between bonded (true) or nonbonded (false) atoms
80 */
81 argument_t(
82 const indices_t &_indices,
83 const types_t &_types,
84 const double &_distance,
85 const bool _bonded = false) :
86 SubgraphEdge(_indices, _types),
87 distance(_distance),
88 globalid(-1),
89 bonded(_bonded)
90 {}
91
92 /** Comparator with respect to the distance.
93 *
94 * \note We'll have this as static function to allow usage in e.g. STL's sort.
95 *
96 * \param one first argument
97 * \param other other argument to compare to \a one to
98 * \return true - first distance is less
99 */
100 static bool DistanceComparator(const argument_t &one, const argument_t &other)
101 {
102 return one.distance < other.distance;
103 }
104
105 /** Comparator with respect to the pair of types.
106 *
107 * \note We'll have this as static function to allow usage in e.g. STL's sort.
108 *
109 * \param one first argument
110 * \param other other argument to compare to \a one to
111 * \return true - first type is less or if equal, second type is less, else
112 */
113 bool static IndexComparator(const argument_t &one, const argument_t &other)
114 {
115 return (static_cast<const SubgraphEdge &>(one) < static_cast<const SubgraphEdge &>(other));
116 }
117
118 //!> distance
119 double distance;
120 //!> global id refers to some global index, e.g. the configuration id in training set
121 size_t globalid;
122 //!> states whether this argument is between bonded (true) or nonbonded (false) atoms
123 bool bonded;
124};
125
126/** Print given \a arg to stream \a ost.
127 *
128 * \param ost output stream to print to
129 * \param arg argument to print
130 * \return output stream for concatenation
131 */
132std::ostream& operator<<(std::ostream &ost, const argument_t &arg);
133
134
135#endif /* FUNCTIONARGUMENT_HPP_ */
Note: See TracBrowser for help on using the repository browser.