IMP  2.0.1
The Integrative Modeling Platform
GaussianProcessInterpolationRestraintSparse.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/GaussianProcessInterpolationRestraintSparse.h
3  * \brief Normal distribution of Function
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_SPARSE_H
9 #define IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_SPARSE_H
10 
11 #include <IMP/isd/isd_config.h>
12 
13 #ifdef IMP_ISD_USE_CHOLMOD
14 
15 #include <IMP/macros.h>
16 #include <boost/scoped_ptr.hpp>
19 #include <IMP/isd/ISDRestraint.h>
22 #include <IMP/internal/OwnerPointer.h>
23 #include <Eigen/Dense>
24 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
25 #include <Eigen/Sparse>
26 #include <unsupported/Eigen/CholmodSupport>
27 #include <ufsparse/cholmod.h>
28 
29 
30 
31 IMPISD_BEGIN_NAMESPACE
32 #ifndef SWIG
33 using Eigen::SparseMatrix;
34 using Eigen::MatrixXd;
35 using Eigen::VectorXd;
36 #endif
37 
38 //! gaussian process restraint
39 /* the restraint is a multivariate normal distribution on the vector of
40 * observations with mean and standard deviation given by the posterior of the
41 * gaussian process.
42 */
43 class IMPISDEXPORT GaussianProcessInterpolationRestraintSparse
44  : public ISDRestraint
45 {
46  private:
47  // checks and makes necessary updates
48  void update_mean_and_covariance();
49 
50  private:
51  IMP::Pointer<GaussianProcessInterpolationSparse> gpi_;
52  IMP::internal::OwnerPointer<MultivariateFNormalSufficientSparse> mvn_;
53  //number of observation points
54  unsigned M_;
55  cholmod_common *c_;
56 
57  public:
58  // this is a restraint on other restraints. It first constructs the
59  // necessary vectors from GaussianProcessInterpolation, then creates a
60  // multivariate normal distribution around it. Upon evaluation, it
61  // checks if parameters have changed, reconstructs the matrix if
62  // necessary, changes the DA weight and passes it to the functions.
63  GaussianProcessInterpolationRestraintSparse(
64  GaussianProcessInterpolationSparse *gpi);
65 
66  double get_probability() const
67  {
68  const_cast<GaussianProcessInterpolationRestraintSparse*>(this)->
69  update_mean_and_covariance();
70  return mvn_->density();
71  }
72 
73  IMP_RESTRAINT(GaussianProcessInterpolationRestraintSparse);
74 
75 };
76 
77 IMPISD_END_NAMESPACE
78 
79 #endif /* IMP_ISD_USE_CHOLMOD */
80 
81 #endif /* IMPISD_GAUSSIAN_PROCESS_INTERPOLATION_RESTRAINT_SPARSE_H */