9 #ifndef IMPISD_EM_UTILITIES_H
10 #define IMPISD_EM_UTILITIES_H
18 #include <boost/random/uniform_real.hpp>
19 #include <boost/random/variate_generator.hpp>
21 IMPISD_BEGIN_NAMESPACE
23 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
24 inline Float score_gaussian_overlap(Model *m,
26 IMP_Eigen::Vector3d * deriv){
29 IMP_Eigen::Matrix3d inverse = IMP_Eigen::Matrix3d::Zero();
30 Float mass12 = atom::Mass(m,pp[0]).get_mass() *
31 atom::Mass(m,pp[1]).get_mass();
32 core::Gaussian g1(m,pp[0]);
33 core::Gaussian g2(m,pp[1]);
34 IMP_Eigen::Matrix3d covar = g1.get_global_covariance() +
35 g2.get_global_covariance();
36 IMP_Eigen::Vector3d v = IMP_Eigen::Vector3d(g2.get_coordinates().get_data())
37 - IMP_Eigen::Vector3d(g1.get_coordinates().get_data());
38 covar.computeInverseAndDetWithCheck(inverse,determinant,invertible);
39 IMP_Eigen::Vector3d tmp = inverse*v;
41 Float score = mass12 * 0.06349363593424097 / (std::sqrt(determinant)) *
42 std::exp(-0.5*v.transpose()*tmp);
48 inline FloatsList sample_points_from_density(
const em::DensityMap * dmap_orig,
54 const em::DensityHeader * dhead = dmap->get_header();
55 Float dmax=dhead->dmax;
60 boost::mt19937 generator(std::time(0));
61 boost::uniform_real<> uni_dist(0,1);
62 boost::variate_generator<boost::mt19937&, boost::uniform_real<> > uni(generator, uni_dist);
63 for (
int i=0;i<npoints;i++){
65 Float den=(dmap->get_value(vs))/dmax;
Decorator to hold Gaussian3D.
BoundingBoxD< 3 > BoundingBox3D
Typedef for Python.
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
DensityMap * get_threshold_map(const DensityMap *orig_map, float threshold)
Return a map with 0 for all voxels below the threshold.
Class for handling density maps.
IMP::Vector< Floats > FloatsList
Standard way to pass a bunch of Floats values.
Functions to generate vectors.
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
double Float
Basic floating-point value (could be float, double...)