Changeset 1015
- Timestamp:
- 05/27/10 23:08:07 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/user_info.cpp
r959 r1015 257 257 new_field = matrix ( i, j ); 258 258 } 259 } 260 261 void UI::save ( const ldmat &matrix, Setting &element, const string &name ) { 262 Setting &set = ( name == "" ) ? element.add ( Setting::TypeGroup) 263 : element.add ( name, Setting::TypeGroup ); 264 265 save (matrix._L(), set, "L"); 266 save (matrix._D(), set, "D"); 259 267 } 260 268 … … 371 379 } 372 380 381 void UI::from_setting ( ldmat& matrix, const Setting &element ) { 382 if(element.exists("L")){ 383 UI::from_setting(matrix.__L(), element["L"]); 384 } 385 if(element.exists("D")){ 386 UI::from_setting(matrix.__D(), element["D"]); 387 } 388 matrix.validate(); 389 } 390 373 391 void UI::from_setting ( vec &vector, const Setting &element ) { 374 392 const SettingResolver link ( element ); -
library/bdm/base/user_info.h
r959 r1015 25 25 #include "../shared_ptr.h" 26 26 #include "itpp/itbase.h" 27 #include "../math/square_mat.h" 28 #include "../math/chmat.h" 27 29 28 30 using std::string; … … 302 304 //! This method converts a Setting into a matrix 303 305 static void from_setting ( mat& matrix, const Setting &element ); 306 //! This method converts a Setting into a ldmat 307 static void from_setting ( ldmat& matrix, const Setting &element ); 304 308 //! This method converts a Setting into an integer vector 305 309 static void from_setting ( ivec &vector, const Setting &element ); … … 550 554 //! A matrix(of type mat) is stored in the new child Setting appended to the passed element 551 555 static void save ( const mat &matrix, Setting &element, const string &name = "" ); 552 556 557 //! A matrix(of type mat) is stored in the new child Setting appended to the passed element 558 static void save ( const ldmat &matrix, Setting &element, const string &name = "" ); 559 553 560 //! An integer vector (of type ivec) is stored in the new child Setting appended to the passed element 554 561 static void save ( const ivec &vec, Setting &element, const string &name = "" ); -
library/bdm/math/square_mat.h
r766 r1015 307 307 } 308 308 309 //! Access functions 310 const vec& _D() const { 311 return D; 312 } 313 //! Access functions 314 const mat& _L() const { 315 return L; 316 } 309 //! Access functions 310 const vec& _D() const { 311 return D; 312 } 313 //! Access functions 314 const mat& _L() const { 315 return L; 316 } 317 //! Access functions 318 vec& __D() { 319 return D; 320 } 321 //! Access functions 322 mat& __L() { 323 return L; 324 } 325 void validate(){ 326 dim= L.rows(); 327 } 317 328 318 329 //! add another ldmat matrix -
library/bdm/stat/exp_family.cpp
r1013 r1015 20 20 void egiw::set_parameters ( int dimx0, ldmat V0, double nu0 ) { 21 21 dimx = dimx0; 22 nPsi = V0.rows() - dimx; 23 22 nPsi = V0.rows()-dimx; 24 23 V = V0; 25 24 if ( nu0 < 0 ) { … … 323 322 nu = -1; 324 323 } 325 mat V; 326 if ( !UI::get ( V, set, "V", UI::optional ) ) { 327 vec dV; 328 UI::get ( dV, set, "dV", UI::compulsory ); 329 set_parameters ( dimx, ldmat ( dV ), nu ); 330 331 } else { 332 set_parameters ( dimx, V, nu ); 324 mat Vful; 325 if (!UI::get(V, set, "V", UI::optional)){ 326 if ( !UI::get ( Vful, set, "V", UI::optional ) ) { 327 vec dV; 328 UI::get ( dV, set, "dV", UI::compulsory ); 329 set_parameters ( dimx, ldmat ( dV ), nu ); 330 331 } else { 332 set_parameters ( dimx, Vful, nu ); 333 } 333 334 } 334 335 } … … 337 338 epdf::to_setting ( set ); 338 339 UI::save ( dimx, set, "dimx" ); 339 UI::save ( V .to_mat(), set, "V" );340 UI::save ( V, set, "V" ); 340 341 UI::save ( nu, set, "nu" ); 341 342 }; … … 343 344 void egiw::validate() { 344 345 eEF::validate(); 346 nPsi = V.rows() - dimx; 345 347 dim = dimx * ( dimx + nPsi ); 348 349 if ( nu < 0 ) { 350 nu = 0.1 + nPsi + 2 * dimx + 2; // +2 assures finite expected value of R 351 // terms before that are sufficient for finite normalization 352 } 346 353 347 354 // check sizes, rvs etc. -
library/bdm/stat/exp_family.h
r1013 r1015 443 443 \code 444 444 class = 'egiw'; 445 V = []; // square matrix 446 dV = []; // vector of diagonal of V (when V not given) 447 nu = []; // scalar \nu ((almost) degrees of freedom) 445 V.L = []; // L part of matrix V 446 V.D = []; // D part of matrix V 447 -or- V = [] // full matrix V 448 -or- dV = []; // vector of diagonal of V (when V not given) 449 nu = []; // scalar \nu ((almost) degrees of freedom) 448 450 // when missing, it will be computed to obtain proper pdf 449 dimx = []; // dimension of the wishart part451 dimx = []; // dimension of the wishart part 450 452 rv = RV({'name'}) // description of RV 451 453 rvc = RV({'name'}) // description of RV in condition 452 log_level = 'tri'; // set the level of logged details453 454 \endcode 454 455