Changeset 504 for library/bdm/stat/exp_family.h
- Timestamp:
- 08/12/09 09:27:40 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/exp_family.h
r488 r504 99 99 }; 100 100 101 template<class sq_T, template <typename> class TEpdf 101 template<class sq_T, template <typename> class TEpdf> 102 102 class mlnorm; 103 103 … … 142 142 vec variance() const {return diag (R.to_mat());} 143 143 // mlnorm<sq_T>* condition ( const RV &rvn ) const ; <=========== fails to cmpile. Why? 144 mpdf* condition (const RV &rvn) const ; 145 enorm<sq_T>* marginal (const RV &rv) const; 146 // epdf* marginal ( const RV &rv ) const; 144 shared_ptr<mpdf> condition ( const RV &rvn ) const; 145 146 // target not typed to mlnorm<sq_T, enorm<sq_T> > & 147 // because that doesn't compile (perhaps because we 148 // haven't finished defining enorm yet), but the type 149 // is required 150 void condition ( const RV &rvn, mpdf &target ) const; 151 152 shared_ptr<epdf> marginal (const RV &rvn ) const; 153 void marginal ( const RV &rvn, enorm<sq_T> &target ) const; 147 154 //!@} 148 155 … … 1235 1242 1236 1243 template<class sq_T> 1237 enorm<sq_T>* enorm<sq_T>::marginal (const RV &rvn) const 1244 shared_ptr<epdf> enorm<sq_T>::marginal ( const RV &rvn ) const 1245 { 1246 enorm<sq_T> *tmp = new enorm<sq_T> (); 1247 shared_ptr<epdf> narrow(tmp); 1248 marginal ( rvn, *tmp ); 1249 return narrow; 1250 } 1251 1252 template<class sq_T> 1253 void enorm<sq_T>::marginal ( const RV &rvn, enorm<sq_T> &target ) const 1238 1254 { 1239 1255 it_assert_debug (isnamed(), "rv description is not assigned"); 1240 1256 ivec irvn = rvn.dataind (rv); 1241 1257 1242 sq_T Rn (R, irvn); //select rows and columns of R 1243 1244 enorm<sq_T>* tmp = new enorm<sq_T>; 1245 tmp->set_rv (rvn); 1246 tmp->set_parameters (mu (irvn), Rn); 1247 return tmp; 1258 sq_T Rn (R, irvn); // select rows and columns of R 1259 1260 target.set_rv ( rvn ); 1261 target.set_parameters (mu (irvn), Rn); 1248 1262 } 1249 1263 1250 1264 template<class sq_T> 1251 mpdf* enorm<sq_T>::condition (const RV &rvn) const 1252 { 1265 shared_ptr<mpdf> enorm<sq_T>::condition ( const RV &rvn ) const 1266 { 1267 mlnorm<sq_T> *tmp = new mlnorm<sq_T> (); 1268 shared_ptr<mpdf> narrow(tmp); 1269 condition ( rvn, *tmp ); 1270 return narrow; 1271 } 1272 1273 template<class sq_T> 1274 void enorm<sq_T>::condition ( const RV &rvn, mpdf &target ) const 1275 { 1276 typedef mlnorm<sq_T> TMlnorm; 1253 1277 1254 1278 it_assert_debug (isnamed(), "rvs are not assigned"); 1279 TMlnorm &uptarget = dynamic_cast<TMlnorm &>(target); 1255 1280 1256 1281 RV rvc = rv.subt (rvn); … … 1276 1301 sq_T R_n (S11 - A *S12.T()); 1277 1302 1278 mlnorm<sq_T>* tmp = new mlnorm<sq_T> (); 1279 tmp->set_rv (rvn); tmp->set_rvc (rvc); 1280 tmp->set_parameters (A, mu1 - A*mu2, R_n); 1281 return tmp; 1303 uptarget.set_rv (rvn); 1304 uptarget.set_rvc (rvc); 1305 uptarget.set_parameters (A, mu1 - A*mu2, R_n); 1282 1306 } 1283 1307