8 #ifndef IMPISD_MULTIVARIATE_FNORMAL_SUFFICIENT_SPARSE_H
9 #define IMPISD_MULTIVARIATE_FNORMAL_SUFFICIENT_SPARSE_H
11 #include <IMP/isd/isd_config.h>
13 #ifdef IMP_ISD_USE_CHOLMOD
19 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
20 #include <Eigen/Dense>
21 #include <Eigen/Sparse>
22 #include <unsupported/Eigen/CholmodSupport>
23 #include <ufsparse/cholmod.h>
26 IMPISD_BEGIN_NAMESPACE
27 using Eigen::SparseMatrix;
28 using Eigen::MatrixXd;
29 using Eigen::VectorXd;
89 class IMPISDEXPORT MultivariateFNormalSufficientSparse :
public Object
103 MultivariateFNormalSufficientSparse(
const MatrixXd& FX,
double JF,
104 const VectorXd& FM,
const SparseMatrix<double>& Sigma,
105 cholmod_common *c,
double cutoff=1e-7);
117 MultivariateFNormalSufficientSparse(
const VectorXd& Fbar,
double JF,
118 const VectorXd& FM,
int Nobs,
const SparseMatrix<double>& W,
119 const SparseMatrix<double>& Sigma, cholmod_common *c);
122 double density()
const;
125 double evaluate()
const;
128 cholmod_dense *evaluate_derivative_FM()
const;
131 cholmod_sparse *evaluate_derivative_Sigma()
const;
134 void set_FX(
const MatrixXd& f,
double cutoff=1e-7);
136 void set_JF(
double f);
138 void set_FM(
const VectorXd& f);
140 void set_Fbar(
const VectorXd& f);
142 void set_W(
const SparseMatrix<double>& f);
144 void set_Sigma(
const SparseMatrix<double>& f);
148 out <<
"MultivariateFNormalSufficientSparse: "
149 << N_ <<
" observations of "
150 << M_ <<
" variables " <<std::endl,
152 cholmod_free_sparse(&W_,c_);
153 cholmod_free_sparse(&P_,c_);
154 cholmod_free_sparse(&Sigma_,c_);
155 cholmod_free_dense(&epsilon_,c_);
156 cholmod_free_factor(&L_,c_);
163 double trace_WP()
const;
166 double mean_dist()
const;
169 cholmod_sparse *compute_PTP()
const;
172 cholmod_sparse *compute_PWP()
const;
175 void compute_sufficient_statistics(
double cutoff);
178 void compute_epsilon();
181 double JF_,lJF_,norm_,lnorm_;
182 cholmod_sparse *W_, *Sigma_, *P_, *PW_;
183 cholmod_dense *epsilon_;