IMP Reference Guide  develop.4f1ba46383,2024/09/10 The Integrative Modeling Platform
Go to the documentation of this file.
1 // Autogenerated by ../../../../tmp/nightly-build-56926/imp-20240910.develop.4f1ba46383/tools/build/make_containers.py
2 // from ../../../../tmp/nightly-build-56926/imp-20240910.develop.4f1ba46383/tools/build/container_templates/kernel/classname_macros.h
3 // Do not edit - any changes will be lost!
4
5 /**
7  * \brief Macros for various classes.
8  *
10  */
11
14
15 #include "internal/TupleRestraint.h"
16 #include "internal/functors.h"
17 #include "container_macros.h"
18 #include <IMP/object_macros.h>
19 #include <algorithm>
20
21 /** Define
24  */
26  double evaluate_indexes(Model *m, const ParticleIndexQuads &p, \
27  DerivativeAccumulator *da, unsigned int lower_bound, \
28  unsigned int upper_bound) \
29  const override final { \
30  double ret = 0; \
31  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
32  ret += evaluate_index(m, p[i], da); \
33  } \
34  return ret; \
35  } \
36  double evaluate_indexes_scores( \
37  Model *m, const ParticleIndexQuads &p, \
38  DerivativeAccumulator *da, unsigned int lower_bound, \
39  unsigned int upper_bound, \
40  std::vector<double> &score) \
41  const override final { \
42  double ret = 0; \
43  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
44  double s = evaluate_index(m, p[i], da); \
45  score[i] = s; \
46  ret += s; \
47  } \
48  return ret; \
49  } \
50  double evaluate_indexes_delta( \
51  Model *m, const ParticleIndexQuads &p, \
52  DerivativeAccumulator *da, \
53  const std::vector<unsigned> &indexes, \
54  std::vector<double> &score) \
55  const override final { \
56  double ret = 0; \
57  for (std::vector<unsigned>::const_iterator it = indexes.begin(); \
58  it != indexes.end(); ++it) { \
59  double s = evaluate_index(m, p[*it], da); \
60  ret = ret - score[*it] + s; \
61  score[*it] = s; \
62  } \
63  return ret; \
64  } \
65  double evaluate_if_good_indexes( \
66  Model *m, const ParticleIndexQuads &p, DerivativeAccumulator *da, \
67  double max, unsigned int lower_bound, \
68  unsigned int upper_bound) const override { \
69  double ret = 0; \
70  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
71  ret += evaluate_if_good_index(m, p[i], da, max - ret); \
72  if (ret > max) return std::numeric_limits<double>::max(); \
73  } \
74  return ret; \
75  }
76
77 //! Define extra the functions needed for a QuadPredicate
79  int get_value(const ParticleQuad& a) const { \
80  return get_value_index(IMP::internal::get_model(a), \
81  IMP::internal::get_index(a)); \
82  } \
83  Ints get_value(const ParticleQuadsTemp &o) const { \
84  Ints ret(o.size()); \
85  for (unsigned int i = 0; i < o.size(); ++i) { \
86  ret[i] += Name::get_value(o[i]); \
87  } \
88  return ret; \
89  } \
90  Ints get_value_index(Model *m, const ParticleIndexQuads &o) const override { \
91  Ints ret(o.size()); \
92  for (unsigned int i = 0; i < o.size(); ++i) { \
93  ret[i] += Name::get_value_index(m, o[i]); \
94  } \
95  return ret; \
96  } \
97  IMP_IMPLEMENT_INLINE_NO_SWIG( \
98  void remove_if_equal(Model *m, ParticleIndexQuads &ps, \
99  int value) const, \
100  { \
101  ps.erase( \
102  std::remove_if(ps.begin(), ps.end(), \
103  IMP::internal::PredicateEquals<Name, true>( \
104  this, m, value)), \
105  ps.end()); \
106  }); \
107  IMP_IMPLEMENT_INLINE_NO_SWIG(void remove_if_not_equal(Model *m, \
109  int value) const, \
110  { \
111  ps.erase( \
112  std::remove_if(ps.begin(), ps.end(), \
113  IMP::internal::PredicateEquals<Name, false>( \
114  this, m, value)), \
115  ps.end()); \
116  });
117
120
121 /** Define
123 */
125  virtual void apply_indexes(Model *m, const ParticleIndexQuads &o, \
126  unsigned int lower_bound, \
127  unsigned int upper_bound) \
128  const override final { \
129  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
130  apply_index(m, o[i]); \
131  } \
132  }
133
137
138 #ifndef IMP_DOXYGEN
140  IMP_IMPLEMENT_INLINE(void do_apply(const QuadModifier *sm) const, \
141  { apply_generic(sm); }); \
142  IMP_IMPLEMENT_INLINE(void do_apply_moved(const QuadModifier *sm, \
143  const ParticleIndexes &moved_pis, \
144  const ParticleIndexes &reset_pis) const, \
145  { apply_generic_moved(sm, moved_pis, reset_pis); }); \
146  virtual ParticleIndexes get_all_possible_indexes() const override; \
147  IMP_OBJECT_METHODS(Name)
148 #endif
149
150 /** Use this to fill in container methods