IMP  2.0.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-2013 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 {
26 public:
28 
29  static Scale setup_particle(Particle *p, double scale=1.0);
30 
31  static bool particle_is_instance(Particle *p) {
32  return Nuisance::particle_is_instance(p) && Nuisance(p).get_lower()>=0;
33  }
34 
35  Float get_scale() const {
36  return Nuisance(get_particle()).get_nuisance();
37  }
38 
39  void set_scale(Float d) { set_nuisance(d); }
40 
41  void add_to_scale_derivative(Float d, DerivativeAccumulator &accum)
42  {
43  add_to_nuisance_derivative(d, accum);
44  }
45 
46  Float get_scale_derivative() const
47  {
48  return get_nuisance_derivative();
49  }
50 
51  static FloatKey get_scale_key() { return get_nuisance_key(); }
52 
53  bool get_scale_is_optimized() const
54  {
55  return get_nuisance_is_optimized();
56  }
57 
58  void set_scale_is_optimized(bool val)
59  {
60  set_nuisance_is_optimized(val);
61  }
62 
63 };
64 
65 
66 IMP_DECORATORS(Scale, Scales, Nuisances);
67 
68 IMPISD_END_NAMESPACE
69 
70 #endif /* IMPISD_SCALE_H */