IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
Scale.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/Scale.h
3  * \brief A decorator for scale parameters particles
4  *
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPISD_SCALE_H
9 #define IMPISD_SCALE_H
10 
11 #include <IMP/isd/isd_config.h>
12 
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
15 #include <IMP/Decorator.h>
16 #include <IMP/decorator_macros.h>
17 #include <IMP/isd/Nuisance.h>
18 
19 IMPISD_BEGIN_NAMESPACE
20 
21 //! Add scale parameter to particle
22 /** This is just syntactic sugar for a Nuisance bounded to be positive.
23  */
24 class IMPISDEXPORT Scale : public Nuisance {
25  static void do_setup_particle(Model *m, ParticleIndex pi,
26  double scale = 1.0);
27 
28  public:
31  IMP_DECORATOR_SETUP_1(Scale, double, scale);
32 
33  static bool get_is_setup(Model *m, ParticleIndex pi) {
34  return Nuisance::get_is_setup(m, pi) && Nuisance(m, pi).get_lower() >= 0;
35  }
36 
37  Float get_scale() const { return Nuisance(get_particle()).get_nuisance(); }
38 
39  void set_scale(Float d) { set_nuisance(d); }
40 
41  void add_to_scale_derivative(Float d, DerivativeAccumulator &accum) {
42  add_to_nuisance_derivative(d, accum);
43  }
44 
45  Float get_scale_derivative() const { return get_nuisance_derivative(); }
46 
47  static FloatKey get_scale_key() { return get_nuisance_key(); }
48 
49  bool get_scale_is_optimized() const { return get_nuisance_is_optimized(); }
50 
51  void set_scale_is_optimized(bool val) { set_nuisance_is_optimized(val); }
52 };
53 
54 IMP_DECORATORS(Scale, Scales, Nuisances);
55 
56 IMPISD_END_NAMESPACE
57 
58 #endif /* IMPISD_SCALE_H */
The base class for decorators.
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition: base_types.h:32
A container for Singletons.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
A decorator for nuisance parameters particles.
Add scale parameter to particle.
Definition: Scale.h:24
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
A container for Pairs.
Add nuisance parameter to particle.
Definition: Nuisance.h:25
Various general useful macros for IMP.
#define IMP_DECORATOR_SETUP_0(Name)
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:171
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.