IMP  2.4.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-2015 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(kernel::Model *m, kernel::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(kernel::Model *m, kernel::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 */
Import IMP/kernel/Decorator.h in the namespace.
Import IMP/kernel/SingletonContainer.h in the namespace.
Particle * get_particle() const
Returns the particle decorated by this decorator.
IMP::kernel::DerivativeAccumulator DerivativeAccumulator
#define IMP_DECORATOR_METHODS(Name, Parent)
A decorator for nuisance parameters particles.
Add scale parameter to particle.
Definition: Scale.h:24
Import IMP/kernel/PairContainer.h in the namespace.
#define IMP_DECORATOR_SETUP_0(Name)
Add nuisance parameter to particle.
Definition: Nuisance.h:25
Import IMP/kernel/decorator_macros.h in the namespace.
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73